Exemple #1
0
        public static DuelInfo GetInfoNoCreate(Mobile from)           //Gets or creates DuelInfo for player
        {
            DuelInfo info = null;

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

            return(info);
        }
        public int CompareTo(object obj)
        {
            DuelInfo info = (DuelInfo)obj;

            if (info.Wins - Wins == 0)
            {
                return(info.Losses - Losses);
            }

            return(info.Wins - Wins);
        }
Exemple #3
0
        public static void LoadData()
        {
            if (File.Exists(SavePath))
            {
                using (FileStream fs = new FileStream(SavePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    try
                    {
                        BinaryReader     br     = new BinaryReader(fs);
                        BinaryFileReader reader = new BinaryFileReader(br);

                        int version = reader.ReadInt();

                        int count = reader.ReadInt();

                        for (int i = 0; i < count; ++i)
                        {
                            Serial   serial = reader.ReadInt();
                            DuelInfo info   = new DuelInfo(null);

                            info.Deserialize(reader);

                            m_Infos.Add(serial, info);
                        }

                        count = reader.ReadInt();

                        for (int i = 0; i < count; ++i)
                        {
                            DuelArena arena = new DuelArena("Loading...");
                            arena.Deserialize(reader);

                            m_Arenas.Add(arena);
                        }

                        m_Enabled = reader.ReadBool();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                    finally
                    {
                        fs.Close();
                    }
                }
            }
        }
Exemple #4
0
 public DuelInfoGump(DuelInfo info)
     : base(0, 0)
 {
     m_Info          = info;
     this.Closable   = true;
     this.Disposable = true;
     this.Dragable   = true;
     this.Resizable  = false;
     this.AddPage(0);
     this.AddBackground(100, 115, 278, 313, 9270);
     this.AddLabel(124, 139, 100, info.Mobile.Name);
     this.AddLabel(124, 169, 1149, String.Format("Wins: {0}", info.Wins));
     this.AddLabel(124, 199, 1149, String.Format("Losses: {0}", info.Losses));
     this.AddLabel(183, 243, 100, @"History (last 50)");
     this.AddHtml(116, 265, 245, 144, GetLog(), (bool)true, (bool)true);
 }
Exemple #5
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);
        }
Exemple #6
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;
        }
Exemple #7
0
        public static void EventSink_Speech(SpeechEventArgs e)
        {
            Mobile from = e.Mobile;

            if (e.Speech.ToLower().IndexOf("showladder") != -1)
            {
                if (m_Enabled)
                {
                    if (from != null)
                    {
                        if (m_Infos.ContainsKey(from.Serial))
                        {
                            DuelInfo info = m_Infos[from.Serial];

                            from.NonlocalOverheadMessage(Server.Network.MessageType.Regular, 1161, true, String.Format("I have {0} win{1} and {2} loss{3}.", info.Wins, (info.Wins != 1 ? "s" : ""), info.Losses, (info.Losses != 1 ? "es" : "")));
                            from.LocalOverheadMessage(Server.Network.MessageType.Regular, 1161, true, String.Format("I have {0} win{1} and {2} loss{3}.", info.Wins, (info.Wins != 1 ? "s" : ""), info.Losses, (info.Losses != 1 ? "es" : "")));
                        }
                        else
                        {
                            from.NonlocalOverheadMessage(Server.Network.MessageType.Regular, 1161, true, String.Format("I have not participated in any duels yet."));
                            from.LocalOverheadMessage(Server.Network.MessageType.Regular, 1161, true, String.Format("You have not participated in any duels yet."));
                        }
                    }
                }
                else
                {
                    from.SendMessage("The dueling system has been disabled.");
                }
            }

            if (e.Speech.ToLower().IndexOf("bank") != -1)
            {
                if (FindDuel(from) != null)
                {
                    e.Handled = true;
                    return;
                }
            }

            if (e.Speech.ToLower().IndexOf("top 10") != -1)
            {
                if (m_Enabled)
                {
                    from.CloseGump(typeof(TopTenGump));
                    from.SendGump(new TopTenGump(from));
                }
                else
                {
                    from.SendMessage("The dueling system has been disabled");
                }
            }

            if (e.Speech.ToLower().IndexOf("i wish to duel") != -1)
            {
                if (m_Enabled)
                {
                    if (from == null)
                    {
                        return;
                    }

                    if (!CanDuel(from))
                    {
                        return;
                    }

                    Duel duel = new Duel(from, null);

                    m_Duels.Add(duel);

                    duel.State = DuelState.Setup;

                    from.CloseGump(typeof(PlayerDuelAcceptGump));
                    from.CloseGump(typeof(PlayerDuelGump));
                    from.SendGump(new PlayerDuelGump(duel));
                }
                else
                {
                    from.SendMessage("The dueling system has been disabled.");
                }
            }
        }