예제 #1
0
 public void UpdateStanding(GameResult gameResult)
 {
 }
예제 #2
0
        public void UpdateStanding(GameResult gameResult)
        {
            var standing = this.DbEntity.Standings.First(s => s.SeasonId == gameResult.DbEntity.SeasonId);

            standing.Experience += gameResult.ExpGain;

            if (gameResult.Score - 5 > 0)
            {
                standing.Won += 1;
                standing.CardPoints += gameResult.CardPtsGain;
            }
            else if (gameResult.Score - 5 < 0)
            {
                standing.Lost += 1;
            }
            else
            {
                standing.Draw += 1;
            }

            if (standing.Experience < 0)
            {
                standing.Experience = 0;
            }

            standing.UnlockedRules = Data.Models.Rules.Open;

            DbRepository.Current.Update(standing);
        }
        private void GameEnded(Game game)
        {
            // TODO: if called by ai player error wont be handled by interceptor
            GameResult result = null;
            DbRepository.Transacted(() =>
            {
                result = new GameResult(game);
                DbRepository.Current.Add(result.DbEntity);
                game.FirstPlayer.UpdateStanding(result.GetFor(game.FirstPlayer));
                game.SecondPlayer.UpdateStanding(result.GetFor(game.SecondPlayer));
            });

            Games.RemoveGame(game);
            BroadcastGameList();
            Hub.Clients.Group(game.GameId).updateBoard(game);
            Hub.Clients.Caller.receiveResult(result.GetFor(game.GetCurrentPlayer(Hub.Context.ConnectionId)));
        }