Ejemplo n.º 1
0
        public void HealOneTimeModTest()
        {
            Setup.SetupTestInfrastructure();
            ActiveGame activeGame = GameContainer.ActiveGame;

            try
            {
                AmountModifier   healthMod   = new AmountModifier("Healing Field", "Increase next healing by 1", ModifierTargets.Local, AmountModifierType.Health, 1, true);
                CharacterAccount fromAccount = activeGame.AllTargets[43];
                CharacterAccount toAccount   = activeGame.AllTargets[87];
                GameContainer.AddHealthModifier(healthMod, toAccount);

                GameContainer.DealDamage(fromAccount, toAccount, 4, DamageType.Melee);

                GameContainer.HealCharacter(toAccount, toAccount, 1);

                int expectedHealth = 13;
                int actualhealth   = toAccount.CurrentHealth;
                Assert.IsTrue(expectedHealth == actualhealth, $"{toAccount.Name} health doesn't match expected health. Expected {expectedHealth}, actually {actualhealth}");

                int expectedMod = 0;
                int actualMod   = toAccount.HealthMod;
                Assert.IsTrue(expectedMod == actualMod, $"{toAccount.Name} health mod doesn't match expected mod. Expected {expectedMod}, actually {actualMod}");
            }
            catch (Exception e)
            {
                Assert.Fail("Test failed: " + e);
            }
        }
Ejemplo n.º 2
0
        public void ImmunityTypeSpecificModTest()
        {
            Setup.SetupTestInfrastructure();
            ActiveGame activeGame = GameContainer.ActiveGame;

            try
            {
                ImmunityModifier immunityMod = new ImmunityModifier("Flesh of the Sun God", "Ra is Immune to Fire Damage", ModifierTargets.Local, DamageType.Fire);
                CharacterAccount fromAccount = activeGame.AllTargets[43];
                CharacterAccount toAccount   = activeGame.AllTargets[87];
                GameContainer.AddDamageImmunityModifier(immunityMod, toAccount);

                GameContainer.DealDamage(fromAccount, toAccount, 4, DamageType.Melee);

                int expectedHealth = 11;
                int actualhealth   = toAccount.CurrentHealth;
                Assert.IsTrue(expectedHealth == actualhealth, $"{toAccount.Name} health doesn't match expected health for Melee test. Expected {expectedHealth}, actually {actualhealth}");

                GameContainer.DealDamage(fromAccount, toAccount, 4, DamageType.Fire);

                expectedHealth = 11;
                actualhealth   = toAccount.CurrentHealth;
                Assert.IsTrue(expectedHealth == actualhealth, $"{toAccount.Name} health doesn't match expected health for Fire test. Expected {expectedHealth}, actually {actualhealth}");
            }
            catch (Exception e)
            {
                Assert.Fail("Test failed: " + e);
            }
        }
Ejemplo n.º 3
0
        private void NewGame()
        {
            HeroTargets        = new ObservableCollection <CharacterAccount>();
            NonHeroTargets     = new ObservableCollection <CharacterAccount>();
            AllTargets         = new ObservableCollection <CharacterAccount>();
            VillainTargets     = new ObservableCollection <CharacterAccount>();
            EnvironmentTargets = new ObservableCollection <CharacterAccount>();


            AddBaseIndicesToAllTargets();

            GameContainer.SetupGame();
            SelectCharacters sc = new SelectCharacters(this);

            sc.ShowDialog();
            lbHeroTargets.ItemsSource           = HeroTargets;
            lbNonHeroTargets.ItemsSource        = NonHeroTargets;
            cbDamageAllTargetList.ItemsSource   = AllTargets;
            cbDamageTypeList.ItemsSource        = Enum.GetValues(typeof(DamageType));
            cbDamageAllTargetList.SelectedIndex = 0;
            cbHealAllTargetList.ItemsSource     = AllTargets;
            cbHealAllTargetList.SelectedIndex   = 0;
            cbDamageTypeList.SelectedIndex      = 1;
            tbDmgAmount.Text            = "0";
            tbHealAmount.Text           = "0";
            lbGlobalModList.ItemsSource = GameContainer.ActiveGame.GlobalAllModifiers;

            if (HeroTargets.Count > 0)
            {
                lbHeroTargets.SelectedIndex = 0;
                selectedCharacter           = (CharacterAccount)lbHeroTargets.SelectedItem;
                UpdateSelection();
            }
        }
