예제 #1
0
        public static DuelInfo GetInfo(Mobile from)         //Gets or creates DuelInfo for player
        {
            DuelInfo info;

            if (m_Infos.ContainsKey(from.Serial))
            {
                info = m_Infos[from.Serial];
            }

            else
            {
                info = new DuelInfo(from);
                info.AddLogEntry("DuelInfo created.");

                m_Infos.Add(from.Serial, info);
            }

            return(info);
        }
예제 #2
0
        public static void EndDuel(Duel duel, Mobile loser)
        {
            duel.State = DuelState.End;

            Mobile winner;

            if (loser == duel.Defender)
            {
                winner = duel.Attacker;
            }
            else
            {
                winner = duel.Defender;
            }

            DuelInfo wInfo = GetInfo(winner);
            DuelInfo lInfo = GetInfo(loser);

            wInfo.AddLogEntry(String.Format("Won in a{0}duel against {1}.", (duel.Ranked ? " ranked " : "n unranked "), loser.Name));
            lInfo.AddLogEntry(String.Format("Lost in a{0}duel against {1}.", (duel.Ranked ? " ranked " : "n unranked "), winner.Name));

            if (duel.Ranked)
            {
                ++wInfo.Wins;
                ++lInfo.Losses;
            }

            if (!loser.Alive)
            {
                loser.Resurrect();

                if (loser.Corpse != null && loser.Corpse is Corpse)
                {
                    Corpse c = (Corpse)loser.Corpse;

                    for (int i = 0; i < c.Items.Count; ++i)
                    {
                        c.SetRestoreInfo(c.Items[i], c.Items[i].Location);
                    }

                    c.Open(loser, true);
                    c.Delete();
                }
            }

            Mobile[] mobs = new Mobile[] { winner, loser };

            winner.Delta(MobileDelta.Noto); /*	  Update	*/
            loser.Delta(MobileDelta.Noto);  /*   Notoriety	*/

            foreach (Mobile m in mobs)
            {
                m.CurePoison(m);
                m.StatMods.Clear();
                m.Combatant = null;

                m.Hits = m.HitsMax;
                m.Mana = m.ManaMax;
                m.Stam = m.StamMax;

                m.Location = duel.Arena.Home;

                m.Warmode  = false;
                m.Criminal = false;

                m.Aggressed.Clear();
                m.Aggressors.Clear();

                m.Delta(MobileDelta.Noto);
                m.InvalidateProperties();
            }

            winner.Say(String.Format("{0} has won the duel.", winner.Name));
            loser.Say(String.Format("{0} has lost the duel.", loser.Name));

            CancelDuel(duel);

            duel.Arena.Duel = null;
            duel.Arena      = null;
        }