Exemplo n.º 1
0
        public void PoisonBiteAbilityUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Mage)
            {
                HitPoints = 100, MaxHitPoints = 100
            };

            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Spider)
            {
                HitPoints = 50, MaxHitPoints = 100
            };

            MonsterBuilder.BuildMonster(monster);
            int abilityIndex = monster.Abilities.FindIndex(
                f => f.AbilityCategory == Ability.PoisonBite);

            foreach (IItem item in player.Inventory.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            monster.Abilities[abilityIndex].UseOffenseDamageAbility(monster, player, abilityIndex);
            int abilityCost = monster.Abilities[abilityIndex].EnergyCost;

            Assert.AreEqual(monster.MaxEnergyPoints - abilityCost, monster.EnergyPoints);
            int    abilityDamage         = monster.Abilities[abilityIndex].Offensive.Amount;
            int    abilityDamageOverTime = monster.Abilities[abilityIndex].Offensive.AmountOverTime;
            int    abilityCurRounds      = monster.Abilities[abilityIndex].Offensive.AmountCurRounds;
            int    abilityMaxRounds      = monster.Abilities[abilityIndex].Offensive.AmountMaxRounds;
            string attackString          = $"The {monster.Name} tries to bite you!";

            Assert.AreEqual(attackString, OutputHelper.Display.Output[0][2]);
            string attackSuccessString = $"The {monster.Name} bites you for {abilityDamage} physical damage.";

            Assert.AreEqual(attackSuccessString, OutputHelper.Display.Output[1][2]);
            string bleedString = $"You are bleeding from {monster.Name}'s attack!";

            Assert.AreEqual(bleedString, OutputHelper.Display.Output[2][2]);
            Assert.AreEqual(true, player.Effects[0] is BleedingEffect);
            Assert.AreEqual(player.MaxHitPoints - abilityDamage, player.HitPoints);
            Assert.AreEqual(abilityCurRounds, player.Effects[0].CurrentRound);
            Assert.AreEqual(abilityMaxRounds, player.Effects[0].MaxRound);
            OutputHelper.Display.ClearUserOutput();
            BleedingEffect bleedEffect = player.Effects[0] as BleedingEffect;

            for (int i = 2; i < 5; i++)
            {
                bleedEffect.ProcessRound();
                int    bleedAmount      = bleedEffect.BleedDamageOverTime;
                string bleedRoundString = $"You bleed for {bleedAmount} physical damage.";
                Assert.AreEqual(bleedRoundString, OutputHelper.Display.Output[i - 2][2]);
                Assert.AreEqual(i, player.Effects[0].CurrentRound);
                GameHelper.RemovedExpiredEffectsAsync(player);
                Thread.Sleep(1000);
            }
            Assert.AreEqual(false, player.Effects.Any());
            Assert.AreEqual(player.MaxHitPoints - abilityDamage - (abilityDamageOverTime * abilityMaxRounds),
                            player.HitPoints);
        }
Exemplo n.º 2
0
    public GameObject handleTowerCanvasGo;//处理塔的画布

    private void Awake()
    {
#if Game
        _instance     = this;
        mGameManager  = GameManager.Instance;
        mCurrentStage = mGameManager.CurrentStage;
        //normalModelPanel = mGameManager.uiManager.mUIFacade.currentScenePanelDict[StringManager.NormalModelPanel] as NormalModelPanel;
        mapMaker = GetComponent <MapMaker>();
        mapMaker.InitMapMaker();
        //mapMaker.LoadMap(mCurrentStage.mBigLevelID, mCurrentStage.mLevelID);
        mapMaker.LoadMap(1, 3);

        GameSpeed      = 1;
        monsterBuilder = new MonsterBuilder();
        mLevel         = new Level(mapMaker.roundInfoList.Count, mapMaker.roundInfoList);
        mLevel.HandleRound();


        AnimControllers = new RuntimeAnimatorController[12];
        for (int i = 0; i < AnimControllers.Length; i++)
        {
            AnimControllers[i] = GetRuntimeAnimatorController("Monster/" + mapMaker.bigLevelID.ToString() + "/" + (i + 1).ToString());
        }
#endif
    }
Exemplo n.º 3
0
        public void TailWhipAbilityUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Mage)
            {
                HitPoints = 200, MaxHitPoints = 200
            };

            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Dragon);

            MonsterBuilder.BuildMonster(monster);
            int abilityIndex = monster.Abilities.FindIndex(
                f => f.AbilityCategory == Ability.TailWhip);

            foreach (IItem item in player.Inventory.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            monster.Abilities[abilityIndex].UseOffenseDamageAbility(monster, player, abilityIndex);
            int abilityCost = monster.Abilities[abilityIndex].EnergyCost;

            Assert.AreEqual(monster.MaxEnergyPoints - abilityCost, monster.EnergyPoints);
            int attackDamage = monster.Abilities[abilityIndex].Offensive.Amount;

            Assert.AreEqual(player.MaxHitPoints - attackDamage, player.HitPoints);
            string attackString = $"The {monster.Name} swings its tail at you!";

            Assert.AreEqual(attackString, OutputHelper.Display.Output[0][2]);
            string attackSuccessString = $"The {monster.Name} strikes you with its tail for {attackDamage} physical damage.";

            Assert.AreEqual(attackSuccessString, OutputHelper.Display.Output[1][2]);
        }
Exemplo n.º 4
0
        public void PlayerResistanceUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Mage)
            {
                MaxManaPoints = 100, ManaPoints = 100
            };

            GearHelper.EquipInitialGear(player);
            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Elemental);

            while (monster.ElementalCategory != ElementalType.Air)
            {
                monster = new Monster(3, MonsterType.Elemental);
            }
            MonsterBuilder.BuildMonster(monster);
            foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            Assert.AreEqual(player.Level * 5, player.FireResistance);
            Assert.AreEqual(player.Level * 5, player.FrostResistance);
            Assert.AreEqual(player.Level * 5, player.ArcaneResistance);
            int    arcaneResistance = player.ArcaneResistance;
            double resistanceMod    = (100 - arcaneResistance) / 100.0;
            int    spellIndex       = monster.Spellbook.FindIndex(
                f => f.SpellCategory == SpellType.Lightning);

            monster.Spellbook[spellIndex].CastArcaneOffense(monster, player, spellIndex);
            int reducedDamage = (int)(monster.Spellbook[spellIndex].Offensive.Amount * resistanceMod);

            Assert.AreEqual(player.HitPoints, player.MaxHitPoints - reducedDamage);
        }
Exemplo n.º 5
0
        public void WarCryAbilityUnitTest()
        {
            OutputHelper.Display.ClearUserOutput();
            Player player = new Player("test", PlayerClassType.Warrior)
            {
                MaxRagePoints = 100,
                RagePoints    = 100,
                InCombat      = true
            };

            player.Abilities.Add(new PlayerAbility(
                                     "war cry", 50, 1, WarriorAbility.WarCry, 4));
            Monster monster = new Monster(3, MonsterType.Demon)
            {
                HitPoints = 100, MaxHitPoints = 100
            };

            MonsterBuilder.BuildMonster(monster);
            int abilityIndex = player.Abilities.FindIndex(
                f => f.WarAbilityCategory == WarriorAbility.WarCry);

            string[] inputInfo = new[] { "ability", "war", "cry" };
            PlayerHelper.AbilityInfo(player, inputInfo);
            Assert.AreEqual("War Cry", OutputHelper.Display.Output[0][2]);
            Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]);
            Assert.AreEqual("Rage Cost: 50", OutputHelper.Display.Output[2][2]);
            Assert.AreEqual("War Cry Amount: 25", OutputHelper.Display.Output[3][2]);
            Assert.AreEqual("Opponent's attacks are decreased by 25 for 3 rounds.",
                            OutputHelper.Display.Output[4][2]);
            string[] input       = new[] { "use", "war", "cry" };
            string   abilityName = InputHelper.ParseInput(input);

            Assert.AreEqual("war cry", abilityName);
            player.UseAbility(input);
            int?rageCost = player.Abilities[abilityIndex].RageCost;

            Assert.AreEqual(player.MaxRagePoints - rageCost, player.RagePoints);
            Assert.AreEqual("You shout a War Cry, intimidating your opponent, and decreasing incoming damage.",
                            OutputHelper.Display.Output[5][2]);
            OutputHelper.Display.ClearUserOutput();
            Assert.AreEqual(true, player.Effects[0] is ChangeMonsterDamageEffect);
            ChangeMonsterDamageEffect changeMonsterDmgEffect = player.Effects[0] as ChangeMonsterDamageEffect;

            for (int i = 2; i < 5; i++)
            {
                int baseAttackDamageM  = monster.UnarmedAttackDamage;
                int attackDamageM      = baseAttackDamageM;
                int changeDamageAmount = changeMonsterDmgEffect.ChangeAmount < attackDamageM ?
                                         changeMonsterDmgEffect.ChangeAmount : attackDamageM;
                attackDamageM -= changeDamageAmount;
                Assert.AreEqual(baseAttackDamageM - changeDamageAmount, attackDamageM);
                changeMonsterDmgEffect.ProcessChangeMonsterDamageRound(player);
                string changeDmgString = $"Incoming damage is decreased by {-1 * changeMonsterDmgEffect.ChangeAmount}.";
                Assert.AreEqual(i, player.Effects[0].CurrentRound);
                Assert.AreEqual(changeDmgString, OutputHelper.Display.Output[i - 2][2]);
            }
            GameHelper.RemovedExpiredEffectsAsync(player);
            Thread.Sleep(1000);
            Assert.AreEqual(false, player.Effects.Any());
        }
