コード例 #1
0
        public virtual bool CheckQualify(Mobile m)
        {
            if (m == null)
            {
                return(false);
            }

            XmlPoints a = (XmlPoints)XmlAttach.FindAttachment(m, typeof(XmlPoints));

            if (a == null)
            {
                XmlPoints.SendText(Challenger, 100536, m.Name);   // "{0} does not qualify. No points support."
                return(false);
            }

            // make sure they qualify
            if (a.HasChallenge)
            {
                XmlPoints.SendText(Challenger, 100537, m.Name);  // "{0} is already in a Challenge."
                return(false);
            }

            // and they have the Entry fee in the bank
            if (!HasEntryFee(m))
            {
                XmlPoints.SendText(Challenger, 100538, m.Name);  // "{0} cannot afford the Entry fee."
                return(false);
            }

            return(true);
        }
コード例 #2
0
        public virtual void Forfeit(Mobile m)
        {
            if (m == null)
            {
                return;
            }

            ClearNameHue(m);

            // inform him that he has been kicked
            XmlPoints.SendText(m, 100543, ChallengeName); // "You dropped out of {0}"
            GameBroadcast(100544, m.Name);                // "{0} has dropped out."

            RefreshSymmetricNoto(m);

            // this could end the game so check
            CheckForGameEnd();

            // and clear his challenge game
            XmlPoints a = (XmlPoints)XmlAttach.FindAttachment(m, typeof(XmlPoints));

            if (a != null)
            {
                a.ChallengeGame = null;
            }
        }
コード例 #3
0
        public virtual bool CollectEntryFee(Mobile m, int amount)
        {
            if (m == null)
            {
                return(false);
            }

            if (amount <= 0)
            {
                return(true);
            }

            // take the money
            if (m.BankBox != null)
            {
                if (!m.BankBox.ConsumeTotal(typeof(Gold), amount, true))
                {
                    XmlPoints.SendText(m, 100541, amount);  // "Could not withdraw the Entry fee of {0} gold from your bank."
                    return(false);
                }
            }
            else
            {
                XmlPoints.SendText(m, 100541, amount);  // "Could not withdraw the Entry fee of {0} gold from your bank."
                return(false);
            }

            XmlPoints.SendText(m, 100542, amount);   // "The Entry fee of {0} gold has been withdrawn from your bank."

            // and add it to the purse
            TotalPurse += amount;

            return(true);
        }
コード例 #4
0
ファイル: ChallengeGameRegion.cs プロジェクト: omni86/ServUO
 public override void OnExit(Mobile m)
 {
     if (m != null)
     {
         XmlPoints.SendText(m, 100107, this.Name);  // "You have left the Challenge Game region '{0}'"
     }
     base.OnExit(m);
 }
コード例 #5
0
 public override void OnEnter(Mobile m)
 {
     if (m != null)
     {
         XmlPoints.SendText(m, 100106, Name); // "You have entered the Challenge Game region '{0}'"
     }
     base.OnEnter(m);
 }
コード例 #6
0
        public override void OnDelete()
        {
            // if the game is in progress, then return all Entry fees
            if (GameInProgress)
            {
                GameBroadcast(100003, ChallengeName);  // "{0} cancelled"

                // go through the participants and return their fees and clear noto
                if (Participants != null)
                {
                    foreach (IChallengeEntry entry in Participants)
                    {
                        if (entry.Status == ChallengeStatus.Forfeit)
                        {
                            continue;
                        }

                        Mobile from = entry.Participant;

                        // return the entry fee
                        if (from != null && from.BankBox != null && EntryFee > 0)
                        {
                            Item gold = new Gold(EntryFee);

                            if (!from.BankBox.TryDropItem(from, gold, false))
                            {
                                gold.Delete();
                                from.AddToBackpack(new BankCheck(EntryFee));
                                XmlPoints.SendText(from, 100000, EntryFee);                         // "Entry fee of {0} gold has been returned to you."
                            }
                            else
                            {
                                XmlPoints.SendText(from, 100001, EntryFee);  // "Entry fee of {0} gold has been returned to your bank account."
                            }
                        }

                        entry.Status = ChallengeStatus.None;
                    }

                    // clear all noto
                    foreach (IChallengeEntry entry in Participants)
                    {
                        RefreshNoto(entry.Participant);
                    }
                }

                EndGame();
            }
            else
            if (!GameCompleted)
            {
                // this is when a game is cancelled during setup
                GameBroadcast(100003, ChallengeName); // "{0} cancelled"
            }

            base.OnDelete();
        }
コード例 #7
0
        public override void CheckForGameEnd()
        {
            if (Participants == null || !GameInProgress)
            {
                return;
            }

            int    leftstanding = 0;
            Mobile winner       = null;

            foreach (IChallengeEntry entry in Participants)
            {
                // either being the last participant left
                if (entry.Status == ChallengeStatus.Active)
                {
                    leftstanding++;
                    winner = entry.Participant;
                }

                // or reaching the target score
                if (entry.Score >= TargetScore)
                {
                    winner       = entry.Participant;
                    leftstanding = 1;
                    break;
                }
            }

            // and then check to see if this is the King of the Hill
            if (leftstanding == 1 && winner != null)
            {
                // declare the winner and end the game
                XmlPoints.SendText(winner, 100311, ChallengeName);  // "You have won {0}"
                Winner = winner;
                RefreshSymmetricNoto(winner);
                GameBroadcast(100312, winner.Name);  // "The winner is {0}"
                AwardWinnings(winner, TotalPurse);

                EndGame();
                KingOfTheHillGump.RefreshAllGumps(this, true);
            }
            if (leftstanding < 1)
            {
                // declare a tie and keep the fees
                GameBroadcast(100313);  // "The match is a draw"

                EndGame();
                KingOfTheHillGump.RefreshAllGumps(this, true);
            }
        }
