Пример #1
0
        public bool NoneInJail()
        {
            IEnumerator key = Handeling.Teams.Keys.GetEnumerator();

            for (int i = 0; i < Handeling.Teams.Count; ++i)
            {
                key.MoveNext();
                Field_Team team = (Field_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);
        }
Пример #2
0
        public FieldSetup_ViewParticipants(Field 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;
            Field_Team d_team = (Field_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;
            }
        }
Пример #3
0
        public bool AllAlive()
        {
            IEnumerator key = Handeling.Teams.Keys.GetEnumerator();

            for (int i = 0; i < Handeling.Teams.Count; ++i)
            {
                key.MoveNext();
                Field_Team team = (Field_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.Alive)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Пример #4
0
        public int FilledTeams(Field d)
        {
            int         filled = 0;
            IEnumerator key    = Handling.Teams.Keys.GetEnumerator();

            for (int i = 0; i < Handling.Teams.Count; ++i)
            {
                key.MoveNext();
                Field_Team d_team = (Field_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);
        }
Пример #5
0
        public FieldSetup_Pending(Field 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();
                Field_Team d_team = (Field_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;
                    }
                }
            }
        }
Пример #6
0
        public bool NoneFlagged()
        {
            IEnumerator key = Handeling.Teams.Keys.GetEnumerator();

            for (int i = 0; i < Handeling.Teams.Count; ++i)
            {
                key.MoveNext();
                Field_Team team = (Field_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);
        }
Пример #7
0
        public bool CheckLoggedIn()
        {
            IEnumerator key = Handeling.Teams.Keys.GetEnumerator();

            for (int i = 0; i < Handeling.Teams.Count; ++i)
            {
                key.MoveNext();
                Field_Team team = (Field_Team)Handeling.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;
                            Handeling.Teams[(int)key.Current].Players[i2] = "@null";
                            Handeling.Teams[(int)key.Current].Accepted.Remove(pm);
                        }
                    }
                }

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

            return(true);
        }
Пример #8
0
 public Field_AddTarget(Field d, int team, int i)
     : base(16, false, TargetFlags.None)
 {
     Handeling = d;
     TeamID    = team;
     Index     = i;
     D_Team    = (Field_Team)Handeling.Teams[TeamID];
 }
        public int TeamPlayers(Field_Team team)
        {
            int toreturn = 0;

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

            return toreturn;
        }
Пример #10
0
        public int PlayerCount(Field_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);
        }
Пример #11
0
        public int TeamPlayers(Field_Team team)
        {
            int toreturn = 0;

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

            return(toreturn);
        }
Пример #12
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
                Field_Team d_team = (Field_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(FieldSetup_Pending));
                        }
                        else if ((bool)d_team.Accepted[pm])
                        {
                            pm.CloseGump(typeof(FieldSetup_Pending));
                            pm.SendGump(new FieldSetup_Pending(this));
                        }
                        else
                        {
                            pm.CloseGump(typeof(FieldSetup_Rules_View));
                            pm.SendGump(new FieldSetup_Rules_View(this, (int)key.Current, i2));
                        }
                    }
                }
            }

            if (start)
            {
                EchoMessage("Field Duel Starting....");
                StartTimer = new Field_StartTimer(this, 1, 1);
            }
        }
Пример #13
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();
                Field_Team d_team = (Field_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()));
        }