Exemplo n.º 6
0
        public void DoubleShotAbilityUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Archer)
            {
                MaxComboPoints = 100,
                ComboPoints    = 100,
                MaxHitPoints   = 100,
                HitPoints      = 10
            };

            GearHelper.EquipInitialGear(player);
            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Demon)
            {
                HitPoints = 100, MaxHitPoints = 100, InCombat = true
            };

            MonsterBuilder.BuildMonster(monster);
            int abilityIndex = player.Abilities.FindIndex(
                f => f.ArcAbilityCategory == ArcherAbility.Double);

            string[] inputInfo = new[] { "ability", "double" };
            PlayerHelper.AbilityInfo(player, inputInfo);
            Assert.AreEqual("Double Shot", OutputHelper.Display.Output[0][2]);
            Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]);
            Assert.AreEqual("Combo Cost: 25", OutputHelper.Display.Output[2][2]);
            Assert.AreEqual("Instant Damage: 25", OutputHelper.Display.Output[3][2]);
            Assert.AreEqual(
                "Two arrows are fired which each cause instant damage. Cost and damage are per arrow.",
                OutputHelper.Display.Output[4][2]);
            string[] input       = new[] { "use", "double" };
            string   abilityName = InputHelper.ParseInput(input);

            Assert.AreEqual("double", abilityName);
            int arrowCount = player.PlayerQuiver.Quantity;

            player.UseAbility(monster, input);
            Assert.AreEqual(arrowCount - 2, player.PlayerQuiver.Quantity);
            int?comboCost = player.Abilities[abilityIndex].ComboCost;
            int hitAmount = player.Abilities[abilityIndex].Offensive.Amount;

            Assert.AreEqual(monster.MaxHitPoints - (2 * hitAmount), monster.HitPoints);
            Assert.AreEqual(player.MaxComboPoints - (2 * comboCost), player.ComboPoints);
            string attackString = $"Your double shot hit the {monster.Name} for 25 physical damage.";

            Assert.AreEqual(attackString, OutputHelper.Display.Output[5][2]);
            Assert.AreEqual(attackString, OutputHelper.Display.Output[6][2]);
            player.MaxComboPoints = 25;
            player.ComboPoints    = player.MaxComboPoints;
            monster.MaxHitPoints  = 100;
            monster.HitPoints     = monster.MaxHitPoints;
            arrowCount            = player.PlayerQuiver.Quantity;
            player.UseAbility(monster, input);
            Assert.AreEqual(arrowCount - 1, player.PlayerQuiver.Quantity);
            Assert.AreEqual(player.MaxComboPoints - comboCost, player.ComboPoints);
            Assert.AreEqual(attackString, OutputHelper.Display.Output[7][2]);
            const string outOfComboString = "You didn't have enough combo points for the second shot!";

            Assert.AreEqual(outOfComboString, OutputHelper.Display.Output[8][2]);
        }
Exemplo n.º 7
0
        public Form1()
        {
            InitializeComponent();

            //instatiate required workers
            UIworker = new MonsterPrinter();

            //List of picture boxs to print to
            outputImageBoxeList = new List<PictureBox>() { pbhead, pbbody, pbLegs };

            //list of avaliable monsters to choose parts from
            comboBoxList = new List<string>() { "Fairy", "Frankenstein","Skeleton","Vampire","Werewolf","Witch" };

            //Populate combo boxes
            populateComboBox(cbhead, comboBoxList);
            populateComboBox(cbbody, comboBoxList);
            populateComboBox(cblegs, comboBoxList);

            headWorker = new HeadFactory();
            bodyWorker = new BodyFactory();
            legsWorker = new Legfactory();

            //Set initial monster on form
            monsterbuilderWorker = new MonsterBuilder(headWorker.requiredpart(cbhead.SelectedIndex),bodyWorker.requiredpart(cbbody.SelectedIndex),legsWorker.requiredpart(cblegs.SelectedIndex));

            UIworker.printMonster(outputImageBoxeList, monsterbuilderWorker);
        }
Exemplo n.º 8
0
        public void FireballSpellUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Mage)
            {
                MaxManaPoints = 100, ManaPoints = 100, InCombat = true
            };

            GearHelper.EquipInitialGear(player);
            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Demon)
            {
                HitPoints = 50, MaxHitPoints = 100, FireResistance = 0
            };

            MonsterBuilder.BuildMonster(monster);
            player.PlayerWeapon.CritMultiplier = 1;             // Remove crit chance to remove "noise" in test
            string[] inputInfo  = new[] { "spell", "fireball" };
            int      spellIndex = player.Spellbook.FindIndex(
                f => f.SpellCategory == SpellType.Fireball);

            PlayerHelper.SpellInfo(player, inputInfo);
            Assert.AreEqual("Fireball", OutputHelper.Display.Output[0][2]);
            Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]);
            Assert.AreEqual("Mana Cost: 35", OutputHelper.Display.Output[2][2]);
            Assert.AreEqual("Instant Damage: 25", OutputHelper.Display.Output[3][2]);
            Assert.AreEqual("Damage Over Time: 5", OutputHelper.Display.Output[4][2]);
            Assert.AreEqual("Fire damage over time will burn for 3 rounds.",
                            OutputHelper.Display.Output[5][2]);
            OutputHelper.Display.ClearUserOutput();
            string[] input     = new[] { "cast", "fireball" };
            string   spellName = InputHelper.ParseInput(input);

            Assert.AreEqual("fireball", spellName);
            player.CastSpell(monster, spellName);
            Assert.AreEqual(player.MaxManaPoints - player.Spellbook[spellIndex].ManaCost, player.ManaPoints);
            Assert.AreEqual(25, monster.HitPoints);
            Assert.AreEqual(3, monster.Effects[0].MaxRound);
            Assert.AreEqual($"You hit the {monster.Name} for {player.Spellbook[spellIndex].Offensive.Amount} fire damage.",
                            OutputHelper.Display.Output[0][2]);
            Assert.AreEqual($"The {monster.Name} bursts into flame!",
                            OutputHelper.Display.Output[1][2]);
            BurningEffect burnEffect = monster.Effects[0] as BurningEffect;

            for (int i = 2; i < 5; i++)
            {
                burnEffect.ProcessRound();
                Assert.AreEqual(
                    $"The {monster.Name} burns for {burnEffect.FireDamageOverTime} fire damage.",
                    OutputHelper.Display.Output[i][2]);
                Assert.AreEqual(i, monster.Effects[0].CurrentRound);
                GameHelper.RemovedExpiredEffectsAsync(monster);
                Thread.Sleep(1000);
            }
            Assert.AreEqual(false, monster.Effects.Any());
            Assert.AreEqual(10, monster.HitPoints);
        }
Exemplo n.º 9
0
        public void FirebreathSpellUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Mage)
            {
                HitPoints = 200, MaxHitPoints = 200, FireResistance = 0
            };

            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Dragon);

            MonsterBuilder.BuildMonster(monster);
            int spellIndex = monster.Spellbook.FindIndex(
                f => f.SpellCategory == SpellType.Fireball);

            foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            monster.MonsterWeapon.CritMultiplier = 1;             // Remove crit chance to remove "noise" in test
            monster.Spellbook[spellIndex].CastFireOffense(monster, player, spellIndex);
            int spellCost = monster.Spellbook[spellIndex].EnergyCost;

            Assert.AreEqual(monster.MaxEnergyPoints - spellCost, monster.EnergyPoints);
            int spellDamage = monster.Spellbook[spellIndex].Offensive.Amount;

            Assert.AreEqual(player.MaxHitPoints - spellDamage, player.HitPoints);
            int spellMaxRounds = monster.Spellbook[spellIndex].Offensive.AmountMaxRounds;

            Assert.AreEqual(spellMaxRounds, player.Effects[0].MaxRound);
            string attackString = $"The {monster.Name} breathes a pillar of fire at you!";

            Assert.AreEqual(attackString, OutputHelper.Display.Output[0][2]);
            string attackSuccessString = $"The {monster.Name} hits you for {spellDamage} fire damage.";

            Assert.AreEqual(attackSuccessString, OutputHelper.Display.Output[1][2]);
            const string onFireString = "You burst into flame!";

            Assert.AreEqual(onFireString, OutputHelper.Display.Output[2][2]);
            Assert.AreEqual(true, player.Effects[0] is BurningEffect);
            int           burnDamage = monster.Spellbook[spellIndex].Offensive.AmountOverTime;
            BurningEffect burnEffect = player.Effects[0] as BurningEffect;

            for (int i = 2; i < 5; i++)
            {
                burnEffect.ProcessRound();
                string burnString = $"You burn for {burnDamage} fire damage.";
                Assert.AreEqual(burnString, OutputHelper.Display.Output[i + 1][2]);
                Assert.AreEqual(i, player.Effects[0].CurrentRound);
                GameHelper.RemovedExpiredEffectsAsync(player);
                Thread.Sleep(1000);
            }
            Assert.AreEqual(false, player.Effects.Any());
            Assert.AreEqual(player.MaxHitPoints - spellDamage - (burnDamage * 3), player.HitPoints);
        }
