本文整理汇总了C#中Santase.Logic.Players.PlayerTurnContext类的典型用法代码示例。如果您正苦于以下问题:C# PlayerTurnContext类的具体用法?C# PlayerTurnContext怎么用?C# PlayerTurnContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayerTurnContext类属于Santase.Logic.Players命名空间,在下文中一共展示了PlayerTurnContext类的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: EndGameTurn
private PlayerAction EndGameTurn(PlayerTurnContext context, ICardTracker tracker, ICollection<Card> myHand)
{
this.root = new Node(null, null, context.IsFirstPlayerTurn);
if (context.IsFirstPlayerTurn && this.root.Children.Count == 0)
{
tracker.SetFinalRoundHands(myHand);
var myCards = myHand.ToList();
EndgameAnalyzer.Compute(this.root, null, myCards, tracker.OpponentTookWith, context.SecondPlayerRoundPoints, context.FirstPlayerRoundPoints);
}
else if (this.root.Children.Count == 0)
{
tracker.SetFinalRoundHands(myHand);
var myCards = myHand.ToList();
while (tracker.OpponentTookWith.Count < 6)
{
tracker.OpponentTookWith.Add(null);
}
EndgameAnalyzer.Compute(this.root, context.FirstPlayedCard, myCards, tracker.OpponentTookWith, context.FirstPlayerRoundPoints, context.SecondPlayerRoundPoints);
}
if (!context.IsFirstPlayerTurn)
{
this.root = this.root.Children.First(x => x.Card == context.FirstPlayedCard);
}
var card = this.root.Children.OrderByDescending(x => x.Wins / (decimal)x.Total).First().Card;
return PlayerAction.PlayCard(card);
}
示例3: GetTurn
public override PlayerAction GetTurn(PlayerTurnContext context)
{
//if (this.PlayerActionValidator.IsValid(PlayerAction.ChangeTrump(), context, this.Cards))
//{
// this.CardsNotInDeck.Add(context.TrumpCard);
// this.CardsNotInDeck.RemoveWhere(c => c.Suit == context.TrumpCard.Suit && c.Type == CardType.Nine);
// return this.ChangeTrump(context.TrumpCard);
//}
//foreach (var card in this.Cards)
//{
// if (card.Type == CardType.King &&
// (this.AnnounceValidator.GetPossibleAnnounce(this.Cards, card, context.TrumpCard) == Announce.Forty ||
// this.AnnounceValidator.GetPossibleAnnounce(this.Cards, card, context.TrumpCard) == Announce.Twenty))
// {
// this.Cards.Remove(card);
// return this.PlayCard(card);
// }
//}
var bestCard = this.GetCardToPlay(context);
return this.PlayCard(bestCard);
}
示例4: 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;
}
示例5: GetTurn
public override PlayerAction GetTurn(PlayerTurnContext context)
{
var possibleCardsToPlay = this.PlayerActionValidator.GetPossibleCardsToPlay(context, this.Cards);
var shuffledCards = possibleCardsToPlay.Shuffle();
var cardToPlay = shuffledCards.First();
return this.PlayCard(cardToPlay);
}
示例6: CloneShouldReturnObjectOfTypePlayerTurnContext
public void CloneShouldReturnObjectOfTypePlayerTurnContext()
{
var haveStateMock = new Mock<IStateManager>();
var state = new TwoCardsLeftRoundState(haveStateMock.Object);
var playerTurnContext = new PlayerTurnContext(state, new Card(CardSuit.Diamond, CardType.Ace), 2, 0, 0);
var clonedPlayerTurnContext = playerTurnContext.DeepClone();
Assert.IsInstanceOf<PlayerTurnContext>(clonedPlayerTurnContext);
}
示例7: 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;
}
示例8: CloneShouldReturnDifferentReference
public void CloneShouldReturnDifferentReference()
{
var haveStateMock = new Mock<IStateManager>();
var state = new StartRoundState(haveStateMock.Object);
var playerTurnContext = new PlayerTurnContext(state, new Card(CardSuit.Heart, CardType.Queen), 12, 0, 0);
var clonedPlayerTurnContext = playerTurnContext.DeepClone();
Assert.AreNotSame(playerTurnContext, clonedPlayerTurnContext);
}
示例9: PlayingCardThatsNotInHandShouldBeInvalid
public void PlayingCardThatsNotInHandShouldBeInvalid()
{
var cards = new List<Card>() { new Card(CardSuit.Diamond, CardType.Jack) };
var action = new PlayerAction(PlayerActionType.PlayCard, new Card(CardSuit.Club, CardType.Jack), Announce.None);
var state = new FinalRoundState();
var context = new PlayerTurnContext(state, new Card(CardSuit.Club, CardType.Jack), 0);
Assert.IsFalse(this.validater.IsValid(action, context, cards));
}
示例10: EndTurn
public override void EndTurn(PlayerTurnContext context)
{
this.UpdateContextInfo(context);
var playedCards = this.iAmFirstThisTurn
? new Tuple<Card, Card>(context.FirstPlayedCard, context.SecondPlayedCard)
: new Tuple<Card, Card>(context.SecondPlayedCard, context.FirstPlayedCard);
this.RedrawPlayedCards?.Invoke(this, playedCards);
base.EndTurn(context);
}
示例11: EndTurn
public override void EndTurn(PlayerTurnContext context)
{
Console.SetCursorPosition(20, 9);
Console.WriteLine($"{context.FirstPlayedCard} - {context.SecondPlayedCard} ");
Thread.Sleep(3000);
Console.SetCursorPosition(20, 9);
Console.WriteLine($" ");
}
示例12: NumberOfHandsCardCanTake
private int NumberOfHandsCardCanTake(Card card, PlayerTurnContext context)
{
var count = this.cardTracker.AllCards[card.Suit]
.Where(x => (x.Value == CardTracerState.InOpponentHand || x.Value == CardTracerState.Unknown)
&& x.Key < card.GetValue())
.Count();
return count;
}
示例13: PlayingCardFromHandShouldBeValid
public void PlayingCardFromHandShouldBeValid()
{
var cards = new List<Card>() { new Card(CardSuit.Club, CardType.Ace) };
var action = new PlayerAction(PlayerActionType.PlayCard, new Card(CardSuit.Club, CardType.Ace), Announce.None);
var state = new FinalRoundState();
var context = new PlayerTurnContext(state, new Card(CardSuit.Club, CardType.Jack), 0);
Assert.IsTrue(validator.IsValid(action, context, cards));
}
示例14: PlayerChangesTrumpWithQueen_ShouldBeInvalid
public void PlayerChangesTrumpWithQueen_ShouldBeInvalid()
{
var cards = new List<Card>() { new Card(CardSuit.Club, CardType.Queen) };
var action = new PlayerAction(PlayerActionType.ChangeTrump, new Card(CardSuit.Club, CardType.Queen), Announce.None);
var round = new GameRound(new Player(), new Player(), PlayerPosition.FirstPlayer);
var state = new MoreThanTwoCardsLeftRoundState(round);
var context = new PlayerTurnContext(state, new Card(CardSuit.Club, CardType.Jack), 0);
Assert.IsFalse(validator.IsValid(action, context, cards));
}
示例15: BiggestGainParameter
private float BiggestGainParameter(Card card, PlayerTurnContext context, ICollection<Card> allowedCards)
{
var suit = card.Suit;
float value = card.GetValue();
var allOfSuit = this.cardtracker.AllCards[suit];
var maxAvailableForTaking = allOfSuit.Where(x => x.Value != CardTracerState.TakenByOpponent ||
x.Value != CardTracerState.TakenByPlayer).Max(x => x.Key);
return (value + maxAvailableForTaking) / BiggestGainDivisor;
}