Пример #14
0
        public Dictionary <int, Field_Team> Teams;       // Declares the dictionary to keep track of all the teams involved in the duel

        public Field(PlayerMobile starter)               // The constructor for Field, initializes required variables
        {
            Caller = starter;                            // sets the caller
            Teams  = new Dictionary <int, Field_Team>(); // initializes the Teams dictionary so it does not = null
            Teams.Add(1, new Field_Team(1));             // creates & adds two default teams 1 & 2 to the Teams dictionary
            Teams.Add(2, new Field_Team(2));
            Field_Team TeamOne = (Field_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
            Field_Team TeamTwo = (Field_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;
        }
Пример #15
0
        public bool InField(PlayerMobile m)
        {
            IEnumerator key = (IEnumerator)Teams.Keys.GetEnumerator();

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

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

            return(false);
        }
Пример #16
0
        public void HandleDeath(object o)
        {
            PlayerMobile died = (PlayerMobile)o;

            if (Handeling == null)
            {
                return;
            }

            if (!Handeling.InField(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();
                Field_Team d_team = (Field_Team)Handeling.Teams[(int)key.Current];

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

            if (alive == 1 || alive == 0)
            {
                AllKilled = true;
                EndField(teamid);
            }
        }
Пример #17
0
        public void EchoMessage(string msg)
        {
            IEnumerator key = Teams.Keys.GetEnumerator();

            for (int i = 0; i < Teams.Count; ++i)
            {
                key.MoveNext();
                Field_Team team = (Field_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);
                    }
                }
            }
        }
Пример #18
0
        public FieldSetup_ParticipantSetup(Field d, int id) : base(0, 0)
        {
            Handeling = d;
            TeamID    = id;
            D_Team    = (Field_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;
            }
        }
Пример #19
0
        public int PlayerCount()
        {
            int         count = 0;
            IEnumerator key   = Handeling.Teams.Keys.GetEnumerator();

            for (int i = 0; i < Handeling.Teams.Count; ++i)
            {
                key.MoveNext();
                Field_Team d_team = (Field_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);
        }
Пример #20
0
        public static bool IsEnemy(PlayerMobile from, PlayerMobile target)
        {
            for (int i = 0; i < Registry.Count; ++i)
            {
                Field d = (Field)Registry[i];

                IEnumerator key = d.Teams.Keys.GetEnumerator();
                for (int i2 = 0; i2 < d.Teams.Count; ++i2)
                {
                    key.MoveNext();
                    Field_Team d_team = (Field_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);
        }
Пример #21
0
        public static bool FieldStarted(PlayerMobile pm)
        {
            for (int i = 0; i < Registry.Count; ++i)
            {
                Field d = (Field)Registry[i];

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

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

            return(false);
        }
Пример #22
0
        public void SendControllerSetup()
        {
            if (IsRematch)
            {
                EndSelf();
                return;
            }
            PauseField();

            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
                Field_Team d_team = (Field_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(FieldSetup_Pending));
                            pm.SendGump(new FieldSetup_Main(this));
                        }
                        else
                        {
                            pm.CloseGump(typeof(FieldSetup_Pending));
                            pm.CloseGump(typeof(FieldSetup_Rules_View));
                        }
                    }
                }
            }

            EchoMessage("A player has left the field duel, start has been delayed.");
        }
Пример #23
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();
                Field_Team d_team = (Field_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 FieldHead(pm2, pm));
                        }
                    }
                }
            }

            for (int i = 0; i < heads.Count; ++i)
            {
                FieldHead head = (FieldHead)heads[i];
                pack.DropItem(head);
            }
        }
Пример #24
0
        public FieldSetup_Main(Field 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, @"Field Setup");
            AddLabel(315, 172, 40, @"Rules");
            AddLabel(315, 192, 70, @"Start Field");
            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 Field
            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();
                Field_Team team = (Field_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;
            }
        }
Пример #25
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();
                Field_Team team = (Field_Team)Teams[(int)key.Current];

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

            if (isaenemy)
            {
                return(true);
            }

            return(false);
        }
		public FieldSetup_ParticipantSetup(Field d, int id) : base(0, 0)
		{
            Handeling = d;
            TeamID = id;
            D_Team = (Field_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;
            }
		}
Пример #27
0
        public FieldSetup_AddParticipant(Field d, int team, int i)
            : base(0, 0)
        {
            Handeling = d;
            TeamID    = team;
            Index     = i;
            D_Team    = (Field_Team)Handeling.Teams[TeamID];

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

            AddBackground(187, 187, 260, 216, 9300);
            AddLabel(239, 193, 40, @"Incoming Field 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");
        }
Пример #28
0
        public bool AllAccepted()
        {
            IEnumerator key = Teams.Keys.GetEnumerator();

            for (int i = 0; i < Teams.Count; ++i)
            {
                key.MoveNext();
                Field_Team team = (Field_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);
        }
Пример #29
0
        public void UnInvul()
        {
            if (Handeling == null)
            {
                return;
            }
            if (Handeling.Ended)
            {
                EndField(0);
            }

            IEnumerator key = Handeling.Teams.Keys.GetEnumerator();

            for (int i = 0; i < Handeling.Teams.Count; ++i)
            {
                key.MoveNext();
                Field_Team d_team = (Field_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!");
            }
        }
Пример #30
0
        public void EndSelf()
        {
            if (Ended)
            {
                return;
            }

            if (InProgress)
            {
                Controller.EndField(0);
            }

            Ended = true;

            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
                Field_Team d_team = (Field_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];

                        RefundBuyIn(pm);

                        pm.CloseGump(typeof(FieldSetup_Main));
                        pm.CloseGump(typeof(FieldSetup_Pending));
                        pm.CloseGump(typeof(FieldSetup_ParticipantSetup));
                        pm.CloseGump(typeof(FieldSetup_AddParticipant));
                        pm.CloseGump(typeof(FieldSetup_Rules_View));
                        pm.CloseGump(typeof(FieldSetup_ViewParticipants));
                        pm.CloseGump(typeof(FieldSetup_Rules_Armor_View));
                        pm.CloseGump(typeof(FieldSetup_Rules_Combat_View));
                        pm.CloseGump(typeof(FieldSetup_Rules_Items_View));
                        pm.CloseGump(typeof(FieldSetup_Rules_Skills_View));
                        pm.CloseGump(typeof(FieldSetup_Rules_Weapons_View));
                        pm.CloseGump(typeof(FieldSetup_Rules_Spells_View));
                        pm.CloseGump(typeof(FieldSetup_Rules_Spells_1st_View));
                        pm.CloseGump(typeof(FieldSetup_Rules_Spells_2nd_View));
                        pm.CloseGump(typeof(FieldSetup_Rules_Spells_3rd_View));
                        pm.CloseGump(typeof(FieldSetup_Rules_Spells_4th_View));
                        pm.CloseGump(typeof(FieldSetup_Rules_Spells_5th_View));
                        pm.CloseGump(typeof(FieldSetup_Rules_Spells_6th_View));
                        pm.CloseGump(typeof(FieldSetup_Rules_Spells_7th_View));
                        pm.CloseGump(typeof(FieldSetup_Rules_Spells_8th_View));
                    }
                }
            }

            EchoMessage(String.Format("The field duel has been cancelled."));
            if (Field_Config.Registry.Contains(this))
            {
                Field_Config.Registry.Remove(this);
            }
        }
