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!"); }
private bool IsGameEnded(GuessModel guess) { if (guess.BullsCount == 4) { return true; } else { return false; } }