Exemple #1
0
        public void NotEnoughItemsExchangeEncounterTest()
        {
            Dwarf            gimli   = new Dwarf();
            Elf              legolas = new Elf();
            BasicSword       sword   = new BasicSword();
            StygianBlade     blade   = new StygianBlade();
            HearthSeekingBow bow     = new HearthSeekingBow();

            gimli.AddItem(blade);
            gimli.AddItem(bow);

            List <string> itemList = new List <string>()
            {
                sword.Name, blade.Name, bow.Name
            };
            ExchangeEncounter encounter = new ExchangeEncounter(gimli, legolas, itemList);

            try
            {
                encounter.PlayEncounter();
                Assert.Fail();
            }
            //Si hay una excepción al tratar de intercambiar un item que no se tiene, se pasa al bloque catch y por ende se cumple el test.
            catch
            {
                Assert.Pass();
            }
        }
Exemple #2
0
        public void BattleEncounterWithArmorAndWeaponsTest()
        {
            Scenario scenario = new Scenario();
            Dwarf    gimli    = new Dwarf();
            Orc      orc      = new Orc();

            BasicSword sword = new BasicSword();
            ChainMail  armor = new ChainMail();
            GoldenCoat coat  = new GoldenCoat();

            orc.AddItem(sword);
            orc.AddItem(armor);
            orc.AddItem(coat);

            List <CharacterClass> heroes = new List <CharacterClass>()
            {
                gimli
            };
            List <CharacterClass> villains = new List <CharacterClass>()
            {
                orc
            };

            BattleEncounter battle = new BattleEncounter(heroes, villains);

            List <List <CharacterClass> > everything = battle.PlayEncounter();

            Assert.AreEqual(0, everything[0][0].HealthActual);
        }
    // Constructor to load from save file with levels on weapons
    public WeaponManager(int[] weaponsLevels, int equippedWeapon)
    {
        weaponsAvailable = new Weapon[WeaponManager.WEAPONS_AVAILABLE];

        weaponsAvailable[0] = new BasicSword(weaponsLevels[0]);
        weaponsAvailable[1] = new SwordOfTruth(weaponsLevels[1]);
        weaponsAvailable[2] = new KnightSword(weaponsLevels[2]);
        weaponsAvailable[2] = new WhirlwindAxe(weaponsLevels[3]);
        weaponIndex = equippedWeapon;
        currentWeapon = weaponsAvailable[weaponIndex];
    }
    private int weaponIndex; //the current index of the weapon array

    #endregion Fields

    #region Constructors

    public WeaponManager()
    {
        weaponsAvailable = new Weapon[WeaponManager.WEAPONS_AVAILABLE];

        weaponsAvailable[0] = new BasicSword(1);
        weaponsAvailable[1] = new SwordOfTruth(0);
        weaponsAvailable[2] = new KnightSword(0);
        weaponsAvailable[3] = new WhirlwindAxe(0);
        weaponIndex = 0;
        currentWeapon = weaponsAvailable[weaponIndex];
    }
Exemple #5
0
        public void ExchangeEncounterTest()
        {
            Dwarf      gimli   = new Dwarf();
            Elf        legolas = new Elf();
            BasicSword sword   = new BasicSword();

            gimli.AddItem(sword);

            ExchangeEncounter encounter = new ExchangeEncounter(gimli, legolas, sword.Name);

            Assert.AreEqual(1, encounter.PlayEncounter()[1][0].ItemList.Count);
        }
Exemple #6
0
        public void PuttingAttackItemInTest()
        {
            Dwarf gimli  = new Dwarf();
            Orc   dummy1 = new Orc();

            dummy1.ReceiveDamage(gimli.Attack());

            Orc        dummy2 = new Orc();
            BasicSword sword  = new BasicSword();

            gimli.AddItem(sword);

            dummy2.ReceiveDamage(gimli.Attack());

            Assert.AreEqual(dummy1.HealthActual - dummy2.HealthActual, sword.AttackPower);
        }
Exemple #7
0
        public void RemoveAnItemThatYouDoNotHaveTest()
        {
            Dwarf      gimli = new Dwarf();
            BasicSword sword = new BasicSword();

            try
            {
                gimli.RemoveItem(sword);
                Assert.Fail();
            }
            //Si hay una excepción al tratar de remover un item que no se tiene, se pasa el test.
            catch
            {
                Assert.Pass();
            }
        }
Exemple #8
0
        public void TwoAttackItemsTest()
        {
            Dwarf gimli  = new Dwarf();
            Orc   dummy1 = new Orc();

            dummy1.ReceiveDamage(gimli.Attack());

            Orc          dummy2 = new Orc();
            BasicSword   sword  = new BasicSword();
            StygianBlade sword2 = new StygianBlade();

            gimli.AddItem(sword);
            gimli.AddItem(sword2);

            dummy2.ReceiveDamage(gimli.Attack());

            Assert.AreEqual(dummy1.HealthActual - dummy2.HealthActual, sword.AttackPower + sword2.AttackPower);
        }
Exemple #9
0
        public void NoItemForExchangeEncounterTest()
        {
            Dwarf      gimli   = new Dwarf();
            Elf        legolas = new Elf();
            BasicSword sword   = new BasicSword();

            try
            {
                ExchangeEncounter encounter = new ExchangeEncounter(gimli, legolas, sword.Name);
                encounter.PlayEncounter();
                Assert.Fail();
            }
            //Si hay una excepción al tratar de intercambiar un item que no se tiene, se pasa al bloque catch y por ende se cumple el test.
            catch
            {
                Assert.Pass();
            }
        }
Exemple #10
0
        public void ManyItemsExchangeEncounterTest()
        {
            Dwarf            gimli   = new Dwarf();
            Elf              legolas = new Elf();
            BasicSword       sword   = new BasicSword();
            StygianBlade     blade   = new StygianBlade();
            HearthSeekingBow bow     = new HearthSeekingBow();

            gimli.AddItem(sword);
            gimli.AddItem(blade);
            gimli.AddItem(bow);

            List <string> itemList = new List <string>()
            {
                sword.Name, blade.Name, bow.Name
            };

            ExchangeEncounter encounter = new ExchangeEncounter(gimli, legolas, itemList);

            Assert.AreEqual(3, encounter.PlayEncounter()[1][0].ItemList.Count);
        }
Exemple #11
0
    //method for the drop at the end of the level
    //return the droping weapon or null if the player don't got a weapon
    public static Weapon getWeaponDrop(int level)
    {
        Weapon returnValue = null;
        int randomType = Random.Range(0, 100);
        int randomWeapon = Random.Range(0, 100);

        if (randomType < 5)
        {
            returnValue = new SwordOfTruth(level);
        }
        else if (randomType < 25)
        {
            if (randomWeapon < 50)
                returnValue = new KnightSword(level);
            else
                returnValue = new WhirlwindAxe(level);
        }
        else
        {
            returnValue = new BasicSword(level);
        }

        return returnValue;
    }
Exemple #12
0
 public BasicSword(BasicSword basicSword) : base(basicSword)
 {
 }