Ejemplo n.º 1
0
        //War executed on equal cards, will lay off 3 cards and check the fourth
        protected WarOutcome MultiCardWar(PlayBoard playBoard)
        {
            var outcome = new WarOutcome();

            //Pop the amount of cards
            for (int i = 0; i < _warCardCount; i++)
            {
                if (playBoard.PopCardPlayer1() == null)
                {
                    outcome.WinningPlayer = 2; outcome.ExitBecauseOutOfCards = true; return(outcome);
                }
                if (playBoard.PopCardPlayer2() == null)
                {
                    outcome.WinningPlayer = 1; outcome.ExitBecauseOutOfCards = true; return(outcome);
                }
            }
            //Try getting a normal run
            var singleRes = SingleCardWar(playBoard);

            if (singleRes.WinningPlayer == null)
            {
                Log("War resulted in more war!"); return(MultiCardWar(playBoard));
            }
            outcome.WinningPlayer = singleRes.WinningPlayer.Value;
            return(outcome);
        }
Ejemplo n.º 2
0
        protected WarCheck SingleCardWar(PlayBoard playBoard)
        {
            var c1 = playBoard.PopCardPlayer1();
            var c2 = playBoard.PopCardPlayer2();

            Log($"Playing->  p1: {c1} p2: {c2}");
            if (c1 == null || c2 == null)
            {
                return(null);
            }
            return(new WarCheck()
            {
                P1Card = c1,
                P2Card = c2,
                CausesWar = c1.Strength == c2.Strength,
                WinningPlayer = GetWinningPlayer(c1, c2)
            });
        }