Пример #1
0
        public void RemoveCardTestMethod6()
        {
            Field field = new Field(1);

            int eventCallCounter_remove = 0;
            int eventCallCounter_update = 0;

            field.OnCardChanged += (fieldCard, chageCode) =>
            {
                if (chageCode == Protocol.DataChangeCode.Remove)
                {
                    eventCallCounter_remove++;
                }
                else
                {
                    eventCallCounter_update++;
                }
            };

            field.AddCard(5, 0);
            field.AddCard(3, 1);
            field.RemoveCard(5);

            Assert.AreEqual(eventCallCounter_remove, 1);
            Assert.AreEqual(eventCallCounter_update, 3);
        }
Пример #2
0
        public void RemoveCardTestMethod4()
        {
            Field field = new Field(1);

            field.AddCard(5, 0);
            field.AddCard(3, 1);
            field.RemoveCard(3);

            var cards = field.FieldCards.GetEnumerator();

            Assert.IsTrue(cards.MoveNext());
            Assert.AreEqual(cards.Current.CardRecordID, 5);
            Assert.AreEqual(cards.Current.PositionIndex, 0);
        }
Пример #3
0
        public void DisplayCheckTestMethod2()
        {
            Field field = new Field(1);

            field.AddCard(5, 0);

            Assert.IsFalse(field.DisplayCheck(-1));
        }
Пример #4
0
        public void DisplayCheckTestMethod1()
        {
            Field field = new Field(1);

            field.AddCard(5, 0);

            Assert.IsTrue(field.DisplayCheck(0));
        }
Пример #5
0
        public void AnyTauntServantTestMethod()
        {
            Field field = new Field(1);
            var   game  = GameUnitTest.InitialGameStatus();

            field.BindGame(game);
            Assert.IsTrue(field.AddCard(5, 0));
            Assert.IsFalse(field.AnyTauntServant());
        }
Пример #6
0
        public void AddCardTestMethod2()
        {
            Field field = new Field(1);

            field.AddCard(5, 3);

            var cards = field.FieldCards.GetEnumerator();

            Assert.IsFalse(cards.MoveNext());
        }
Пример #7
0
        public void FindCardWithPositionIndexTestMethod2()
        {
            Field field = new Field(1);

            field.AddCard(5, 0);

            int cardID = 2;

            Assert.IsTrue(field.FindCardWithPositionIndex(0, out cardID));
        }
Пример #8
0
        public void DisplayCheckTestMethod3()
        {
            Field field = new Field(1);

            for (int i = 0; i < 7; i++)
            {
                field.AddCard(i, i);
            }

            Assert.IsFalse(field.DisplayCheck(3));
        }
Пример #9
0
        public void UpdateCardTestMethod2()
        {
            Field field = new Field(1);

            Assert.IsTrue(field.AddCard(5, 0));
            Assert.IsFalse(field.UpdateCard(6, 2));

            var cards = field.FieldCards.GetEnumerator();

            Assert.IsTrue(cards.MoveNext());
            Assert.AreEqual(cards.Current.CardRecordID, 5);
            Assert.AreEqual(cards.Current.PositionIndex, 0);
        }
Пример #10
0
        public void AddCardTestMethod4()
        {
            Field field = new Field(1);
            int   eventCallCounter_add    = 0;
            int   eventCallCounter_update = 0;

            field.OnCardChanged += (fieldCard, chageCode) =>
            {
                if (chageCode == Protocol.DataChangeCode.Update)
                {
                    eventCallCounter_update++;
                }
                else
                {
                    eventCallCounter_add++;
                }
            };
            Assert.IsTrue(field.AddCard(5, 0));
            Assert.IsTrue(field.UpdateCard(5, 1));
            Assert.IsTrue(field.AddCard(6, 0));

            Assert.AreEqual(eventCallCounter_add, 2);
            Assert.AreEqual(eventCallCounter_update, 2);
        }
Пример #11
0
        public void AddCardTestMethod3()
        {
            Field field = new Field(1);

            Assert.IsTrue(field.AddCard(5, 0));
            var cards = field.FieldCards.GetEnumerator();

            Assert.IsTrue(cards.MoveNext());
            int eventCallCounter = 0;

            field.OnCardChanged += (fieldCard, chageCode) =>
            {
                Assert.AreEqual(chageCode, Protocol.DataChangeCode.Update);
                eventCallCounter++;
            };
        }
