コード例 #1
0
 void Grind()
 {
     state = states.Grind;
     AnimateGrind();
     currentTrick = new grind();
     park.PerformedTrick(currentTrick);
 }
コード例 #2
0
        public void PlayShouldCorrectlyDetermineTheWinner()
        {
            var firstPlayer      = new ValidPlayer();
            var firstPlayerInfo  = new RoundPlayerInfo(firstPlayer);
            var secondPlayer     = new ValidPlayer();
            var secondPlayerInfo = new RoundPlayerInfo(secondPlayer);
            var stateManager     = new StateManager();
            var deck             = new Deck();

            firstPlayerInfo.AddCard(Card.GetCard(CardSuit.Heart, CardType.Nine));
            secondPlayerInfo.AddCard(Card.GetCard(deck.TrumpCard.Suit, CardType.Jack));

            var trick  = new Trick(firstPlayerInfo, secondPlayerInfo, stateManager, deck, GameRulesProvider.Santase);
            var winner = trick.Play();

            Assert.IsTrue(winner == secondPlayerInfo);
            Assert.AreEqual(2, winner.RoundPoints);
            Assert.AreEqual(2, winner.TrickCards.Count);
            Assert.IsTrue(winner.TrickCards.Contains(Card.GetCard(CardSuit.Heart, CardType.Nine)));
            Assert.IsTrue(winner.TrickCards.Contains(Card.GetCard(deck.TrumpCard.Suit, CardType.Jack)));
            Assert.AreEqual(0, firstPlayerInfo.TrickCards.Count);

            Assert.AreEqual(0, firstPlayer.EndTurnContextObject.FirstPlayerRoundPoints);
            Assert.AreEqual(2, firstPlayer.EndTurnContextObject.SecondPlayerRoundPoints);
            Assert.AreEqual(0, secondPlayer.EndTurnContextObject.FirstPlayerRoundPoints);
            Assert.AreEqual(2, secondPlayer.EndTurnContextObject.SecondPlayerRoundPoints);

            Assert.AreEqual(0, firstPlayer.GetTurnContextObject.FirstPlayerRoundPoints);
            Assert.AreEqual(0, firstPlayer.GetTurnContextObject.SecondPlayerRoundPoints);
            Assert.AreEqual(0, secondPlayer.GetTurnContextObject.FirstPlayerRoundPoints);
            Assert.AreEqual(0, secondPlayer.GetTurnContextObject.SecondPlayerRoundPoints);
        }
コード例 #3
0
        public void PlayShouldCallGetTurnAndEndTurnForBothPlayers()
        {
            var firstPlayer      = new ValidPlayer();
            var firstPlayerInfo  = new RoundPlayerInfo(firstPlayer);
            var secondPlayer     = new ValidPlayer();
            var secondPlayerInfo = new RoundPlayerInfo(secondPlayer);
            var stateManager     = new StateManager();
            var deck             = new Deck();

            SimulateGame(firstPlayerInfo, secondPlayerInfo, deck);

            var trick  = new Trick(firstPlayerInfo, secondPlayerInfo, stateManager, deck, GameRulesProvider.Santase);
            var winner = trick.Play();

            Assert.AreEqual(1, firstPlayer.GetTurnCalledCount);
            Assert.AreEqual(1, secondPlayer.GetTurnCalledCount);
            Assert.AreEqual(1, firstPlayer.EndTurnCalledCount);
            Assert.AreEqual(1, secondPlayer.EndTurnCalledCount);

            Assert.IsNotNull(firstPlayer.GetTurnContextObject);
            Assert.IsNotNull(secondPlayer.GetTurnContextObject);
            Assert.IsNotNull(firstPlayer.EndTurnContextObject);
            Assert.IsNotNull(secondPlayer.EndTurnContextObject);

            Assert.IsNotNull(firstPlayer.EndTurnContextObject.FirstPlayedCard);
            Assert.IsNotNull(firstPlayer.EndTurnContextObject.SecondPlayedCard);
            Assert.IsNotNull(secondPlayer.EndTurnContextObject.FirstPlayedCard);
            Assert.IsNotNull(secondPlayer.EndTurnContextObject.SecondPlayedCard);

            Assert.IsTrue(winner == firstPlayerInfo || winner == secondPlayerInfo);
        }
コード例 #4
0
 void Frontside180()
 {
     state = states.Tricking;
     AnimateFrontside180();
     currentTrick = new frontside180();
     park.PerformedTrick(currentTrick);
 }
