コード例 #1
0
        private void addPlayerToPeerToTournaments(IPeer peer, PreTournamentGame newTournament)
        {
            if (peerToTournaments.ContainsKey(peer.Id) == false)
            {
                peerToTournaments.Add(peer.Id, newTournament);
                return;
            }

            PreTournamentGame oldTournament = peerToTournaments[peer.Id];

            if (SpectatorAuthModule.existsAdmin(peer))   //Admin
            {
                closeTournament(oldTournament);
                peerToTournaments.Remove(peer.Id);
            }
            else    //User
            {
                if (oldTournament.getRoomID() != newTournament.getRoomID())
                {
                    removePlayerFromGame(peer, oldTournament);
                }
                else
                {
                    return;
                }
            }

            peerToTournaments.Add(peer.Id, newTournament);
        }
コード例 #2
0
 private bool isValidAdmin(IIncommingMessage rawMsg)
 {
     if (SpectatorAuthModule.existsAdmin(rawMsg.Peer) == false)
     {
         rawMsg.Respond("Peer ID is not a registred Admin", ResponseStatus.Error);
         return(false);
     }
     return(true);
 }
コード例 #3
0
 private void handleRequestSpectatorGames(IIncommingMessage msg)
 {
     if (SpectatorAuthModule.existsAdmin(msg.Peer) == false)
     {
         return;
     }
     byte[] bytes = allGamesList.Select(g => g.convertToGameInfoPacket()).Select(l => (ISerializablePacket)l).ToBytes();
     msg.Respond(bytes, ResponseStatus.Success);
 }
コード例 #4
0
        public void handleReconnectPlayer(IIncommingMessage rawMsg)
        {
            TournamentReconnectPlayer info = rawMsg.Deserialize <TournamentReconnectPlayer>();
            RunningTournamentGame     game;

            if (findGame(info.tournamentID, out game, rawMsg) && SpectatorAuthModule.existsAdmin(rawMsg.Peer))
            {
                game.reconnectPlayer(info.username);
            }
        }
コード例 #5
0
        public void handleForeceRoundWinner(IIncommingMessage rawMsg)
        {
            TournamentForceWinnerMessage info = rawMsg.Deserialize <TournamentForceWinnerMessage>();
            RunningTournamentGame        game;

            if (findGame(info.tournamentID, out game, rawMsg) && SpectatorAuthModule.existsAdmin(rawMsg.Peer))
            {
                game.forceIndexWinner(info.roundID, info.winIndex);
            }
        }
コード例 #6
0
        private void handleRoundStarted(IIncommingMessage rawMsg)
        {
            TournamentPreGameInfo info = rawMsg.Deserialize <TournamentPreGameInfo>();
            RunningTournamentGame game;

            if (findGame(info.tournamentID, out game, rawMsg) && SpectatorAuthModule.existsAdmin(rawMsg.Peer))
            {
                game.startRound(info.roundID);
            }
        }
コード例 #7
0
        public void handleCreateTournament(IIncommingMessage rawMsg)
        {
            IPeer peer = rawMsg.Peer;

            if (SpectatorAuthModule.existsAdmin(peer) == false)
            {
                rawMsg.Respond("You don't have admin permission", ResponseStatus.Failed);
                return;
            }

            TournamentInfoMsg msg           = rawMsg.Deserialize <TournamentInfoMsg>();
            string            key           = generateGameKey();
            PreTournamentGame newTournament = new PreTournamentGame(msg, peer, key);

            currentPreTournaments.Add(key, newTournament);
            addPlayerToPeerToTournaments(rawMsg.Peer, newTournament);
            rawMsg.Respond(key, ResponseStatus.Success);
            newTournament.updateAdmin();
            Debug.LogError("Created Tournament: " + key + " With admin: " + rawMsg.Peer.Id);
        }