Esempio n. 1
0
        public void ShouldNotCallDos_AfterNextPlayerMadeAMove()
        {
            game = new DosGame(new NonShufflingDealer(TwentyGreenSharps), 2, 3);
            game.Start();
            game.MatchCenterRowCard(Player0, GreenSharp, GreenSharp);
            game.AddCardToCenterRow(Player0, GreenSharp);
            game.EndTurn(Player0);

            game.Draw(Player1);
            game.CallDos(Player1).ShouldBeFail();
        }
Esempio n. 2
0
        private Result ChooseMove(DosGame game)
        {
            if (game.CurrentState.CanMatch)
            {
                var match = MakeMatch(game);
                if (match != null)
                {
                    var(matchers, target) = match.Value;
                    game.PublicLog($"`Match {matchers.ToLogString()} on {target.ToString()}` ({target.MatchWith(matchers).Message()})");
                    return(game.MatchCenterRowCard(this, target, matchers));
                }
            }

            if (game.CurrentState.CanAdd)
            {
                var card = ChooseCardForAdding(game);
                game.PublicLog($"`Add {card}`");
                return(game.AddCardToCenterRow(this, card));
            }

            if (game.CurrentState.CanDraw)
            {
                game.PublicLog("`Draw`");
                return(game.Draw(this));
            }

            if (game.CurrentState is TriggeredSwapGameState)
            {
                var swapTarget = game.Players
                                 .Where(p => p != this && p.IsActive())
                                 .OrderBy(p => p.Hand.Count)
                                 .First();
                game.PublicLog($"`Swapping with {swapTarget}`");
                return(game.SwapWith(this, swapTarget));
            }

            game.PublicLog("`Done`");
            return(game.EndTurn(this));
        }
Esempio n. 3
0
 public void CanDraw_AtTurnStart()
 {
     game.Draw(Player0).ShouldBeSuccess();
 }