コード例 #5
0
        public void PlayShouldChangeTheDeckTrumpWhenPlayerPlaysChangeTrumpAction()
        {
            var firstPlayer      = new ValidPlayer(PlayerActionType.ChangeTrump);
            var firstPlayerInfo  = new RoundPlayerInfo(firstPlayer);
            var secondPlayer     = new ValidPlayer();
            var secondPlayerInfo = new RoundPlayerInfo(secondPlayer);
            var stateManager     = new StateManager();

            stateManager.SetState(new MoreThanTwoCardsLeftRoundState(stateManager));
            var deck      = new Deck();
            var trumpSuit = deck.TrumpCard.Suit;

            var oldTrumpCard = deck.TrumpCard;
            var nineOfTrump  = Card.GetCard(trumpSuit, CardType.Nine);

            firstPlayerInfo.AddCard(nineOfTrump);
            secondPlayerInfo.AddCard(
                Card.GetCard(trumpSuit == CardSuit.Heart ? CardSuit.Club : CardSuit.Heart, CardType.Ace));

            var trick = new Trick(firstPlayerInfo, secondPlayerInfo, stateManager, deck, GameRulesProvider.Santase);

            trick.Play();

            Assert.AreEqual(nineOfTrump, deck.TrumpCard);
            Assert.AreEqual(nineOfTrump, secondPlayer.GetTurnContextObject.TrumpCard);
            Assert.IsTrue(firstPlayerInfo.TrickCards.Contains(oldTrumpCard), "Trick cards should contain oldTrumpCard");
            Assert.IsFalse(firstPlayerInfo.Cards.Contains(nineOfTrump));
            Assert.IsFalse(
                firstPlayer.CardsCollection.Contains(nineOfTrump),
                "Player contains nine of trump after changing trump card");
        }
コード例 #6
0
ファイル: TrickTests.cs プロジェクト: JohnBloom/SpadeBots
        public void TrumpInGetWinningPlayerTest()
        {
            var trick = new Trick(new Hand(Players, Deck)
            {
                SpadesHaveBeenBroken = true
            });

            trick.PlayCard(PlayerOne, new Card()
            {
                Rank = Rank.Seven, Suit = Suit.Diamonds
            });
            trick.PlayCard(PlayerTwo, new Card()
            {
                Rank = Rank.Ten, Suit = Suit.Diamonds
            });
            trick.PlayCard(PlayerThree, new Card()
            {
                Rank = Rank.Two, Suit = Suit.Spades
            });
            trick.PlayCard(PlayerFour, new Card()
            {
                Rank = Rank.Nine, Suit = Suit.Diamonds
            });

            var winner = trick.GetWinningPlayer();

            Assert.AreEqual(PlayerThree, winner);
        }
コード例 #7
0
        public void TestValue()
        {
            var        player = new Player(0, "PlayerTest", null);
            const Suit trump  = Suit.DIAMONDS;

            Card[] cards =
            {
                new Card("10", Suit.DIAMONDS,    1, 0),
                new Card("A",  Suit.DIAMONDS,   10, 1),
                new Card("9",  Suit.DIAMONDS,  100, 2),
                new Card("J",  Suit.DIAMONDS, 1000, 3)
            };
            foreach (var card in cards)
            {
                player.GetDeck().AddCard(card);
            }
            var trick     = new Trick();
            var firstCard = new Card("8", Suit.SPADES, 0, 8);

            trick.AddCard(firstCard);
            trick.SetLeadingCard(firstCard);
            Assert.Equal(true, player.PutCard(trick, player.GetDeck().GetCardById(0).GetId(), trump));
            Assert.Equal(true, player.PutCard(trick, player.GetDeck().GetCardById(1).GetId(), trump));
            Assert.Equal(true, player.PutCard(trick, player.GetDeck().GetCardById(2).GetId(), trump));
            Assert.Equal(true, player.PutCard(trick, player.GetDeck().GetCardById(3).GetId(), trump));
            Assert.Equal(1111, trick.GetValue());
        }
