當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。