本文整理匯總了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);
}