Пример #1
0
        private static void OnCombatantDeath(PlayerDeathEventArgs e)
        {
            try
            {
                PlayerMobile victim, killer;
                if (e.Mobile is PlayerMobile && e.Mobile.LastKiller is PlayerMobile)
                {
                    victim = e.Mobile as PlayerMobile;
                    killer = victim.LastKiller as PlayerMobile;

                    CombatantProfile victor   = ((IPlayerCombatant)killer).CombatProfile;
                    CombatantProfile defeated = ((IPlayerCombatant)victim).CombatProfile;

                    Handler.IncreaseDeaths(defeated);
                    Handler.IncreaseKills(victor);

                    QueryRankChange(victor);
                    QueryRankChange(defeated);

                    Handler.CalculateNewRating(victor, defeated.CombatRating, CombatResults.Victory);
                    Handler.CalculateNewRating(defeated, victor.CombatRating, CombatResults.Loss);
                }
            }
            catch (Exception x)
            {
                eqUtility.HandleGenericException(x);
            }
        }
Пример #2
0
        protected override void OnTarget(Mobile from, object o)
        {
            try
            {
                if (o is PlayerMobile)
                {
                    CombatantProfile profile = ((IPlayerCombatant)o).CombatProfile;
                    switch (m_ModType)
                    {
                    case ModType.Deaths:
                    {
                        profile.TotalDeaths = modifierValue;
                        break;
                    }

                    case ModType.Kills:
                    {
                        profile.TotalKills = modifierValue;
                        break;
                    }

                    case ModType.Rating:
                    {
                        profile.CombatRating = modifierValue;
                        break;
                    }

                    default: break;
                    }
                }
            }
            catch (Exception e) { eqUtility.HandleGenericException(e); }
        }
Пример #3
0
 internal static void IncreaseDeaths(CombatantProfile profile)
 {
     try
     {
         profile.TotalDeaths++;
     }
     catch (Exception e) { eqUtility.HandleGenericException(e); }
 }
Пример #4
0
 private static void CreateCombatProfile(Mobile m)
 {
     if (m is PlayerMobile)
     {
         try
         {
             CombatantProfile cProfile = new CombatantProfile(m as PlayerMobile);
             m_CombatProfiles.Add(cProfile);
             Console.WriteLine
                 ("New Combat Profile Created For: ({0}) [{1}]", m.Name, m.Serial);
         }
         catch (Exception e) { eqUtility.HandleGenericException(e); }
     }
 }
Пример #5
0
        internal static void QueryRankChange(CombatantProfile profile)
        {
            int kdSum = profile.TotalKills - profile.TotalDeaths;
            int rank  = kdSum / 20;

            switch (rank)
            {
            case 0:
            {
                profile.Rank = CombatantProfile.CombatRank.Pawn;
                break;
            }

            case 1:
            {
                profile.Rank = CombatantProfile.CombatRank.Bishop;
                break;
            }

            case 2:
            {
                profile.Rank = CombatantProfile.CombatRank.Knight;
                break;
            }

            case 4:
            {
                profile.Rank = CombatantProfile.CombatRank.Rook;
                break;
            }

            case 5:
            {
                profile.Rank = (profile.IsFemale()
                            ? CombatantProfile.CombatRank.Queen : CombatantProfile.CombatRank.King);
                break;
            }

            case 6:
            {
                profile.Rank = CombatantProfile.CombatRank.Master;
                break;
            }

            default: break;
            }
        }
Пример #6
0
        private static void Deserialize(BinaryFileReader reader)
        {
            int version = reader.ReadInt();

            if (version >= 0)
            {
                int profileCount = reader.ReadInt();
                if (profileCount > 0)
                {
                    for (int z = 0; z < profileCount; z++)
                    {
                        CombatantProfile p = new CombatantProfile();
                        p.Deserialize(reader);
                        m_CombatProfiles.Add(p);
                    }
                }
            }
        }
Пример #7
0
        internal static int CalculateNewRating(CombatantProfile profile, int opRating, CombatResults results)
        {
            try
            {
                int currentRating = profile.CombatRating, newRating = currentRating;

                switch (results)
                {
                case CombatResults.Victory:
                {
                    newRating = CalculateVictory(currentRating, opRating); break;
                }

                case CombatResults.Loss:
                {
                    newRating = CalculateDefeat(currentRating, opRating); break;
                }

                case CombatResults.Draw:
                {
                    newRating = CalculateDraw(currentRating, opRating); break;
                }

                default: break;
                }

                return(newRating);
            }

            catch (Exception e)
            {
                if (profile.Combatant.AccessLevel == AccessLevel.Administrator)
                {
                    profile.Combatant.SendMessage("Error Updating Combat Rating!");
                }
                eqUtility.HandleGenericException(e);
                return(profile.CombatRating);
            }
        }