コード例 #8
0
        public void ObserversAreNotifiedWhenStateChanges_TestObserver_ObserverNotified()
        {
            //Arrange
            var spectatorMock  = new Mock <IObserver>();
            var spectator2Mock = new Mock <IObserver>();

            var monkeyName = "Singe1";
            var monkey     = new Monkey(monkeyName);
            var trickName  = "Salto";
            var trickType  = TrickType.Acrobatie;

            var trick = new Trick(trickName, trickType);

            monkey.Attach(spectatorMock.Object);
            monkey.Attach(spectator2Mock.Object);

            //Act - Assert
            monkey.PerformTrick(trick);

            spectatorMock.Verify(x => x.Update(monkey, trick), Times.Once);
            spectator2Mock.Verify(x => x.Update(monkey, trick), Times.Once);

            monkey.Detach(spectator2Mock.Object);
            spectator2Mock.Invocations.Clear();

            monkey.PerformTrick(trick);

            spectatorMock.Verify(x => x.Update(monkey, trick), Times.Exactly(2));
            spectator2Mock.Verify(x => x.Update(monkey, trick), Times.Never);
        }
コード例 #9
0
        public void TestPutCardCuttingNonTrumpTrick()
        {
            var        player = new Player(0, "PlayerTest", null);
            const Suit trump  = Suit.DIAMONDS;

            Card[] cards =
            {
                new Card("J",  Suit.DIAMONDS, 0, 0),
                new Card("9",  Suit.DIAMONDS, 0, 1),
                new Card("Q",  Suit.CLUBS,    0, 2),
                new Card("J",  Suit.CLUBS,    0, 3),
                new Card("Q",  Suit.CLUBS,    0, 4),
                new Card("K",  Suit.HEARTS,   0, 5),
                new Card("7",  Suit.HEARTS,   0, 6),
                new Card("10", Suit.SPADES,   0, 7)
            };
            foreach (var card in cards)
            {
                player.GetDeck().AddCard(card);
            }

            var trick     = new Trick();
            var firstCard = new Card("8", Suit.SPADES, 0, 8);

            trick.AddCard(firstCard);
            trick.SetLeadingCard(firstCard);
            Assert.Equal(true, player.PutCard(trick, player.GetDeck().GetCardById(7).GetId(), trump));
            Assert.Equal(true, player.PutCard(trick, player.GetDeck().GetCardById(1).GetId(), trump));
            Assert.Equal(true, player.PutCard(trick, player.GetDeck().GetCardById(0).GetId(), trump));
        }
コード例 #10
0
ファイル: Hand.cs プロジェクト: whitemanthedj/BridgeBackEnd
        public void PlayTricks()
        {
            // person to the left of the bidder starts
            int currentPlayerIndex = (this.auction.ContractPlayerIndex() + (this.nummaOfPlayers + 1)) % this.nummaOfPlayers;

            for (int i = 0; i < this.nummaOfTricks; i++)
            {
                Trick currentTrick = new Trick(this.nummaOfPlayers);

                //currentPlayerIndex %= this.nummaOfPlayers;
                for (int j = currentPlayerIndex; j < currentPlayerIndex + this.nummaOfPlayers; j++)
                {
                    currentTrick = this.NextCardInTrick(j % this.nummaOfPlayers, currentTrick);
                }

                currentPlayerIndex = currentTrick.TrickWinner();
                // increment the number of tricks taken if it was taken by the right team
                //this.tricksTakenByBidWinners = ( this.AuctionWinners(currentPlayerIndex) ? this.tricksTakenByBidWinners + 1 : this.tricksTakenByBidWinners );

                if (this.AuctionWinners(currentPlayerIndex))
                {
                    this.tricksTakenByBidWinners++;
                    Console.WriteLine("the winners of the bid have now gotten " + this.tricksTakenByBidWinners + " tricks.");
                }

                this.allTricks[i] = currentTrick;
                Console.WriteLine("End of trick " + (i + 1) + ": Player " + (currentPlayerIndex + 1) + " took the trick with: " + currentTrick.WinningTrick().ToString());
                currentTrick.PrintRecord();
            }
        }
コード例 #11
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();
    }
コード例 #12
0
        public async Task <Trick> Create([FromBody] Trick trick)
        {
            _ctx.Add(trick);
            await _ctx.SaveChangesAsync();

            return(trick);
        }
