Пример #1
0
 public void Add(TournamentMember member)
 {
     if (members.Contains(member) == false)
     {
         members.Add(member);
     }
 }
Пример #2
0
 public MatchUp(string id, Tournament tournament, TournamentMember playerOne, TournamentMember playerTwo)
 {
     this.id = id;
     this.tournament = tournament;
     this.playerOne = playerOne;
     this.playerTwo = playerTwo;
 }
Пример #3
0
        internal void MatchUpComplete(MatchUp matchUp)
        {
            activeMatchups.Remove(matchUp);

            if (activeMatchups.Count == 0)
            {
                // All match-ups have been completed, and winners were determined

                int remainingPlayersCount = CountRemainingPlayers() + 1;
                if (remainingPlayersCount == 1)
                {
                    // Only one player left, so this player wins the tournament!
                    TournamentMember winner = null;
                    // Find the winning player instance
                    for (int i = 0; i < registeredMembers.Count; i++)
                    {
                        if (registeredMembers[i].Active)
                        {
                            winner = registeredMembers[i];
                        }
                    }
                    if (winner != null)
                    {
                        TournamentComplete(winner);
                    }
                }
                else if (remainingPlayersCount > 1)
                {
                    // We have more than one player, continue the match-ups

                    Scripting.ScriptManager.InvokeSub("OnTournamentRoundComplete", this);
                }
            }
        }
Пример #4
0
 public MatchUp(string id, Tournament tournament, TournamentMember playerOne, TournamentMember playerTwo)
 {
     this.id         = id;
     this.tournament = tournament;
     this.playerOne  = playerOne;
     this.playerTwo  = playerTwo;
 }
Пример #5
0
        public void EndMatchUp(string winnerPlayerID)
        {
            TournamentMember winner = null;
            TournamentMember loser  = null;

            if (winnerPlayerID == playerOne.Client.Player.CharID)
            {
                winner = playerOne;
                loser  = playerTwo;
            }
            else if (winnerPlayerID == playerTwo.Client.Player.CharID)
            {
                winner = playerTwo;
                loser  = playerOne;
            }
            if (winner != null && loser != null)
            {
                // Warp both players to the hub
                tournament.WarpToHub(playerOne.Client);
                tournament.WarpToHub(playerTwo.Client);
                // Allow the winner to continue, prevent the loser from continuing
                winner.Active = true;
                loser.Active  = false;

                winner.Client.Player.TournamentMatchUp = null;
                loser.Client.Player.TournamentMatchUp  = null;

                tournament.MatchUpComplete(this);
            }
        }
Пример #6
0
 public void RegisterSpectator(Client client)
 {
     if (registeredMembers.Contains(client.Player.CharID) == false)
     {
         TournamentMember member = new TournamentMember(this, client);
         client.Player.Tournament = this;
         member.Active            = false;
         registeredMembers.Add(member);
         OnPlayerRegistered(member);
     }
 }
Пример #7
0
 public void RegisterPlayer(TournamentMember member)
 {
     if (tournamentStarted == false)
     {
         if (registeredMembers.Count < playersNeeded)
         {
             member.Client.Player.Tournament = this;
             registeredMembers.Add(member);
             OnPlayerRegistered(member);
         }
     }
 }
Пример #8
0
        public static Tournament CreateTournament(Client manager, string name, string hubMap, int hubStartX, int hubStartY)
        {
            Tournament tournament = new Tournament(GenerateUniqueID(), name,  new WarpDestination(hubMap, hubStartX, hubStartY));
            // Add the manager
            TournamentMember member = new TournamentMember(tournament, manager);
            member.Admin = true;
            member.Active = true;
            tournament.RegisterPlayer(member);

            tournaments.AddTournament(tournament);

            return tournament;
        }
Пример #9
0
 public void RegisterPlayer(Client client)
 {
     if (tournamentStarted == false)
     {
         if (registeredMembers.Count < playersNeeded && registeredMembers.Contains(client.Player.CharID) == false)
         {
             TournamentMember member = new TournamentMember(this, client);
             client.Player.Tournament = this;
             member.Active            = true;
             registeredMembers.Add(member);
             OnPlayerRegistered(member);
         }
     }
 }
Пример #10
0
        public static Tournament CreateTournament(Client manager, string name, string hubMap, int hubStartX, int hubStartY)
        {
            Tournament tournament = new Tournament(GenerateUniqueID(), name, new WarpDestination(hubMap, hubStartX, hubStartY));
            // Add the manager
            TournamentMember member = new TournamentMember(tournament, manager);

            member.Admin  = true;
            member.Active = true;
            tournament.RegisterPlayer(member);

            tournaments.AddTournament(tournament);

            return(tournament);
        }