コード例 #8
0
ファイル: ChallengeGameRegion.cs プロジェクト: omni86/ServUO
        public override bool OnDoubleClick(Mobile m, object o)
        {
            if (o is Corpse)
            {
                // dont allow other players to loot corpses while a challenge game is present
                if ((this.ChallengeGame != null) && !this.ChallengeGame.Deleted && (m != null) && !(((Corpse)o).Owner is BaseCreature) &&
                    (((Corpse)o).Owner != m) && (m.IsPlayer()))
                {
                    XmlPoints.SendText(m, 100105); // "You are not allowed to open that here."
                    return(false);
                }
            }

            return(base.OnDoubleClick(m, o));
        }
コード例 #9
0
        public virtual void AwardWinnings(Mobile m, int amount)
        {
            if (m == null)
            {
                return;
            }

            if (m.Backpack != null && amount > 0)
            {
                // give them a check for the winnings
                BankCheck check = new BankCheck(amount);
                check.Name = String.Format(XmlPoints.GetText(m, 100300), ChallengeName); // "Prize from {0}"
                m.AddToBackpack(check);
                XmlPoints.SendText(m, 100301, amount);                                   // "You have received a bank check for {0}"
            }
        }
コード例 #10
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (from == null || targeted == null || m_gauntlet == null || m_list == null)
                {
                    return;
                }

                if (targeted is Mobile && ((Mobile)targeted).Player)
                {
                    Mobile pm = targeted as Mobile;

                    // make sure they qualify
                    if (!m_gauntlet.CheckQualify(pm))
                    {
                        return;
                    }

                    // see if they are already in the game
                    if (m_gauntlet.Participants != null)
                    {
                        foreach (TeamDeathballGauntlet.ChallengeEntry entry in m_gauntlet.Participants)
                        {
                            if (pm == entry.Participant)
                            {
                                XmlPoints.SendText(from, 100548, pm.Name);  // "{0} has already been added to the game."
                                return;
                            }
                        }
                    }

                    m_list.Add(new TeamDeathballGauntlet.ChallengeEntry(pm));

                    XmlPoints.SendText(from, 100549, pm.Name);       // "You have added {0} to the challenge."

                    XmlPoints.SendText(pm, 100550, m_gauntlet.Name); // "You have been invited to participate in {0}."

                    // clear all acceptances
                    m_gauntlet.ResetAcceptance();

                    // refresh all gumps
                    RefreshAllGumps(m_gauntlet, true);

                    // refresh the gump with the new member
                    //from.SendGump( new TeamDeathballGump( m_gauntlet, from));
                }
            }
コード例 #11
0
        public void AwardTeamWinnings(int team, int amount)
        {
            if (team == 0)
            {
                return;
            }

            int count = 0;

            // go through all of the team members
            foreach (IChallengeEntry entry in Participants)
            {
                if (entry.Team == team)
                {
                    count++;
                }
            }

            if (count == 0)
            {
                return;
            }

            int split = amount / count;

            // and split the purse
            foreach (IChallengeEntry entry in Participants)
            {
                if (entry.Team == team)
                {
                    Mobile m = entry.Participant;
                    if (m.Backpack != null && amount > 0)
                    {
                        // give them a check for the winnings
                        BankCheck check = new BankCheck(split);
                        check.Name = String.Format(XmlPoints.GetText(m, 100300), ChallengeName); // "Prize from {0}"
                        m.AddToBackpack(check);
                        XmlPoints.SendText(m, 100301, split);                                    // "You have received a bank check for {0}"
                    }
                }
            }
        }
コード例 #12
0
        public override void CheckForGameEnd()
        {
            if (this.Participants == null || !this.GameInProgress)
            {
                return;
            }

            int    leftstanding = 0;
            Mobile winner       = null;

            foreach (ChallengeEntry entry in this.Participants)
            {
                if (entry.Status == ChallengeStatus.Active)
                {
                    leftstanding++;
                    winner = entry.Participant;
                }
            }

            // and then check to see if this is the last man standing
            if (leftstanding == 1 && winner != null)
            {
                // declare the winner and end the game
                XmlPoints.SendText(winner, 100311, this.ChallengeName);  // "You have won {0}"
                this.Winner = winner;
                this.RefreshSymmetricNoto(winner);
                this.GameBroadcast(100312, winner.Name); // "The winner is {0}"
                this.AwardWinnings(winner, this.TotalPurse);

                this.EndGame();
                LastManStandingGump.RefreshAllGumps(this, true);
            }
            if (leftstanding < 1)
            {
                // declare a tie and keep the fees
                this.GameBroadcast(100313);  // "The match is a draw"

                this.EndGame();
                LastManStandingGump.RefreshAllGumps(this, true);
            }
        }