コード例 #13
0
        private static List <Trick> TestTricks(Suit trump, Seat declarer)
        {
            //D = declarer's team, d = defender's team
            var  tricks = new List <Trick>(13);
            Seat lead   = declarer.GetNextSeat(); //Lead:d, Win: D

            tricks.Add(Trick.FromCards(trump, lead, new[] { Deck.TwoOfClubs, Deck.FiveOfClubs, Deck.FourOfClubs, Deck.ThreeOfClubs }));
            lead = lead.GetNextSeat();  // Lead:D, Win:d
            tricks.Add(Trick.FromCards(trump, lead, new[] { Deck.EightOfClubs, Deck.NineOfClubs, Deck.SevenOfClubs, Deck.SixOfClubs }));
            lead = lead.GetNextSeat();  // Lead:d, Win:d
            tricks.Add(Trick.FromCards(trump, lead, new[] { Deck.AceOfClubs, Deck.KingOfClubs, Deck.QueenOfClubs, Deck.JackOfClubs }));
            //lead = lead.GetNextSeat();  // Lead:d, Win:d
            tricks.Add(Trick.FromCards(trump, lead, new[] { Deck.TenOfClubs, Deck.TwoOfDiamonds, Deck.ThreeOfDiamonds, Deck.FourOfDiamonds }));
            //lead = lead.GetNextSeat();  // Lead:d, Win:D
            tricks.Add(Trick.FromCards(trump, lead, new[] { Deck.FiveOfDiamonds, Deck.EightOfDiamonds, Deck.SixOfDiamonds, Deck.SevenOfDiamonds }));
            lead = lead.GetNextSeat();  // Lead:D, Win:D
            tricks.Add(Trick.FromCards(trump, lead, new[] { Deck.KingOfDiamonds, Deck.QueenOfDiamonds, Deck.JackOfDiamonds, Deck.TenOfDiamonds }));
            //lead = lead.GetNextSeat();  // Lead:D, Win:d
            tricks.Add(Trick.FromCards(trump, lead, new[] { Deck.TwoOfHearts, Deck.FourOfHearts, Deck.AceOfDiamonds, Deck.ThreeOfHearts }));
            lead = lead.GetNextSeat();  // Lead:d, Win:D
            tricks.Add(Trick.FromCards(trump, lead, new[] { Deck.FiveOfHearts, Deck.EightOfHearts, Deck.SixOfHearts, Deck.SevenOfHearts }));
            lead = lead.GetNextSeat();  // Lead:D, Win:d
            tricks.Add(Trick.FromCards(trump, lead, new[] { Deck.NineOfHearts, Deck.QueenOfHearts, Deck.TenOfHearts, Deck.JackOfHearts }));
            lead = lead.GetNextSeat();  // Lead:d, Win:D
            tricks.Add(Trick.FromCards(trump, lead, new[] { Deck.KingOfHearts, Deck.AceOfHearts, Deck.AceOfSpades, Deck.KingOfSpades }));
            lead = lead.GetNextSeat();  // Lead:D, Win:D
            tricks.Add(Trick.FromCards(trump, lead, new[] { Deck.NineOfDiamonds, Deck.QueenOfSpades, Deck.JackOfSpades, Deck.TenOfSpades }));
            //lead = lead.GetNextSeat();  // Lead:D, Win:d
            tricks.Add(Trick.FromCards(trump, lead, new[] { Deck.EightOfSpades, Deck.NineOfSpades, Deck.SevenOfSpades, Deck.SixOfSpades }));
            lead = lead.GetNextSeat();  // Lead:d, Win:D
            tricks.Add(Trick.FromCards(trump, lead, new[] { Deck.FourOfSpades, Deck.FiveOfSpades, Deck.ThreeOfSpades, Deck.TwoOfSpades }));
            //Score D: 7, d: 6
            return(tricks);
        }
