< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
QuestModel()0%110100%
TryGetSection(...)0%110100%
TryGetReward(...)0%330100%
GetDataFromJSON(...)0%110100%

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;
 4
 5public static class QuestsLiterals
 6{
 7    public static class Status
 8    {
 9        public const string BLOCKED = "blocked";
 10        public const string NOT_STARTED = "not_started";
 11        public const string ON_GOING = "on_going";
 12        public const string COMPLETED = "completed";
 13        public const string FAILED = "failed";
 14    }
 15
 16    public static class RewardStatus
 17    {
 18        public const string NOT_GIVEN = "not_given";
 19        public const string OK = "ok";
 20        public const string ALREADY_GIVEN = "already_given";
 21        public const string TASK_ALREADY_COMPLETED = "task_already_completed";
 22        public const string FAILED = "failed";
 23    }
 24
 25    public static class Visibility
 26    {
 27        public const string VISIBLE = "visible";
 28        public const string VISIBLE_IF_CAN_START = "visible_if_can_start";
 29        public const string SECRET = "secret";
 30    }
 31}
 32
 33[System.Serializable]
 34public class QuestModel : BaseModel
 35{
 36    public string id;
 37    public string name;
 38    public string description;
 39    public string thumbnail_entry;
 40    public string status;
 41    public string visibility;
 42    public string thumbnail_banner;
 43    public QuestSection[] sections;
 10144    public DateTime assignmentTime = DateTime.Now; //TODO remove this once kernel send the data properly
 10145    public DateTime completionTime = DateTime.Now; //TODO remove this once kernel send the data properly
 46    public QuestReward[] rewards;
 47
 48    [NonSerialized]
 49    public float oldProgress = 0;
 50
 51    public bool TryGetSection(string sectionId, out QuestSection section)
 52    {
 1053        section = sections.FirstOrDefault(x => x.id == sectionId);
 554        return section != null;
 55    }
 56
 57    public bool TryGetReward(string rewardId, out QuestReward reward)
 58    {
 1259        reward = rewards?.FirstOrDefault(x => x.id == rewardId);
 760        return reward != null;
 61    }
 62
 1163    public bool canBePinned => !isCompleted && status != QuestsLiterals.Status.BLOCKED;
 9964    public bool isCompleted => status == QuestsLiterals.Status.COMPLETED;
 5165    public bool hasAvailableTasks => sections.Any(x => x.tasks.Any(y => y.status != QuestsLiterals.Status.BLOCKED));
 1566    public bool justProgressed => sections.Any(x => x.tasks.Any(y => y.status != QuestsLiterals.Status.BLOCKED && y.just
 12567    public float progress => sections.Average(x => x.progress);
 68
 469    public override BaseModel GetDataFromJSON(string json) { return Utils.SafeFromJson<QuestModel>(json); }
 70}