コード例 #13
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (state == null || info == null || state.Mobile == null || m_gauntlet == null || m_gauntlet.Challenger == null)
            {
                return;
            }

            XmlPoints afrom = (XmlPoints)XmlAttach.FindAttachment(state.Mobile, typeof(XmlPoints));

            switch (info.ButtonID)
            {
            case 1:
                // refresh

                //m_gauntlet.CheckForDisqualification();

                state.Mobile.SendGump(new TeamDeathballGump(m_gauntlet, state.Mobile, viewpage));
                break;

            case 10:
                // Entry fee
                int       val = 0;
                TextRelay tr  = info.GetTextEntry(10);
                if (tr != null)
                {
                    try{ val = int.Parse(tr.Text); } catch {}
                }
                m_gauntlet.EntryFee = val;

                m_gauntlet.ResetAcceptance();

                // update all the gumps
                RefreshAllGumps(m_gauntlet, true);

                state.Mobile.SendGump(new TeamDeathballGump(m_gauntlet, state.Mobile, viewpage));
                break;

            case 11:
                // update teams
                if (m_WorkingList != null)
                {
                    for (int i = 0; i < m_WorkingList.Count; i++)
                    {
                        // is this on the visible page?
                        if ((int)(i / PlayersPerPage) != viewpage)
                        {
                            continue;
                        }

                        TeamDeathballGauntlet.ChallengeEntry entry = (TeamDeathballGauntlet.ChallengeEntry)m_WorkingList[i];
                        if (entry != null)
                        {
                            int tval = 0;
                            tr = info.GetTextEntry(500 + i);
                            if (tr != null)
                            {
                                try{ tval = int.Parse(tr.Text); } catch {}
                            }
                            entry.Team = tval;
                        }
                    }
                }

                m_gauntlet.ResetAcceptance();
                // update all the gumps
                RefreshAllGumps(m_gauntlet, true);

                state.Mobile.SendGump(new TeamDeathballGump(m_gauntlet, state.Mobile, viewpage));
                break;

            case 12:
                // page up
                // try doing the default for non-participants
                int nplayers = 0;
                if (m_gauntlet.Participants != null)
                {
                    nplayers = m_gauntlet.Participants.Count;
                }

                int page = viewpage + 1;
                if (page > (int)(nplayers / PlayersPerPage))
                {
                    page = (int)(nplayers / PlayersPerPage);
                }

                if (m_WorkingList != null)
                {
                    for (int i = 0; i < m_WorkingList.Count; i++)
                    {
                        TeamDeathballGauntlet.ChallengeEntry entry = (TeamDeathballGauntlet.ChallengeEntry)m_WorkingList[i];
                        if (entry != null)
                        {
                            if (entry.Participant == state.Mobile)
                            {
                                entry.PageBeingViewed++;

                                if (entry.PageBeingViewed > (int)(nplayers / PlayersPerPage))
                                {
                                    entry.PageBeingViewed = (int)(nplayers / PlayersPerPage);
                                }

                                page = entry.PageBeingViewed;
                                //break;
                            }
                        }
                    }
                }

                state.Mobile.SendGump(new TeamDeathballGump(m_gauntlet, state.Mobile, page));
                break;

            case 13:
                // page down
                // try doing the default for non-participants
                page = viewpage - 1;
                if (page < 0)
                {
                    page = 0;
                }
                if (m_WorkingList != null)
                {
                    for (int i = 0; i < m_WorkingList.Count; i++)
                    {
                        TeamDeathballGauntlet.ChallengeEntry entry = (TeamDeathballGauntlet.ChallengeEntry)m_WorkingList[i];
                        if (entry != null)
                        {
                            if (entry.Participant == state.Mobile)
                            {
                                entry.PageBeingViewed--;

                                if (entry.PageBeingViewed < 0)
                                {
                                    entry.PageBeingViewed = 0;
                                }

                                page = entry.PageBeingViewed;
                                //break;
                            }
                        }
                    }
                }

                state.Mobile.SendGump(new TeamDeathballGump(m_gauntlet, state.Mobile, page));
                break;

            case 20:
                // arena size
                val = 0;
                tr  = info.GetTextEntry(20);
                if (tr != null)
                {
                    try{ val = int.Parse(tr.Text); } catch {}
                }
                m_gauntlet.ArenaSize = val;

                m_gauntlet.ResetAcceptance();

                // update all the gumps
                RefreshAllGumps(m_gauntlet, true);

                state.Mobile.SendGump(new TeamDeathballGump(m_gauntlet, state.Mobile, viewpage));
                break;

            case 30:
                // target score
                val = 0;
                tr  = info.GetTextEntry(30);
                if (tr != null)
                {
                    try{ val = int.Parse(tr.Text); } catch {}
                }
                m_gauntlet.TargetScore = val;

                m_gauntlet.ResetAcceptance();

                // update all the gumps
                RefreshAllGumps(m_gauntlet, true);

                state.Mobile.SendGump(new TeamDeathballGump(m_gauntlet, state.Mobile, viewpage));
                break;

            case 100:

                // add to Participants
                if (m_gauntlet.Participants == null)
                {
                    m_gauntlet.Participants = new ArrayList();
                }

                if (MaxTeamSize > 0 && m_gauntlet.Participants.Count >= MaxTeamSize)
                {
                    XmlPoints.SendText(state.Mobile, 100535);         // "Challenge is full!"
                }
                else
                {
                    state.Mobile.Target = new MemberTarget(m_gauntlet, m_gauntlet.Participants);
                }


                state.Mobile.SendGump(new TeamDeathballGump(m_gauntlet, state.Mobile, viewpage));
                break;

            case 300:
                // Start game
                if (m_WorkingList == null)
                {
                    return;
                }

                bool complete = true;
                foreach (TeamDeathballGauntlet.ChallengeEntry entry in m_WorkingList)
                {
                    if (entry != null)
                    {
                        Mobile m = entry.Participant;

                        if (m == null)
                        {
                            continue;
                        }

                        if (!m_gauntlet.CheckQualify(m))
                        {
                            complete = false;
                            break;
                        }

                        if (!entry.Accepted)
                        {
                            XmlPoints.SendText(m_gauntlet.Challenger, 100539, m.Name);      // "{0} has not accepted yet."
                            complete = false;
                            break;
                        }

                        // and they have a team
                        if (entry.Team <= 0)
                        {
                            XmlPoints.SendText(m_gauntlet.Challenger, 100594, m.Name);     // "{0} has not been assigned a team."
                            complete = false;
                        }
                    }
                }

                if (m_WorkingList.Count < 2)
                {
                    XmlPoints.SendText(m_gauntlet.Challenger, 100540);      // "Insufficient number of players."
                    complete = false;
                }
                // copy all of the accepted entries to the final participants list


                if (complete)
                {
                    m_gauntlet.Participants = new ArrayList();

                    foreach (TeamDeathballGauntlet.ChallengeEntry entry in m_WorkingList)
                    {
                        if (entry != null)
                        {
                            Mobile m = entry.Participant;

                            if (m == null)
                            {
                                continue;
                            }

                            // try to collect any entry fee
                            if (!m_gauntlet.CollectEntryFee(m, m_gauntlet.EntryFee))
                            {
                                continue;
                            }

                            // set up the challenge on each player
                            XmlPoints a = (XmlPoints)XmlAttach.FindAttachment(m, typeof(XmlPoints));
                            if (a != null)
                            {
                                a.ChallengeGame = m_gauntlet;
                            }

                            entry.Status = ChallengeStatus.Active;

                            m_gauntlet.Participants.Add(entry);
                        }
                    }

                    // and lock the game
                    m_gauntlet.StartGame();

                    // refresh all gumps
                    RefreshAllGumps(m_gauntlet, true);
                }
                else
                {
                    state.Mobile.SendGump(new TeamDeathballGump(m_gauntlet, state.Mobile, viewpage));
                }

                break;

            default:
            {
                // forfeit buttons
                if (info.ButtonID >= 4000)
                {
                    int selection = info.ButtonID - 4000;

                    if (selection < m_WorkingList.Count)
                    {
                        TeamDeathballGauntlet.ChallengeEntry entry = (TeamDeathballGauntlet.ChallengeEntry)m_WorkingList[selection];

                        // find the master participants list entry with the same participant
                        if (m_gauntlet.Participants != null)
                        {
                            TeamDeathballGauntlet.ChallengeEntry forfeitentry = null;

                            foreach (TeamDeathballGauntlet.ChallengeEntry masterentry in m_gauntlet.Participants)
                            {
                                if (entry == masterentry)
                                {
                                    forfeitentry = masterentry;
                                    break;
                                }
                            }

                            // and remove it
                            if (forfeitentry != null)
                            {
                                forfeitentry.Status = ChallengeStatus.Forfeit;

                                // inform him that he has been kicked
                                m_gauntlet.Forfeit(forfeitentry.Participant);
                            }
                        }
                    }
                }
                // kick buttons
                if (info.ButtonID >= 2000)
                {
                    int selection = info.ButtonID - 2000;

                    if (selection < m_WorkingList.Count)
                    {
                        TeamDeathballGauntlet.ChallengeEntry entry = (TeamDeathballGauntlet.ChallengeEntry)m_WorkingList[selection];
                        // find the master participants list entry with the same participant
                        if (m_gauntlet.Participants != null)
                        {
                            TeamDeathballGauntlet.ChallengeEntry kickentry = null;

                            foreach (TeamDeathballGauntlet.ChallengeEntry masterentry in m_gauntlet.Participants)
                            {
                                if (entry == masterentry)
                                {
                                    kickentry = masterentry;
                                    break;
                                }
                            }

                            // and remove it
                            if (kickentry != null)
                            {
                                m_gauntlet.Participants.Remove(kickentry);

                                // refresh his gump and inform him that he has been kicked
                                if (kickentry.Participant != null)
                                {
                                    kickentry.Participant.SendMessage("You have been kicked from {0}", m_gauntlet.ChallengeName);
                                    kickentry.Participant.SendGump(new TeamDeathballGump(m_gauntlet, kickentry.Participant, viewpage));
                                }
                            }
                        }

                        m_gauntlet.ResetAcceptance();
                    }

                    // refresh all gumps
                    RefreshAllGumps(m_gauntlet, true);
                    //state.Mobile.SendGump( new TeamDeathballGump( m_gauntlet, state.Mobile));
                }
                else
                // accept buttons
                if (info.ButtonID >= 1000)
                {
                    int selection = info.ButtonID - 1000;
                    // set the acceptance flag of the participant
                    if (selection < m_WorkingList.Count)
                    {
                        TeamDeathballGauntlet.ChallengeEntry entry = (TeamDeathballGauntlet.ChallengeEntry)m_WorkingList[selection];

                        entry.Accepted = !entry.Accepted;
                    }

                    // refresh all gumps
                    RefreshAllGumps(m_gauntlet, true);

                    //state.Mobile.SendGump( new TeamDeathballGump( m_gauntlet, state.Mobile));
                }


                break;
            }
            }
        }