コード例 #14
0
        public void PlayShouldProvideCorrectPlayerTurnContextToPlayers()
        {
            var firstPlayer      = new ValidPlayer();
            var firstPlayerInfo  = new RoundPlayerInfo(firstPlayer);
            var secondPlayer     = new ValidPlayer();
            var secondPlayerInfo = new RoundPlayerInfo(secondPlayer);
            var stateManager     = new StateManager();
            var deck             = new Deck();

            firstPlayerInfo.AddCard(Card.GetCard(CardSuit.Heart, CardType.King));
            firstPlayerInfo.AddCard(Card.GetCard(CardSuit.Heart, CardType.Queen));
            stateManager.SetState(new MoreThanTwoCardsLeftRoundState(stateManager));

            secondPlayerInfo.AddCard(Card.GetCard(CardSuit.Diamond, CardType.Ten));
            secondPlayerInfo.AddCard(Card.GetCard(CardSuit.Diamond, CardType.Ace));

            var trick = new Trick(firstPlayerInfo, secondPlayerInfo, stateManager, deck, GameRulesProvider.Santase);

            trick.Play();

            Assert.IsTrue(firstPlayer.GetTurnContextObject.IsFirstPlayerTurn);
            Assert.IsFalse(secondPlayer.GetTurnContextObject.IsFirstPlayerTurn);
            Assert.IsTrue(secondPlayer.GetTurnContextObject.FirstPlayerAnnounce != Announce.None);
            Assert.IsNotNull(secondPlayer.GetTurnContextObject.FirstPlayedCard);
            Assert.AreEqual(CardSuit.Heart, secondPlayer.GetTurnContextObject.FirstPlayedCard.Suit);

            Assert.IsTrue(
                secondPlayer.GetTurnContextObject.FirstPlayerRoundPoints == 20 ||
                secondPlayer.GetTurnContextObject.FirstPlayerRoundPoints == 40);
        }
コード例 #15
0
    private void PrimeTricks()
    {
        //For every trick listed in the inspector
        for (int i = 0; i < tricks.Count; i++)
        {
            //Assign that given trick to "trick".
            Trick trick = tricks[i];

            //Wait and listen for that trick to be completed.
            trick.onInputted.AddListener(() =>
            {
                //When a trick is fully inputted, we want to do these things.

                //skip = true;

                if (performedTrick != null)
                {
                    if (trick.inputs.Count > performedTrick.inputs.Count)
                    {
                        //Save that trick for later use.
                        performedTrickStep = trick.trickStep;
                        performedTrick     = trick;
                    }
                }
                else
                {
                    performedTrickStep = trick.trickStep;
                    performedTrick     = trick;
                }
            });
        }
    }
コード例 #16
0
        public async Task <object> Create([FromBody] TrickForm trickForm)
        {
            var trick = new Trick
            {
                Slug            = trickForm.Name.Replace(" ", "-").ToLowerInvariant(),
                Name            = trickForm.Name,
                Version         = 1,
                Description     = trickForm.Description,
                Difficulty      = trickForm.Difficulty,
                TrickCategories = trickForm.Categories.Select(x => new TrickCategory {
                    CategoryId = x
                }).ToList()
            };

            _ctx.Add(trick);
            await _ctx.SaveChangesAsync();

            _ctx.Add(new ModerationItem
            {
                Target = trick.Id,
                Type   = ModerationTypes.Trick,
            });
            await _ctx.SaveChangesAsync();

            return(TrickViewModels.Create(trick));
        }
コード例 #17
0
        public void PlayMultipleColors()
        {
            var players     = PlayersSetup.BuildFourAIPlayers();
            var firstPlayer = players[0];

            var cardsHeldByPlayer   = new Dictionary <IPlayer, List <Card> >();
            var cardsPlayedByPlayer = new Dictionary <IPlayer, List <Card> >();

            var heart = SuitHelper.GetSuit(CardSuit.Heart);
            var spade = SuitHelper.GetSuit(CardSuit.Spade);
            var club  = SuitHelper.GetSuit(CardSuit.Club);

            cardsHeldByPlayer[players[0]] = new List <Card> {
                new Card(RankHelper.GetRank("7"), heart)
            };
            cardsHeldByPlayer[players[1]] = new List <Card> {
                new Card(RankHelper.GetRank("A"), club)
            };
            cardsHeldByPlayer[players[2]] = new List <Card> {
                new Card(RankHelper.GetRank("8"), club)
            };
            cardsHeldByPlayer[players[3]] = new List <Card> {
                new Card(RankHelper.GetRank("9"), club)
            };

            var trick = new Trick(players, spade);

            trick.Play(cardsHeldByPlayer, cardsPlayedByPlayer);
            var winner = trick.GetTaker();

            Assert.AreEqual(firstPlayer, winner);
        }
コード例 #18
0
 void Impossible()
 {
     state = states.Tricking;
     AnimateImpossible();
     currentTrick = new impossible();
     park.PerformedTrick(currentTrick);
 }
コード例 #19
0
 // Fall off your board
 // Classic bail boy
 void Bail()
 {
     state = states.Bail;
     AnimateBail();
     currentTrick = new bail();
     park.PerformedTrick(currentTrick);
 }