Exemplo n.º 10
0
        public void OnslaughtAbilityUnitTest()
        {
            OutputHelper.Display.ClearUserOutput();
            Player player = new Player("test", PlayerClassType.Warrior)
            {
                MaxRagePoints = 100,
                RagePoints    = 100,
                InCombat      = true
            };

            player.Abilities.Add(new PlayerAbility(
                                     "onslaught", 25, 1, WarriorAbility.Onslaught, 8));
            Monster monster = new Monster(3, MonsterType.Demon)
            {
                HitPoints = 100, MaxHitPoints = 100, InCombat = true
            };

            MonsterBuilder.BuildMonster(monster);
            int abilityIndex = player.Abilities.FindIndex(
                f => f.WarAbilityCategory == WarriorAbility.Onslaught);

            string[] inputInfo = new[] { "ability", "onslaught" };
            PlayerHelper.AbilityInfo(player, inputInfo);
            Assert.AreEqual("Onslaught", OutputHelper.Display.Output[0][2]);
            Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]);
            Assert.AreEqual("Rage Cost: 25", OutputHelper.Display.Output[2][2]);
            Assert.AreEqual("Instant Damage: 25", OutputHelper.Display.Output[3][2]);
            Assert.AreEqual(
                "Two attacks are launched which each cause instant damage. Cost and damage are per attack.",
                OutputHelper.Display.Output[4][2]);
            string[] input       = new[] { "use", "onslaught" };
            string   abilityName = InputHelper.ParseInput(input);

            Assert.AreEqual("onslaught", abilityName);
            player.UseAbility(monster, input);
            int?rageCost  = player.Abilities[abilityIndex].RageCost;
            int hitAmount = player.Abilities[abilityIndex].Offensive.Amount;

            Assert.AreEqual(monster.MaxHitPoints - (2 * hitAmount), monster.HitPoints);
            Assert.AreEqual(player.MaxRagePoints - (2 * rageCost), player.RagePoints);
            string attackString = $"Your onslaught hit the {monster.Name} for 25 physical damage.";

            Assert.AreEqual(attackString, OutputHelper.Display.Output[5][2]);
            Assert.AreEqual(attackString, OutputHelper.Display.Output[6][2]);
            player.MaxRagePoints = 25;
            player.RagePoints    = player.MaxRagePoints;
            monster.MaxHitPoints = 100;
            monster.HitPoints    = monster.MaxHitPoints;
            player.UseAbility(monster, input);
            Assert.AreEqual(player.MaxRagePoints - rageCost, player.RagePoints);
            Assert.AreEqual(attackString, OutputHelper.Display.Output[7][2]);
            const string outOfRageString = "You didn't have enough rage points for the second attack!";

            Assert.AreEqual(outOfRageString, OutputHelper.Display.Output[8][2]);
        }
Exemplo n.º 11
0
    private void Awake()
    {
#if Game
        _instance    = this;
        mGameManager = GameManager.Instance;
        //测试代码:currentStage = new Stage(1, 1,new int[]{ 1,2,3,4,5},5,0,10,true,false,false);
        currentStage     = mGameManager.currentStage;
        normalModelPanel = mGameManager.uiManager.mUIFacade.currentScenePanelDict[StringManager.NormalModelPanel] as NormalModelPanel;
        normalModelPanel.EnterPanel();
        mapMaker = GetComponent <MapMaker>();
        mapMaker.InitMapMaker();
        mapMaker.LoadMap(currentStage.mBigLevelID, currentStage.mLevelID);
        //为什么要这样写呢?因为可以在进来的时候把资源都加载一次放进数组里面,以后直接拿就好了,不要每次都问工厂要,加载要时间
        controllers = new RuntimeAnimatorController[12];

        //mapMaker.LoadMap(2, 1);
        //成员变量赋值
        coin           = 1000;
        gameSpeed      = 1;
        monsterBuilder = new MonsterBuilder();
        towerBuilder   = new TowerBuilder();
        //建塔列表的处理
        for (int i = 0; i < currentStage.mTowerIDList.Length; i++)
        {
            GameObject itemGo = GameManager.Instance.GetGameObjectResource(FactoryType.UIFactory, "Btn_TowerBuild");
            itemGo.GetComponent <ButtonTower>().towerID = currentStage.mTowerIDList[i];//把关卡可以建造的箭塔ID赋值过来
            itemGo.transform.localPosition = transform.position;
            itemGo.transform.SetParent(towerListGo.transform);
            itemGo.transform.localScale = Vector3.one;
        }
        //箭塔价格标
        towerPriceDict = new Dictionary <int, int>
        {
            { 1, 100 },
            { 2, 120 },
            { 3, 140 },
            { 4, 160 },
            { 5, 160 }
        };
        //monsterBuilder.m_monsterID = 1;
        for (int i = 0; i < controllers.Length; i++)
        {
            controllers[i] = GetRuntimeAnimatorController("Monster/" + mapMaker.bigLevelID.ToString() + "/" + (i + 1).ToString());
        }

        level = new Level(mapMaker.roundInfoList.Count, mapMaker.roundInfoList);
        normalModelPanel.topPage.UpdateCoinText();
        normalModelPanel.topPage.UpdateRoundCount();
        isPause = true;
        //level.HandleRound();//执行责任链方法,注释掉是因为要在倒计时完毕以后调用这个方法
#endif
    }
Exemplo n.º 12
0
    [HideInInspector] public int gameSpeed; // 游戏速度(一倍速,二倍速)

    private void Awake()
    {
#if Game
        // 一些引用的赋值
        Instance         = this;
        mGameManager     = GameManager.Instance;
        currentStage     = mGameManager.CurrentStage;
        normalModelPanel = mGameManager.UIManager.mUIFacade.currentScenePanelDict[StringManager.P_NormalModelPanel] as NormalModelPanel;
        mapMaker         = GetComponent <MapMaker>();
        mapMaker.InitMapMaker();
        mapMaker.Loadmap(currentStage.bigLevelID, currentStage.levelID);                  // 加载地图
        level          = new Level(mapMaker.roundInfoList.Count, mapMaker.roundInfoList); // 获取加载完地图中怪物波次的信息
        monsterBuilder = new MonsterBuilder();
        towerBuilder   = new TowerBuilder();

        // 玩家属性的赋值
        gameSpeed = 1;
        Coin      = 500;
        isPause   = true;
        gameOver  = false;

        normalModelPanel.EnterPanel();

        // RuntimeAnimatorController资源的赋值
        controllers = new RuntimeAnimatorController[12];
        for (int i = 0; i < controllers.Length; i++)
        {
            controllers[i] = GetRuntimeAnimator("Monster/" + currentStage.bigLevelID.ToString() + "/" + (i + 1));
        }

        // 建塔列表的赋值
        for (int i = 0; i < currentStage.towerIDList.Length; i++)
        {
            GameObject item = mGameManager.GetItem(FactoryType.UI, "Btn_TowerBuilder");
            item.GetComponent <ButtonTower>().towerID = currentStage.towerIDList[i];
            item.transform.SetParent(towerListCanvas.transform);
            item.transform.localPosition = Vector3.zero;
            item.transform.localScale    = Vector3.one;
        }

        // 建塔列表的价格赋值
        towerPriceList = new Dictionary <int, int>()
        {
            { 1, 100 },
            { 2, 120 },
            { 3, 160 },
            { 4, 160 },
            { 5, 160 },
        };
#endif
    }
Exemplo n.º 13
0
    public GameObject handleTowerCanvasGo;       //处理塔升级与买卖的画布



    private void Awake()
    {
#if Game
        _instance    = this;
        mGameManager = GameManager.Instance;
        //测试代码
        //currentStage = new Stage(10,5,new int[] { 1,2,3,4,5},false,0,1,1,true,false);
        currentStage     = mGameManager.currentStage;
        normalModelpanel = mGameManager.uiManager.mUIFacade.currentScenePanelDict[StringManager.NormalModelPanel] as NormalModelPanel;
        normalModelpanel.EnterPanel();
        mapMaker = GetComponent <MapMaker>();
        mapMaker.InitMapMaker();
        mapMaker.LoadMap(currentStage.mBigLevelID, currentStage.mLevelID);
        //成员变量赋值
        gameSpeed = 1;
        coin      = 1000;

        monsterBuilder = new MonsterBuilder();
        towerBuilder   = new TowerBuilder();
        //建塔列表的处理
        for (int i = 0; i < currentStage.mTowerIDList.Length; i++)
        {
            GameObject itemGo = mGameManager.GetGameObjectResource(FactoryType.UIFactory, "Btn_TowerBuild");
            itemGo.transform.GetComponent <ButtonTower>().towerID = currentStage.mTowerIDList[i];
            itemGo.transform.SetParent(towerListGo.transform);
            itemGo.transform.localPosition = Vector3.zero;
            itemGo.transform.localScale    = Vector3.one;
        }
        //建塔价格表
        towerPriceDict = new Dictionary <int, int>
        {
            { 1, 100 },
            { 2, 120 },
            { 3, 140 },
            { 4, 160 },
            { 5, 160 }
        };

        controllers = new RuntimeAnimatorController[12];
        for (int i = 0; i < controllers.Length; i++)
        {
            controllers[i] = GetRuntimeAnimatorController("Monster/" + mapMaker.bigLevelID.ToString() + "/" + (i + 1).ToString());
        }
        level = new Level(mapMaker.roundInfoList.Count, mapMaker.roundInfoList);
        normalModelpanel.topPage.UpdateCoinText();
        normalModelpanel.topPage.UpdateRoundText();
        //level.HandleRound();
        isPause = true;
#endif
    }
