當前位置: 首頁>>代碼示例>>C#>>正文


C# Cards.Card類代碼示例

本文整理匯總了C#中Santase.Logic.Cards.Card的典型用法代碼示例。如果您正苦於以下問題:C# Card類的具體用法?C# Card怎麽用?C# Card使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Card類屬於Santase.Logic.Cards命名空間,在下文中一共展示了Card類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MaxHandValue

        private float MaxHandValue(Card card, PlayerTurnContext context)
        {
            var suit = card.Suit;
            var value = card.GetValue();
            var isTrump = context.TrumpCard.Suit == suit;

            var result = 0f;

            var cardsToTake = this.cardtracker
                .AllCards[suit]
                .Where(x => x.Key < value &&
                    (x.Value == CardTracerState.InOpponentHand || x.Value == CardTracerState.Unknown))
                .ToList();

            if (isTrump)
            {
                cardsToTake
                    .AddRange(this.cardtracker
                        .AllCards
                        .Where(s => s.Key != suit)
                        .SelectMany(c => c.Value)
                        .Where(x => x.Value == CardTracerState.InOpponentHand || x.Value == CardTracerState.Unknown));
            }

            var high = cardsToTake.Count > 0 ? cardsToTake.Max(x => x.Key) : 0;

            result += high;

            if (isTrump)
            {
                result += 10;
            }

            return result / (this.MaxTakeCases(value, suit) - cardsToTake.Count());
        }
開發者ID:KonstantinSimeonov,項目名稱:Zatvoreno,代碼行數:35,代碼來源:CardEvaluatorWorthBased.cs

示例2: TwoEqualCardsAreConsideredTheSame

        public void TwoEqualCardsAreConsideredTheSame()
        {
            var first = new Card(CardSuit.Club, CardType.Ace);
            var second = new Card(CardSuit.Club, CardType.Ace);

            Assert.AreEqual(first, second);
        }
開發者ID:Hri100v,項目名稱:Telerik-Academy,代碼行數:7,代碼來源:DeckTests.cs

示例3: GetOpponentCards

        public ICollection<Card> GetOpponentCards(ICollection<Card> myCards, ICollection<Card> playedCards, Card activeTrumpCard, CardSuit suit)
        {
            var playerCards = new CardCollection
                                  {
                                      new Card(suit, CardType.Nine),
                                      new Card(suit, CardType.Jack),
                                      new Card(suit, CardType.Queen),
                                      new Card(suit, CardType.King),
                                      new Card(suit, CardType.Ten),
                                      new Card(suit, CardType.Ace),
                                  };

            foreach (var card in myCards.Where(x => x.Suit == suit))
            {
                playerCards.Remove(card);
            }

            foreach (var card in playedCards.Where(x => x.Suit == suit))
            {
                playerCards.Remove(card);
            }

            if (activeTrumpCard != null)
            {
                playerCards.Remove(activeTrumpCard);
            }

            return playerCards;
        }
開發者ID:NotDemons,項目名稱:NotDemonsRepo,代碼行數:29,代碼來源:OpponentSuitCardsProvider.cs

示例4: TestDeckChangeTrumpCard

 public void TestDeckChangeTrumpCard()
 {
     var card = new Card(CardSuit.Club, CardType.Jack);
     var deck = new Santase.Logic.Cards.Deck();
     deck.ChangeTrumpCard(card);
     Assert.AreEqual(card, deck.GetTrumpCard);
 }
開發者ID:SimoPrG,項目名稱:TelerikAcademyHomeworks,代碼行數:7,代碼來源:DeckNUnitTests.cs

示例5: PointAndSuitCountParameter

 private float PointAndSuitCountParameter(Card card, PlayerTurnContext context, ICollection<Card> allowedCards)
 {
     var cardSuit = card.Suit;
     float cardValue = card.GetValue();
     float coutOfSuitInHand = allowedCards.Count(x => x.Suit == cardSuit);
     return (11f - cardValue) * coutOfSuitInHand;
 }
開發者ID:KonstantinSimeonov,項目名稱:Zatvoreno,代碼行數:7,代碼來源:CardEvaluatorFirstPlayer.cs

示例6: CalculateProbabilityCardToBeTaken

        public double CalculateProbabilityCardToBeTaken(Card card, ICollection<Card> myCards, ICollection<Card> playedCards)
        {
            ICollection<Card> opponentCards = this.opponentsCardProvider.GetOpponentCards(myCards, playedCards, this.context.TrumpCard, card.Suit);
            ICollection<Card> trumpOpponentCard = this.opponentsCardProvider.GetOpponentCards(myCards, playedCards, this.context.TrumpCard, this.context.TrumpCard.Suit);
            int biggestThanCardCount = 0;
            foreach (var opponentCard in opponentCards)
            {
                if (opponentCard.Suit == this.context.TrumpCard.Suit && card.Suit != opponentCard.Suit)
                {
                    biggestThanCardCount++;
                }
                else if (opponentCard.GetValue() > card.GetValue())
                {
                    biggestThanCardCount++;
                }
            }

            if (card.Suit != this.context.TrumpCard.Suit)
            {
                biggestThanCardCount += trumpOpponentCard.Count;
            }

            int lesserThanCardCount = 24 - playedCards.Count - biggestThanCardCount - 6;
            if (lesserThanCardCount < 6)
            {
                return 1;
            }

            double result = CalculateFactoriel(lesserThanCardCount) / SixFactoriel * CalculateFactoriel(lesserThanCardCount - 6);
            return 1 - result;
        }