コード例 #20
0
 void Kickflip()
 {
     state = states.Tricking;
     AnimateKickflip();
     currentTrick = new kickflip();
     park.PerformedTrick(currentTrick);
 }
コード例 #21
0
 void Heelflip()
 {
     state = states.Tricking;
     AnimateHeelflip();
     currentTrick = new heelflip();
     park.PerformedTrick(currentTrick);
 }
コード例 #22
0
 void PopShoveIt()
 {
     state = states.Tricking;
     AnimatePopShoveIt();
     currentTrick = new popshoveit();
     park.PerformedTrick(currentTrick);
 }
コード例 #23
0
    public void AddTrick(Trick _trick, float _grindTime = 0.0f)
    {
        if (_trick == Trick.EnemyHit)
        {
            enemyHit = true;
        }
        // If score is a kick, add to kick score. Otherwise add to building score
        else if (_trick >= Trick.Kick1 && _trick <= Trick.Kick3)
        {
            kickScore += playerSettings.trickValues[_trick];
        }
        else if (_trick == Trick.Grind)
        {
            grindingScore += Mathf.FloorToInt((float)playerSettings.trickValues[Trick.Grind] * _grindTime);
        }
        else
        {
            buildingScore += playerSettings.trickValues[_trick];
        }

        if (!scoreAnimating)
        {
            SetBuildingScoreText();
        }
    }
コード例 #24
0
ファイル: TrickView.cs プロジェクト: sdevlin/clarity-hearts
 internal TrickView(Trick trick, PlayerBase beholder)
 {
     IsFirstTrick = trick.IsFirstTrick;
     PlayList = trick
         .Select(p => new PlayView(p, beholder))
         .ToList();
 }
コード例 #25
0
 void Backside180()
 {
     state = states.Tricking;
     AnimateBackside180();
     currentTrick = new backside180();
     park.PerformedTrick(currentTrick);
 }
コード例 #26
0
ファイル: TrickTests.cs プロジェクト: JohnBloom/SpadeBots
        public void AllTrumpsGetWinningPlayerTest()
        {
            var trick = new Trick(new Hand(Players, Deck)
            {
                SpadesHaveBeenBroken = true
            });

            trick.PlayCard(PlayerTwo, new Card()
            {
                Rank = Rank.King, Suit = Suit.Spades
            });
            trick.PlayCard(PlayerThree, new Card()
            {
                Rank = Rank.Queen, Suit = Suit.Spades
            });
            trick.PlayCard(PlayerFour, new Card()
            {
                Rank = Rank.Jack, Suit = Suit.Spades
            });
            trick.PlayCard(PlayerOne, new Card()
            {
                Rank = Rank.Ace, Suit = Suit.Spades
            });

            var winner = trick.GetWinningPlayer();

            Assert.AreEqual(PlayerOne, winner);
        }
コード例 #27
0
 void NoseManual()
 {
     state = states.Manual;
     AnimateNoseManual();
     currentTrick = new noseManual();
     park.PerformedTrick(currentTrick);
 }
コード例 #28
0
        public async Task <IActionResult> Create([FromBody] Trick trick)
        {
            _appDbContext.Add(trick);
            await _appDbContext.SaveChangesAsync();

            return(Ok(trick.Id));
        }
コード例 #29
0
        public void PlayTrumpOrderTest()
        {
            var players      = PlayersSetup.BuildFourAIPlayers();
            var fourthPlayer = players[3];

            var cardsHeldByPlayer   = new Dictionary <IPlayer, List <Card> >();
            var cardsPlayedByPlayer = new Dictionary <IPlayer, List <Card> >();

            var heart = SuitHelper.GetSuit(CardSuit.Heart);

            cardsHeldByPlayer[players[0]] = new List <Card> {
                new Card(RankHelper.GetRank("7"), heart)
            };
            cardsHeldByPlayer[players[1]] = new List <Card> {
                new Card(RankHelper.GetRank("A"), heart)
            };
            cardsHeldByPlayer[players[2]] = new List <Card> {
                new Card(RankHelper.GetRank("8"), heart)
            };
            cardsHeldByPlayer[players[3]] = new List <Card> {
                new Card(RankHelper.GetRank("9"), heart)
            };

            var trick = new Trick(players, heart);

            trick.Play(cardsHeldByPlayer, cardsPlayedByPlayer);
            var winner = trick.GetTaker();

            Assert.AreEqual(fourthPlayer, winner);
        }