Exemplo n.º 14
0
        public void PreciseShotAbilityUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Archer)
            {
                MaxComboPoints = 100,
                ComboPoints    = 100,
                MaxHitPoints   = 100,
                HitPoints      = 10
            };

            GearHelper.EquipInitialGear(player);
            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Demon)
            {
                HitPoints = 100, MaxHitPoints = 100
            };

            MonsterBuilder.BuildMonster(monster);
            foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            string[] inputInfo    = new[] { "ability", "precise" };
            int      abilityIndex = player.Abilities.FindIndex(
                f => f.ArcAbilityCategory == ArcherAbility.Precise);

            PlayerHelper.AbilityInfo(player, inputInfo);
            Assert.AreEqual("Precise Shot", OutputHelper.Display.Output[0][2]);
            Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]);
            Assert.AreEqual("Combo Cost: 40", OutputHelper.Display.Output[2][2]);
            Assert.AreEqual("Instant Damage: 50", OutputHelper.Display.Output[3][2]);
            string[] input       = new[] { "use", "precise" };
            string   abilityName = InputHelper.ParseInput(input);

            Assert.AreEqual("precise", abilityName);
            int arrowCount = player.PlayerQuiver.Quantity;

            player.UseAbility(monster, input);
            Assert.AreEqual(arrowCount - 1, player.PlayerQuiver.Quantity);
            int?comboCost = player.Abilities[abilityIndex].ComboCost;

            Assert.AreEqual(player.MaxComboPoints - comboCost, player.ComboPoints);
            int abilityDamage = player.Abilities[abilityIndex].Offensive.Amount;

            Assert.AreEqual(monster.HitPoints, monster.MaxHitPoints - abilityDamage);
            string abilitySuccessString = $"Your {player.Abilities[abilityIndex].Name} hit the {monster.Name} for {abilityDamage} physical damage.";

            Assert.AreEqual(abilitySuccessString, OutputHelper.Display.Output[4][2]);
        }
Exemplo n.º 15
0
        public void DisarmAbilityUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Warrior)
            {
                MaxRagePoints = 100,
                RagePoints    = 100,
                MaxHitPoints  = 100,
                HitPoints     = 100
            };

            GearHelper.EquipInitialGear(player);
            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Demon)
            {
                HitPoints = 100, MaxHitPoints = 100
            };

            MonsterBuilder.BuildMonster(monster);
            int abilityIndex = player.Abilities.FindIndex(
                f => f.WarAbilityCategory == WarriorAbility.Disarm);

            string[] inputInfo = new[] { "ability", "disarm" };
            PlayerHelper.AbilityInfo(player, inputInfo);
            Assert.AreEqual("Disarm", OutputHelper.Display.Output[0][2]);
            Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]);
            Assert.AreEqual("Rage Cost: 25", OutputHelper.Display.Output[2][2]);
            string abilityString = $"{player.Abilities[abilityIndex].Offensive.Amount}% chance to disarm opponent's weapon.";

            Assert.AreEqual(abilityString, OutputHelper.Display.Output[3][2]);
            player.Abilities[abilityIndex].Offensive.Amount = 0;             // Set disarm success chance to 0% for test
            string[] input       = new[] { "use", "disarm" };
            string   abilityName = InputHelper.ParseInput(input);

            Assert.AreEqual("disarm", abilityName);
            player.UseAbility(monster, input);
            int?rageCost = player.Abilities[abilityIndex].RageCost;

            Assert.AreEqual(player.MaxRagePoints - rageCost, player.RagePoints);
            Assert.AreEqual(true, monster.MonsterWeapon.Equipped);
            string disarmFailString = $"You tried to disarm {monster.Name} but failed!";

            Assert.AreEqual(disarmFailString, OutputHelper.Display.Output[4][2]);
            player.Abilities[abilityIndex].Offensive.Amount = 100;             // Set disarm success chance to 100% for test
            player.UseAbility(monster, input);
            Assert.AreEqual(player.MaxRagePoints - (rageCost * 2), player.RagePoints);
            Assert.AreEqual(false, monster.MonsterWeapon.Equipped);
            string disarmSuccessString = $"You successfully disarmed {monster.Name}!";

            Assert.AreEqual(disarmSuccessString, OutputHelper.Display.Output[5][2]);
        }
Exemplo n.º 16
0
        public void ValueUnitTests()
        {
            // Test RoundNumber method in Helper class
            Assert.AreEqual(110, GameHelper.RoundNumber(107));
            Assert.AreEqual(110, GameHelper.RoundNumber(105));
            Assert.AreEqual(100, GameHelper.RoundNumber(104));

            /* Test _Monster constructor HP and exp smoothing
             * if values smoothed correctly, % should be 0 */
            Monster monster = new Monster(1, MonsterType.Skeleton);

            MonsterBuilder.BuildMonster(monster);
            Assert.AreEqual(0, monster.MaxHitPoints % 10);
            Assert.AreEqual(0, monster.ExperienceProvided % 10);
        }
Exemplo n.º 17
0
        public void DetermineAttackUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Mage)
            {
                HitPoints = 100, MaxHitPoints = 100
            };
            Monster monster = new Monster(3, MonsterType.Dragon);

            MonsterBuilder.BuildMonster(monster);
            OutputHelper.Display.ClearUserOutput();
            AttackOption attackChoice = monster.DetermineAttack(player, false);

            Assert.AreEqual(AttackType.Spell, attackChoice.AttackCategory);
            monster.EnergyPoints = 0;
            attackChoice         = monster.DetermineAttack(player, false);
            Assert.AreEqual(AttackType.Physical, attackChoice.AttackCategory);
        }
Exemplo n.º 18
0
        public void AmbushAbilityUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Archer)
            {
                MaxComboPoints = 100,
                ComboPoints    = 100,
                MaxHitPoints   = 100,
                HitPoints      = 10
            };

            GearHelper.EquipInitialGear(player);
            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Demon)
            {
                HitPoints = 100, MaxHitPoints = 100
            };

            MonsterBuilder.BuildMonster(monster);
            player.Abilities.Add(new PlayerAbility(
                                     "ambush", 75, 1, ArcherAbility.Ambush, 4));
            string[] inputInfo = new[] { "ability", "ambush" };
            PlayerHelper.AbilityInfo(player, inputInfo);
            Assert.AreEqual("Ambush", OutputHelper.Display.Output[0][2]);
            Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]);
            Assert.AreEqual("Combo Cost: 75", OutputHelper.Display.Output[2][2]);
            Assert.AreEqual("Instant Damage: 50", OutputHelper.Display.Output[3][2]);
            Assert.AreEqual("A surprise attack is launched, which initiates combat.",
                            OutputHelper.Display.Output[4][2]);
            string[] input = new[] { "use", "ambush", monster.Name };
            player.InCombat = true;
            int arrowCount = player.PlayerQuiver.Quantity;

            player.UseAbility(monster, input);
            Assert.AreEqual($"You can't ambush {monster.Name}, you're already in combat!",
                            OutputHelper.Display.Output[5][2]);
            player.InCombat = false;
            player.UseAbility(monster, input);
            int index = player.Abilities.FindIndex(
                f => f.ArcAbilityCategory == ArcherAbility.Ambush);
            int    abilityDamage = player.Abilities[index].Offensive.Amount;
            string attackString  = "Your ambush hit the " + monster.Name + " for " + abilityDamage + " physical damage.";

            Assert.AreEqual(arrowCount - 1, player.PlayerQuiver.Quantity);
            Assert.AreEqual(attackString, OutputHelper.Display.Output[6][2]);
            Assert.AreEqual(monster.HitPoints, monster.MaxHitPoints - abilityDamage);
        }
