本文整理汇总了C#中Santase.Logic.Players.PlayerTurnContext.DeepClone方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerTurnContext.DeepClone方法的具体用法?C# PlayerTurnContext.DeepClone怎么用?C# PlayerTurnContext.DeepClone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Santase.Logic.Players.PlayerTurnContext
的用法示例。
在下文中一共展示了PlayerTurnContext.DeepClone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: CloneShouldReturnObjectWithTheSameProperties
public void CloneShouldReturnObjectWithTheSameProperties()
{
var haveStateMock = new Mock<IStateManager>();
var state = new StartRoundState(haveStateMock.Object);
var playerTurnContext = new PlayerTurnContext(state, new Card(CardSuit.Club, CardType.Ten), 12, 0, 0)
{
FirstPlayedCard = new Card(CardSuit.Spade, CardType.King),
FirstPlayerAnnounce = Announce.Forty,
SecondPlayedCard = new Card(CardSuit.Heart, CardType.Nine)
};
var clonedPlayerTurnContext = playerTurnContext.DeepClone();
Assert.IsNotNull(clonedPlayerTurnContext);
Assert.AreSame(playerTurnContext.State, clonedPlayerTurnContext.State);
Assert.AreEqual(playerTurnContext.CardsLeftInDeck, clonedPlayerTurnContext.CardsLeftInDeck);
Assert.AreEqual(playerTurnContext.FirstPlayedCard, clonedPlayerTurnContext.FirstPlayedCard);
Assert.AreEqual(playerTurnContext.FirstPlayerAnnounce, clonedPlayerTurnContext.FirstPlayerAnnounce);
Assert.AreEqual(playerTurnContext.SecondPlayedCard, clonedPlayerTurnContext.SecondPlayedCard);
Assert.AreEqual(playerTurnContext.TrumpCard, clonedPlayerTurnContext.TrumpCard);
}
示例4: GetPlayerAction
private static PlayerAction GetPlayerAction(RoundPlayerInfo playerInfo, PlayerTurnContext context)
{
var action = playerInfo.Player.GetTurn(context.DeepClone());
var isActionValid = PlayerActionValidator.Instance.IsValid(action, context, playerInfo.Cards);
if (!isActionValid)
{
throw new InternalGameException($"Invalid action played from {playerInfo.Player.Name}");
}
return action;
}
示例5: GetTurn
public override PlayerAction GetTurn(PlayerTurnContext context)
{
this.GetTurnCalledCount++;
this.GetTurnContextObject = context.DeepClone();
if (this.actionToPlay == PlayerActionType.ChangeTrump)
{
this.actionToPlay = PlayerActionType.PlayCard;
return this.ChangeTrump(context.TrumpCard);
}
if (this.actionToPlay == PlayerActionType.CloseGame)
{
this.actionToPlay = PlayerActionType.PlayCard;
return PlayerAction.CloseGame();
}
var possibleCardsToPlay = this.PlayerActionValidator.GetPossibleCardsToPlay(context, this.Cards);
return this.PlayCard(possibleCardsToPlay.First());
}
示例6: EndTurn
public override void EndTurn(PlayerTurnContext context)
{
this.EndTurnCalledCount++;
this.EndTurnContextObject = context.DeepClone();
base.EndTurn(context);
}