Пример #12
0
        public bool NonTargetDisplayServant(int gamePlayerID, int servantCardRecordID, int positionIndex)
        {
            if (CurrentGamePlayerID != gamePlayerID)
            {
                return(false);
            }
            Field field = (gamePlayerID == 1) ? Field1 : Field2;

            if (!field.DisplayCheck(positionIndex))
            {
                return(false);
            }
            CardRecord servantCardRecord;

            if (!GameCardManager.FindCard(servantCardRecordID, out servantCardRecord) || !(servantCardRecord is ServantCardRecord))
            {
                return(false);
            }
            if (servantCardRecord.Effectors(GameCardManager).Any(x => x is TargetEffector || x is MinionTargetEffector))
            {
                return(false);
            }
            GamePlayer gamePlayer = (gamePlayerID == 1) ? GamePlayer1 : GamePlayer2;

            if (CanUseCard(gamePlayer, servantCardRecord))
            {
                UseCard(gamePlayer, servantCardRecord);
                foreach (var effector in servantCardRecord.Effectors(GameCardManager))
                {
                    if (effector is AutoExecutetEffector)
                    {
                        (effector as AutoExecutetEffector).Affect(gamePlayer);
                    }
                }
                (servantCardRecord as ServantCardRecord).IsDisplayInThisTurn = true;
                field.AddCard(servantCardRecordID, positionIndex);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #13
0
    /// <summary>
    /// 各場所にカードを配る処理
    /// </summary>
    public void CardHandOutProcess()
    {
        var where = (handoutCounter / 4) % 3;

        var card = deck.transform.GetChild(0).gameObject;

        switch (where)
        {
        case 0:    //プレイヤーの手札にカードを配る
            player.AddCard(card);
            break;

        case 1:    //場にカードを配る
            field.AddCard(card);
            break;

        case 2:    //CPUの手札にカードを配る
            cpu.AddCard(card);
            break;
        }
    }
Пример #14
0
        public bool TargetDisplayServant(int gamePlayerID, int servantCardRecordID, int positionIndex, int targetID, bool isTargetServant)
        {
            if (CurrentGamePlayerID != gamePlayerID)
            {
                return(false);
            }
            Field field = (gamePlayerID == 1) ? Field1 : Field2;

            if (!field.DisplayCheck(positionIndex))
            {
                return(false);
            }
            CardRecord servantCardRecord;

            if (!GameCardManager.FindCard(servantCardRecordID, out servantCardRecord) || !(servantCardRecord is ServantCardRecord))
            {
                return(false);
            }
            if (!servantCardRecord.Effectors(GameCardManager).Any(x => x is TargetEffector || (isTargetServant && x is MinionTargetEffector)))
            {
                return(false);
            }
            GamePlayer gamePlayer = (gamePlayerID == 1) ? GamePlayer1 : GamePlayer2;

            if (CanUseCard(gamePlayer, servantCardRecord))
            {
                if (isTargetServant)
                {
                    CardRecord targetCardRecord;
                    if (GameCardManager.FindCard(targetID, out targetCardRecord) && targetCardRecord is ServantCardRecord)
                    {
                        UseCard(gamePlayer, servantCardRecord);
                        foreach (var effector in servantCardRecord.Effectors(GameCardManager))
                        {
                            if (effector is TargetEffector)
                            {
                                (effector as TargetEffector).AffectServant(targetCardRecord as ServantCardRecord, gamePlayer);
                            }
                            else if (effector is MinionTargetEffector)
                            {
                                (effector as MinionTargetEffector).AffectServant(targetCardRecord as ServantCardRecord, gamePlayer);
                            }
                            else if (effector is AutoExecutetEffector)
                            {
                                (effector as AutoExecutetEffector).Affect(gamePlayer);
                            }
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    if (targetID != 1 && targetID != 2)
                    {
                        return(false);
                    }
                    else
                    {
                        UseCard(gamePlayer, servantCardRecord);
                        Hero hero = (targetID == 1) ? GamePlayer1.Hero : GamePlayer2.Hero;
                        foreach (var effector in servantCardRecord.Effectors(GameCardManager))
                        {
                            if (effector is TargetEffector)
                            {
                                (effector as TargetEffector).AffectHero(hero, gamePlayer);
                            }
                            else if (effector is AutoExecutetEffector)
                            {
                                (effector as AutoExecutetEffector).Affect(gamePlayer);
                            }
                        }
                    }
                }
                (servantCardRecord as ServantCardRecord).IsDisplayInThisTurn = true;
                field.AddCard(servantCardRecordID, positionIndex);
                return(true);
            }
            else
            {
                return(false);
            }
        }