Esempio n. 1
0
        private bool getPlayerPreGameReady(TournamentPlayer p)
        {
            if (p.getIsNPC())
            {
                return(true);
            }

            try { return(thePregame.isPlayerReady(p.peer.Id)); }
            catch {} return(false);
        }
Esempio n. 2
0
        private void insertBots()
        {
            if (getNPCPlayers().Count == 0)
            {
                return;
            }

            TournamentPlayer bot     = getNPCPlayers()[0];
            PreGameSlotInfo  botSlot = new PreGameSlotInfo()
            {
                slotID = 1, playerInfo = LocalTrainingBots.StandardTrainingBotInfo, isReady = true, type = PreGameSlotType.TrainingBot
            };

            thePregame.updateSlotType(botSlot, extraHost);
        }
Esempio n. 3
0
        public void setGameOver(TournamentPlayer winner)
        {
            winner.isWinning = true;
            score.winner     = winner.info.username;
            winnerUsername   = winner.info.username;
            setState(RoundState.Over);

            if (nextRound != null)
            {
                nextRound.addPlayer(winner, nextWinGameSlotIndex);
            }
            if (nextLoserRound != null)
            {
                getLosers(winner).ForEach(p => nextLoserRound.addPlayer(p, nextLoseGameSlotIndex));
            }
        }
        public static void addBots(List <List <TournamentRound> > tree, List <TournamentPlayer> players)
        {
            List <TournamentRound> firstRow = tree[0];
            int totalPlayers = firstRow.Count * 2;
            int botsNeeded   = totalPlayers - players.Count;

            for (int i = 0; i < botsNeeded; i++)
            {
                List <TournamentRound> temp = firstRow.OrderByDescending(g => g.calcRoundsUntilPossibleBotGame()).ToList(); //Calculate round to bot battle
                temp = temp.Where(g => g.stashedRoundsUntilBotGame == temp[0].stashedRoundsUntilBotGame).ToList();          //Sort

                TournamentRound  round = temp[Random.Range(0, temp.Count)];                                                 //Pick random game
                TournamentPlayer bot   = new TournamentPlayer(true, i);
                players.Add(bot);
                round.addPlayer(bot);
            }
        }
Esempio n. 5
0
        public void addPlayer(TournamentPlayer player, int id = -1)
        {
            try {
                if (id == -1)
                {
                    playerSlotIndex.Add(player.info.username, players.Count);
                }
                else
                {
                    playerSlotIndex.Add(player.info.username, id);
                }
            } catch { }

            players.Add(player);
            if (player.getIsNPC())
            {
                setHasPossibleBotGame();
            }
            setState(RoundState.Idle);
        }
Esempio n. 6
0
 private List <TournamentPlayer> getLosers(TournamentPlayer winner)
 {
     return(players.Where(p => p != winner).ToList());
 }