Пример #1
0
        private static WarCardGame Play(IEnumerable <FiftyTwoCardGamePlayer> players, FiftyTwoCardGameDeck deck,
                                        ILogger logger, bool distribute)
        {
            var game = new WarCardGame(players, deck)
            {
                Logger = logger
            };

            if (distribute)
            {
                game.DistributeCards();
            }
            game.Play();
            return(PrintLeaderBoard(game));
        }
Пример #2
0
        private static WarCardGame PrintLeaderBoard(WarCardGame game)
        {
            game.Logger.Information("----------------------LEADER BOARD-------------------");
            var winner = game.Winner;
            var losers = game.Players.Where(x => x.Status != PlayerStatus.Won).OrderBy(x => x.OutOfGameAt);

            game.Logger.Information($"1st place - {winner} - Out of game at {winner.OutOfGameAt}");
            int i = 2;

            foreach (var fiftyTwoCardGamePlayer in losers)
            {
                game.Logger.Information($"{i++} - {fiftyTwoCardGamePlayer} - Out of game at {fiftyTwoCardGamePlayer.OutOfGameAt}");
            }
            game.Logger.Information("-------------------------------------------------------");
            return(game);
        }