コード例 #1
0
        public void Combine(Entry entry, GameResult result)
        {
            Count        += entry.Count;
            TotalEloDiff += entry.EloDiff.Or(0);

            switch (result)
            {
            case GameResult.WhiteWin:
                WinCount += entry.Count;
                break;

            case GameResult.Draw:
                DrawCount += entry.Count;
                break;

            case GameResult.BlackWin:
                LossCount += entry.Count;
                break;
            }

            if (FirstGame.Count() == 0)
            {
                FirstGame = entry.FirstGame;
            }
            else if (entry.FirstGame.Count() != 0 && entry.FirstGame.First().GameId < FirstGame.First().GameId)
            {
                FirstGame = entry.FirstGame;
            }
        }
コード例 #2
0
        public async Task <Guid> CreateGame(
            FirstGameType firstGameType,
            DateTimeOffset registrationEndDate,
            DateTimeOffset gameDate,
            string description)
        {
            switch (firstGameType)
            {
            case FirstGameType.Basketball:
                var basketballGame = new FirstGame
                {
                    RegistrationEndDate         = registrationEndDate,
                    MaxPlayersCount             = 10,
                    MinimalRequiredPlayersCount = 6,
                    Description = description,
                    GameDate    = gameDate,
                    Guid        = Guid.NewGuid()
                };
                await _gameRepository.SaveGameAsync(basketballGame);

                return(basketballGame.Guid);

            case FirstGameType.Chess:
                var chessGame = new FirstGame
                {
                    RegistrationEndDate         = registrationEndDate,
                    MaxPlayersCount             = 10,
                    MinimalRequiredPlayersCount = 6,
                    Description = description,
                    GameDate    = gameDate,
                    Guid        = Guid.NewGuid()
                };
                await _gameRepository.SaveGameAsync(chessGame);

                return(chessGame.Guid);

            case FirstGameType.Soccer:
                var soccerGame = new FirstGame
                {
                    RegistrationEndDate         = registrationEndDate,
                    MaxPlayersCount             = 10,
                    MinimalRequiredPlayersCount = 6,
                    Description = description,
                    GameDate    = gameDate,
                    Guid        = Guid.NewGuid()
                };
                await _gameRepository.SaveGameAsync(soccerGame);

                return(soccerGame.Guid);

            default:
                throw new ArgumentException();
            }
        }
コード例 #3
0
        public Task SaveGameAsync(FirstGame newGame)
        {
            var storedGame = _store.SingleOrDefault(x => x.Guid == newGame.Guid);

            if (storedGame != null)
            {
                _store.Remove(storedGame);
            }

            _store.Add(newGame);
            return(Task.CompletedTask);
        }
コード例 #4
0
        public void Combine(AggregatedEntry entry)
        {
            if (entry == null)
            {
                return;
            }

            Count        += entry.Count;
            WinCount     += entry.WinCount;
            DrawCount    += entry.DrawCount;
            LossCount    += entry.LossCount;
            TotalEloDiff += entry.TotalEloDiff;

            if (FirstGame.Count() == 0)
            {
                FirstGame = entry.FirstGame;
            }
            else if (entry.FirstGame.Count() != 0 && entry.FirstGame.First().IsBefore(FirstGame.First()))
            {
                FirstGame = entry.FirstGame;
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: SenojLuap/FirstGame
 static void Main()
 {
     using (var game = new FirstGame())
         game.Run();
 }
コード例 #6
0
 public void UpdateBothGameStatus()
 {
     FirstGame.UpdateGameStatus();
     SecondGame.UpdateGameStatus();
 }