Exemplo n.º 1
0
        public static void On_Logout(LogoutEventArgs args)
        {
            PlayerMobile pm = (PlayerMobile)args.Mobile;

            for (int i = 0; i < Registry.Count; ++i)
            {
                Duel d = (Duel)Registry[i];

                if (d.Caller == pm)
                {
                    Registry.Remove(d);
                    d.EndSelf();
                }
                else if (d.InDuel(pm))
                {
                    if (!d.InProgress)
                    {
                        d.RefundBuyIn(pm);
                        d.SendControllerSetup();
                    }
                    else
                    {
                        d.EchoMessage("A player disconnected, duel must end.");
                        d.EndSelf();
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            switch (info.ButtonID)
            {
            case 0:
            {
                from.CloseGump(typeof(DuelSetup_Main));
                from.SendGump(new DuelSetup_Main(Handeling));
                return;
            }

            case 1:
            {
                if (D_Team.Size >= 6)
                {
                    from.SendMessage("There is a maximum of 6 players per team.");
                    from.SendGump(new DuelSetup_ParticipantSetup(Handeling, TeamID));
                    return;
                }

                Handeling.Teams[TeamID].Size += 1;
                Handeling.Teams[TeamID].Players.Add("@null");
                from.SendGump(new DuelSetup_ParticipantSetup(Handeling, TeamID));
                break;
            }

            case 2:
            {
                if (D_Team.Size <= 1)
                {
                    from.SendMessage("A team may not have less then 1 player.");
                    from.SendGump(new DuelSetup_ParticipantSetup(Handeling, TeamID));
                    return;
                }

                int at = ((int)Handeling.Teams[TeamID].Players.Count - 1);
                if (Handeling.Teams[TeamID].Players[at] != "@null")
                {
                    from.SendMessage("A player slot must be empty to be removed.");
                    from.SendGump(new DuelSetup_ParticipantSetup(Handeling, TeamID));
                    return;
                }

                Handeling.Teams[TeamID].Players.RemoveAt(at);
                Handeling.Teams[TeamID].Size -= 1;
                from.SendMessage("The player slot has been removed.");
                from.SendGump(new DuelSetup_ParticipantSetup(Handeling, TeamID));
                break;
            }
            }

            if (info.ButtonID >= 3)
            {
                int index = (info.ButtonID - 3);

                if (D_Team.Players[index] == Handeling.Caller)
                {
                    from.SendMessage("You cannot remove your self from the duel.");
                    from.SendGump(new DuelSetup_ParticipantSetup(Handeling, TeamID));
                    return;
                }

                if (D_Team.Players[index] != "@null")
                {
                    PlayerMobile pm = (PlayerMobile)D_Team.Players[index];
                    Handeling.Teams[TeamID].Players[index] = "@null";
                    Handeling.Teams[TeamID].Accepted.Remove(pm);
                    pm.SendMessage("You have been removed from the duel.");
                    Handeling.RefundBuyIn(pm);

                    from.SendMessage("The player has been removed.");
                    from.SendGump(new DuelSetup_ParticipantSetup(Handeling, TeamID));
                    return;
                }
                else
                {
                    from.Target = new Duel_AddTarget(Handeling, TeamID, index);
                    return;
                }
            }
        }
Exemplo n.º 3
0
        public void EndDuel(int teamid)
        {
            if (Handeling == null)
            {
                return;
            }

            if (EndTimer != null)
            {
                EndTimer.Stop();
            }

            Handeling.EchoMessage(String.Format("The duel has ended, team {0} has won!", teamid.ToString()));

            HasStarted           = false;
            InUse                = false;
            Handeling.InProgress = false;

            if (!Handeling.Ended)
            {
                IEnumerator key = Handeling.Teams.Keys.GetEnumerator();
                for (int i = 0; i < Handeling.Teams.Count; ++i)
                {
                    key.MoveNext();
                    Duel_Team d_team = (Duel_Team)Handeling.Teams[(int)key.Current];

                    for (int i2 = 0; i2 < d_team.Players.Count; ++i2)
                    {
                        if (d_team.Players[i2] != "@null")
                        {
                            object o = (object)d_team.Players[i2];

                            if (o is PlayerMobile && o != "@null")
                            {
                                PlayerMobile pm = (PlayerMobile)o;
                                if (teamid != 0)
                                {
                                    if ((int)key.Current == teamid)
                                    {
                                        //GiveHeads(pm, teamid);
                                        BoardGameData.AddWin(GameName, pm);
                                    }
                                    else
                                    {
                                        //BoardGameData.ChangeScore( GameName, pm, -1 );
                                        BoardGameData.AddLose(GameName, pm);
                                    }
                                    int score = BoardGameData.getWins(GameName, pm) - BoardGameData.getLosses(GameName, pm);
                                    BoardGameData.SetScore(GameName, pm, score);

                                    if ((int)key.Current == teamid && AllKilled && !Handeling.IsRematch)
                                    {
                                        PayBuyIn(pm, teamid);
                                    }
                                }
                                else
                                if (!AllKilled && !Handeling.IsRematch)
                                {
                                    Handeling.RefundBuyIn(pm);
                                }

                                Handeling.Teams[(int)key.Current].Accepted[pm] = false;
                                ResurrectPlayer(pm);
                                LoadPlayer(pm);
                                PlayerNoto(pm);
                            }
                        }
                    }
                }
                if (InsuredItems != null)
                {
                    for (int i = 0; i < InsuredItems.Count; ++i)
                    {
                        Item item = (Item)InsuredItems[i];
                        item.Insured = true;
                    }
                }
                if (FrozenItems != null)
                {
                    for (int i = 0; i < FrozenItems.Count; ++i)
                    {
                        Item item = (Item)FrozenItems[i];
                        item.Movable = true;
                    }
                }
                UnInvul();
            }

            InsuredItems = null;
            FrozenItems  = null;

            Handeling.UpdateAllPending();
            Handeling.BuyIn     = 0;
            Handeling.IsRematch = true;
        }
Exemplo n.º 4
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            switch (info.ButtonID)
            {
            case 0:     // Close
            {
                PlayerMobile pm = (PlayerMobile)Handeling.Teams[TeamID].Players[Index];
                Handeling.Teams[TeamID].Players[Index] = "@null";
                Handeling.Teams[TeamID].Accepted.Remove(pm);
                Handeling.EchoMessage(String.Format("{0} has declined the duel, and has been removed.", pm.Name));
                Handeling.RefundBuyIn(pm);

                Handeling.SendControllerSetup();
                break;
            }

            case 1:     // Spells
            {
                from.SendGump(new DuelSetup_Rules_Spells_View(Handeling, TeamID, Index));
                break;
            }

            case 2:     // Combat Abilities
            {
                from.SendGump(new DuelSetup_Rules_Combat_View(Handeling, TeamID, Index));
                break;
            }

            case 3:     // Skills
            {
                from.SendGump(new DuelSetup_Rules_Skills_View(Handeling, TeamID, Index));
                break;
            }

            case 4:      // Weapons
            {
                from.SendGump(new DuelSetup_Rules_Weapons_View(Handeling, TeamID, Index));
                break;
            }

            case 5:     // Armor
            {
                from.SendGump(new DuelSetup_Rules_Armor_View(Handeling, TeamID, Index));
                break;
            }

            case 6:     // Items
            {
                from.SendGump(new DuelSetup_Rules_Items_View(Handeling, TeamID, Index));
                break;
            }

            case 7:     // Samurai
            {
                from.SendGump(new DuelSetup_Rules_Samurai_View(Handeling, TeamID, Index));
                break;
            }

            case 8:     // Chivalry
            {
                from.SendGump(new DuelSetup_Rules_Chivalry_View(Handeling, TeamID, Index));
                break;
            }

            case 9:     // Necromancy
            {
                from.SendGump(new DuelSetup_Rules_Necromancy_View(Handeling, TeamID, Index));
                break;
            }

            case 10:     // Ninjitsu
            {
                from.SendGump(new DuelSetup_Rules_Ninjitsu_View(Handeling, TeamID, Index));
                break;
            }

            case 11:     //Accepted
            {
                PlayerMobile pm = (PlayerMobile)Handeling.Teams[TeamID].Players[Index];
                Handeling.Teams[TeamID].Accepted[pm] = true;
                Handeling.UpdateAllPending();
                Handeling.EchoMessage(String.Format("{0} has accepted the duel.", pm.Name));
                break;
            }
            }

            if (info.ButtonID > 11)
            {
                int teamid2 = (info.ButtonID - 11);
                from.SendGump(new DuelSetup_ViewParticipants(Handeling, TeamID, Index, teamid2));
            }
        }