当前位置: 首页>>代码示例>>C#>>正文


C# PlayerTurnContext.DeepClone方法代码示例

本文整理汇总了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);
 }
开发者ID:NotDemons,项目名称:NotDemonsRepo,代码行数:8,代码来源:PlayerTurnContextTests.cs

示例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);
 }
开发者ID:NotDemons,项目名称:NotDemonsRepo,代码行数:8,代码来源:PlayerTurnContextTests.cs

示例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);
        }
开发者ID:NotDemons,项目名称:NotDemonsRepo,代码行数:21,代码来源:PlayerTurnContextTests.cs

示例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;
        }
开发者ID:NotDemons,项目名称:NotDemonsRepo,代码行数:11,代码来源:Trick.cs

示例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());
            }
开发者ID:NotDemons,项目名称:NotDemonsRepo,代码行数:20,代码来源:TrickTestsForSantase.cs

示例6: EndTurn

            public override void EndTurn(PlayerTurnContext context)
            {
                this.EndTurnCalledCount++;
                this.EndTurnContextObject = context.DeepClone();

                base.EndTurn(context);
            }
开发者ID:NotDemons,项目名称:NotDemonsRepo,代码行数:7,代码来源:TrickTestsForSantase.cs


注:本文中的Santase.Logic.Players.PlayerTurnContext.DeepClone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。