コード例 #1
0
ファイル: GamesController.cs プロジェクト: jesusico83/Telerik
        private IHttpActionResult ProcessGameEnd(Game game, GuessModel guess)
        {
            var redPlayer = game.RedPlayer;
            var bluePlayer = game.BluePlayer;

            if (game.RedPlayerId == guess.UserId)
            {
                redPlayer.WinsCount++;
                bluePlayer.LoosesCount++;

                game.State = GameState.WonByRed;
            }
            else
            {
                redPlayer.LoosesCount++;
                bluePlayer.WinsCount++;

                game.State = GameState.WonByBlue;
            }

            this.Data.SaveChanges();

            return Ok("Congratulations " + guess.Username + " ! You won the game!");
        }
コード例 #2
0
ファイル: GamesController.cs プロジェクト: jesusico83/Telerik
 private bool IsGameEnded(GuessModel guess)
 {
     if (guess.BullsCount == 4)
     {
         return true;
     }
     else
     {
         return false;
     }
 }