示例#1
0
    public void TestRoyalRule()
    {
        foreach (Rank rank in Rank.Values)
        {
            if (!CardRuleUtils.IsRoyal(rank))
            {
                continue;
            }
            else
            {
                PlayingCard source = new PlayingCard(rank, Suit.SPADES);

                foreach (Rank targetRank in Rank.Values)
                {
                    PlayingCard target = new PlayingCard(targetRank, Suit.SPADES);

                    if (rank.Equals(Rank.JOKER) || CardRuleUtils.IsRoyal(targetRank))
                    {
                        Assert.AreEqual(0, CardRuleUtils.Resolve(source, target));
                    }
                    if (targetRank.Equals(Rank.ACE))
                    {
                        Assert.LessOrEqual(CardRuleUtils.Resolve(source, target), -1);
                    }
                }
            }
        }
    }
示例#2
0
    public void TestAceRule()
    {
        foreach (Suit suit in Suit.Values)
        {
            PlayingCard ace = new PlayingCard(Rank.ACE, suit);

            foreach (Rank rank in Rank.Values)
            {
                if (rank.Equals(Rank.JOKER))
                {
                    continue;
                }

                PlayingCard target = new PlayingCard(rank, suit);

                if (rank.Equals(Rank.ACE))
                {
                    Assert.AreEqual(0, CardRuleUtils.Resolve(ace, target));
                }
                else if (CardRuleUtils.IsRoyal(target))
                {
                    Assert.GreaterOrEqual(CardRuleUtils.Resolve(ace, target), 1);
                }
                else
                {
                    Assert.LessOrEqual(CardRuleUtils.Resolve(ace, target), -1);
                }
            }
        }
    }
示例#3
0
    public void TestNumericRule()
    {
        foreach (Rank rank in Rank.Values)
        {
            if (isRankSpecial(rank))
            {
                continue;
            }

            PlayingCard source = new PlayingCard(rank, Suit.SPADES);

            foreach (Rank targetRank in Rank.Values)
            {
                if (!isRankSpecial(targetRank))
                {
                    PlayingCard target = new PlayingCard(targetRank, Suit.SPADES);

                    if (rank > targetRank)
                    {
                        Assert.GreaterOrEqual(CardRuleUtils.Resolve(source, target), 1);
                    }
                    else if (rank < targetRank)
                    {
                        Assert.LessOrEqual(CardRuleUtils.Resolve(source, target), -1);
                    }
                    else
                    {
                        Assert.AreEqual(0, CardRuleUtils.Resolve(source, target));
                    }
                }
            }
        }
    }
示例#4
0
        public override void execute()
        {
            // after animation resolve
            if (!CardUtils.isCardPlaying(SelectedLane.PlayerCard) &&
                !CardUtils.isCardPlaying(SelectedLane.OpponentCard))
            {
                waitTime += Time.deltaTime;
            }

            if (waitTime >= 1.5f)
            {
                bool destroy = true;
                // resolve
                CardScript playerCardScript   = SelectedLane.PlayerCard.GetComponent <CardScript>();
                CardScript opponentCardScript = SelectedLane.OpponentCard.GetComponent <CardScript>();
                resolution = CardRuleUtils.Resolve(playerCardScript.Card, opponentCardScript.Card);

                if (resolution > 0)
                {
                    SelectedLane.playerPoints += SelectedLane.playerStockpile.childCount + 1;
                }
                else if (resolution < 0)
                {
                    SelectedLane.opponentPoints += SelectedLane.opponentStockpile.childCount + 1;
                }
                else if (StockpileRule)
                {
                    // handle stockpile maneuver here
                    destroy = false;
                    ArenaManager.placeStockpile(SelectedLane.removeCard(Lane.Slot.PLAYER), SelectedLane.playerStockpile);
                    ArenaManager.placeStockpile(SelectedLane.removeCard(Lane.Slot.OPPONENT), SelectedLane.opponentStockpile);
                }

                //TODO it'd be cool to have a fade animation
                // remove cards from lane slots
                if (destroy)
                {
                    GameObject.Destroy(SelectedLane.removeCard(Lane.Slot.PLAYER));
                    GameObject.Destroy(SelectedLane.removeCard(Lane.Slot.OPPONENT));
                    foreach (Transform child in SelectedLane.playerStockpile)
                    {
                        GameObject.Destroy(child.gameObject);
                    }
                    foreach (Transform child in SelectedLane.opponentStockpile)
                    {
                        GameObject.Destroy(child.gameObject);
                    }
                }
            }
        }
示例#5
0
    public void TestJokerRule()
    {
        PlayingCard joker = new PlayingCard(Rank.JOKER, Suit.NONE);

        foreach (Suit suit in Suit.Values)
        {
            foreach (Rank rank in Rank.Values)
            {
                PlayingCard card = new PlayingCard(rank, suit);

                Assert.AreEqual(0, CardRuleUtils.Resolve(joker, card));
            }
        }
    }