Exemplo n.º 19
0
        public void LightningSpellUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Mage)
            {
                MaxManaPoints = 100, ManaPoints = 100
            };

            GearHelper.EquipInitialGear(player);
            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Demon)
            {
                HitPoints = 100, MaxHitPoints = 100, ArcaneResistance = 0
            };

            MonsterBuilder.BuildMonster(monster);
            foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            string[] inputInfo  = new[] { "spell", "lightning" };
            int      spellIndex = player.Spellbook.FindIndex(
                f => f.SpellCategory == SpellType.Lightning);

            PlayerHelper.SpellInfo(player, inputInfo);
            Assert.AreEqual("Lightning", OutputHelper.Display.Output[0][2]);
            Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]);
            Assert.AreEqual("Mana Cost: 25", OutputHelper.Display.Output[2][2]);
            Assert.AreEqual("Instant Damage: 35", OutputHelper.Display.Output[3][2]);
            string[] input     = new[] { "cast", "lightning" };
            string   spellName = InputHelper.ParseInput(input);

            Assert.AreEqual("lightning", spellName);
            player.PlayerWeapon.Durability = 100;
            player.CastSpell(monster, spellName);
            Assert.AreEqual(player.MaxManaPoints - player.Spellbook[spellIndex].ManaCost, player.ManaPoints);
            int arcaneSpellDamage = player.Spellbook[spellIndex].Offensive.Amount;

            Assert.AreEqual(monster.HitPoints, monster.MaxHitPoints - arcaneSpellDamage);
            string attackSuccessString = $"You hit the {monster.Name} for {arcaneSpellDamage} arcane damage.";

            Assert.AreEqual(attackSuccessString, OutputHelper.Display.Output[4][2]);
        }
Exemplo n.º 20
0
        public void SlashAbilityUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Warrior)
            {
                MaxRagePoints = 100, RagePoints = 100
            };

            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Demon)
            {
                HitPoints = 100, MaxHitPoints = 100
            };

            MonsterBuilder.BuildMonster(monster);
            foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            string[] inputInfo    = new[] { "ability", "slash" };
            int      abilityIndex = player.Abilities.FindIndex(
                f => f.WarAbilityCategory == WarriorAbility.Slash);

            PlayerHelper.AbilityInfo(player, inputInfo);
            Assert.AreEqual("Slash", OutputHelper.Display.Output[0][2]);
            Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]);
            Assert.AreEqual("Rage Cost: 40", OutputHelper.Display.Output[2][2]);
            Assert.AreEqual("Instant Damage: 50", OutputHelper.Display.Output[3][2]);
            string[] input       = new[] { "use", "slash" };
            string   abilityName = InputHelper.ParseInput(input);

            Assert.AreEqual("slash", abilityName);
            player.UseAbility(monster, input);
            Assert.AreEqual(player.MaxRagePoints - player.Abilities[abilityIndex].RageCost,
                            player.RagePoints);
            int abilityDamage = player.Abilities[abilityIndex].Offensive.Amount;

            Assert.AreEqual(monster.HitPoints, monster.MaxHitPoints - abilityDamage);
            string abilitySuccessString = $"Your {player.Abilities[abilityIndex].Name} hit the {monster.Name} for {abilityDamage} physical damage.";

            Assert.AreEqual(abilitySuccessString, OutputHelper.Display.Output[4][2]);
        }
Exemplo n.º 21
0
        public void BloodLeechAbilityUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Mage)
            {
                HitPoints = 100, MaxHitPoints = 100
            };

            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Vampire)
            {
                HitPoints = 10, MaxHitPoints = 100
            };

            MonsterBuilder.BuildMonster(monster);
            int abilityIndex = monster.Abilities.FindIndex(
                f => f.AbilityCategory == Ability.BloodLeech);

            foreach (IItem item in player.Inventory.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            int monsterHealthBase = monster.HitPoints;

            monster.Abilities[abilityIndex].UseBloodLeechAbility(monster, player, abilityIndex);
            int abilityCost = monster.Abilities[abilityIndex].EnergyCost;

            Assert.AreEqual(monster.MaxEnergyPoints - abilityCost, monster.EnergyPoints);
            int leechAmount = monster.Abilities[abilityIndex].Offensive.Amount;

            Assert.AreEqual(player.MaxHitPoints - leechAmount, player.HitPoints);
            Assert.AreEqual(monsterHealthBase + leechAmount, monster.HitPoints);
            string attackString = $"The {monster.Name} tries to sink its fangs into you and suck your blood!";

            Assert.AreEqual(attackString, OutputHelper.Display.Output[0][2]);
            string attackSuccessString = $"The {monster.Name} leeches {leechAmount} life from you.";

            Assert.AreEqual(attackSuccessString, OutputHelper.Display.Output[1][2]);
        }
Exemplo n.º 22
0
    public GameObject handleTowerCanvasGo;            // 处理塔升级与买卖的画布

    private void Awake()
    {
#if Game
        _instance    = this;
        mGameManager = GameManager.Instance;
        currentStage = mGameManager.currentStage;
        // mUIFacade = mGameManager.uiManager.mUIFacade; //因为测试注销
        // normalModelPanel = mUIFacade.currentScenePanels[StringManager.NormalModelPanel] as NormalModelPanel; //因为测试注销
        mapMaker = transform.GetComponent <MapMaker>();
        // 初始化地图
        mapMaker.InitMapMaker();
        // mapMaker.LoadMap(currentStage.mBigLevelID,currentStage.mLevelID); //因为测试注销
        GetMonsterAnimator();         // 获得需要的动画控制器
        // 属性赋值
        gameSpeed      = 1;
        monsterBuilder = new MonsterBuilder();
        // test
        mapMaker.LoadMap(1, 1);
        level = new Level(mapMaker.roundInfoList.Count, mapMaker.roundInfoList);
        level.HandleRound();
        // test
#endif
    }
Exemplo n.º 23
0
        public void LightningSpellUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Mage)
            {
                HitPoints = 200, MaxHitPoints = 200, ArcaneResistance = 0
            };

            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Elemental);

            while (monster.ElementalCategory != ElementalType.Air)
            {
                monster = new Monster(3, MonsterType.Elemental);
            }
            MonsterBuilder.BuildMonster(monster);
            int spellIndex = monster.Spellbook.FindIndex(
                f => f.SpellCategory == SpellType.Lightning);

            foreach (IItem item in player.Inventory.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            monster.Spellbook[spellIndex].CastArcaneOffense(monster, player, spellIndex);
            int spellCost = monster.Spellbook[spellIndex].EnergyCost;

            Assert.AreEqual(monster.MaxEnergyPoints - spellCost, monster.EnergyPoints);
            int spellDamage = monster.Spellbook[spellIndex].Offensive.Amount;

            Assert.AreEqual(player.MaxHitPoints - spellDamage, player.HitPoints);
            string attackString = $"The {monster.Name} casts a bolt of lightning at you!";

            Assert.AreEqual(attackString, OutputHelper.Display.Output[0][2]);
            string attackSuccessString = $"The {monster.Name} hits you for {spellDamage} arcane damage.";

            Assert.AreEqual(attackSuccessString, OutputHelper.Display.Output[1][2]);
        }
Exemplo n.º 24
0
        public void MonsterResistanceUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Mage)
            {
                MaxManaPoints = 100, ManaPoints = 100
            };

            GearHelper.EquipInitialGear(player);
            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Demon)
            {
                HitPoints = 100, MaxHitPoints = 100
            };

            MonsterBuilder.BuildMonster(monster);
            foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            Assert.AreEqual(monster.Level * 5, monster.FireResistance);
            Assert.AreEqual(monster.Level * 5, monster.FrostResistance);
            Assert.AreEqual(monster.Level * 5, monster.ArcaneResistance);
            int    arcaneResistance = monster.ArcaneResistance;
            double resistanceMod    = (100 - arcaneResistance) / 100.0;

            string[] input      = new[] { "cast", "lightning" };
            int      spellIndex = player.Spellbook.FindIndex(
                f => f.SpellCategory == SpellType.Lightning);
            string spellName = InputHelper.ParseInput(input);

            player.CastSpell(monster, spellName);
            int reducedDamage = (int)(player.Spellbook[spellIndex].Offensive.Amount * resistanceMod);

            Assert.AreEqual(monster.HitPoints, monster.MaxHitPoints - reducedDamage);
        }
