コード例 #1
0
        public void RedrawLastCard()
        {
            var player1 = new Player
            {
                User = new User
                {
                    Id = 1
                },
                Deck = new Deck
                {
                    BattleKingCard = new DeckCard(),
                },
                HandCards =
                {
                    new PlayerCard()
                    {
                        Card = new Card
                        {
                            Id = 1
                        }
                    }
                },
                DeckCards =
                {
                    new PlayerCard
                    {
                        Card = new Card
                        {
                            Id = 2
                        }
                    }
                }
            };
            var game = new Game
            {
                State = new RedrawState
                {
                    Substates =
                    {
                        new RedrawPlayerSubstate
                        {
                            UserId          = 1,
                            RedrawCardCount = 1
                        },
                        new RedrawPlayerSubstate
                        {
                            UserId          = 2,
                            RedrawCardCount = 0
                        }
                    }
                },
                Players =
                {
                    player1,
                    new Player
                    {
                        User = new User
                        {
                            Id = 2
                        },
                        Deck = new Deck
                        {
                            BattleKingCard = new DeckCard()
                        }
                    }
                }
            };

            var command = new RedrawCardCommand()
            {
                SenderUserId = 1,
                CardId       = 1
            };

            command.Execute(game);

            Assert.IsType(typeof(RoundState), command.NextState);

            var handCard = player1.HandCards.SingleOrDefault();

            Assert.NotNull(handCard);
            Assert.Equal(2, handCard.Card.Id);

            var deckCard = player1.DeckCards.SingleOrDefault();

            Assert.NotNull(deckCard);
            Assert.Equal(1, deckCard.Card.Id);
        }
コード例 #2
0
        public void RedrawFirstOfTwoCard()
        {
            var redrawPlayer1Substate = new RedrawPlayerSubstate
            {
                UserId          = 1,
                RedrawCardCount = 2
            };
            var game = new Game
            {
                State = new RedrawState
                {
                    Substates =
                    {
                        redrawPlayer1Substate,
                        new RedrawPlayerSubstate
                        {
                            UserId          = 2,
                            RedrawCardCount = 0
                        }
                    }
                },
                Players =
                {
                    new Player
                    {
                        User = new User
                        {
                            Id = 1
                        },
                        Deck = new Deck
                        {
                            BattleKingCard = new DeckCard(),
                            Cards          = new List <DeckCard>
                            {
                                new DeckCard
                                {
                                    Card = new Card()
                                }
                            }
                        },
                        HandCards =
                        {
                            new PlayerCard()
                            {
                                Card = new Card
                                {
                                    Id = 1
                                }
                            }
                        },
                        DeckCards =
                        {
                            new PlayerCard()
                            {
                                Card = new Card()
                            }
                        }
                    },
                    new Player
                    {
                        User = new User
                        {
                            Id = 2
                        },
                        Deck = new Deck
                        {
                            BattleKingCard = new DeckCard()
                        }
                    }
                }
            };

            var command = new RedrawCardCommand()
            {
                SenderUserId = 1,
                CardId       = 1
            };

            command.Execute(game);

            Assert.Null(command.NextState);

            Assert.Equal(1, redrawPlayer1Substate.RedrawCardCount);
        }
コード例 #3
0
        public void RedrawLastCardWhileOpponentCanStillRedraw()
        {
            var redrawPlayer1Substate = new RedrawPlayerSubstate
            {
                UserId          = 1,
                RedrawCardCount = 1
            };
            var game = new Game
            {
                State = new RedrawState
                {
                    Substates =
                    {
                        redrawPlayer1Substate,
                        new RedrawPlayerSubstate
                        {
                            UserId          = 2,
                            RedrawCardCount = 1
                        }
                    }
                },
                Players =
                {
                    new Player
                    {
                        User = new User
                        {
                            Id = 1
                        },
                        Deck = new Deck
                        {
                            BattleKingCard = new DeckCard()
                        },
                        HandCards =
                        {
                            new PlayerCard()
                            {
                                Card = new Card
                                {
                                    Id = 1
                                }
                            }
                        },
                        DeckCards =
                        {
                            new PlayerCard()
                            {
                                Card = new Card
                                {
                                    Id = 2
                                }
                            }
                        }
                    },
                    new Player
                    {
                        User = new User
                        {
                            Id = 2
                        },
                        Deck = new Deck
                        {
                            BattleKingCard = new DeckCard()
                        }
                    }
                }
            };

            var command = new RedrawCardCommand()
            {
                SenderUserId = 1,
                CardId       = 1
            };

            command.Execute(game);

            Assert.Null(command.NextState);
            Assert.Equal(0, redrawPlayer1Substate.RedrawCardCount);
        }