/// <summary>
        /// Initializes the <see cref="LogicQuests"/> class.
        /// </summary>
        internal static void Init()
        {
            if (LogicQuests.Initialized)
            {
                return;
            }

            LogicDataTable questCsv      = CSV.Tables.Get(Gamefile.Quests);
            Table          questCsvTable = questCsv.Table;

            string lastStoredName = "";

            Task.Run(() =>
            {
                for (int i = 0; i < questCsvTable.GetColumnRowCount(); i++)
                {
                    string name  = questCsvTable.GetValue("Name", i);
                    string value = questCsvTable.GetValueAt(questCsvTable.GetColumnIndexByName("LevelFile"), i);

                    if (name.IsNullOrEmptyOrWhitespace())
                    {
                        name = lastStoredName;
                    }
                    else
                    {
                        lastStoredName = name;
                    }

                    if (LogicQuests.Quests.ContainsKey(questCsv.GetDataByName(lastStoredName).GlobalID))
                    {
                        LogicQuest.LogicLevel level = JsonConvert.DeserializeObject <LogicQuest.LogicLevel>(File.ReadAllText($"Gamefiles/{value}"));
                        LogicQuests.Quests[questCsv.GetDataByName(lastStoredName).GlobalID].Levels.Add(level);
                    }
                    else
                    {
                        LogicQuest quest = new LogicQuest
                        {
                            Name = lastStoredName,
                            Data = (LogicQuestData)questCsv.GetDataByName(lastStoredName)
                        };

                        quest.Levels.Add(JsonConvert.DeserializeObject <LogicQuest.LogicLevel>(File.ReadAllText($"Gamefiles/{value}")));

                        LogicQuests.Quests.Add(quest.GlobalID, quest);
                    }
                }

                Console.WriteLine($"Loaded {LogicQuests.Quests.Count} Quests." + Environment.NewLine);
            }).Wait();

            LogicQuests.Initialized = true;
        }
Exemple #2
0
        /// <summary>
        /// Calculates the chest loot.
        /// Very much WIP.
        /// </summary>
        internal void CalculateChestLoot()
        {
            if (this.Avatar.CurrentArea["Level"].ToObject <int>() == this.Levels.Count && (this.Data.QuestType != "Unlock" || this.Data.QuestType != "PvP"))
            {
                Debugger.Debug("Create a chest.");

                var        areaNames      = LogicQuests.Quests;
                int        currentAreaIdx = areaNames.Values.ToList().FindIndex(value => value.Name.Equals(this.Name));
                LogicQuest area           = areaNames[currentAreaIdx + 1];

                this.Avatar.OngoingQuestData = area.GlobalID;
                this.SaveCurrentArea(area.Name, 0);
            }
            else
            {
                Debugger.Debug("No chest yet.");
            }
        }