コード例 #30
0
 void FrontsidePopShoveIt()
 {
     state = states.Tricking;
     AnimateFrontsidePopShoveIt();
     currentTrick = new frontsidepopshoveit();
     park.PerformedTrick(currentTrick);
 }
コード例 #31
0
ファイル: TrickTests.cs プロジェクト: rsyNinja/Sheepshead
        public void Trick_IsLegal_PlayerDoesNotHaveSuit()
        {
            var firstPlayer = new Participant()
            {
                Cards = "9♠"
            }.Player;
            var player = new Participant()
            {
                Cards = "K♥;7♥;Q♣;8♣"
            }.Player;
            var startingPlayerCalcMock = new Mock <IStartingPlayerCalculator>();

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

            handMock.Setup(m => m.Players).Returns(new List <IPlayer>());
            handMock.Setup(m => m.ITricks).Returns(new List <ITrick>());
            handMock.Setup(m => m.IGame.PartnerMethodEnum).Returns(PartnerMethod.JackOfDiamonds);
            handMock.Setup(m => m.PartnerCardEnum).Returns(SheepCard.JACK_DIAMONDS);
            var trick = new Trick(handMock.Object, startingPlayerCalcMock.Object);

            trick.Add(firstPlayer, SheepCard.N9_SPADES);
            Assert.IsTrue(trick.IsLegalAddition(SheepCard.N7_HEARTS, player), "There is no spades in the hand. Hearts is fine.");
            Assert.IsTrue(trick.IsLegalAddition(SheepCard.N8_CLUBS, player), "There is no spades in the hand. Clubs is fine.");
            Assert.IsTrue(trick.IsLegalAddition(SheepCard.QUEEN_CLUBS, player), "There is no spades in the hand. Trump is fine.");
        }
コード例 #32
0
ファイル: Player.cs プロジェクト: ChrisMaire/surfenstein
 public void DoTrick(Trick t)
 {
     switch(t)
     {
         case(Trick.Frontflip):
             announcer.AnnounceFrontFlip();
             break;
         case(Trick.Backflip):
             announcer.AnnounceFrontFlip();
             break;
         case(Trick.Handstand):
             announcer.AnnounceHandstand();
             break;
         case(Trick.Kickflip):
             announcer.AnnounceFrontFlip();
             break;
         default:
             Debug.Log("Unknown trick?!");
             break;
     }
     scoreManager.AddTrick(t);
 }
コード例 #33
0
ファイル: Game.cs プロジェクト: alastairs/BridgeSolver
        private void ReviewTrick(Trick trick)
        {
            var current = trick.Lead;

            for (var i = 0; i < _numberOfPlayers; i++)
            {
                current.ReviewTrick(trick);
                current = current.Next;
            }
        }
コード例 #34
0
ファイル: Round.cs プロジェクト: andrewphoy/Hearts
        private void PlayTrick()
        {
            Trick t = new Trick(this, myIsFirstTrick, myHeartsBroken);

            t.Play(myTrickStarter);

            myTakenCards[t.Winner].AddRange(t.Cards);

            if (!myHeartsBroken && t.HasPointCards) {
                myHeartsBroken = true;
            }

            myTrickStarter = t.Winner;
            myIsFirstTrick = false;
        }
コード例 #35
0
ファイル: Player.cs プロジェクト: alastairs/BridgeSolver
 public void WinTrick(Trick trickWon)
 {
     _tricksWon.Add(trickWon);
 }
コード例 #36
0
ファイル: Game.cs プロジェクト: alastairs/BridgeSolver
        private void PlayGame(Player lead)
        {
            var current = lead;

            for (var i = 0; i < 13; i++)
            {
                var cardsPlayed = PlayRound(current);
                var winner = DetermineWinner(cardsPlayed);
                var trick = new Trick(lead, cardsPlayed, winner);

                ReviewTrick(trick);
                winner.WinTrick(trick);
                _logger.InfoFormat("{0} won trick {1} ({2}) with {3}", winner, i + 1, trick, cardsPlayed[winner]);

                current = winner;
            }
        }
コード例 #37
0
ファイル: Player.cs プロジェクト: alastairs/BridgeSolver
 public virtual void ReviewTrick(Trick trick)
 {
     return;
 }
コード例 #38
0
 public void AddTrick(Trick t)
 {
     Comboing = true;
     Combo[t.ToString()] += 1;
     UpdateStrings();
 }