コード例 #1
0
ファイル: TrickTests.cs プロジェクト: rsyNinja/Sheepshead
        public void Trick_IsComplete()
        {
            var firstPlayer            = new Mock <IPlayer>().Object;
            var startingPlayerCalcMock = new Mock <IStartingPlayerCalculator>();

            startingPlayerCalcMock.Setup(m => m.GetStartingPlayer(It.IsAny <IHand>(), It.IsAny <ITrick>())).Returns(firstPlayer);
            var mockHand = new Mock <IHand>();

            mockHand.Setup(m => m.Players).Returns(new List <IPlayer>());
            mockHand.Setup(m => m.PartnerCardEnum).Returns(SheepCard.N10_DIAMONDS);
            var trickList = new List <ITrick>();

            mockHand.Setup(m => m.ITricks).Returns(trickList);
            mockHand.Setup(m => m.AddTrick(It.IsAny <ITrick>())).Callback((ITrick newTrick) => { trickList.Add(newTrick); });
            foreach (var playerCount in new[] { 3, 5 })
            {
                mockHand.Setup(m => m.PlayerCount).Returns(playerCount);
                var trick = new Trick(mockHand.Object, startingPlayerCalcMock.Object);
                for (var cardsInTrick = 0; cardsInTrick < playerCount; ++cardsInTrick)
                {
                    Assert.IsFalse(trick.IsComplete(), "Trick should not be complete when there are " + cardsInTrick + " cards in the trick and " + playerCount + " players in the game.");
                    trick.Add(new MockPlayer(), 0);
                }
                Assert.IsTrue(trick.IsComplete(), "Trick should be complete when there are " + playerCount + " cards in the trick and " + playerCount + " players in the game.");
            }
        }
コード例 #2
0
    private IEnumerator PlayTrick()
    {
        currentTrick  = new Trick(numPlayers, trumpCard.GetSuit());
        currentPlayer = currentLeader;

        while (!currentTrick.IsComplete())
        {
            if (gm.IsHeadRound())
            {
                yield return(PlayHeadCard());
            }
            else
            {
                yield return(PlayCard());
            }
        }

        yield return(gm.WaitForMovingCards());

        Debug.Log(currentTrick.GetWinningPlayer().GetName() + " has won this trick!");

        yield return(gm.AwardTrick(currentTrick.GetWinningPlayer()));

        tricksAwarded++;
        currentLeader = currentTrick.GetWinningPlayer();
    }