コード例 #14
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (state == null || info == null || state.Mobile == null || this.m_gauntlet == null || this.m_gauntlet.Challenger == null)
                return;

            XmlPoints afrom = (XmlPoints)XmlAttach.FindAttachment(state.Mobile, typeof(XmlPoints));

            switch ( info.ButtonID )
            {
                case 1:
                    // refresh

                    this.m_gauntlet.CheckForDisqualification();

                    state.Mobile.SendGump(new DeathmatchGump(this.m_gauntlet, state.Mobile, this.viewpage));
                    break;
                case 10:
                    // Entry fee
                    int val = 0;
                    TextRelay tr = info.GetTextEntry(10);
                    if (tr != null)
                    {
                        try
                        {
                            val = int.Parse(tr.Text);
                        }
                        catch
                        {
                        }
                    }
                    this.m_gauntlet.EntryFee = val;

                    this.m_gauntlet.ResetAcceptance();

                    // update all the gumps
                    RefreshAllGumps(this.m_gauntlet, true);

                    state.Mobile.SendGump(new DeathmatchGump(this.m_gauntlet, state.Mobile, this.viewpage));
                    break;
                case 12:
                    // page up
                    // try doing the default for non-participants
                    int nplayers = 0;
                    if (this.m_gauntlet.Participants != null)
                        nplayers = this.m_gauntlet.Participants.Count;

                    int page = this.viewpage + 1;
                    if (page > (int)(nplayers / this.PlayersPerPage))
                    {
                        page = (int)(nplayers / this.PlayersPerPage);
                    }

                    foreach (DeathmatchGauntlet.ChallengeEntry entry in this.m_WorkingList)
                    {
                        if (entry != null)
                        {
                            if (entry.Participant == state.Mobile)
                            {
                                entry.PageBeingViewed++;

                                if (entry.PageBeingViewed > (int)(nplayers / this.PlayersPerPage))
                                    entry.PageBeingViewed = (int)(nplayers / this.PlayersPerPage);
                                page = entry.PageBeingViewed;
                                break;
                            }
                        }
                    }

                    state.Mobile.SendGump(new DeathmatchGump(this.m_gauntlet, state.Mobile, page));
                    break;
                case 13:
                    // page down
                    // try doing the default for non-participants

                    page = this.viewpage - 1;
                    if (page < 0)
                    {
                        page = 0;
                    }
                    foreach (DeathmatchGauntlet.ChallengeEntry entry in this.m_WorkingList)
                    {
                        if (entry != null)
                        {
                            if (entry.Participant == state.Mobile)
                            {
                                entry.PageBeingViewed--;

                                if (entry.PageBeingViewed < 0)
                                    entry.PageBeingViewed = 0;
                                page = entry.PageBeingViewed;
                                break;
                            }
                        }
                    }

                    state.Mobile.SendGump(new DeathmatchGump(this.m_gauntlet, state.Mobile, page));
                    break;
                case 20:
                    // arena size
                    val = 0;
                    tr = info.GetTextEntry(20);
                    if (tr != null)
                    {
                        try
                        {
                            val = int.Parse(tr.Text);
                        }
                        catch
                        {
                        }
                    }
                    this.m_gauntlet.ArenaSize = val;

                    this.m_gauntlet.ResetAcceptance();

                    // update all the gumps
                    RefreshAllGumps(this.m_gauntlet, true);

                    state.Mobile.SendGump(new DeathmatchGump(this.m_gauntlet, state.Mobile, this.viewpage));
                    break;
                case 30:
                    // target score
                    val = 0;
                    tr = info.GetTextEntry(30);
                    if (tr != null)
                    {
                        try
                        {
                            val = int.Parse(tr.Text);
                        }
                        catch
                        {
                        }
                    }
                    this.m_gauntlet.TargetScore = val;

                    this.m_gauntlet.ResetAcceptance();

                    // update all the gumps
                    RefreshAllGumps(this.m_gauntlet, true);

                    state.Mobile.SendGump(new DeathmatchGump(this.m_gauntlet, state.Mobile, this.viewpage));
                    break;
                case 40:
                    // match length
                    double dval = 0;
                    tr = info.GetTextEntry(40);
                    if (tr != null)
                    {
                        try
                        {
                            dval = double.Parse(tr.Text);
                        }
                        catch
                        {
                        }
                    }
                    this.m_gauntlet.MatchLength = TimeSpan.FromMinutes(dval);

                    this.m_gauntlet.ResetAcceptance();

                    // update all the gumps
                    RefreshAllGumps(this.m_gauntlet, true);

                    state.Mobile.SendGump(new DeathmatchGump(this.m_gauntlet, state.Mobile, this.viewpage));
                    break;
                case 100:

                    // add to Participants
                    if (this.m_gauntlet.Participants == null)
                        this.m_gauntlet.Participants = new ArrayList();

                    if (this.MaxTeamSize > 0 && this.m_gauntlet.Participants.Count >= this.MaxTeamSize)
                    {
                        XmlPoints.SendText(state.Mobile, 100535);     // "Challenge is full!"
                    }
                    else
                    {
                        state.Mobile.Target = new MemberTarget(this.m_gauntlet, this.m_gauntlet.Participants);
                    }

                    state.Mobile.SendGump(new DeathmatchGump(this.m_gauntlet, state.Mobile, this.viewpage));
                    break;
                case 300:
                    // Start game
                    if (this.m_WorkingList == null)
                        return;

                    bool complete = true;
                    foreach (DeathmatchGauntlet.ChallengeEntry entry in this.m_WorkingList)
                    {
                        if (entry != null)
                        {
                            Mobile m = entry.Participant;

                            if (m == null)
                                continue;

                            if (!this.m_gauntlet.CheckQualify(m))
                            {
                                complete = false;
                                break;
                            }

                            if (!entry.Accepted)
                            {
                                XmlPoints.SendText(this.m_gauntlet.Challenger, 100539, m.Name);  // "{0} has not accepted yet."
                                complete = false;
                                break;
                            }
                        }
                    }

                    if (this.m_WorkingList.Count < 2)
                    {
                        XmlPoints.SendText(this.m_gauntlet.Challenger, 100540);  // "Insufficient number of players."
                        complete = false;
                    }

                    if (this.m_gauntlet.TargetScore <= 0 && this.m_gauntlet.MatchLength <= TimeSpan.Zero)
                    {
                        XmlPoints.SendText(this.m_gauntlet.Challenger, 100568);  // "No valid end condition for match."
                        complete = false;
                    }
                    // copy all of the accepted entries to the final participants list

                    if (complete)
                    {
                        this.m_gauntlet.Participants = new ArrayList();

                        foreach (DeathmatchGauntlet.ChallengeEntry entry in this.m_WorkingList)
                        {
                            if (entry != null)
                            {
                                Mobile m = entry.Participant;

                                if (m == null)
                                    continue;

                                // try to collect any entry fee
                                if (!this.m_gauntlet.CollectEntryFee(m, this.m_gauntlet.EntryFee))
                                    continue;

                                // set up the challenge on each player
                                XmlPoints a = (XmlPoints)XmlAttach.FindAttachment(m, typeof(XmlPoints));
                                if (a != null)
                                {
                                    a.ChallengeGame = this.m_gauntlet;
                                }

                                entry.Status = ChallengeStatus.Active;

                                this.m_gauntlet.Participants.Add(entry);
                            }
                        }

                        // and lock the game
                        this.m_gauntlet.StartGame();

                        // refresh all gumps
                        RefreshAllGumps(this.m_gauntlet, true);
                    }
                    else
                    {
                        state.Mobile.SendGump(new DeathmatchGump(this.m_gauntlet, state.Mobile, this.viewpage));
                    }

                    break;
                default:
                    {
                        // forfeit buttons
                        if (info.ButtonID >= 4000)
                        {
                            int selection = info.ButtonID - 4000;

                            if (selection < this.m_WorkingList.Count)
                            {
                                DeathmatchGauntlet.ChallengeEntry entry = (DeathmatchGauntlet.ChallengeEntry)this.m_WorkingList[selection];

                                // find the master participants list entry with the same participant
                                if (this.m_gauntlet.Participants != null)
                                {
                                    DeathmatchGauntlet.ChallengeEntry forfeitentry = null;

                                    foreach (DeathmatchGauntlet.ChallengeEntry masterentry in this.m_gauntlet.Participants)
                                    {
                                        if (entry == masterentry)
                                        {
                                            forfeitentry = masterentry;
                                            break;
                                        }
                                    }

                                    // and remove it
                                    if (forfeitentry != null)
                                    {
                                        forfeitentry.Status = ChallengeStatus.Forfeit;

                                        // inform him that he has been kicked
                                        this.m_gauntlet.Forfeit(forfeitentry.Participant);
                                    }
                                }
                            }
                        }
                        // kick buttons
                        if (info.ButtonID >= 2000)
                        {
                            int selection = info.ButtonID - 2000;

                            if (selection < this.m_WorkingList.Count)
                            {
                                DeathmatchGauntlet.ChallengeEntry entry = (DeathmatchGauntlet.ChallengeEntry)this.m_WorkingList[selection];
                                // find the master participants list entry with the same participant
                                if (this.m_gauntlet.Participants != null)
                                {
                                    DeathmatchGauntlet.ChallengeEntry kickentry = null;

                                    foreach (DeathmatchGauntlet.ChallengeEntry masterentry in this.m_gauntlet.Participants)
                                    {
                                        if (entry == masterentry)
                                        {
                                            kickentry = masterentry;
                                            break;
                                        }
                                    }

                                    // and remove it
                                    if (kickentry != null)
                                    {
                                        this.m_gauntlet.Participants.Remove(kickentry);

                                        // refresh his gump and inform him that he has been kicked
                                        if (kickentry.Participant != null)
                                        {
                                            XmlPoints.SendText(kickentry.Participant, 100545, this.m_gauntlet.ChallengeName); // "You have been kicked from {0}"
                                            kickentry.Participant.SendGump(new DeathmatchGump(this.m_gauntlet, kickentry.Participant, this.viewpage));
                                        }
                                    }
                                }

                                this.m_gauntlet.ResetAcceptance();
                            }

                            // refresh all gumps
                            RefreshAllGumps(this.m_gauntlet, true);
                            //state.Mobile.SendGump( new DeathmatchGump( m_gauntlet, state.Mobile));
                        }
                        else if (info.ButtonID >= 1000)
                        {
                            int selection = info.ButtonID - 1000;
                            // set the acceptance flag of the participant
                            if (selection < this.m_WorkingList.Count)
                            {
                                DeathmatchGauntlet.ChallengeEntry entry = (DeathmatchGauntlet.ChallengeEntry)this.m_WorkingList[selection];

                                entry.Accepted = !entry.Accepted;
                            }

                            // refresh all gumps
                            RefreshAllGumps(this.m_gauntlet, true);
                            //state.Mobile.SendGump( new DeathmatchGump( m_gauntlet, state.Mobile));
                        }

                        break;
                    }
            }
        }