Ejemplo n.º 4
0
        private void DealDamage(int amount, CharacterAccount to)
        {
            CharacterAccount from    = selectedCharacter;
            DamageType       dmgType = (DamageType)cbDamageTypeList.SelectedItem;

            GameContainer.DealDamage(from, to, amount, dmgType);
        }
Ejemplo n.º 5
0
        public void DamageGivenOneTimeModTest()
        {
            Setup.SetupTestInfrastructure();
            ActiveGame activeGame = GameContainer.ActiveGame;

            try
            {
                AmountModifier   damageGivenMod = new AmountModifier("Critical Multiplier", "Increase next damage by 1", ModifierTargets.Local, AmountModifierType.DamageGiven, 1, true);
                CharacterAccount fromAccount    = activeGame.AllTargets[43];
                CharacterAccount toAccount      = activeGame.AllTargets[87];
                GameContainer.AddDamageGivenModifier(damageGivenMod, fromAccount);

                GameContainer.DealDamage(fromAccount, toAccount, 4, DamageType.Melee);

                int expectedHealth = 10;
                int actualhealth   = toAccount.CurrentHealth;
                Assert.IsTrue(expectedHealth == actualhealth, $"{toAccount.Name} health doesn't match expected health. Expected {expectedHealth}, actually {actualhealth}");

                int expectedMod = 0;
                int actualMod   = fromAccount.DamageGivenMod;
                Assert.IsTrue(expectedMod == actualMod, $"{fromAccount.Name} damage given mod doesn't match expected mod. Expected {expectedMod}, actually {actualMod}");
            }
            catch (Exception e)
            {
                Assert.Fail("Test failed: " + e);
            }
        }
Ejemplo n.º 6
0
        public void HealGlobalVillainTargetsModTest()
        {
            Setup.SetupTestInfrastructure();
            ActiveGame activeGame = GameContainer.ActiveGame;

            try
            {
                AmountModifier   healthModifier = new AmountModifier("Obsidion Field", "Increase all damage by 1", ModifierTargets.VillainTargets, AmountModifierType.DamageGiven, 1, false);
                CharacterAccount fromAccount    = activeGame.AllTargets[43];
                CharacterAccount toAccount      = activeGame.AllTargets[87];
                GameContainer.AddHealthModifier(healthModifier, fromAccount);


                Assert.IsTrue(!activeGame.GlobalEnvironmentModifiers.ContainsValue(healthModifier), "Global Environment Mods List incorrectly contains expected modifier");
                Assert.IsTrue(!activeGame.GlobalHeroModifers.ContainsValue(healthModifier), "Global Environment Mods List incorrectly contains expected modifier");
                Assert.IsTrue(activeGame.GlobalVillainModifiers.ContainsValue(healthModifier), "Global Environment Mods List does not contain expected modifier");

                foreach (CharacterAccount characterAccount in activeGame.VillainTargets)
                {
                    Assert.IsTrue(characterAccount.HealingModList.ContainsValue(healthModifier), $"{characterAccount} does not contain the expected modifier");
                }
            }
            catch (Exception e)
            {
                Assert.Fail("Test failed: " + e);
            }
        }