Exemplo n.º 25
0
        public void BerserkAbilityUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Warrior)
            {
                MaxRagePoints = 100,
                RagePoints    = 100,
                InCombat      = true,
                MaxHitPoints  = 100,
                HitPoints     = 100,
                DodgeChance   = 0
            };

            GearHelper.EquipInitialGear(player);
            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Demon)
            {
                HitPoints = 100, MaxHitPoints = 100, InCombat = true
            };

            MonsterBuilder.BuildMonster(monster);
            foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            int abilityIndex = player.Abilities.FindIndex(
                f => f.WarAbilityCategory == WarriorAbility.Berserk);

            string[] inputInfo = new[] { "ability", "berserk" };
            PlayerHelper.AbilityInfo(player, inputInfo);
            Assert.AreEqual("Berserk", OutputHelper.Display.Output[0][2]);
            Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]);
            Assert.AreEqual("Rage Cost: 40", OutputHelper.Display.Output[2][2]);
            string dmgIncreaseString = $"Damage Increase: {player.Abilities[abilityIndex].Offensive.Amount}";

            Assert.AreEqual(dmgIncreaseString, OutputHelper.Display.Output[3][2]);
            string armDecreaseString = $"Armor Decrease: {player.Abilities[abilityIndex].ChangeAmount.Amount}";

            Assert.AreEqual(armDecreaseString, OutputHelper.Display.Output[4][2]);
            string dmgInfoString = $"Damage increased at cost of armor decrease for {player.Abilities[abilityIndex].ChangeAmount.ChangeMaxRound} rounds";

            Assert.AreEqual(dmgInfoString, OutputHelper.Display.Output[5][2]);
            string[] input       = new[] { "use", "berserk" };
            string   abilityName = InputHelper.ParseInput(input);

            Assert.AreEqual("berserk", abilityName);
            int baseArmorRating = GearHelper.CheckArmorRating(player);
            int baseDamage      = player.PhysicalAttack(monster);

            player.UseAbility(monster, input);
            int?rageCost = player.Abilities[abilityIndex].RageCost;

            Assert.AreEqual(player.MaxRagePoints - rageCost, player.RagePoints);
            Assert.AreEqual(2, player.Effects.Count);
            Assert.AreEqual(true, player.Effects[0] is ChangePlayerDamageEffect);
            Assert.AreEqual(true, player.Effects[1] is ChangeArmorEffect);
            ChangePlayerDamageEffect changePlayerDmgEffect = player.Effects[0] as ChangePlayerDamageEffect;
            ChangeArmorEffect        changeArmorEffect     = player.Effects[1] as ChangeArmorEffect;
            const string             berserkString         = "You go into a berserk rage!";

            Assert.AreEqual(berserkString, OutputHelper.Display.Output[6][2]);
            for (int i = 2; i < 6; i++)
            {
                OutputHelper.Display.ClearUserOutput();
                int berserkArmorAmount  = player.Abilities[abilityIndex].ChangeAmount.Amount;
                int berserkDamageAmount = player.Abilities[abilityIndex].Offensive.Amount;
                int berserkArmorRating  = GearHelper.CheckArmorRating(player);
                int berserkDamage       = player.PhysicalAttack(monster);
                Assert.AreEqual(berserkArmorRating, baseArmorRating + berserkArmorAmount);
                Assert.AreEqual(berserkDamage, baseDamage + berserkDamageAmount, 5);
                changePlayerDmgEffect.ProcessChangePlayerDamageRound(player);
                string changeDmgString = $"Your damage is increased by {berserkDamageAmount}.";
                Assert.AreEqual(changeDmgString, OutputHelper.Display.Output[0][2]);
                changeArmorEffect.ProcessChangeArmorRound();
                string changeArmorString = $"Your armor is decreased by {berserkArmorAmount * -1}.";
                Assert.AreEqual(changeArmorString, OutputHelper.Display.Output[1][2]);
                GameHelper.RemovedExpiredEffectsAsync(player);
                Thread.Sleep(1000);
            }
            Assert.AreEqual(false, player.Effects.Any());
        }
