예제 #1
0
 public ActionResult CreateGame([FromBody] DummyGame temp)
 {
     if (temp.PlayerName != null && temp.GameName != null)
     {
         return(Ok(_gameEngine.PushGame(temp.PlayerName, temp.GameName)));
     }
     else
     {
         return(NotFound());
     }
 }
예제 #2
0
        public ActionResult AddPlayer([FromBody] DummyGame temp)
        {
            if (_gameEngine.LoadGames(temp.GameName).Where(x => x.NameOfGameInstance == temp.GameName).First().Players.Where(y => y.Name == temp.PlayerName).Any())
            {
                return(NotFound());
            }
            else
            {
                _gameEngine.LoadGames(temp.GameName).Where(x => x.NameOfGameInstance == temp.GameName).
                First().AddPlayer(temp.PlayerName);
            }


            return(Ok());
        }
예제 #3
0
        public ActionResult <int> RollDie([FromBody] DummyGame gameInstance)
        {
            Game   currentGame   = _gameEngine.LoadGames(gameInstance.GameName).FirstOrDefault();
            Player currentPlayer = currentGame.Players.Where(x => x.Name == gameInstance.PlayerName).FirstOrDefault();

            if (currentGame.CurrentTurn == currentPlayer.turnOrder && currentGame.HasRolled == false)
            {
                int real = _gameEngine.LoadGames(gameInstance.GameName).FirstOrDefault().LatestRoll = _dice.Roll();

                _gameEngine.LoadGames(gameInstance.GameName).FirstOrDefault().HasRolled = true;

                if (currentPlayer.Pieces.Where(x => x.State.ToString() == "Fence").Count() == 4 && real != 1 && real != 6)
                {
                    _gameEngine.LoadGames(gameInstance.GameName).FirstOrDefault().HasRolled = false;
                    currentGame.PassTurn();
                }

                return(real);
            }
            else
            {
                return(-1);
            }
        }