Пример #31
0
        public void EndField(int teamid)
        {
            if (Handeling == null)
            {
                return;
            }

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

            Handeling.EchoMessage(String.Format("The field 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();
                    Field_Team d_team = (Field_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.ChangeScore( GameName, pm, 1 );
                                        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);
                                ResurrectPets(pm);
                                LoadPlayer(pm);
                                PlayerNoto(pm);
                                PetNoto(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();
            }

            //PlayerLocations = null;
            //PlayerMaps = null;
            //PlayerItems = null;
            //ItemLocations = null;
            InsuredItems = null;
            FrozenItems  = null;

            DeleteTrees();
            Trees = null;
            DeleteTraps();
            Traps = null;

            Handeling.UpdateAllPending();
            Handeling.BuyIn     = 0;
            Handeling.IsRematch = true;
            //Handeling = null;
        }
Пример #32
0
        public void StartField(Field d)
        {
            Handeling = d;

            if (Handeling.Caller.NetState == null)
            {
                Handeling.EndSelf();
                return;
            }

            HasStarted           = true;
            InUse                = true;
            Handeling.InProgress = true;
            Handeling.Controller = this;

            if (PlayerLocations == null)
            {
                PlayerLocations = new Dictionary <Serial, Point3D>();
            }
            if (PlayerMaps == null)
            {
                PlayerMaps = new Dictionary <Serial, Map>();
            }
            if (PlayerItems == null)
            {
                PlayerItems = new Dictionary <Serial, ArrayList>();
            }
            if (ItemLocations == null)
            {
                ItemLocations = new Dictionary <Serial, Point3D>();
            }
            if (InsuredItems == null)
            {
                InsuredItems = new ArrayList();
            }
            if (FrozenItems == null)
            {
                FrozenItems = new ArrayList();
            }
            if (Trees == null)
            {
                Trees = new ArrayList();
            }
            if (Traps == null)
            {
                Traps = new ArrayList();
            }

            SpawnTrees(Handeling);
            SpawnTraps(Handeling);

            IEnumerator key = Handeling.Teams.Keys.GetEnumerator();

            for (int i = 0; i < Handeling.Teams.Count; ++i)
            {
                key.MoveNext();
                Field_Team d_team = (Field_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;
                        StorePlayer(pm);
                        SpawnPlayer(pm, (int)key.Current);
                        PlayerNoto(pm);
                        PetNoto(pm);
                        pm.Blessed = true;
                        pm.Frozen  = true;
                        pm.Spell   = null;
                        ResurrectPlayer(pm);
                        ResurrectPets(pm);
                    }
                }
            }

            Timer.DelayCall(TimeSpan.FromSeconds(3.0), new TimerCallback(UnInvul));
            EndTimer = new Field_EndTimer(Handeling);
        }
        public FieldSetup_AddParticipant(Field d, int team, int i)
            : base(0, 0)
        {
            Handeling = d;
            TeamID = team;
            Index = i;
            D_Team = (Field_Team)Handeling.Teams[TeamID];

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

            AddBackground(187, 187, 260, 216, 9300);
            AddLabel(239, 193, 40, @"Incoming Field 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");
        }
Пример #34
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 FieldSetup_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 FieldSetup_Main(Handling));
                            return;
                        }
                        else if (!AllAlive())
                        {
                            Handling.EchoMessage("Not all players participating in the duel are alive, duel start delayed.");
                            from.SendGump(new FieldSetup_Main(Handling));
                            return;
                        }
                        else // Start Field
                        {
                            Handling.UpdateAllPending();
                            return;
                        }
                    }
                case 2: // Rules
                    {
                        from.SendGump(new FieldSetup_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 >= 8)
                        {
                            from.SendMessage("There is a maximum of 8 teams");
                            from.SendGump(new FieldSetup_Main(Handling));
                            return;
                        }

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

                        Field_Team toremove = (Field_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 FieldSetup_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 FieldSetup_Main(Handling));
                            return;
                        }

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

            if (info.ButtonID >= 6)
            {
                int id = (info.ButtonID - 5);
                from.SendGump(new FieldSetup_ParticipantSetup(Handling, id));
            }
		}
 public Field_AddTarget(Field d, int team, int i)
     : base(16, false, TargetFlags.None)
 {
     Handeling = d;
     TeamID = team;
     Index = i;
     D_Team = (Field_Team)Handeling.Teams[TeamID];
 }