Пример #11
0
        public void StartRound(MatchUpRules matchUpRules)
        {
            if (!tournamentStarted)
            {
                tournamentStarted = true;
            }
            bool evenPlayerCount = (CountRemainingPlayers() % 2 == 0);
            TournamentMemberCollection membersWaitList = registeredMembers.Clone() as TournamentMemberCollection;

            // Remove inactive players from wait list
            for (int i = membersWaitList.Count - 1; i >= 0; i--)
            {
                if (membersWaitList[i].Active == false)
                {
                    membersWaitList.RemoveAt(i);
                }
            }
            if (!evenPlayerCount)
            {
                int skipIndex = MathFunctions.Rand(0, membersWaitList.Count);
                membersWaitList.RemoveAt(skipIndex);
            }
            activeMatchups.Clear();
            // Continue making match-ups until all players have been accounted for
            while (membersWaitList.Count > 0)
            {
                int playerOneIndex         = MathFunctions.Rand(0, membersWaitList.Count);
                TournamentMember playerOne = membersWaitList[playerOneIndex];
                membersWaitList.RemoveAt(playerOneIndex);

                int playerTwoIndex         = MathFunctions.Rand(0, membersWaitList.Count);
                TournamentMember playerTwo = membersWaitList[playerTwoIndex];
                membersWaitList.RemoveAt(playerTwoIndex);

                MatchUp matchUp = new MatchUp(GenerateUniqueMatchUpID(), this, playerOne, playerTwo);
                matchUp.Rules = matchUpRules;

                activeMatchups.Add(matchUp);

                int          combatMapIndex = MathFunctions.Rand(0, combatMaps.Count);
                InstancedMap iMap           = MapCloner.CreateInstancedMap(MapManager.RetrieveMap(combatMaps[combatMapIndex]));
                matchUp.StartMatchUp(iMap);
            }
        }
Пример #12
0
 internal void TournamentComplete(TournamentMember winner)
 {
     Scripting.ScriptManager.InvokeSub("OnTournamentComplete", this, winner);
 }
Пример #13
0
 public void RegisterSpectator(Client client)
 {
     if (registeredMembers.Contains(client.Player.CharID) == false) {
         TournamentMember member = new TournamentMember(this, client);
         client.Player.Tournament = this;
         member.Active = false;
         registeredMembers.Add(member);
         OnPlayerRegistered(member);
     }
 }
Пример #14
0
 public void RegisterPlayer(TournamentMember member)
 {
     if (tournamentStarted == false) {
         if (registeredMembers.Count < playersNeeded) {
             member.Client.Player.Tournament = this;
             registeredMembers.Add(member);
             OnPlayerRegistered(member);
         }
     }
 }
Пример #15
0
 public void RegisterPlayer(Client client)
 {
     if (tournamentStarted == false) {
         if (registeredMembers.Count < playersNeeded && registeredMembers.Contains(client.Player.CharID) == false) {
             TournamentMember member = new TournamentMember(this, client);
             client.Player.Tournament = this;
             member.Active = true;
             registeredMembers.Add(member);
             OnPlayerRegistered(member);
         }
     }
 }
Пример #16
0
 public void Add(TournamentMember member)
 {
     if (members.Contains(member) == false) {
         members.Add(member);
     }
 }
Пример #17
0
 public void Remove(TournamentMember member)
 {
     RemoveAt(IndexOf(member.Client.Player.CharID));
 }
Пример #18
0
 internal void TournamentComplete(TournamentMember winner)
 {
     Scripting.ScriptManager.InvokeSub("OnTournamentComplete", this, winner);
 }
Пример #19
0
        public static void OnPlayerRegisteredInTournament(Tournament tournament, TournamentMember member, bool isSpectator)
        {
            try {
                if (member.Client.Player.MapID == MapManager.GenerateMapID(1192)) {
                    if (!isSpectator) {
                        Story story = new Story();
                        StoryBuilderSegment segment = StoryBuilder.BuildStory();

                        StoryBuilder.AppendSaySegment(segment, "Please step into the left door.", -1, 0, 0);
                        StoryBuilder.AppendMovePlayerAction(segment, 9, 1, Enums.Speed.Walking, true);

                        segment.AppendToStory(story);
                        StoryManager.PlayStory(member.Client, story);
                    } else {
                        // Player is a spectator
                        tournament.WarpToHub(member.Client);
                    }
                }
            } catch (Exception ex) {
                Messenger.AdminMsg("Error: OnPlayerRegisteredInTournament", Text.Black);
            }
        }
Пример #20
0
 public static void OnTournamentComplete(Tournament tournament, TournamentMember member)
 {
     Messenger.AdminMsg("[Staff] The winner was " + member.Client.Player.Name + "!", Text.BrightBlue);
 }
Пример #21
0
 private void OnPlayerRegistered(TournamentMember member)
 {
     Scripting.ScriptManager.InvokeSub("OnPlayerRegisteredInTournament", this, member, !member.Active);
 }
Пример #22
0
 private void OnPlayerRegistered(TournamentMember member)
 {
     Scripting.ScriptManager.InvokeSub("OnPlayerRegisteredInTournament", this, member, !member.Active);
 }
Пример #23
0
 public void Remove(TournamentMember member)
 {
     RemoveAt(IndexOf(member.Client.Player.CharID));
 }