Exemplo n.º 26
0
        public void WeaponUnitTests()
        {
            // Test weapon creation values
            // Test case 1, weapon on level 1 skeleton based on possible weapon types
            // _Name check
            Monster skeletonLevelOne = new Monster(1, MonsterType.Skeleton);

            MonsterBuilder.BuildMonster(skeletonLevelOne);
            Weapon skeletonWeapon = skeletonLevelOne.MonsterWeapon;

            switch (skeletonWeapon.Quality)
            {
            case 1:
                switch (skeletonWeapon.WeaponGroup)
                {
                case WeaponType.Dagger:
                    Assert.AreEqual("chipped dagger", skeletonWeapon.Name);
                    break;

                case WeaponType.OneHandedSword:
                    Assert.AreEqual("chipped sword (1H)", skeletonWeapon.Name);
                    break;

                case WeaponType.TwoHandedSword:
                    Assert.AreEqual("chipped sword (2H)", skeletonWeapon.Name);
                    break;

                case WeaponType.Axe:
                case WeaponType.Bow:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;

            case 2:
                switch (skeletonWeapon.WeaponGroup)
                {
                case WeaponType.Dagger:
                    Assert.AreEqual("chipped sturdy dagger", skeletonWeapon.Name);
                    break;

                case WeaponType.OneHandedSword:
                    Assert.AreEqual("chipped sturdy sword (1H)", skeletonWeapon.Name);
                    break;

                case WeaponType.TwoHandedSword:
                    Assert.AreEqual("chipped sturdy sword (2H)", skeletonWeapon.Name);
                    break;

                case WeaponType.Axe:
                case WeaponType.Bow:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;

            case 3:
                switch (skeletonWeapon.WeaponGroup)
                {
                case WeaponType.Dagger:
                    Assert.AreEqual("chipped fine dagger", skeletonWeapon.Name);
                    break;

                case WeaponType.OneHandedSword:
                    Assert.AreEqual("chipped fine sword (1H)", skeletonWeapon.Name);
                    break;

                case WeaponType.TwoHandedSword:
                    Assert.AreEqual("chipped fine sword (2H)", skeletonWeapon.Name);
                    break;

                case WeaponType.Axe:
                case WeaponType.Bow:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;
            }
            // Test case 2, weapon on level 1 spider based on possible weapon types
            // _Name check
            Monster spiderLevelOne = new Monster(1, MonsterType.Spider);

            MonsterBuilder.BuildMonster(spiderLevelOne);
            Weapon spiderWeapon = spiderLevelOne.MonsterWeapon;

            switch (spiderWeapon.Quality)
            {
            case 1:
                switch (spiderWeapon.WeaponGroup)
                {
                case WeaponType.Dagger:
                    Assert.AreEqual("venomous fang", spiderWeapon.Name);
                    break;

                case WeaponType.OneHandedSword:
                case WeaponType.TwoHandedSword:
                case WeaponType.Axe:
                case WeaponType.Bow:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;

            case 2:
                switch (spiderWeapon.WeaponGroup)
                {
                case WeaponType.Dagger:
                    Assert.AreEqual("sturdy venomous fang", spiderWeapon.Name);
                    break;

                case WeaponType.OneHandedSword:
                case WeaponType.TwoHandedSword:
                case WeaponType.Axe:
                case WeaponType.Bow:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;

            case 3:
                switch (spiderWeapon.WeaponGroup)
                {
                case WeaponType.Dagger:
                    Assert.AreEqual("fine venomous fang", spiderWeapon.Name);
                    break;

                case WeaponType.OneHandedSword:
                case WeaponType.TwoHandedSword:
                case WeaponType.Axe:
                case WeaponType.Bow:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;
            }
            // Test case 3, weapon on level 3 zombie based on possible weapon types
            // _Name check
            Monster zombieLevelThree = new Monster(3, MonsterType.Zombie);

            MonsterBuilder.BuildMonster(zombieLevelThree);
            Weapon zombieWeapon = zombieLevelThree.MonsterWeapon;

            switch (zombieWeapon.Quality)
            {
            case 1:
                switch (zombieWeapon.WeaponGroup)
                {
                case WeaponType.Dagger:
                case WeaponType.OneHandedSword:
                case WeaponType.TwoHandedSword:
                case WeaponType.Bow:
                    break;

                case WeaponType.Axe:
                    Assert.AreEqual("worn axe", zombieWeapon.Name);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;

            case 2:
                switch (zombieWeapon.WeaponGroup)
                {
                case WeaponType.Dagger:
                case WeaponType.OneHandedSword:
                case WeaponType.TwoHandedSword:
                case WeaponType.Bow:
                    break;

                case WeaponType.Axe:
                    Assert.AreEqual("worn sturdy axe", zombieWeapon.Name);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;

            case 3:
                switch (zombieWeapon.WeaponGroup)
                {
                case WeaponType.Dagger:
                case WeaponType.OneHandedSword:
                case WeaponType.TwoHandedSword:
                case WeaponType.Bow:
                    break;

                case WeaponType.Axe:
                    Assert.AreEqual("worn fine axe", zombieWeapon.Name);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;
            }
            // Test case 3, weapon on level 3 zombie based on possible weapon types
            // _Name check
            Monster demonLevelTwo = new Monster(2, MonsterType.Demon);

            MonsterBuilder.BuildMonster(demonLevelTwo);
            Weapon demonWeapon = demonLevelTwo.MonsterWeapon;

            switch (demonWeapon.Quality)
            {
            case 1:
                switch (demonWeapon.WeaponGroup)
                {
                case WeaponType.Dagger:
                case WeaponType.Bow:
                    break;

                case WeaponType.OneHandedSword:
                    Assert.AreEqual("dull sword (1H)", demonWeapon.Name);
                    break;

                case WeaponType.TwoHandedSword:
                    Assert.AreEqual("dull sword (2H)", demonWeapon.Name);
                    break;

                case WeaponType.Axe:
                    Assert.AreEqual("dull axe", demonWeapon.Name);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;

            case 2:
                switch (demonWeapon.WeaponGroup)
                {
                case WeaponType.Dagger:
                case WeaponType.Bow:
                    break;

                case WeaponType.OneHandedSword:
                    Assert.AreEqual("dull sturdy sword (1H)", demonWeapon.Name);
                    break;

                case WeaponType.TwoHandedSword:
                    Assert.AreEqual("dull sturdy sword (2H)", demonWeapon.Name);
                    break;

                case WeaponType.Axe:
                    Assert.AreEqual("dull sturdy axe", demonWeapon.Name);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;

            case 3:
                switch (demonWeapon.WeaponGroup)
                {
                case WeaponType.Dagger:
                case WeaponType.Bow:
                    break;

                case WeaponType.OneHandedSword:
                    Assert.AreEqual("dull fine sword (1H)", demonWeapon.Name);
                    break;

                case WeaponType.TwoHandedSword:
                    Assert.AreEqual("dull fine sword (2H)", demonWeapon.Name);
                    break;

                case WeaponType.Axe:
                    Assert.AreEqual("dull fine axe", demonWeapon.Name);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;
            }
        }
Exemplo n.º 27
0
 //Print each part to picturbox
 public void printMonster(List<PictureBox> printBoxes, MonsterBuilder monster)
 {
     printBoxes[0].ImageLocation = monster.headpicture();
     printBoxes[1].ImageLocation = monster.bodyPictur();
     printBoxes[2].ImageLocation = monster.legPicture();
 }
Exemplo n.º 28
0
        public override void CreateEntities(Mogwai mogwai, Shift shift)
        {
            mogwai.Reset();
            mogwai.AdventureEntityId = NextId;
            Entities.Add(mogwai.AdventureEntityId, mogwai);

            var adjCr = GetChallengeRating();

            //var monsterSet = Monsters.Instance.AllBuilders()
            //    .Where(p => (p.EnvironmentTypes.Contains(EnvironmentType.Any)
            //              || p.EnvironmentTypes.Contains(EnvironmentType.Undergrounds))
            //                && p.ChallengeRating <= adjCr).ToList();

            // TODO work here again and replace it with a real algorithm or make it dungeon dependend.
            var monsterSet = new List <MonsterBuilder>()
            {
                IceCave.BunnyRat,
                IceCave.BearWarrior,
                IceCave.CrystalGuardian,
                IceCave.GoblinFrost,
                IceCave.GoblinMage,
                IceCave.GoblinTorch,
                IceCave.GoblinVenom,
                IceCave.ThreeTailedWolf,
                IceCave.SnowMonster
            };

            var totXpAmount = 500 * Math.Pow(adjCr, 2);

            var allMonsters = new List <MonsterBuilder>();

            for (var i = 0; i < 100 && totXpAmount > 0; i++)
            {
                MonsterBuilder mob = monsterSet[DungeonRandom.Next(monsterSet.Count)];
                allMonsters.Add(mob);
                totXpAmount -= mob.Experience;
            }

            // make sure there are at least 7 mobs in the dungeon
            if (allMonsters.Count < 7)
            {
                var subMonsterSet = monsterSet.Where(p => p.ChallengeRating <= 0.5).ToList();
                if (subMonsterSet.Count > 0)
                {
                    for (var i = 0; i < 10; i++)
                    {
                        MonsterBuilder mob = subMonsterSet[DungeonRandom.Next(subMonsterSet.Count)];
                        allMonsters.Add(mob);
                    }
                }
            }

            var maxCr           = allMonsters.Max(p => p.ChallengeRating);
            var potentialBosses = allMonsters.Where(p => p.ChallengeRating == maxCr).ToList();

            Monster boss = potentialBosses[DungeonRandom.Next(potentialBosses.Count)].Build();

            boss.AdventureEntityId = NextId;
            boss.Initialize(new Dice(shift, 1));
            Entities.Add(boss.AdventureEntityId, boss);
            BossKeys.Add(boss.AdventureEntityId);

            var monsterMod = 100;

            foreach (MonsterBuilder monsterBuilder in allMonsters)
            {
                Monster mob = monsterBuilder.Build();
                mob.AdventureEntityId = NextId;
                mob.Initialize(new Dice(shift, monsterMod++));
                Entities.Add(mob.AdventureEntityId, mob);
            }

            // exploration order
            _explorationOrder = EntitiesList.OrderBy(p => p.Intelligence).ThenBy(p => p.SizeType).ToList();
        }
Exemplo n.º 29
0
        public void FrostboltSpellUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Mage)
            {
                MaxManaPoints = 100, ManaPoints = 100
            };

            GearHelper.EquipInitialGear(player);
            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Demon)
            {
                HitPoints = 100, MaxHitPoints = 100, FrostResistance = 0
            };

            MonsterBuilder.BuildMonster(monster);
            foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            string[] inputInfo  = new[] { "spell", "frostbolt" };
            int      spellIndex = player.Spellbook.FindIndex(
                f => f.SpellCategory == SpellType.Frostbolt);

            PlayerHelper.SpellInfo(player, inputInfo);
            Assert.AreEqual("Frostbolt", OutputHelper.Display.Output[0][2]);
            Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]);
            Assert.AreEqual("Mana Cost: 25", OutputHelper.Display.Output[2][2]);
            Assert.AreEqual("Instant Damage: 15", OutputHelper.Display.Output[3][2]);
            Assert.AreEqual("Frost damage will freeze opponent for 2 rounds.",
                            OutputHelper.Display.Output[4][2]);
            Assert.AreEqual("Frozen opponents take 1.5x physical, arcane and frost damage.",
                            OutputHelper.Display.Output[5][2]);
            OutputHelper.Display.ClearUserOutput();
            string[] input     = new[] { "cast", "frostbolt" };
            string   spellName = InputHelper.ParseInput(input);

            Assert.AreEqual("frostbolt", spellName);
            player.PlayerWeapon.Durability = 100;
            double baseDamage = player.PhysicalAttack(monster);

            player.CastSpell(monster, spellName);
            Assert.AreEqual(player.MaxManaPoints - player.Spellbook[spellIndex].ManaCost, player.ManaPoints);
            Assert.AreEqual(85, monster.HitPoints);
            Assert.AreEqual(1, monster.Effects[0].CurrentRound);
            Assert.AreEqual(2, monster.Effects[0].MaxRound);
            string attackString = $"You hit the {monster.Name} for {player.Spellbook[spellIndex].Offensive.Amount} frost damage.";

            Assert.AreEqual(attackString, OutputHelper.Display.Output[0][2]);
            string frozenString = $"The {monster.Name} is frozen. Physical, frost and arcane damage to it will be increased by 50%!";

            Assert.AreEqual(frozenString, OutputHelper.Display.Output[1][2]);
            FrozenEffect frozenEffect           = monster.Effects[0] as FrozenEffect;
            int          monsterHitPointsBefore = monster.HitPoints;
            double       totalBaseDamage        = 0.0;
            double       totalFrozenDamage      = 0.0;
            double       multiplier             = frozenEffect.EffectMultiplier;

            for (int i = 2; i < 4; i++)
            {
                frozenEffect.ProcessRound();
                Assert.AreEqual(i, monster.Effects[0].CurrentRound);
                Assert.AreEqual(frozenString, OutputHelper.Display.Output[i][2]);
                player.PlayerWeapon.Durability = 100;
                double frozenDamage = player.PhysicalAttack(monster);
                monster.HitPoints -= (int)frozenDamage;
                totalBaseDamage   += baseDamage;
                totalFrozenDamage += frozenDamage;
            }
            GameHelper.RemovedExpiredEffectsAsync(monster);
            Thread.Sleep(1000);
            Assert.AreEqual(false, monster.Effects.Any());
            int finalBaseDamageWithMod = (int)(totalBaseDamage * multiplier);
            int finalTotalFrozenDamage = (int)totalFrozenDamage;

            Assert.AreEqual(finalTotalFrozenDamage, finalBaseDamageWithMod, 14);
            Assert.AreEqual(monster.HitPoints, monsterHitPointsBefore - (int)totalFrozenDamage);
        }
Exemplo n.º 30
0
        public void ReflectDamageSpellUnitTest()
        {
            OutputHelper.Display.ClearUserOutput();
            Player player = new Player("test", PlayerClassType.Mage)
            {
                MaxManaPoints = 100, ManaPoints = 100
            };
            Monster monster = new Monster(3, MonsterType.Zombie)
            {
                HitPoints = 100, MaxHitPoints = 100
            };

            MonsterBuilder.BuildMonster(monster);
            foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            player.Spellbook.Add(new PlayerSpell(
                                     "reflect", 100, 1, SpellType.Reflect, 4));
            string[] inputInfo  = new[] { "spell", "reflect" };
            int      spellIndex = player.Spellbook.FindIndex(
                f => f.SpellCategory == SpellType.Reflect);

            PlayerHelper.SpellInfo(player, inputInfo);
            Assert.AreEqual("Reflect", OutputHelper.Display.Output[0][2]);
            Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]);
            Assert.AreEqual("Mana Cost: 100", OutputHelper.Display.Output[2][2]);
            Assert.AreEqual("Reflect Damage Amount: 25", OutputHelper.Display.Output[3][2]);
            string reflectInfoString = $"Damage up to {player.Spellbook[spellIndex].ChangeAmount.Amount} will be reflected for " +
                                       $"{player.Spellbook[spellIndex].ChangeAmount.ChangeMaxRound} rounds.";

            Assert.AreEqual(reflectInfoString, OutputHelper.Display.Output[4][2]);
            string[] input     = new[] { "cast", "reflect" };
            string   spellName = InputHelper.ParseInput(input);

            Assert.AreEqual("reflect", spellName);
            player.CastSpell(spellName);
            Assert.AreEqual(player.MaxManaPoints - player.Spellbook[spellIndex].ManaCost, player.ManaPoints);
            Assert.AreEqual("You create a shield around you that will reflect damage.",
                            OutputHelper.Display.Output[5][2]);
            Assert.AreEqual(true, player.Effects.Any());
            Assert.AreEqual(true, player.Effects[0] is ReflectDamageEffect);
            ReflectDamageEffect reflectDmgEffect = player.Effects[0] as ReflectDamageEffect;

            OutputHelper.Display.ClearUserOutput();
            for (int i = 2; i < 5; i++)
            {
                int attackDamageM = monster.MonsterWeapon.Attack();
                int reflectAmount = reflectDmgEffect.ReflectDamageAmount < attackDamageM ?
                                    reflectDmgEffect.ReflectDamageAmount : attackDamageM;
                Assert.AreEqual(true, reflectAmount <= reflectDmgEffect.ReflectDamageAmount);
                monster.HitPoints -= reflectAmount;
                Assert.AreEqual(monster.HitPoints, monster.MaxHitPoints - (reflectAmount * (i - 1)));
                reflectDmgEffect.ProcessChangeDamageRound(reflectAmount);
                Assert.AreEqual(
                    $"You reflected {reflectAmount} damage back at your opponent!",
                    OutputHelper.Display.Output[i - 2][2]);
            }
            GameHelper.RemovedExpiredEffectsAsync(player);
            Thread.Sleep(1000);
            Assert.AreEqual(false, player.Effects.Any());
        }
Exemplo n.º 31
0
        public void BlockAbilityUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Warrior)
            {
                MaxRagePoints = 100,
                RagePoints    = 100,
                InCombat      = true,
                MaxHitPoints  = 100,
                HitPoints     = 100,
                DodgeChance   = 0,
                Level         = 3
            };

            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Zombie)
            {
                HitPoints = 100, MaxHitPoints = 100, InCombat = true
            };

            MonsterBuilder.BuildMonster(monster);
            monster.MonsterWeapon.CritMultiplier = 1;
            int abilityIndex = player.Abilities.FindIndex(
                f => f.WarAbilityCategory == WarriorAbility.Block);

            string[] inputInfo = new[] { "ability", "block" };
            PlayerHelper.AbilityInfo(player, inputInfo);
            Assert.AreEqual("Block", OutputHelper.Display.Output[0][2]);
            Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]);
            Assert.AreEqual("Rage Cost: 25", OutputHelper.Display.Output[2][2]);
            Assert.AreEqual("Block Damage: 50", OutputHelper.Display.Output[3][2]);
            const string blockInfoString =
                "Block damage will prevent incoming damage from opponent until block damage is used up.";

            Assert.AreEqual(blockInfoString, OutputHelper.Display.Output[4][2]);
            string[] input       = new[] { "use", "block" };
            string   abilityName = InputHelper.ParseInput(input);

            Assert.AreEqual("block", abilityName);
            player.UseAbility(monster, input);
            int?rageCost = player.Abilities[abilityIndex].RageCost;

            Assert.AreEqual(player.MaxRagePoints - rageCost, player.RagePoints);
            int    blockAmount = player.Abilities[abilityIndex].Defensive.BlockDamage;
            string blockString = $"You start blocking your opponent's attacks! You will block {blockAmount} damage.";

            Assert.AreEqual(blockString, OutputHelper.Display.Output[5][2]);
            OutputHelper.Display.ClearUserOutput();
            Assert.AreEqual(true, player.Effects[0] is BlockDamageEffect);
            Assert.AreEqual(player.MaxHitPoints, player.HitPoints);
            BlockDamageEffect blockDmgEffect = player.Effects[0] as BlockDamageEffect;
            int blockAmountRemaining         = blockDmgEffect.BlockAmount;

            Assert.AreEqual(blockAmount, blockAmountRemaining);
            int i = 0;

            while (blockAmountRemaining > 0)
            {
                monster.MonsterWeapon.Durability = 100;
                int blockAmountBefore = blockAmountRemaining;
                monster.Attack(player);
                blockAmountRemaining = player.Effects.Any() ? blockDmgEffect.BlockAmount : 0;
                if (blockAmountRemaining > 0)
                {
                    Assert.AreEqual(player.MaxHitPoints, player.HitPoints);
                    string blockRoundString = $"Your defensive move blocked {(blockAmountBefore - blockAmountRemaining)} damage!";
                    Assert.AreEqual(blockRoundString, OutputHelper.Display.Output[i + (i * 1)][2]);
                }
                else
                {
                    GameHelper.RemovedExpiredEffectsAsync(player);
                    int attackAmount = monster.MonsterWeapon.Attack() - blockAmountBefore;
                    Assert.AreEqual(player.MaxHitPoints - attackAmount, player.HitPoints);
                    const string blockEndString = "You are no longer blocking damage!";
                    Assert.AreEqual(blockEndString, OutputHelper.Display.Output[i + 3][2]);
                    Thread.Sleep(1000);
                    Assert.AreEqual(false, player.Effects.Any());
                    string hitString = $"The {monster.Name} hits you for {attackAmount} physical damage.";
                    Assert.AreEqual(hitString, OutputHelper.Display.Output[i + 4][2]);
                }
                i++;
            }
        }