コード例 #15
0
        public void CheckForDisqualification()
        {
            if (Participants == null || !GameInProgress)
            {
                return;
            }

            bool statuschange = false;

            foreach (ChallengeEntry entry in Participants)
            {
                if (entry.Participant == null || entry.Status != ChallengeStatus.Active)
                {
                    continue;
                }

                bool hadcaution = (entry.Caution != ChallengeStatus.None);

                // and a map check
                if (entry.Participant.Map != Map)
                {
                    // check to see if they are offline
                    if (entry.Participant.Map == Map.Internal)
                    {
                        // then give them a little time to return before disqualification
                        if (entry.Caution == ChallengeStatus.Offline)
                        {
                            // were previously out of bounds so check for disqualification
                            // check to see how long they have been out of bounds
                            if (DateTime.Now - entry.LastCaution > MaximumOfflineDuration)
                            {
                                // penalize them
                                SubtractScore(entry);
                                entry.LastCaution = DateTime.Now;
                            }
                        }
                        else
                        {
                            entry.LastCaution = DateTime.Now;
                            statuschange      = true;
                        }

                        entry.Caution = ChallengeStatus.Offline;
                    }
                    else
                    {
                        // changing to any other map results in instant
                        // teleport back to the gauntlet
                        // and point loss
                        RespawnWithPenalty(entry);
                        entry.Caution = ChallengeStatus.None;
                    }
                }
                else
                // make a range check
                if (m_ArenaSize > 0 && !Utility.InRange(entry.Participant.Location, Location, m_ArenaSize) ||
                    (IsInChallengeGameRegion && !(Region.Find(entry.Participant.Location, entry.Participant.Map) is ChallengeGameRegion)))
                {
                    if (entry.Caution == ChallengeStatus.OutOfBounds)
                    {
                        // were previously out of bounds so check for disqualification
                        // check to see how long they have been out of bounds
                        if (DateTime.Now - entry.LastCaution > MaximumOutOfBoundsDuration)
                        {
                            // teleport them back to the gauntlet
                            RespawnWithPenalty(entry);
                            GameBroadcast(100401, entry.Participant.Name);  // "{0} was penalized."
                            entry.Caution = ChallengeStatus.None;
                            statuschange  = true;
                        }
                    }
                    else
                    {
                        entry.LastCaution = DateTime.Now;
                        // inform the player
                        XmlPoints.SendText(entry.Participant, 100309, MaximumOutOfBoundsDuration.TotalSeconds);  // "You are out of bounds!  You have {0} seconds to return"
                        statuschange = true;
                    }

                    entry.Caution = ChallengeStatus.OutOfBounds;
                }
                else
                // make a hiding check
                if (entry.Participant.Hidden)
                {
                    if (entry.Caution == ChallengeStatus.Hidden)
                    {
                        // were previously hidden so check for disqualification
                        // check to see how long they have hidden
                        if (DateTime.Now - entry.LastCaution > MaximumHiddenDuration)
                        {
                            // penalize them
                            SubtractScore(entry);
                            entry.Participant.Hidden = false;
                            GameBroadcast(100401, entry.Participant.Name);  // "{0} was penalized."
                            entry.Caution = ChallengeStatus.None;
                            statuschange  = true;
                        }
                    }
                    else
                    {
                        entry.LastCaution = DateTime.Now;
                        // inform the player
                        XmlPoints.SendText(entry.Participant, 100310, MaximumHiddenDuration.TotalSeconds); // "You have {0} seconds become unhidden"
                        statuschange = true;
                    }

                    entry.Caution = ChallengeStatus.Hidden;
                }
                else
                {
                    entry.Caution = ChallengeStatus.None;
                }

                if (hadcaution && entry.Caution == ChallengeStatus.None)
                {
                    statuschange = true;
                }
            }

            if (statuschange)
            {
                // update gumps with the new status
                TeamDeathmatchGump.RefreshAllGumps(this, false);
            }

            // it is possible that the game could end like this so check
            CheckForGameEnd();
        }
