Exemple #1
0
        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);
        }
Exemple #2
0
        public static void Death(string killer, AccountModel acc, CharacterModel character)
        {
#if DEBUG
            if (character == null)
            {
                throw new Exception("Undefined character model");
            }
#endif
            acc.AliveChars.Remove(character.Id);
            if (acc.DeadChars.Count == AccountModel.MaxDeadCharsStored)
            {
                acc.DeadChars.RemoveAt(AccountModel.MaxDeadCharsStored - 1);
            }
            acc.DeadChars.Insert(0, character.Id);

            int deathTime = UnixTime();
            int baseFame  = character.Fame;
            int totalFame = character.Fame;

            XElement fame = new XElement("Fame");
            XElement ce   = character.ExportFame();
            ce.Add(new XAttribute("id", character.Id));
            ce.Add(new XElement("Account", new XElement("Name", acc.Name)));
            fame.Add(ce);
            character.FameStats.ExportTo(fame);

            ClassStatsInfo classStats = acc.Stats.GetClassStats(character.ClassType);
            FameStats      fameStats  = CalculateStats(acc, character, killer);
            totalFame = fameStats.TotalFame;
            foreach (FameBonus bonus in fameStats.Bonuses)
            {
                fame.Add(new XElement("Bonus", new XAttribute("id", bonus.Name), bonus.Fame));
            }

            fame.Add(new XElement("CreatedOn", character.CreationTime));
            fame.Add(new XElement("KilledOn", deathTime));
            fame.Add(new XElement("KilledBy", killer));
            fame.Add(new XElement("BaseFame", baseFame));
            fame.Add(new XElement("TotalFame", totalFame));

            if (classStats.BestFame < baseFame)
            {
                classStats.BestFame = baseFame;
            }

            if (classStats.BestLevel < character.Level)
            {
                classStats.BestLevel = character.Level;
            }


            character.Dead      = true;
            character.DeathTime = UnixTime();
            character.DeathFame = totalFame;
            character.Save();

            acc.Stats.Fame         += totalFame;
            acc.Stats.TotalCredits += totalFame;
            acc.Save();

            if (character.Fame >= MinFameRequiredToEnterLegends)
            {
                PushLegend(acc.Id, character.Id, totalFame, deathTime);
            }

            CreateKey($"death.{acc.Id}.{character.Id}", fame.ToString());
        }