Exemplo n.º 32
0
        public void RendAbilityUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Warrior)
            {
                MaxRagePoints = 100, RagePoints = 100
            };

            OutputHelper.Display.ClearUserOutput();
            Monster monster = new Monster(3, MonsterType.Demon)
            {
                HitPoints = 100, MaxHitPoints = 100
            };

            MonsterBuilder.BuildMonster(monster);
            foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped))
            {
                IEquipment eItem = item as IEquipment;
                eItem.Equipped = false;
            }
            int abilityIndex = player.Abilities.FindIndex(
                f => f.WarAbilityCategory == WarriorAbility.Rend);

            string[] inputInfo = new[] { "ability", "rend" };
            PlayerHelper.AbilityInfo(player, inputInfo);
            Assert.AreEqual("Rend", OutputHelper.Display.Output[0][2]);
            Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]);
            Assert.AreEqual("Rage Cost: 25", OutputHelper.Display.Output[2][2]);
            Assert.AreEqual("Instant Damage: 15", OutputHelper.Display.Output[3][2]);
            Assert.AreEqual("Damage Over Time: 5", OutputHelper.Display.Output[4][2]);
            string bleedOverTimeString = $"Bleeding damage over time for {player.Abilities[abilityIndex].Offensive.AmountMaxRounds} rounds.";

            Assert.AreEqual(bleedOverTimeString, OutputHelper.Display.Output[5][2]);
            string[] input       = new[] { "use", "rend" };
            string   abilityName = InputHelper.ParseInput(input);

            Assert.AreEqual("rend", abilityName);
            player.UseAbility(monster, input);
            int?rageCost = player.Abilities[abilityIndex].RageCost;

            Assert.AreEqual(player.MaxRagePoints - rageCost, player.RagePoints);
            int    abilityDamage         = player.Abilities[abilityIndex].Offensive.Amount;
            int    abilityDamageOverTime = player.Abilities[abilityIndex].Offensive.AmountOverTime;
            int    abilityCurRounds      = player.Abilities[abilityIndex].Offensive.AmountCurRounds;
            int    abilityMaxRounds      = player.Abilities[abilityIndex].Offensive.AmountMaxRounds;
            string abilitySuccessString  = $"Your {player.Abilities[abilityIndex].Name} hit the {monster.Name} for {abilityDamage} physical damage.";

            Assert.AreEqual(abilitySuccessString, OutputHelper.Display.Output[6][2]);
            string bleedString = $"The {monster.Name} is bleeding!";

            Assert.AreEqual(bleedString, OutputHelper.Display.Output[7][2]);
            Assert.AreEqual(true, monster.Effects[0] is BleedingEffect);
            Assert.AreEqual(monster.MaxHitPoints - abilityDamage, monster.HitPoints);
            Assert.AreEqual(abilityCurRounds, monster.Effects[0].CurrentRound);
            Assert.AreEqual(abilityMaxRounds, monster.Effects[0].MaxRound);
            BleedingEffect bleedEffect = monster.Effects[0] as BleedingEffect;

            OutputHelper.Display.ClearUserOutput();
            for (int i = 2; i < 5; i++)
            {
                bleedEffect.ProcessRound();
                int    bleedAmount      = bleedEffect.BleedDamageOverTime;
                string bleedRoundString = $"The {monster.Name} bleeds for {bleedAmount} physical damage.";
                Assert.AreEqual(bleedRoundString, OutputHelper.Display.Output[i - 2][2]);
                Assert.AreEqual(i, monster.Effects[0].CurrentRound);
                GameHelper.RemovedExpiredEffectsAsync(monster);
                Thread.Sleep(1000);
            }
            Assert.AreEqual(false, monster.Effects.Any());
            Assert.AreEqual(monster.MaxHitPoints - abilityDamage - (abilityDamageOverTime * abilityMaxRounds),
                            monster.HitPoints);
        }