コード例 #16
0
ファイル: CTF.cs プロジェクト: blasterdude9/ForkUO-1
        public void CheckForDisqualification()
        {
            if (this.Participants == null || !this.GameInProgress)
            {
                return;
            }

            bool statuschange = false;

            foreach (ChallengeEntry entry in this.Participants)
            {
                if (entry.Participant == null || entry.Status != ChallengeStatus.Active)
                {
                    continue;
                }

                bool hadcaution = (entry.Caution != ChallengeStatus.None);

                // and a map check
                if (entry.Participant.Map != this.Map)
                {
                    // check to see if they are offline
                    if (entry.Participant.Map == Map.Internal)
                    {
                        // then give them a little time to return before disqualification
                        if (entry.Caution == ChallengeStatus.Offline)
                        {
                            // were previously out of bounds so check for disqualification
                            // check to see how long they have been out of bounds
                            if (DateTime.Now - entry.LastCaution > MaximumOfflineDuration)
                            {
                                // return any flag they might be carrying
                                this.ReturnAnyFlags(entry.Participant);
                                entry.LastCaution = DateTime.Now;
                            }
                        }
                        else
                        {
                            entry.LastCaution = DateTime.Now;
                            statuschange      = true;
                        }

                        entry.Caution = ChallengeStatus.Offline;
                    }
                    else
                    {
                        // changing to any other map results in
                        // return of any flag they might be carrying
                        this.ReturnAnyFlags(entry.Participant);
                        entry.Caution = ChallengeStatus.None;
                    }
                }
                else if (this.m_ArenaSize > 0 && !Utility.InRange(entry.Participant.Location, this.Location, this.m_ArenaSize) ||
                         (this.IsInChallengeGameRegion && !(Region.Find(entry.Participant.Location, entry.Participant.Map) is ChallengeGameRegion)))
                {
                    if (entry.Caution == ChallengeStatus.OutOfBounds)
                    {
                        // were previously out of bounds so check for disqualification
                        // check to see how long they have been out of bounds
                        if (DateTime.Now - entry.LastCaution > MaximumOutOfBoundsDuration)
                        {
                            // return any flag they might be carrying
                            this.ReturnAnyFlags(entry.Participant);
                            entry.Caution = ChallengeStatus.None;
                            statuschange  = true;
                        }
                    }
                    else
                    {
                        entry.LastCaution = DateTime.Now;
                        // inform the player
                        XmlPoints.SendText(entry.Participant, 100309, MaximumOutOfBoundsDuration.TotalSeconds);  // "You are out of bounds!  You have {0} seconds to return"
                        statuschange = true;
                    }

                    entry.Caution = ChallengeStatus.OutOfBounds;
                }
                else if (entry.Participant.Hidden)
                {
                    if (entry.Caution == ChallengeStatus.Hidden)
                    {
                        // were previously hidden so check for disqualification
                        // check to see how long they have hidden
                        if (DateTime.Now - entry.LastCaution > MaximumHiddenDuration)
                        {
                            // return any flag they might be carrying
                            this.ReturnAnyFlags(entry.Participant);
                            entry.Participant.Hidden = false;
                            entry.Caution            = ChallengeStatus.None;
                            statuschange             = true;
                        }
                    }
                    else
                    {
                        entry.LastCaution = DateTime.Now;
                        // inform the player
                        XmlPoints.SendText(entry.Participant, 100310, MaximumHiddenDuration.TotalSeconds); // "You have {0} seconds become unhidden"
                        statuschange = true;
                    }

                    entry.Caution = ChallengeStatus.Hidden;
                }
                else
                {
                    entry.Caution = ChallengeStatus.None;
                }

                if (hadcaution && entry.Caution == ChallengeStatus.None)
                {
                    statuschange = true;
                }
            }

            if (statuschange)
            {
                // update gumps with the new status
                CTFGump.RefreshAllGumps(this, false);
            }

            // it is possible that the game could end like this so check
            this.CheckForGameEnd();
        }
