private static void LoadGameData() { string[] paths = Directory.EnumerateFiles(CombineResourcePath("GameData/"), "*.xml", SearchOption.TopDirectoryOnly).ToArray(); for (int i = 0; i < paths.Length; i++) { #if DEBUG Program.Print(PrintType.Debug, $"Parsing GameData <{paths[i].Split('/').Last()}>"); #endif XElement data = XElement.Parse(File.ReadAllText(paths[i])); foreach (XElement e in data.Elements("Object")) { string id = e.ParseString("@id"); ushort type = e.ParseUshort("@type"); #if DEBUG if (string.IsNullOrWhiteSpace(id)) { throw new Exception("Invalid ID."); } if (Type2Object.ContainsKey(type) || Type2Item.ContainsKey(type)) { throw new Exception($"Duplicate type <{id}:{type}>"); } if (Id2Object.ContainsKey(id) || Id2Item.ContainsKey(id)) { throw new Exception($"Duplicate ID <{id}:{type}>"); } #endif switch (e.ParseString("Class")) { case "Skin": Id2Skin[id] = Type2Skin[type] = new SkinDesc(e, id, type); break; case "Player": Id2Object[id] = IdLower2Object[id.ToLower()] = Type2Object[type] = Id2Player[id] = Type2Player[type] = new PlayerDesc(e, id, type); break; case "Equipment": case "Dye": Id2Item[id] = IdLower2Item[id.ToLower()] = Type2Item[type] = new ItemDesc(e, id, type); break; default: Id2Object[id] = IdLower2Object[id.ToLower()] = Type2Object[type] = new ObjectDesc(e, id, type); break; } } foreach (XElement e in data.Elements("Ground")) { string id = e.ParseString("@id"); ushort type = e.ParseUshort("@type"); #if DEBUG if (string.IsNullOrWhiteSpace(id)) { throw new Exception("Invalid ID."); } if (Type2Tile.ContainsKey(type)) { throw new Exception($"Duplicate type <{id}:{type}>"); } if (Id2Tile.ContainsKey(id)) { throw new Exception($"Duplicate ID <{id}:{type}>"); } #endif Id2Tile[id] = Type2Tile[type] = new TileDesc(e, id, type); } } #if DEBUG Program.Print(PrintType.Debug, $"Parsed <{Type2Object.Count}> Objects"); Program.Print(PrintType.Debug, $"Parsed <{Type2Player.Count}> Player Classes"); Program.Print(PrintType.Debug, $"Parsed <{Type2Skin.Count}> Skins"); Program.Print(PrintType.Debug, $"Parsed <{Type2Item.Count}> Items"); Program.Print(PrintType.Debug, $"Parsed <{Type2Tile.Count}> Tiles"); #endif }
public static FameStats CalculateStats(AccountModel acc, CharacterModel character, string killer = "") { int baseFame = character.Fame; int totalFame = baseFame; FameStats stats = new FameStats { BaseFame = baseFame, Bonuses = new List <FameBonus>() }; ClassStatsInfo classStats = acc.Stats.GetClassStats(character.ClassType); //Ancestor if (acc.Stats.GetClassStats(character.ClassType).BestLevel == 0) { int bonus = (int)(baseFame * .2f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Ancestor", Fame = bonus }); } //First Born if (acc.Stats.BestCharFame < baseFame) { int bonus = (int)(baseFame * .2f); totalFame += bonus; acc.Stats.BestCharFame = baseFame; stats.Bonuses.Add(new FameBonus { Name = "First Born", Fame = bonus }); } //Pacifist if (character.FameStats.DamageDealt == 0 && character.Level == 20) { int bonus = (int)(baseFame * .25f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Pacifist", Fame = bonus }); } //Thirsty if (character.FameStats.PotionsDrank == 0 && character.Level == 20) { int bonus = (int)(baseFame * .25f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Thirsty", Fame = bonus }); } //Mundane if (character.FameStats.AbilitiesUsed == 0 && character.Level == 20) { int bonus = (int)(baseFame * .25f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Mundane", Fame = bonus }); } //Boots On The Ground if (character.FameStats.Teleports == 0 && character.Level == 20) { int bonus = (int)(baseFame * .25f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Boots On The Ground", Fame = bonus }); } //Tunnel Rat if (character.FameStats.PirateCavesCompleted >= 1 && character.FameStats.AbyssOfDemonsCompleted >= 1 && character.FameStats.SnakePitsCompleted >= 1 && character.FameStats.SpiderDensCompleted >= 1 && character.FameStats.SpriteWorldsCompleted >= 1 && character.FameStats.TombsCompleted >= 1 && character.FameStats.UndeadLairsCompleted >= 1) { int bonus = (int)(baseFame * .1f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Tunnel Rat", Fame = bonus }); } //Dungeon Master if (character.FameStats.PirateCavesCompleted >= 20 && character.FameStats.AbyssOfDemonsCompleted >= 20 && character.FameStats.SnakePitsCompleted >= 20 && character.FameStats.SpiderDensCompleted >= 20 && character.FameStats.SpriteWorldsCompleted >= 20 && character.FameStats.TombsCompleted >= 20 && character.FameStats.UndeadLairsCompleted >= 20) { int bonus = (int)(baseFame * .2f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Dungeon Master", Fame = bonus }); } //Enemy Of The Gods if (((float)character.FameStats.GodKills / character.FameStats.MonsterKills) >= 0.1f) { int bonus = (int)(baseFame * .1f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Enemy Of The Gods", Fame = bonus }); } //Slayer Of The Gods if (((float)character.FameStats.GodKills / character.FameStats.MonsterKills) >= 0.5f) { int bonus = (int)(baseFame * .1f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Slayer Of The Gods", Fame = bonus }); } //Oryx Slayer if (character.FameStats.OryxKills >= 1) { int bonus = (int)(baseFame * .1f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Oryx Slayer", Fame = bonus }); } //Dominator Of Realms if (character.FameStats.OryxKills >= 1000) { int bonus = (int)(baseFame * .25f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Dominator Of Realms", Fame = bonus }); } //Accurate if (((float)character.FameStats.ShotsThatDamage / character.FameStats.Shots) >= .25f) { int bonus = (int)(baseFame * .1f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Accurate", Fame = bonus }); } //Sharpshooter if (((float)character.FameStats.ShotsThatDamage / character.FameStats.Shots) >= .5f) { int bonus = (int)(baseFame * .1f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Sharpshooter", Fame = bonus }); } //Sniper if (((float)character.FameStats.ShotsThatDamage / character.FameStats.Shots) >= .75f) { int bonus = (int)(baseFame * .1f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Sniper", Fame = bonus }); } //Explorer if (character.FameStats.TilesUncovered >= 1000000) { int bonus = (int)(baseFame * .05f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Explorer", Fame = bonus }); } //Cartographer if (character.FameStats.TilesUncovered >= 4000000) { int bonus = (int)(baseFame * .05f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Cartographer", Fame = bonus }); } //Pathfinder if (character.FameStats.TilesUncovered >= 20000000) { int bonus = (int)(baseFame * .05f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Pathfinder", Fame = bonus }); } //Team Player if (character.FameStats.LevelUpAssists >= 100) { int bonus = (int)(baseFame * .1f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Team Player", Fame = bonus }); } //Leader Of Men if (character.FameStats.LevelUpAssists >= 1000) { int bonus = (int)(baseFame * .1f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Leader Of Men", Fame = bonus }); } //Friend Of The Cubes if (character.FameStats.CubeKills == 0 && character.Level == 20) { int bonus = (int)(baseFame * .1f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Friend Of The Cubes", Fame = bonus }); } //Careless if (character.FameStats.DamageTaken >= 100000) { int bonus = (int)(baseFame * .05f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Careless", Fame = bonus }); } //Expert Manoeuvres if (character.FameStats.DamageTaken == 0 && character.Level == 20) { int bonus = (int)(baseFame * .5f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Expert Manoeuvres", Fame = bonus }); } //Beginner's Luck if (character.FameStats.NearDeathEscapes >= 1) { int bonus = (int)(baseFame * .05f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Beginner's Luck", Fame = bonus }); } //Living On The Edge if (character.FameStats.NearDeathEscapes >= 50) { int bonus = (int)(baseFame * .1f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Living On The Edge", Fame = bonus }); } //Living In The Nexus if (character.FameStats.Escapes >= 1000) { int bonus = (int)(baseFame * .05f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Living In The Nexus", Fame = bonus }); } //Seal The Deal if (((float)character.FameStats.MonsterKills / (character.FameStats.MonsterKills + character.FameStats.MonsterAssists) >= 0.5f) && character.Level == 20) { int bonus = (int)(baseFame * .1f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Seal The Deal", Fame = bonus }); } //Realm Riches if (character.FameStats.WhiteBags >= 100) { int bonus = (int)(baseFame * .15f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Realm Riches", Fame = bonus }); } //Devil's Advocate if (character.FameStats.AbyssOfDemonsCompleted >= 1000 && character.FameStats.CubeKills >= 50000 && character.FameStats.OryxKills >= 666 && killer == "Lava") { int bonus = (int)(baseFame * 1f); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Devil's Advocate", Fame = bonus }); } //Well Equipped int wellEquipped = 0; for (int k = 0; k < 4; k++) { if (character.Inventory[k] != -1) { wellEquipped += Resources.Type2Item[(ushort)character.Inventory[k]].FameBonus; wellEquipped += (int)ItemDesc.GetStat(character.ItemDatas[k], ItemData.FameBonus, 1); } } if (wellEquipped > 0) { int bonus = (int)(baseFame * (wellEquipped / 100.0f)); totalFame += bonus; stats.Bonuses.Add(new FameBonus { Name = "Well Equipped", Fame = bonus }); } stats.TotalFame = totalFame; return(stats); }