Ejemplo n.º 7
0
        public void DamageImmunityGlobalEnvironmentTargetsModTest()
        {
            Setup.SetupTestInfrastructure();
            ActiveGame activeGame = GameContainer.ActiveGame;

            try
            {
                ImmunityModifier DamageImmunityMod = new ImmunityModifier("Obsidion Field", "Increase all damage by 1", ModifierTargets.EnvironmentTargets, DamageType.All);
                CharacterAccount fromAccount       = activeGame.AllTargets[43];
                CharacterAccount toAccount         = activeGame.AllTargets[87];
                GameContainer.AddDamageImmunityModifier(DamageImmunityMod, fromAccount);


                Assert.IsTrue(activeGame.GlobalEnvironmentModifiers.ContainsValue(DamageImmunityMod), "Global Environment Mods List does not contain expected modifier");
                Assert.IsTrue(!activeGame.GlobalHeroModifers.ContainsValue(DamageImmunityMod), "Global Environment Mods List incorrectly contains expected modifier");
                Assert.IsTrue(!activeGame.GlobalVillainModifiers.ContainsValue(DamageImmunityMod), "Global Environment Mods List incorrectly contains expected modifier");

                foreach (CharacterAccount characterAccount in activeGame.EnvCharacters)
                {
                    Assert.IsTrue(characterAccount.ImmunityModList.ContainsValue(DamageImmunityMod), $"{characterAccount} does not contain the expected modifier");
                }
            }
            catch (Exception e)
            {
                Assert.Fail("Test failed: " + e);
            }
        }
Ejemplo n.º 8
0
        public void DamageTakenModTest()
        {
            Setup.SetupTestInfrastructure();
            ActiveGame activeGame = GameContainer.ActiveGame;

            try
            {
                AmountModifier   damageTakenMod = new AmountModifier("HeavyPlating", "Decrease damage taken by 1", ModifierTargets.Local, AmountModifierType.DamageTaken, -1, false);
                CharacterAccount fromAccount    = activeGame.AllTargets[43];
                CharacterAccount toAccount      = activeGame.AllTargets[87];
                GameContainer.AddDamageTakenModifier(damageTakenMod, toAccount);

                GameContainer.DealDamage(fromAccount, toAccount, 4, DamageType.Melee);

                int expectedHealth = 12;
                int actualhealth   = toAccount.CurrentHealth;
                Assert.IsTrue(expectedHealth == actualhealth, $"{toAccount.Name} health doesn't match expected health. Expected {expectedHealth}, actually {actualhealth}");

                int expectedMod = -1;
                int actualMod   = toAccount.DamageTakenMod;
                Assert.IsTrue(expectedMod == actualMod, $"{toAccount.Name} damage taken mod doesn't match expected mod. Expected {expectedMod}, actually {actualMod}");
            }
            catch (Exception e)
            {
                Assert.Fail("Test failed: " + e);
            }
        }
Ejemplo n.º 9
0
        public void DamageGivenGlobalAllTargetsModTest()
        {
            Setup.SetupTestInfrastructure();
            ActiveGame activeGame = GameContainer.ActiveGame;

            try
            {
                AmountModifier   damageGivenMod = new AmountModifier("Obsidion Field", "Increase all damage by 1", ModifierTargets.AllTargets, AmountModifierType.DamageGiven, 1, false);
                CharacterAccount fromAccount    = activeGame.AllTargets[43];
                CharacterAccount toAccount      = activeGame.AllTargets[87];
                GameContainer.AddDamageGivenModifier(damageGivenMod, fromAccount);

                GameContainer.DealDamage(fromAccount, toAccount, 4, DamageType.Melee);

                int expectedHealth = 10;
                int actualhealth   = toAccount.CurrentHealth;
                Assert.IsTrue(expectedHealth == actualhealth, $"{toAccount.Name} health doesn't match expected health. Expected {expectedHealth}, actually {actualhealth}");

                int expectedMod = 1;
                int actualMod   = fromAccount.DamageGivenMod;
                Assert.IsTrue(expectedMod == actualMod, $"{fromAccount.Name} damage given mod doesn't match expected mod. Expected {expectedMod}, actually {actualMod}");
                Assert.IsTrue(activeGame.GlobalEnvironmentModifiers.ContainsValue(damageGivenMod), "Global Environment Mods List does not contain expected modifier");
                Assert.IsTrue(activeGame.GlobalHeroModifers.ContainsValue(damageGivenMod), "Global Environment Mods List does not contain expected modifier");
                Assert.IsTrue(activeGame.GlobalVillainModifiers.ContainsValue(damageGivenMod), "Global Environment Mods List does not contain expected modifier");

                foreach (CharacterAccount characterAccount in activeGame.AllTargets.Values)
                {
                    Assert.IsTrue(characterAccount.DamageGivenModList.ContainsValue(damageGivenMod), $"{characterAccount} does not contain the expected modifier");
                }
            }
            catch (Exception e)
            {
                Assert.Fail("Test failed: " + e);
            }
        }