コード例 #17
0
        public void CheckForDisqualification()
        {
            if (this.Participants == null || !this.GameInProgress)
            {
                return;
            }

            bool statuschange = false;

            foreach (IChallengeEntry entry in this.Participants)
            {
                if (entry.Participant == null || entry.Status == ChallengeStatus.Forfeit || entry.Status == ChallengeStatus.Disqualified)
                {
                    continue;
                }

                bool hadcaution = (entry.Caution != ChallengeStatus.None);

                // and a map check
                if (entry.Participant.Map != this.Map)
                {
                    // check to see if they are offline
                    if (entry.Participant.Map == Map.Internal)
                    {
                        // then give them a little time to return before disqualification
                        if (entry.Caution == ChallengeStatus.Offline)
                        {
                            // were previously out of bounds so check for disqualification
                            // check to see how long they have been out of bounds
                            if (DateTime.UtcNow - entry.LastCaution > MaximumOfflineDuration)
                            {
                                entry.Status = ChallengeStatus.Disqualified;
                                this.GameBroadcast(100308, entry.Participant.Name);  // "{0} has been disqualified"
                                this.RefreshSymmetricNoto(entry.Participant);
                                statuschange = true;
                            }
                        }
                        else
                        {
                            entry.LastCaution = DateTime.UtcNow;
                            statuschange      = true;
                        }

                        entry.Caution = ChallengeStatus.Offline;
                    }
                    else
                    {
                        // changing to any other map is instant disqualification
                        entry.Status = ChallengeStatus.Disqualified;
                        this.GameBroadcast(100308, entry.Participant.Name);  // "{0} has been disqualified"
                        this.RefreshSymmetricNoto(entry.Participant);
                        statuschange = true;
                    }
                }
                else if (this.m_ArenaSize > 0 && !Utility.InRange(entry.Participant.Location, this.Location, this.m_ArenaSize) ||
                         (this.IsInChallengeGameRegion && !(Region.Find(entry.Participant.Location, entry.Participant.Map) is ChallengeGameRegion)))
                {
                    if (entry.Caution == ChallengeStatus.OutOfBounds)
                    {
                        // were previously out of bounds so check for disqualification
                        // check to see how long they have been out of bounds
                        if (DateTime.UtcNow - entry.LastCaution > MaximumOutOfBoundsDuration)
                        {
                            entry.Status = ChallengeStatus.Disqualified;
                            this.GameBroadcast(100308, entry.Participant.Name);  // "{0} has been disqualified"
                            this.RefreshSymmetricNoto(entry.Participant);
                            statuschange = true;
                        }
                    }
                    else
                    {
                        entry.LastCaution = DateTime.UtcNow;
                        // inform the player
                        XmlPoints.SendText(entry.Participant, 100309, MaximumOutOfBoundsDuration.TotalSeconds);  // "You are out of bounds!  You have {0} seconds to return"
                        statuschange = true;
                    }

                    entry.Caution = ChallengeStatus.OutOfBounds;
                }
                else if (entry.Participant.Hidden)
                {
                    if (entry.Caution == ChallengeStatus.Hidden)
                    {
                        // were previously hidden so check for disqualification
                        // check to see how long they have hidden
                        if (DateTime.UtcNow - entry.LastCaution > MaximumHiddenDuration)
                        {
                            entry.Status = ChallengeStatus.Disqualified;
                            this.GameBroadcast(100308, entry.Participant.Name);  // "{0} has been disqualified"
                            this.RefreshSymmetricNoto(entry.Participant);
                            statuschange = true;
                        }
                    }
                    else
                    {
                        entry.LastCaution = DateTime.UtcNow;
                        // inform the player
                        XmlPoints.SendText(entry.Participant, 100310, MaximumHiddenDuration.TotalSeconds); // "You have {0} seconds become unhidden"
                        statuschange = true;
                    }

                    entry.Caution = ChallengeStatus.Hidden;
                }
                else
                {
                    entry.Caution = ChallengeStatus.None;
                }

                if (hadcaution && entry.Caution == ChallengeStatus.None)
                {
                    statuschange = true;
                }

                // if they were disqualified, then drop any ball they might have had and boot them from the game
                if (entry.Status == ChallengeStatus.Disqualified)
                {
                    this.ClearChallenge(entry.Participant);
                    this.DropBall(entry.Participant, this.Location, this.Map);
                }
            }

            if (statuschange)
            {
                // update gumps with the new status
                TeamDeathballGump.RefreshAllGumps(this, false);
            }

            // it is possible that the game could end like this so check
            this.CheckForGameEnd();
        }
