Example #1
0
        public int FilledTeams(Duel d)
        {
            int         filled = 0;
            IEnumerator key    = Handling.Teams.Keys.GetEnumerator();

            for (int i = 0; i < Handling.Teams.Count; ++i)
            {
                key.MoveNext();
                Duel_Team d_team = (Duel_Team)Handling.Teams[(int)key.Current];

                bool hasplayers = false;
                for (int i2 = 0; i2 < d_team.Players.Count; ++i2)
                {
                    object o = (object)d_team.Players[i2];

                    if (o is PlayerMobile)
                    {
                        hasplayers = true;
                    }
                }

                if (hasplayers)
                {
                    filled += 1;
                }
            }

            return(filled);
        }
Example #2
0
        public bool NoneInJail()
        {
            IEnumerator key = Handeling.Teams.Keys.GetEnumerator();

            for (int i = 0; i < Handeling.Teams.Count; ++i)
            {
                key.MoveNext();
                Duel_Team team = (Duel_Team)Handeling.Teams[(int)key.Current];

                for (int i2 = 0; i2 < team.Players.Count; ++i2)
                {
                    object o = (object)team.Players[i2];

                    if (o is PlayerMobile)
                    {
                        PlayerMobile pm = (PlayerMobile)o;

                        if (pm.Region.IsPartOf(typeof(Server.Regions.Jail)) || pm.Map == Map.Malas)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
        public DuelSetup_ViewParticipants(Duel d, int teamid, int id, int teamid2)
            : base(0, 0)
        {
            Handeling = d;
            TeamID    = teamid;
            Index     = id;

            Closable  = true;
            Dragable  = true;
            Resizable = false;

            int bh = 34 + (Handeling.Teams[teamid2].Players.Count * 20);

            AddBackground(182, 269, 205, bh, 9300);
            AddLabel(204, 276, 70, String.Format(@"View Team {0} Participants", teamid2.ToString()));

            int       y      = 47;
            Duel_Team d_team = (Duel_Team)Handeling.Teams[teamid2];

            for (int i = 0; i < d_team.Players.Count; ++i)
            {
                object o = (object)d_team.Players[i];
                if (o is PlayerMobile)
                {
                    PlayerMobile pm = (PlayerMobile)o;
                    AddLabel(186, 297, y, String.Format(@"{0}: {1}", (i + 1).ToString(), pm.Name));
                }
                else
                {
                    AddLabel(186, 297, y, String.Format(@"{0}: Empty Slot", (i + 1).ToString()));
                }

                y += 20;
            }
        }
Example #4
0
        public bool NoneFlagged()
        {
            IEnumerator key = Handeling.Teams.Keys.GetEnumerator();

            for (int i = 0; i < Handeling.Teams.Count; ++i)
            {
                key.MoveNext();
                Duel_Team team = (Duel_Team)Handeling.Teams[(int)key.Current];

                for (int i2 = 0; i2 < team.Players.Count; ++i2)
                {
                    object o = (object)team.Players[i2];

                    if (o is PlayerMobile)
                    {
                        PlayerMobile pm = (PlayerMobile)o;

                        if (pm.Combatant != null || pm.Aggressed.Count > 0)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Example #5
0
        public bool CheckLoggedIn()
        {
            IEnumerator key = Handling.Teams.Keys.GetEnumerator();

            for (int i = 0; i < Handling.Teams.Count; ++i)
            {
                key.MoveNext();
                Duel_Team team = (Duel_Team)Handling.Teams[(int)key.Current];

                bool alllogged = true;
                for (int i2 = 0; i2 < team.Players.Count; ++i2)
                {
                    object o = (object)team.Players[i2];

                    if (o is PlayerMobile)
                    {
                        PlayerMobile pm = (PlayerMobile)o;

                        if (pm.NetState == null)
                        {
                            alllogged = false;
                            Handling.Teams[(int)key.Current].Players[i2] = "@null";
                            Handling.Teams[(int)key.Current].Accepted.Remove(pm);
                        }
                    }
                }

                if (!alllogged)
                {
                    return(false);
                }
            }

            return(true);
        }
Example #6
0
        public bool AllAlive()
        {
            IEnumerator key = Handling.Teams.Keys.GetEnumerator();

            for (int i = 0; i < Handling.Teams.Count; ++i)
            {
                key.MoveNext();
                Duel_Team team = (Duel_Team)Handling.Teams[(int)key.Current];

                for (int i2 = 0; i2 < team.Players.Count; ++i2)
                {
                    object o = (object)team.Players[i2];

                    if (o is PlayerMobile)
                    {
                        PlayerMobile pm = (PlayerMobile)o;

                        if (!pm.Alive)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Example #7
0
        public DuelSetup_Pending(Duel d) : base(0, 0)
        {
            Handeling = d;

            Closable  = false;
            Dragable  = true;
            Resizable = false;

            int bh = (PlayerCount() * 38);

            AddBackground(212, 177, 251, bh, 9250);
            AddBackground(219, 185, 235, (bh - 15), 9350);

            int         y   = 190;
            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)
                {
                    object o = (object)d_team.Players[i2];
                    if (o is PlayerMobile)
                    {
                        PlayerMobile pm = (PlayerMobile)o;
                        AddLabel(250, y, 0, String.Format("{0}", pm.Name));
                        AddImage(225, y, ImageID((bool)d_team.Accepted[pm]));
                        y += 30;
                    }
                }
            }
        }
Example #8
0
 public Duel_AddTarget(Duel d, int team, int i)
     : base(16, false, TargetFlags.None)
 {
     Handeling = d;
     TeamID    = team;
     Index     = i;
     D_Team    = (Duel_Team)Handeling.Teams[TeamID];
 }
        public DuelSetup_Rules_View(Duel d, int team, int id)
            : base(0, 0)
        {
            Handeling = d;
            TeamID    = team;
            Index     = id;

            Closable  = false;
            Dragable  = true;
            Resizable = false;

            int bh = 309 + (20 * Handeling.Teams.Count);

            AddBackground(221, 179, 194, bh, 9300);
            AddLabel(266, 186, 70, @"View Duel Rules");

            AddButton(225, 209, 1209, 1210, 11, GumpButtonType.Reply, 0);
            AddLabel(245, 206, 57, @"I accept these rules");
            AddButton(225, 230, 1209, 1210, 0, GumpButtonType.Reply, 0);
            AddLabel(245, 227, 38, @"I do not accept these rules");

            AddButton(225, 256, 1209, 1210, 1, GumpButtonType.Reply, 0);
            AddLabel(245, 253, 54, @"Spells");
            AddButton(225, 276, 1209, 1210, 2, GumpButtonType.Reply, 0);
            AddLabel(245, 273, 54, @"Combat Abilities");
            AddButton(225, 296, 1209, 1210, 3, GumpButtonType.Reply, 0);
            AddLabel(245, 293, 54, @"Skills");
            AddButton(225, 316, 1209, 1210, 4, GumpButtonType.Reply, 0);
            AddLabel(245, 313, 54, @"Weapons");
            AddButton(225, 336, 1209, 1210, 5, GumpButtonType.Reply, 0);
            AddLabel(245, 333, 54, @"Armor");
            AddButton(225, 356, 1209, 1210, 6, GumpButtonType.Reply, 0);
            AddLabel(245, 353, 54, @"Items");
            //AddButton(225, 376, 1209, 1210, 7, GumpButtonType.Reply, 0);
            //AddLabel(245, 373, 54, @"Samurai Spells");
            //AddButton(225, 396, 1209, 1210, 8, GumpButtonType.Reply, 0);
            //AddLabel(245, 393, 54, @"Chivalry");
            //AddButton(225, 416, 1209, 1210, 9, GumpButtonType.Reply, 0);
            //AddLabel(245, 413, 54, @"Necromancy");
            //AddButton(225, 436, 1209, 1210, 10, GumpButtonType.Reply, 0);
            //AddLabel(245, 433, 54, @"Ninja Spells");

            AddLabel(256, 463, 70, @"View Participants");
            int         y = 486, bid = 12;
            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];
                AddButton(225, y, 1209, 1210, bid, GumpButtonType.Reply, 0);
                AddLabel(245, (y - 3), 12, String.Format(@"Team {0}: {1} out of {2} players", d_team.TeamID.ToString(), TeamPlayers(d_team).ToString(), d_team.Size.ToString()));

                y   += 20;
                bid += 1;
            }
        }
        public int TeamPlayers(Duel_Team team)
        {
            int toreturn = 0;

            for (int i = 0; i < team.Players.Count; ++i)
            {
                if (team.Players[i] != "@null")
                    toreturn += 1;
            }

            return toreturn;
        }
Example #11
0
        public void UpdateAllPending()
        {
            // This sub is used to send all players the required gumps to view the rules of the duel and
            // eventually accept/decline the duel, after a player has not already accepted the duel they
            // are sent the gump to accept/decline the duel, if they have accepted the duel, they are
            // sent the gump to view all the players that have/have not accepted the duel
            // if all players have accepted the duel this sub will then begin the process of starting the
            // duel

            bool        start = false;                                 // bool to determine weather to start the duel or not
            IEnumerator key   = Teams.Keys.GetEnumerator();            // creates the key variable so we can iterate through the Teams dictionary

            for (int i = 0; i < Teams.Count; ++i)                      // Iterates through the Teams dictionary using a for loop
            {
                key.MoveNext();                                        // Moves the enumerator to its next item
                Duel_Team d_team = (Duel_Team)Teams[(int)key.Current]; // creates a variable referencing the currently iterated team

                for (int i2 = 0; i2 < d_team.Players.Count; ++i2)      // creates a second for loop to iterate through all the players in the current teams
                {
                    object o = (object)d_team.Players[i2];             // creates the currently iterated object in the teams Players variable as an object to be type safe

                    if (o is PlayerMobile)                             // checks if o is infact a Player, if it isn't it is just an empty slot
                    {
                        PlayerMobile pm = (PlayerMobile)o;             // o is a playermobile so we create a variable to reference it as a playermobile

                        if (AllAccepted())
                        {
                            start = true;
                            pm.CloseGump(typeof(DuelSetup_Pending));
                        }
                        else if ((bool)d_team.Accepted[pm])
                        {
                            pm.CloseGump(typeof(DuelSetup_Pending));
                            pm.SendGump(new DuelSetup_Pending(this));
                        }
                        else
                        {
                            pm.CloseGump(typeof(DuelSetup_Rules_View));
                            pm.SendGump(new DuelSetup_Rules_View(this, (int)key.Current, i2));
                        }
                    }
                }
            }

            if (start)
            {
                EchoMessage("Duel Starting....");
                StartTimer = new Duel_StartTimer(this, 1, 1);
            }
        }
Example #12
0
        public int PlayerCount(Duel_Team d_team)
        {
            int count = 0;

            for (int i = 0; i < d_team.Players.Count; ++i)
            {
                if (d_team.Players[i] != "@null")
                {
                    count += 1;
                }
            }

            return(count);
        }
Example #13
0
        public int TeamPlayers(Duel_Team team)
        {
            int toreturn = 0;

            for (int i = 0; i < team.Players.Count; ++i)
            {
                if (team.Players[i] != "@null")
                {
                    toreturn += 1;
                }
            }

            return(toreturn);
        }
Example #14
0
        public void PayBuyIn(PlayerMobile pm, int teamid)
        {
            if (Handeling.BuyIn <= 0)
            {
                return;
            }

            int         playercount = 0;
            int         sharecount  = 0;
            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)
                {
                    object o = (object)d_team.Players[i2];

                    if (o != "@null")
                    {
                        playercount += 1;
                    }

                    if ((int)key.Current == teamid && o != "@null")
                    {
                        sharecount += 1;
                    }
                }
            }

            int goldshare = (playercount * Handeling.BuyIn) / sharecount;

            BankBox box = (BankBox)pm.BankBox;

            if (goldshare >= 5000)
            {
                BankCheck check = new BankCheck(goldshare);
                box.DropItem(check);
            }
            else
            {
                Gold gold = new Gold(goldshare);
                box.DropItem(gold);
            }

            pm.SendMessage(String.Format("Congragulations! you have won {0}gp.", goldshare.ToString()));
        }
Example #15
0
        public bool InDuel(PlayerMobile m)
        {
            IEnumerator key = (IEnumerator)Teams.Keys.GetEnumerator();

            for (int i = 0; i < Teams.Count; ++i)
            {
                key.MoveNext();
                Duel_Team team = (Duel_Team)Teams[(int)key.Current];

                if (team.Players.Contains(m))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #16
0
        public Dictionary <int, Duel_Team> Teams;       // Declares the dictionary to keep track of all the teams involved in the duel

        public Duel(PlayerMobile starter)               // The constructor for Duel, initializes required variables
        {
            Caller = starter;                           // sets the caller
            Teams  = new Dictionary <int, Duel_Team>(); // initializes the Teams dictionary so it does not = null
            Teams.Add(1, new Duel_Team(1));             // creates & adds two default teams 1 & 2 to the Teams dictionary
            Teams.Add(2, new Duel_Team(2));
            Duel_Team TeamOne = (Duel_Team)Teams[1];    // creates a variable reference to the default team 1

            TeamOne.AddPlayer(starter);                 // adds the callers as the first player to the default team 1
            Duel_Team TeamTwo = (Duel_Team)Teams[2];    // creates a variable reference to the defualt team 2

            TeamTwo.Players.Add("@null");               // installs one empty slot into the default team 2

            InProgress = false;
            IsRematch  = false;
            Ended      = false;
        }
Example #17
0
        public void HandleDeath(object o)
        {
            PlayerMobile died = (PlayerMobile)o;

            if (Handeling == null)
            {
                return;
            }

            if (!Handeling.InDuel(died))
            {
                return;
            }

            if (!HasStarted)
            {
                return;
            }

            Handeling.EchoMessage(String.Format("{0} has been killed!", died.Name));

            int teamid = 0;
            int alive  = 0;

            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];

                if (!d_team.AllDead())
                {
                    alive += 1;
                    teamid = (int)key.Current;
                }
            }

            if (alive == 1 || alive == 0)
            {
                AllKilled = true;
                EndDuel(teamid);
            }
        }
Example #18
0
        public void EchoMessage(string msg)
        {
            IEnumerator key = Teams.Keys.GetEnumerator();

            for (int i = 0; i < Teams.Count; ++i)
            {
                key.MoveNext();
                Duel_Team team = (Duel_Team)Teams[(int)key.Current];

                for (int i2 = 0; i2 < team.Players.Count; ++i2)
                {
                    if (team.Players[i2] != "@null")
                    {
                        PlayerMobile player = (PlayerMobile)team.Players[i2];
                        player.SendMessage(msg);
                    }
                }
            }
        }
Example #19
0
        public DuelSetup_ParticipantSetup(Duel d, int id) : base(0, 0)
        {
            Handeling = d;
            TeamID    = id;
            D_Team    = (Duel_Team)Handeling.Teams[TeamID];

            Closable  = true;
            Dragable  = true;
            Resizable = false;

            int bh = 121 + (D_Team.Size * 20);

            AddBackground(115, 85, 215, bh, 9300);
            AddLabel(164, 91, 70, @"Participant Setup");
            AddLabel(123, 113, 113, String.Format(@"Team Size: {0}", D_Team.Size.ToString()));

            AddButton(145, 138, 1209, 1210, 1, GumpButtonType.Reply, 0);
            AddLabel(166, 135, 144, @"Increase Size");
            AddButton(145, 158, 1209, 1210, 2, GumpButtonType.Reply, 0);
            AddLabel(166, 155, 144, @"Decrease Size");

            AddLabel(177, 180, 70, @"Team Players");
            int y = 204, bi = 3;

            for (int i = 0; i < D_Team.Size; ++i)
            {
                if (Handeling.Teams[TeamID].Players[i] == "@null")
                {
                    AddLabel(144, (y - 3), 254, String.Format(@"{0}: Empty", (i + 1).ToString()));
                }
                else
                {
                    PlayerMobile pm = (PlayerMobile)D_Team.Players[i];
                    AddLabel(144, (y - 3), 254, String.Format(@"{0}: {1}", (i + 1).ToString(), pm.Name));
                }
                AddButton(123, y, 1209, 1210, bi, GumpButtonType.Reply, 0);

                y  += 20;
                bi += 1;
            }
        }
Example #20
0
        public int PlayerCount()
        {
            int         count = 0;
            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")
                    {
                        count += 1;
                    }
                }
            }

            return(count);
        }
Example #21
0
        public static bool IsEnemy(PlayerMobile from, PlayerMobile target)
        {
            for (int i = 0; i < Registry.Count; ++i)
            {
                Duel d = (Duel)Registry[i];

                IEnumerator key = d.Teams.Keys.GetEnumerator();
                for (int i2 = 0; i2 < d.Teams.Count; ++i2)
                {
                    key.MoveNext();
                    Duel_Team d_team = (Duel_Team)d.Teams[(int)key.Current];

                    if (d_team.Players.Contains(from) && !d_team.Players.Contains(target) || !d_team.Players.Contains(from) && d_team.Players.Contains(target))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #22
0
        public static bool DuelStarted(PlayerMobile pm)
        {
            for (int i = 0; i < Registry.Count; ++i)
            {
                Duel d = (Duel)Registry[i];

                IEnumerator key = d.Teams.Keys.GetEnumerator();
                for (int i2 = 0; i2 < d.Teams.Count; ++i2)
                {
                    key.MoveNext();
                    Duel_Team d_team = (Duel_Team)d.Teams[(int)key.Current];

                    if (d_team.Players.Contains(pm) && d.InProgress)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #23
0
        public void SendControllerSetup()
        {
            if (IsRematch)
            {
                EndSelf();
                return;
            }
            PauseDuel();

            IEnumerator key = Teams.Keys.GetEnumerator();              // creates the key variable so we can iterate through the Teams dictionary

            for (int i = 0; i < Teams.Count; ++i)                      // Iterates through the Teams dictionary using a for loop
            {
                key.MoveNext();                                        // Moves the enumerator to its next item
                Duel_Team d_team = (Duel_Team)Teams[(int)key.Current]; // creates a variable referencing the currently iterated team

                for (int i2 = 0; i2 < d_team.Players.Count; ++i2)
                {
                    object o = (object)d_team.Players[i2];

                    if (o is PlayerMobile)
                    {
                        PlayerMobile pm = (PlayerMobile)d_team.Players[i2];

                        if (pm == Caller)
                        {
                            pm.CloseGump(typeof(DuelSetup_Pending));
                            pm.SendGump(new DuelSetup_Main(this));
                        }
                        else
                        {
                            pm.CloseGump(typeof(DuelSetup_Pending));
                            pm.CloseGump(typeof(DuelSetup_Rules_View));
                        }
                    }
                }
            }

            EchoMessage("A player has left the duel, duel start has been delayed.");
        }
Example #24
0
        public DuelSetup_Main(Duel d) : base(0, 0)
        {
            Handling = d;

            Closable  = true;
            Dragable  = true;
            Resizable = false;

            int bh = 165 + (Handling.Teams.Count * 20);

            AddBackground(281, 144, 279, bh, 9300);
            AddLabel(381, 151, 70, @"Duel Setup");
            AddLabel(315, 172, 40, @"Rules");
            AddLabel(315, 192, 70, @"Start Duel");
            AddLabel(315, 212, 53, @"Set Buy In");
            AddLabel(315, 232, 104, @"Add A Team");
            AddLabel(315, 252, 142, @"Remove A Team");
            AddLabel(376, 278, 104, @"Participants");
            AddButton(290, 175, 1209, 1210, 2, GumpButtonType.Reply, 0); // Rules
            AddButton(290, 195, 1209, 1210, 1, GumpButtonType.Reply, 0); // Start Duel
            AddButton(290, 215, 1209, 1210, 5, GumpButtonType.Reply, 0); // Set Buy In
            AddButton(290, 235, 1209, 1210, 3, GumpButtonType.Reply, 0); // Add A Team
            AddButton(290, 255, 1209, 1210, 4, GumpButtonType.Reply, 0); // Remove A Team

            int         y   = 298;
            int         id  = 6;
            IEnumerator key = Handling.Teams.Keys.GetEnumerator();

            for (int i = 0; i < Handling.Teams.Count; ++i)
            {
                key.MoveNext();
                Duel_Team team = (Duel_Team)Handling.Teams[(int)key.Current];
                AddLabel(315, (y - 3), 104, String.Format(@"Team {0}: {1} out of {2} players", team.TeamID.ToString(), TeamPlayers(team).ToString(), team.Size.ToString()));
                AddButton(290, y, 1209, 1210, id, GumpButtonType.Reply, 0); // View A Team

                y  += 20;
                id += 1;
            }
        }
Example #25
0
        public void GiveHeads(PlayerMobile pm, int teamid)
        {
            if (Handeling == null)
            {
                return;
            }

            Backpack  pack  = (Backpack)pm.Backpack;
            ArrayList heads = new ArrayList();

            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)
                {
                    object o = (object)d_team.Players[i2];

                    if (o is PlayerMobile)
                    {
                        PlayerMobile pm2 = (PlayerMobile)o;

                        if ((int)key.Current != teamid)
                        {
                            heads.Add(new DuelHead(pm2, pm));
                        }
                    }
                }
            }

            for (int i = 0; i < heads.Count; ++i)
            {
                DuelHead head = (DuelHead)heads[i];
                pack.DropItem(head);
            }
        }
Example #26
0
        public bool IsEnemy(PlayerMobile from, PlayerMobile to)
        {
            bool        isaenemy = false;
            IEnumerator key      = (IEnumerator)Teams.Keys.GetEnumerator();

            for (int i = 0; i < Teams.Count; ++i)
            {
                key.MoveNext();
                Duel_Team team = (Duel_Team)Teams[(int)key.Current];

                if (team.Players.Contains(from) && !team.Players.Contains(to))
                {
                    isaenemy = true;
                }
            }

            if (isaenemy)
            {
                return(true);
            }

            return(false);
        }
		public DuelSetup_ParticipantSetup(Duel d, int id) : base(0, 0)
		{
            Handeling = d;
            TeamID = id;
            D_Team = (Duel_Team)Handeling.Teams[TeamID];

			Closable = true;
			Dragable = true;
			Resizable = false;

            int bh = 121 + (D_Team.Size * 20);
            AddBackground(115, 85, 215, bh, 9300);
            AddLabel(164, 91, 70, @"Participant Setup");
            AddLabel(123, 113, 113, String.Format(@"Team Size: {0}", D_Team.Size.ToString()));

            AddButton(145, 138, 1209, 1210, 1, GumpButtonType.Reply, 0);
            AddLabel(166, 135, 144, @"Increase Size");
            AddButton(145, 158, 1209, 1210, 2, GumpButtonType.Reply, 0);
            AddLabel(166, 155, 144, @"Decrease Size");

            AddLabel(177, 180, 70, @"Team Players");
            int y = 204, bi = 3;
            for (int i = 0; i < D_Team.Size; ++i)
            {
                if (Handeling.Teams[TeamID].Players[i] == "@null")
                    AddLabel(144, (y - 3), 254, String.Format(@"{0}: Empty", (i +1).ToString()));
                else
                {
                    PlayerMobile pm = (PlayerMobile)D_Team.Players[i];
                    AddLabel(144, (y - 3), 254, String.Format(@"{0}: {1}", (i + 1).ToString(), pm.Name));
                }
                AddButton(123, y, 1209, 1210, bi, GumpButtonType.Reply, 0);

                y += 20;
                bi += 1;
            }
		}
Example #28
0
        public DuelSetup_AddParticipant(Duel d, int team, int i)
            : base(0, 0)
        {
            Handeling = d;
            TeamID    = team;
            Index     = i;
            D_Team    = (Duel_Team)Handeling.Teams[TeamID];

            Closable  = true;
            Dragable  = true;
            Resizable = false;

            AddBackground(187, 187, 260, 216, 9300);
            AddLabel(239, 193, 40, @"Incoming Duel Challenge");

            AddHtml(192, 217, 248, 85, @"You have been challenged to a duel by another player, you can choose to either accept or decline this challenge. If you choose to accept the challenge  you will be added to the duel, if you choose to decline the challenge you will not be added to the duel. To accept some duel's you must pay a lump sum, this is known as dueling for cash, the gold is given to the winning team of the duel.", (bool)true, (bool)true);
            AddLabel(200, 310, 33, String.Format(@"Challenger: {0}", Handeling.Caller.Name));
            AddLabel(200, 330, 54, String.Format(@"Buy In: {0}gp", Handeling.BuyIn.ToString()));

            AddButton(200, 360, 1209, 1210, 1, GumpButtonType.Reply, 0);
            AddLabel(225, 357, 42, @"I will accept the duel");
            AddButton(200, 380, 1209, 1210, 2, GumpButtonType.Reply, 0);
            AddLabel(225, 377, 67, @"I will decline the duel");
        }
Example #29
0
        public bool AllAccepted()
        {
            IEnumerator key = Teams.Keys.GetEnumerator();

            for (int i = 0; i < Teams.Count; ++i)
            {
                key.MoveNext();
                Duel_Team team = (Duel_Team)Teams[(int)key.Current];

                for (int i2 = 0; i2 < team.Players.Count; ++i2)
                {
                    object o = (object)team.Players[i2];
                    if (o is PlayerMobile)
                    {
                        if (!(bool)team.Accepted[(PlayerMobile)o])
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Example #30
0
        public void UnInvul()
        {
            if (Handeling == null)
            {
                return;
            }
            if (Handeling.Ended)
            {
                EndDuel(0);
            }

            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)
                {
                    object o = (object)d_team.Players[i2];

                    if (o is PlayerMobile)
                    {
                        PlayerMobile pm = (PlayerMobile)o;
                        pm.Blessed = false;
                        pm.Frozen  = false;
                    }
                }
            }

            if (HasStarted)
            {
                Handeling.EchoMessage("You can now fight!");
            }
        }
        public int PlayerCount(Duel_Team d_team)
        {
            int count = 0;
            for (int i = 0; i < d_team.Players.Count; ++i)
            {
                if (d_team.Players[i] != "@null")
                    count += 1;
            }

            return count;
        }
Example #32
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            switch (info.ButtonID)
            {
            case 0:     // Close
            {
                Handling.EndSelf();
                return;
            }

            case 1:     // Start
            {
                if (FilledTeams(Handling) < 2)
                {
                    Handling.EchoMessage("You must have at least two participating teams to start a duel.");
                    from.SendGump(new DuelSetup_Main(Handling));
                    return;
                }
                else if (!CheckLoggedIn())
                {
                    Handling.EchoMessage("One or more players participating in this duel have logged out, duel start delayed.");
                    from.SendGump(new DuelSetup_Main(Handling));
                    return;
                }
                else if (!AllAlive())
                {
                    Handling.EchoMessage("Not all players participating in the duel are alive, duel start delayed.");
                    from.SendGump(new DuelSetup_Main(Handling));
                    return;
                }
                else         // Start Duel
                {
                    Handling.UpdateAllPending();
                    return;
                }
            }

            case 2:     // Rules
            {
                from.SendGump(new DuelSetup_Rules(Handling));
                from.SendMessage("If the box next to something is checked, it is allowed.");
                return;
            }

            case 3:     // Add A Team
            {
                if (Handling.Teams.Count >= 4)
                {
                    from.SendMessage("There is a maximum of 4 teams");
                    from.SendGump(new DuelSetup_Main(Handling));
                    return;
                }

                Duel_Team toadd = new Duel_Team((Handling.Teams.Count + 1));
                toadd.Players.Add("@null");
                Handling.Teams.Add((Handling.Teams.Count + 1), toadd);
                from.SendGump(new DuelSetup_Main(Handling));
                return;
            }

            case 4:     // Remove A Team
            {
                if (Handling.Teams.Count <= 2)
                {
                    from.SendMessage("Cannot have less then 2 teams.");
                    from.SendGump(new DuelSetup_Main(Handling));
                    return;
                }

                Duel_Team toremove = (Duel_Team)Handling.Teams[Handling.Teams.Count];

                if (toremove.Players.Count <= 1 && toremove.Players[0] == "@null")
                {
                    Handling.Teams.Remove(Handling.Teams.Count);
                }
                else
                {
                    from.SendMessage("You can not remove a team that contains players, move the players to a higher team.");
                }

                from.SendGump(new DuelSetup_Main(Handling));
                return;
            }

            case 5:     // Set Buy In
            {
                if (FilledTeams(Handling) != 1)
                {
                    from.SendMessage("You cannot set the duel buy in after you have already added players.");
                    from.SendGump(new DuelSetup_Main(Handling));
                    return;
                }

                from.SendGump(new DuelSetup_SetBuyIn(Handling));
                return;
            }
            }

            if (info.ButtonID >= 6)
            {
                int id = (info.ButtonID - 5);
                from.SendGump(new DuelSetup_ParticipantSetup(Handling, id));
            }
        }
        public DuelSetup_AddParticipant(Duel d, int team, int i)
            : base(0, 0)
        {
            Handeling = d;
            TeamID = team;
            Index = i;
            D_Team = (Duel_Team)Handeling.Teams[TeamID];

            Closable = true;
            Dragable = true;
            Resizable = false;

            AddBackground(187, 187, 260, 216, 9300);
            AddLabel(239, 193, 40, @"Incoming Duel Challenge");

            AddHtml(192, 217, 248, 85, @"You have been challenged to a duel by another player, you can choose to either accept or decline this challenge. If you choose to accept the challenge  you will be added to the duel, if you choose to decline the challenge you will not be added to the duel. To accept some duel's you must pay a lump sum, this is known as dueling for cash, the gold is given to the winning team of the duel.", (bool)true, (bool)true);
            AddLabel(200, 310, 33, String.Format(@"Challenger: {0}", Handeling.Caller.Name));
            AddLabel(200, 330, 54, String.Format(@"Buy In: {0}gp", Handeling.BuyIn.ToString()));

            AddButton(200, 360, 1209, 1210, 1, GumpButtonType.Reply, 0);
            AddLabel(225, 357, 42, @"I will accept the duel");
            AddButton(200, 380, 1209, 1210, 2, GumpButtonType.Reply, 0);
            AddLabel(225, 377, 67, @"I will decline the duel");
        }
 public Duel_AddTarget(Duel d, int team, int i)
     : base(16, false, TargetFlags.None)
 {
     Handeling = d;
     TeamID = team;
     Index = i;
     D_Team = (Duel_Team)Handeling.Teams[TeamID];
 }
		public override void OnResponse( NetState sender, RelayInfo info )
		{
			Mobile from = sender.Mobile;

            switch (info.ButtonID)
            {
                case 0: // Close
                    {
                        Handling.EndSelf();
                        return;
                    }
                case 1: // Start
                    {
                        if (FilledTeams(Handling) < 2)
                        {
                            Handling.EchoMessage("You must have at least two participating teams to start a duel.");
                            from.SendGump(new DuelSetup_Main(Handling));
                            return;
                        }
                        else if (!CheckLoggedIn())
                        {
                            Handling.EchoMessage("One or more players participating in this duel have logged out, duel start delayed.");
                            from.SendGump(new DuelSetup_Main(Handling));
                            return;
                        }
                        else if (!AllAlive())
                        {
                            Handling.EchoMessage("Not all players participating in the duel are alive, duel start delayed.");
                            from.SendGump(new DuelSetup_Main(Handling));
                            return;
                        }
                        else // Start Duel
                        {
                            Handling.UpdateAllPending();
                            return;
                        }
                    }
                case 2: // Rules
                    {
                        from.SendGump(new DuelSetup_Rules(Handling));
                        from.SendMessage("If the box next to something is checked, it is allowed.");
                        return;
                    }
                case 3: // Add A Team
                    {
                        if (Handling.Teams.Count >= 4)
                        {
                            from.SendMessage("There is a maximum of 4 teams");
                            from.SendGump(new DuelSetup_Main(Handling));
                            return;
                        }

                        Duel_Team toadd = new Duel_Team((Handling.Teams.Count + 1));
                        toadd.Players.Add("@null");
                        Handling.Teams.Add((Handling.Teams.Count + 1), toadd);
                        from.SendGump(new DuelSetup_Main(Handling));
                        return;
                    }
                case 4: // Remove A Team
                    {
                        if (Handling.Teams.Count <= 2)
                        {
                            from.SendMessage("Cannot have less then 2 teams.");
                            from.SendGump(new DuelSetup_Main(Handling));
                            return;
                        }

                        Duel_Team toremove = (Duel_Team)Handling.Teams[Handling.Teams.Count];

                        if (toremove.Players.Count <= 1 && toremove.Players[0] == "@null")
                            Handling.Teams.Remove(Handling.Teams.Count);
                        else
                            from.SendMessage("You can not remove a team that contains players, move the players to a higher team.");

                        from.SendGump(new DuelSetup_Main(Handling));
                        return;
                    }
                case 5: // Set Buy In
                    {
                        if (FilledTeams(Handling) != 1)
                        {
                            from.SendMessage("You cannot set the duel buy in after you have already added players.");
                            from.SendGump(new DuelSetup_Main(Handling));
                            return;
                        }

                        from.SendGump(new DuelSetup_SetBuyIn(Handling));
                        return;
                    }
            }

            if (info.ButtonID >= 6)
            {
                int id = (info.ButtonID - 5);
                from.SendGump(new DuelSetup_ParticipantSetup(Handling, id));
            }
		}
Example #36
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;
        }