開發者ID:KingSharkPower,項目名稱:MyFirstAndOnlyRepository,代碼行數:31,代碼來源:ProbabilityCalculator.cs

示例7: CloneShouldReturnObjectWithTheSameHashCode

 public void CloneShouldReturnObjectWithTheSameHashCode()
 {
     var card = new Card(CardSuit.Spade, CardType.Nine);
     var newCard = card.DeepClone();
     Assert.IsNotNull(newCard);
     Assert.AreEqual(card.GetHashCode(), newCard.GetHashCode());
 }
開發者ID:NotDemons,項目名稱:NotDemonsRepo,代碼行數:7,代碼來源:CardTests.cs

示例8: PossibleAnnounce

        protected Announce PossibleAnnounce(Card cardToBePlayed, Card cardTrump)
        {
            CardType cardTypeToSearch;
            if (cardToBePlayed.Type == CardType.Queen)
            {
                cardTypeToSearch = CardType.King;
            }
            else if (cardToBePlayed.Type == CardType.King)
            {
                cardTypeToSearch = CardType.Queen;
            }
            else
            {
                return Announce.None;
            }
            var cardToSearch = new Card(cardToBePlayed.Suit, cardTypeToSearch);

            if (!this.cards.Contains(cardToSearch))
            {
                return Announce.None;
            }

            if (cardToBePlayed.Suit == cardTrump.Suit)
            {
                return Announce.Forty;
            }
            else
            {
                return Announce.Twenty;
            }
        }
開發者ID:ValentinAlexandrovGeorgiev,項目名稱:SantaseGameEngine,代碼行數:31,代碼來源:BasePlayer.cs

示例9: ExpectTrumpCardToEqualSwappedCard

 public void ExpectTrumpCardToEqualSwappedCard()
 {
     var deck = new Deck();
     var card = new Card(CardSuit.Club, CardType.Ace);
     deck.ChangeTrumpCard(card);
     Assert.AreEqual(card, deck.GetTrumpCard);
 }
開發者ID:kiko81,項目名稱:Teleric-Academy-Homeworks,代碼行數:7,代碼來源:DeckTests.cs

示例10: ChangingTrumpCardShouldNotThrow

 public void ChangingTrumpCardShouldNotThrow()
 {
     Deck deck = new Deck();
     Card trumpCard = deck.GetTrumpCard;
     Card newCard = new Card(CardSuit.Heart, CardType.Nine);
     deck.ChangeTrumpCard(newCard);
 }
開發者ID:Rostech,項目名稱:TelerikAcademyHomeworks,代碼行數:7,代碼來源:DeckTests.cs

示例11: AddCardShouldCallPlayersAddCardMethod

 public void AddCardShouldCallPlayersAddCardMethod()
 {
     var player = new Mock<BasePlayer>();
     var roundPlayerInfo = new RoundPlayerInfo(player.Object);
     var card = new Card(CardSuit.Club, CardType.Ace);
     roundPlayerInfo.AddCard(card);
     player.Verify(x => x.AddCard(card), Times.Once());
 }
開發者ID:NotDemons,項目名稱:NotDemonsRepo,代碼行數:8,代碼來源:RoundPlayerInfoTests.cs

示例12: AddCardShouldAddTheCardToTheLocalCardsList

 public void AddCardShouldAddTheCardToTheLocalCardsList()
 {
     var player = new Mock<BasePlayer>();
     var roundPlayerInfo = new RoundPlayerInfo(player.Object);
     var card = new Card(CardSuit.Club, CardType.Ace);
     roundPlayerInfo.AddCard(card);
     Assert.IsTrue(roundPlayerInfo.Cards.Contains(card));
 }
開發者ID:NotDemons,項目名稱:NotDemonsRepo,代碼行數:8,代碼來源:RoundPlayerInfoTests.cs

示例13: CardScore

        public float CardScore(Card card, PlayerTurnContext context, ICollection<Card> allowedCards)
        {
            float result = 0f;
            result += this.PointAndSuitCountParameter(card, context, allowedCards);
            result -= PointAndSuitMultiplier * this.PointAndSuitCountParameter(card, context, allowedCards);

            return result;
        }
開發者ID:KonstantinSimeonov,項目名稱:Zatvoreno,代碼行數:8,代碼來源:CardEvaluatorFirstPlayer.cs

示例14: EqualsShouldReturnFalseWhenGivenNonCardObject

        public void EqualsShouldReturnFalseWhenGivenNonCardObject()
        {
            var card = new Card(CardSuit.Club, CardType.Nine);

            // ReSharper disable once SuspiciousTypeConversion.Global
            var areEqual = card.Equals(new CardTests());
            Assert.IsFalse(areEqual);
        }
開發者ID:NotDemons,項目名稱:NotDemonsRepo,代碼行數:8,代碼來源:CardTests.cs

示例15: DeckShouldReturnProperTrumpCardAfterChangingIt

 public void DeckShouldReturnProperTrumpCardAfterChangingIt()
 {
     var deck = new Deck();
     var newTrumpCard = new Card(CardSuit.Heart, CardType.Ace);
     deck.ChangeTrumpCard(newTrumpCard);
     var currentTrumpCard = deck.GetTrumpCard;
     Assert.AreSame(newTrumpCard, currentTrumpCard);
 }
開發者ID:zondario,項目名稱:TelerikAcademy-Homeworks,代碼行數:8,代碼來源:DeckTests.cs


注:本文中的Santase.Logic.Cards.Card類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。