Ejemplo n.º 10
0
 private void LbHeroAccounts_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!reloading)
     {
         selectedCharacter = (CharacterAccount)lbHeroTargets.SelectedItem;
         UpdateSelection();
     }
 }
Ejemplo n.º 11
0
 private void LbHeroAccounts_OnFocus(object sender, RoutedEventArgs e)
 {
     if (!reloading)
     {
         if (lbHeroTargets.SelectedIndex == -1)
         {
             lbHeroTargets.SelectedIndex = 0;
         }
         selectedCharacter = (CharacterAccount)lbHeroTargets.SelectedItem;
         UpdateSelection();
     }
 }
Ejemplo n.º 12
0
        public void HeroTargetGetsDestroyed()
        {
            Setup.SetupTestInfrastructure();
            ActiveGame activeGame = GameContainer.ActiveGame;

            try
            {
                CharacterAccount heroTarget = activeGame.AllTargets[88];
                GameContainer.DealDamage(activeGame.AllTargets[55], heroTarget, 4, DamageType.Fire);
                Assert.IsTrue(!activeGame.HeroTargets.Contains(heroTarget), "Raptor Bot is incorrectly still a member of the HeroTargetsList");
                Assert.IsTrue(!activeGame.AllTargets.ContainsKey(heroTarget.UniqueId), "Raptor Bot is incorrectly still a member of the dictionary AllTargets");
            }
            catch (Exception e)
            {
                Assert.Fail("Test failed: " + e);
            }
        }
Ejemplo n.º 13
0
        public void EnvironmentTargetGetsDestroyed()
        {
            Setup.SetupTestInfrastructure();
            ActiveGame activeGame = GameContainer.ActiveGame;

            try
            {
                CharacterAccount environmentTarget = activeGame.AllTargets[87];
                GameContainer.DealDamage(activeGame.AllTargets[55], environmentTarget, 17, DamageType.Fire);
                Assert.IsTrue(!activeGame.EnvCharacters.Contains(environmentTarget), "Enraged T-Rex is incorrectly still a member of the EnvironmentTargetList");
                Assert.IsTrue(!activeGame.NonHeroTargets.Contains(environmentTarget), "Enraged T-Rex is incorrectly still a member of the NonHeroTargetsList");
                Assert.IsTrue(!activeGame.AllTargets.ContainsKey(environmentTarget.UniqueId), "Enraged T-Rex is incorrectly still a member of the dictionary AllTargets");
            }
            catch (Exception e)
            {
                Assert.Fail("Test failed: " + e);
            }
        }
Ejemplo n.º 14
0
        public void VillainTargetGetsDestroyed()
        {
            Setup.SetupTestInfrastructure();
            ActiveGame activeGame = GameContainer.ActiveGame;

            try
            {
                CharacterAccount villainTarget = activeGame.AllTargets[86];
                GameContainer.DealDamage(activeGame.AllTargets[55], villainTarget, 52, DamageType.Fire);
                Assert.IsTrue(!activeGame.VillainTargets.Contains(villainTarget), "Baron Blade is incorrectly still a member of the VillainTargetList");
                Assert.IsTrue(!activeGame.NonHeroTargets.Contains(villainTarget), "Baron Blade is incorrectly still a member of the NonHeroTargetsList");
                Assert.IsTrue(!activeGame.AllTargets.ContainsKey(villainTarget.UniqueId), "Baron Blade is incorrectly still a member of the dictionary AllTargets");
            }
            catch (Exception e)
            {
                Assert.Fail("Test failed: " + e);
            }
        }