コード例 #18
0
        public override void CheckForGameEnd()
        {
            if (this.Participants == null || !this.GameInProgress)
            {
                return;
            }

            ArrayList winner = new ArrayList();

            int             leftstanding = 0;
            IChallengeEntry lastentry    = null;
            int             maxscore     = -99999;

            // has anyone reached the target score
            foreach (IChallengeEntry entry in this.Participants)
            {
                if (entry.Status == ChallengeStatus.Active)
                {
                    if (this.TargetScore > 0 && entry.Score >= this.TargetScore)
                    {
                        winner.Add(entry);
                        entry.Winner = true;
                    }

                    if (entry.Score >= maxscore)
                    {
                        maxscore = entry.Score;
                    }
                    leftstanding++;
                    lastentry = entry;
                }
            }

            // if only one is left then they are the winner
            if (leftstanding == 1 && winner.Count == 0)
            {
                winner.Add(lastentry);
                lastentry.Winner = true;
            }

            if (winner.Count == 0 && this.MatchLength > TimeSpan.Zero && (DateTime.UtcNow >= this.MatchStart + this.MatchLength))
            {
                // find the highest score
                // has anyone reached the target score
                foreach (IChallengeEntry entry in this.Participants)
                {
                    if (entry.Status == ChallengeStatus.Active)
                    {
                        if (entry.Score >= maxscore)
                        {
                            winner.Add(entry);
                            entry.Winner = true;
                        }
                    }
                }
            }

            // and then check to see if this is the Deathmatch
            if (winner.Count > 0)
            {
                // declare the winner(s) and end the game
                foreach (IChallengeEntry entry in winner)
                {
                    if (entry.Participant != null)
                    {
                        XmlPoints.SendText(entry.Participant, 100311, this.ChallengeName); // "You have won {0}"
                        this.GameBroadcast(100312, entry.Participant.Name);                // "The winner is {0}"
                        this.AwardWinnings(entry.Participant, this.TotalPurse / winner.Count);
                    }
                }

                this.EndGame();
                DeathmatchGump.RefreshAllGumps(this, true);
            }
        }