示例#1
0
        [UnityTest]//测试简单效果(支付500点生命值 对敌方造成1000点伤害)
        public IEnumerator Test_SimpleEffect_0()
        {
            int[] codes1     = new int[] { 1, 500, 109, 3, 1, 1, 129, 128, 127 }; //条件
            int[] codes2     = new int[] { 1, 500, 110, 127 };                    //cost
            int[] codes3     = new int[] { 1, 1000, 104, 107, 127 };              //效果
            int   playerID   = 0;
            int   cardHandle = 0;
            var   effect     = new CardEffect(0, codes1, codes2, codes3);
            //玩家初始血量为8000
            var m0 = BattleManager.Instance.GetPlayerModel(0);
            var m1 = BattleManager.Instance.GetPlayerModel(1);

            async UniTask Excute()
            {
                if (effect.IsFillCondition(playerID, cardHandle))
                {
                    await effect.ExecuteCodes_Cost_Chose(playerID, cardHandle);

                    await effect.ExecuteCodes_Body(playerID, cardHandle);
                }
            }

            yield return(Excute().ToCoroutine());

            Assert.AreEqual(m0.GetHp(), 7500);
            Assert.AreEqual(m1.GetHp(), 7000);
            for (int i = 0; i < 20; i++)
            {
                yield return(Excute().ToCoroutine());
            }
            bool isFill = effect.IsFillCondition(playerID, cardHandle);

            Assert.AreEqual(isFill, false);
            Assert.AreEqual(m0.GetHp(), 500);
            Assert.AreEqual(m1.GetHp(), -7000);
        }