Ejemplo n.º 15
0
        private void Submit_ButtonClick(object sender, RoutedEventArgs e)
        {
            bool isNumeric = int.TryParse(tbHealthField.Text, out int health);

            if (String.IsNullOrWhiteSpace(tbNameField.Text) || String.IsNullOrWhiteSpace(tbHealthField.Text) || !isNumeric)
            {
                tb_SubmitErrorMessage.Text = "Please make sure that all entered values are valid";
            }
            else
            {
                string           name       = tbNameField.Text;
                DamageType       type       = (DamageType)cbTypeList_window.SelectedItem;
                int              heroId     = GameContainer.AddHeroTarget(name, health, type);
                CharacterAccount heroTarget = GameContainer.ActiveGame.AllTargets[heroId];
                MainWindow.AllTargets.Add(heroTarget);
                MainWindow.HeroTargets.Add(heroTarget);
                this.Close();
            }
        }
Ejemplo n.º 16
0
        public void HeroPlayerGetsDestroyed()
        {
            Setup.SetupTestInfrastructure();
            ActiveGame activeGame = GameContainer.ActiveGame;

            try
            {
                CharacterAccount heroTarget = activeGame.AllTargets[43];
                GameContainer.DealDamage(activeGame.AllTargets[55], heroTarget, 33, DamageType.Fire);
                Assert.IsTrue(!activeGame.HeroTargets.Contains(heroTarget), "Legacy is incorrectly still a member of the HeroTargetsList");
                Assert.IsTrue(activeGame.HeroPlayers.Contains(heroTarget), "Legacy is incorrectly not a member of the HeroPlayersList");
                Assert.IsTrue(!activeGame.AllTargets.ContainsKey(heroTarget.UniqueId), "Legacy is incorrectly still a member of the dictionary AllTargets");
                Assert.IsTrue(((HeroPlayer)heroTarget).Incapped, "Legacy was not marked as incapped");
            }
            catch (Exception e)
            {
                Assert.Fail("Test failed: " + e);
            }
        }
Ejemplo n.º 17
0
        public void HealGlobalAddNewEnvironmentModTest()
        {
            Setup.SetupTestInfrastructure();
            ActiveGame activeGame = GameContainer.ActiveGame;

            try
            {
                AmountModifier   healthModifier = new AmountModifier("Obsidion Field", "Increase all damage by 1", ModifierTargets.EnvironmentTargets, AmountModifierType.Health, 1, false);
                CharacterAccount fromAccount    = activeGame.AllTargets[43];
                GameContainer.AddHealthModifier(healthModifier, fromAccount);

                EnvironmentTarget environmentTarget = new EnvironmentTarget("Generic Environment", 10, DamageType.Energy);

                Assert.IsTrue(environmentTarget.HealingModList.ContainsValue(healthModifier), "New environment character does not contain the expected modifier");
            }
            catch (Exception e)
            {
                Assert.Fail("Test failed: " + e);
            }
        }
