| | 1 | | using System.Collections.Generic; |
| | 2 | |
|
| | 3 | | /// <summary> |
| | 4 | | /// These events should be tracked in the quest server. |
| | 5 | | /// In the meantime we will implement them here |
| | 6 | | /// </summary> |
| | 7 | | public static class QuestsControllerAnalytics |
| | 8 | | { |
| | 9 | | private const string QUEST_DISCOVERED = "quest_discovered"; |
| | 10 | | private const string QUEST_COMPLETED = "quest_completed"; |
| | 11 | | private const string TASK_COMPLETED = "task_completed"; |
| | 12 | | private const string TASK_PROGRESSED = "task_progressed"; |
| | 13 | | private const string REWARD_OBTAINED = "reward_obtained"; |
| | 14 | |
|
| | 15 | | public static void SendQuestDiscovered(QuestModel quest) |
| | 16 | | { |
| 2 | 17 | | var data = new Dictionary<string, string>(); |
| 2 | 18 | | FillQuestData(data, quest); |
| 2 | 19 | | GenericAnalytics.SendAnalytic(QUEST_DISCOVERED, data); |
| 2 | 20 | | } |
| | 21 | |
|
| | 22 | | public static void SendQuestCompleted(QuestModel quest) |
| | 23 | | { |
| 1 | 24 | | var data = new Dictionary<string, string>(); |
| 1 | 25 | | FillQuestData(data, quest); |
| 1 | 26 | | GenericAnalytics.SendAnalytic(QUEST_COMPLETED, data); |
| 1 | 27 | | } |
| | 28 | |
|
| | 29 | | public static void SendTaskCompleted(QuestModel quest, QuestSection section, QuestTask task) |
| | 30 | | { |
| 1 | 31 | | var data = new Dictionary<string, string>(); |
| 1 | 32 | | FillQuestData(data, quest); |
| 1 | 33 | | FillSectionData(data, section); |
| 1 | 34 | | FillTaskData(data, task); |
| 1 | 35 | | GenericAnalytics.SendAnalytic(TASK_COMPLETED, data); |
| 1 | 36 | | } |
| | 37 | |
|
| | 38 | | public static void SendTaskProgressed(QuestModel quest, QuestSection section, QuestTask task) |
| | 39 | | { |
| 2 | 40 | | var data = new Dictionary<string, string>(); |
| 2 | 41 | | FillQuestData(data, quest); |
| 2 | 42 | | FillSectionData(data, section); |
| 2 | 43 | | FillTaskData(data, task); |
| 2 | 44 | | GenericAnalytics.SendAnalytic(TASK_PROGRESSED, data); |
| 2 | 45 | | } |
| | 46 | |
|
| | 47 | | public static void SendRewardObtained(QuestModel quest, QuestReward reward) |
| | 48 | | { |
| 1 | 49 | | var data = new Dictionary<string, string>(); |
| 1 | 50 | | FillQuestData(data, quest); |
| 1 | 51 | | FillRewardData(data, reward); |
| 1 | 52 | | GenericAnalytics.SendAnalytic(REWARD_OBTAINED, data); |
| 1 | 53 | | } |
| | 54 | |
|
| | 55 | | private static void FillQuestData(Dictionary<string, string> data, QuestModel quest) |
| | 56 | | { |
| 7 | 57 | | if (quest == null) |
| 0 | 58 | | return; |
| | 59 | |
|
| 7 | 60 | | data.Add("quest_id", quest.id); |
| 7 | 61 | | data.Add("quest_name", quest.name); |
| 7 | 62 | | data.Add("quest_progress", quest.progress.ToString()); |
| 7 | 63 | | data.Add("quest_status", quest.status); |
| 7 | 64 | | } |
| | 65 | |
|
| | 66 | | private static void FillSectionData(Dictionary<string, string> data, QuestSection section) |
| | 67 | | { |
| 3 | 68 | | if (section == null) |
| 0 | 69 | | return; |
| | 70 | |
|
| 3 | 71 | | data.Add("section_id", section.id); |
| 3 | 72 | | data.Add("section_name", section.name); |
| 3 | 73 | | data.Add("section_progress", section.progress.ToString()); |
| 3 | 74 | | } |
| | 75 | |
|
| | 76 | | private static void FillTaskData(Dictionary<string, string> data, QuestTask task) |
| | 77 | | { |
| 3 | 78 | | if (task == null) |
| 0 | 79 | | return; |
| | 80 | |
|
| 3 | 81 | | data.Add("task_id", task.id); |
| 3 | 82 | | data.Add("task_name", task.name); |
| 3 | 83 | | data.Add("task_progress", task.progress.ToString()); |
| 3 | 84 | | data.Add("task_status", task.status); |
| 3 | 85 | | } |
| | 86 | |
|
| | 87 | | private static void FillRewardData(Dictionary<string, string> data, QuestReward reward) |
| | 88 | | { |
| 1 | 89 | | if (reward == null) |
| 0 | 90 | | return; |
| | 91 | |
|
| 1 | 92 | | data.Add("reward_id", reward.id); |
| 1 | 93 | | data.Add("reward_name", reward.name); |
| 1 | 94 | | data.Add("reward_type", reward.type); |
| 1 | 95 | | } |
| | 96 | | } |