Ejemplo n.º 1
0
 public manageViewModel(Player caller)
 {
     Robot bot = caller.playerRobot;
     botX = bot.x_pos;
     botY = bot.y_pos;
     botDir = (int)bot.currentDirection;
     player = caller.playerNumber + 1;
     damage = caller.playerRobot.damage;
     lives = caller.lives;
     flags = bot.flags;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Deals cards to a player
 /// </summary>
 /// <param name="caller">The player client requesting a deal</param>
 /// <returns>The cards dealt to the player client</returns>
 public byte[] dealPlayer(Player caller)
 {
     lock (gameStatus.locker)
     {
         if (!caller.dead && !gameStatus.winner)
         {
             // Check if the player has already been dealt
             if (caller.cards == null)
             {
                 byte[] cards;
                 if (caller.shutdown)
                 {
                     cards = new byte[0];
                 }
                 else
                 {
                     cards = new byte[9 - caller.playerRobot.damage];
                     // Draw some cards
                     for (int i = 0; i < cards.Length; i++)
                     {
                         cards[i] = drawCard();
                     }
                 }
                 // Assign cards to player
                 caller.cards = cards;
                 return cards;
             }
             else
             {
                 return caller.cards;
             }
         }
         else
         {
             return new byte[0];
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Processes a player's move, if all players have submitted
        /// their moves, executes those moves.
        /// </summary>
        /// <param name="caller">The player client submitting the move</param>
        /// <param name="cards">The cards submitted for their move</param>
        public void submitMove(Player caller, Hubs.cardModel[] cards)
        {
            lock (gameStatus.locker)
            {
                if (!gameStatus.winner)
                {
                    if (caller.move == null)
                    {
                        caller.move = cards;
                    }

                    // Check to see if timer needs to be started
                    if (!timerStarted && checkTimer())
                    {
                        return;
                    }
                    // Checks if all players have submitted their moves
                    else if (gameStatus.players.Count(p => (p.move != null || p.dead || p.shutdown)) < gameStatus.numPlayersInGame)
                    {
                        return;
                    }
                    timerStarted = false;

                    // Execute player moves
                    moveCalculator.executeRegisters();

                    // Reset for next round
                    if (!gameStatus.winner)
                    {
                        nextRound();
                    }
                }
            }
            // Checks is a timer needs to be started right away
            Thread.Sleep(2000);
            checkTimer();
        }