Ejemplo n.º 18
0
        private void DamageSubmit_ButtonClick(object sender, RoutedEventArgs e)
        {
            if (selectedCharacter.Incapped == false)
            {
                bool isNumeric = int.TryParse(tbDmgAmount.Text, out int amount);
                if (String.IsNullOrWhiteSpace(tbDmgAmount.Text) || !isNumeric)
                {
                    tb_SubmitErrorMessageDamage.Text = "Please make sure that all entered values are valid";
                }
                else
                {
                    tb_SubmitErrorMessageDamage.Text = "";
                    switch (cbDamageAllTargetList.SelectedIndex)
                    {
                    case AllTargetsIndex:
                        foreach (CharacterAccount target in NonHeroTargets)
                        {
                            DealDamage(amount, target);
                        }
                        foreach (CharacterAccount target in HeroTargets)
                        {
                            DealDamage(amount, target);
                        }
                        break;

                    case HeroTargetsIndex:
                        foreach (CharacterAccount target in HeroTargets)
                        {
                            DealDamage(amount, target);
                        }
                        break;

                    case NonHeroTargetsIndex:
                        foreach (CharacterAccount target in NonHeroTargets)
                        {
                            DealDamage(amount, target);
                        }
                        break;

                    case EnvironmentTargetsIndex:
                        foreach (CharacterAccount target in EnvironmentTargets)
                        {
                            DealDamage(amount, target);
                        }
                        break;

                    case VillainTargetsIndex:
                        foreach (CharacterAccount target in VillainTargets)
                        {
                            DealDamage(amount, target);
                        }
                        break;

                    default:
                        CharacterAccount to = (CharacterAccount)cbDamageAllTargetList.SelectedItem;
                        DealDamage(amount, to);
                        break;
                    }

                    reloading = true;
                    AllTargets.Clear();
                    AddBaseIndicesToAllTargets();
                    cbDamageAllTargetList.SelectedIndex = 0;
                    cbHealAllTargetList.SelectedIndex   = 0;
                    NonHeroTargets.Clear();
                    HeroTargets.Clear();
                    VillainTargets.Clear();
                    EnvironmentTargets.Clear();

                    foreach (CharacterAccount characterAccount in GameContainer.ActiveGame.HeroPlayers)
                    {
                        HeroTargets.Add(characterAccount);
                    }

                    foreach (CharacterAccount characterAccount in GameContainer.ActiveGame.HeroTargets)
                    {
                        if (!HeroTargets.Contains(characterAccount))
                        {
                            HeroTargets.Add(characterAccount);
                        }
                        AllTargets.Add(characterAccount);
                    }

                    foreach (CharacterAccount characterAccount in GameContainer.ActiveGame.VillainTargets)
                    {
                        AllTargets.Add(characterAccount);
                        NonHeroTargets.Add(characterAccount);
                        VillainTargets.Add(characterAccount);
                    }

                    foreach (CharacterAccount characterAccount in GameContainer.ActiveGame.EnvCharacters)
                    {
                        AllTargets.Add(characterAccount);
                        NonHeroTargets.Add(characterAccount);
                        EnvironmentTargets.Add(characterAccount);
                    }

                    reloading = false;
                }
            }
        }
Ejemplo n.º 19
0
        private void HealSubmit_ButtonClick(object sender, RoutedEventArgs e)
        {
            if (selectedCharacter.Incapped == false)
            {
                bool isNumeric = int.TryParse(tbHealAmount.Text, out int amount);
                if (String.IsNullOrWhiteSpace(tbHealAmount.Text) || !isNumeric)
                {
                    tb_SubmitErrorMessageHeal.Text = "Please make sure that all entered values are valid";
                }
                else
                {
                    tb_SubmitErrorMessageHeal.Text = "";
                    switch (cbHealAllTargetList.SelectedIndex)
                    {
                    case AllTargetsIndex:
                        foreach (CharacterAccount target in NonHeroTargets)
                        {
                            Heal(amount, target);
                        }
                        foreach (CharacterAccount target in HeroTargets)
                        {
                            Heal(amount, target);
                        }
                        break;

                    case HeroTargetsIndex:
                        foreach (CharacterAccount target in HeroTargets)
                        {
                            Heal(amount, target);
                        }
                        break;

                    case NonHeroTargetsIndex:
                        foreach (CharacterAccount target in NonHeroTargets)
                        {
                            Heal(amount, target);
                        }
                        break;

                    case EnvironmentTargetsIndex:
                        foreach (CharacterAccount target in EnvironmentTargets)
                        {
                            Heal(amount, target);
                        }
                        break;

                    case VillainTargetsIndex:
                        foreach (CharacterAccount target in VillainTargets)
                        {
                            Heal(amount, target);
                        }
                        break;

                    default:
                        CharacterAccount to = (CharacterAccount)cbHealAllTargetList.SelectedItem;
                        Heal(amount, to);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 20
0
        private void Heal(int amount, CharacterAccount to)
        {
            CharacterAccount from = selectedCharacter;

            GameContainer.HealCharacter(from, to, amount);
        }