/// <summary> /// Called when all instances has been loaded for initialized members in instance. /// </summary> internal override void LoadingFinished() { this.RarityData = CSV.Tables.Get(Gamefile.Rarity).GetData <RarityData>(this.Rarity); if (this.RarityData == null) { throw new Exception("Spell " + this.GlobalID + " rarity is NULL."); } this.UnlockArenaData = CSV.Tables.Get(Gamefile.Arena).GetData <ArenaData>(this.UnlockArena); if (this.UnlockArenaData == null) { throw new Exception("UnlockArena not defined for spell " + this.GlobalID + "."); } if (!string.IsNullOrEmpty(this.ReleaseDate)) { if (this.ReleaseDate == "Soon") { this.ReleaseDateTime = new DateTime(2020, 1, 1); } else if (!DateTime.TryParse(this.ReleaseDate, out this.ReleaseDateTime)) { throw new Exception("ReleaseDate must be in format YYYY-MM-DD!"); } } if (!this.NotInUse) { CSV.Tables.Spells.Add(this); } }
/// <summary> /// Gets the chance for specified rarity. /// </summary> internal int GetChanceForRarity(RarityData Data) { int Chance; int Unlocked = this.ArenaData.GetUnlockedSpellCountForRarity(Data); if (Unlocked > 0) { if (this.BaseTreasureChestData != null) { Chance = this.BaseTreasureChestData.GetChanceForRarity(Data); } else { if (Data.Name == "Legendary") { Chance = this.LegendaryChance; } else { if (Data.Name == "Epic") { Chance = this.EpicChance; } else { if (Data.Name == "Rare") { Chance = this.RareChance; } else { Chance = 1; } } } } return(Chance * this.ArenaData.GetUnlockedSpellCountForRarity(CSV.Tables.RarityCommonData) / this.ArenaData.GetUnlockedSpellCountForRarity(Data)); } return(0); }
/// <summary> /// Gets the unlocked spell count for specified rarity. /// </summary> internal int GetUnlockedSpellCountForRarity(RarityData Rarity) { return(this.UnlockedSpellsData[Rarity.Instance].Count); }