本文整理汇总了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());
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
}
示例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);
}
示例10: ChangingTrumpCardShouldNotThrow
public void ChangingTrumpCardShouldNotThrow()
{
Deck deck = new Deck();
Card trumpCard = deck.GetTrumpCard;
Card newCard = new Card(CardSuit.Heart, CardType.Nine);
deck.ChangeTrumpCard(newCard);
}
示例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());
}
示例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));
}
示例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;
}
示例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);
}
示例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);
}