< Summary

Class:QuestModel
Assembly:QuestsModels
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/Quests/QuestModel.cs
Covered lines:0
Uncovered lines:13
Coverable lines:13
Total lines:75
Line coverage:0% (0 of 13)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:10
Method coverage:0% (0 of 10)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
QuestModel()0%2100%
TryGetSection(...)0%2100%
TryGetReward(...)0%12300%
GetDataFromJSON(...)0%2100%
GetDataFromPb(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/Quests/QuestModel.cs

#LineLine coverage
 1using System;
 2using System.Linq;
 3using DCL.Helpers;
 4using Decentraland.Sdk.Ecs6;
 5
 6public static class QuestsLiterals
 7{
 8    public static class Status
 9    {
 10        public const string BLOCKED = "blocked";
 11        public const string NOT_STARTED = "not_started";
 12        public const string ON_GOING = "on_going";
 13        public const string COMPLETED = "completed";
 14        public const string FAILED = "failed";
 15    }
 16
 17    public static class RewardStatus
 18    {
 19        public const string NOT_GIVEN = "not_given";
 20        public const string OK = "ok";
 21        public const string ALREADY_GIVEN = "already_given";
 22        public const string TASK_ALREADY_COMPLETED = "task_already_completed";
 23        public const string FAILED = "failed";
 24    }
 25
 26    public static class Visibility
 27    {
 28        public const string VISIBLE = "visible";
 29        public const string VISIBLE_IF_CAN_START = "visible_if_can_start";
 30        public const string SECRET = "secret";
 31    }
 32}
 33
 34[System.Serializable]
 35public class QuestModel : BaseModel
 36{
 37    public string id;
 38    public string name;
 39    public string description;
 40    public string thumbnail_entry;
 41    public string status;
 42    public string visibility;
 43    public string thumbnail_banner;
 44    public QuestSection[] sections;
 045    public DateTime assignmentTime = DateTime.Now; //TODO remove this once kernel send the data properly
 046    public DateTime completionTime = DateTime.Now; //TODO remove this once kernel send the data properly
 47    public QuestReward[] rewards;
 48
 49    [NonSerialized]
 50    public float oldProgress = 0;
 51
 52    public bool TryGetSection(string sectionId, out QuestSection section)
 53    {
 054        section = sections.FirstOrDefault(x => x.id == sectionId);
 055        return section != null;
 56    }
 57
 58    public bool TryGetReward(string rewardId, out QuestReward reward)
 59    {
 060        reward = rewards?.FirstOrDefault(x => x.id == rewardId);
 061        return reward != null;
 62    }
 63
 064    public bool canBePinned => !isCompleted && status != QuestsLiterals.Status.BLOCKED;
 065    public bool isCompleted => status == QuestsLiterals.Status.COMPLETED;
 066    public bool hasAvailableTasks => sections.Any(x => x.tasks.Any(y => y.status != QuestsLiterals.Status.BLOCKED));
 067    public bool justProgressed => sections.Any(x => x.tasks.Any(y => y.status != QuestsLiterals.Status.BLOCKED && y.just
 068    public float progress => sections.Average(x => x.progress);
 69
 70    public override BaseModel GetDataFromJSON(string json) =>
 071        Utils.SafeFromJson<QuestModel>(json);
 72
 73    public override BaseModel GetDataFromPb(ComponentBodyPayload pbModel) =>
 074        default;
 75}