< Summary

Class:DCL.Huds.QuestsPanel.QuestsPanelTask_Single
Assembly:QuestsPanelHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/QuestsPanelHUD/QuestsPanelTask_Single.cs
Covered lines:10
Uncovered lines:3
Coverable lines:13
Total lines:49
Line coverage:76.9% (10 of 13)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
Populate(...)0%440100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/QuestsPanelHUD/QuestsPanelTask_Single.cs

#LineLine coverage
 1using DCL.Interface;
 2using System;
 3using TMPro;
 4using UnityEngine;
 5using UnityEngine.UI;
 6
 7namespace DCL.Huds.QuestsPanel
 8{
 9    public class QuestsPanelTask_Single : MonoBehaviour, IQuestsPanelTask
 10    {
 11        [SerializeField] internal TextMeshProUGUI taskName;
 12        [SerializeField] internal Toggle status;
 13        [SerializeField] internal Button jumpInButton;
 14        [SerializeField] internal TextMeshProUGUI progressText;
 15        [SerializeField] internal Image ongoingProgress;
 16        [SerializeField] internal Color ongoinColor;
 17        [SerializeField] internal Color completedcolor;
 18
 19        internal TaskPayload_Single payload;
 20
 21        private Action jumpInDelegate;
 22
 1023        public void Awake() { jumpInButton.onClick.AddListener(() => { jumpInDelegate?.Invoke(); }); }
 24
 25        public void Populate( QuestModel quest, QuestTask task)
 26        {
 527            payload = JsonUtility.FromJson<TaskPayload_Single>(task.payload);
 28
 529            jumpInButton.gameObject.SetActive(task.progress < 1 && !string.IsNullOrEmpty(task.coordinates));
 530            jumpInDelegate = () =>
 31            {
 032                WebInterface.SendChatMessage(new ChatMessage
 33                {
 34                    messageType = ChatMessage.Type.NONE,
 35                    recipient = string.Empty,
 36                    body = $"/goto {task.coordinates}",
 37                });
 38
 039                DataStore.i.HUDs.questsPanelVisible.Set(false);
 040            };
 41
 542            taskName.text = task.name;
 543            status.isOn = payload.isDone;
 544            progressText.text = $"{(int)task.progress}/1";
 545            ongoingProgress.transform.localScale = new Vector3(task.progress, 1, 1);
 546            ongoingProgress.color = task.progress < 1 ? ongoinColor : completedcolor;
 547        }
 48    }
 49}