Beispiel #1
0
        public void armor_is_created_an_item()
        {
            ItemFactory itemFactory = new ItemFactory();
            Item        item        = itemFactory.CreateArmor();

            Assert.IsNotNull(item);
        }
Beispiel #2
0
        public void On_Add_Item_Inventory_Will_Have_1_Object()
        {
            Inventory   inventory = new Inventory();
            ItemFactory factory   = new ItemFactory();

            inventory.AddItem(factory.CreateArmor());
            Assert.IsTrue(inventory.Items.Count == 1);
        }
Beispiel #3
0
        public void weapon_has_a_description()
        {
            ItemFactory itemFactory = new ItemFactory();

            Item item = itemFactory.CreateArmor();

            Assert.IsTrue(item.description != "");
        }
Beispiel #4
0
        public void armor_price_is_not_negative()
        {
            ItemFactory itemFactory = new ItemFactory();

            Item item = itemFactory.CreateArmor();

            Assert.IsTrue(item.Price >= 0);
        }
Beispiel #5
0
        public void armor_name_is_set()
        {
            ItemFactory itemFactory = new ItemFactory();

            Item item = itemFactory.CreateArmor();

            Assert.AreNotEqual(item.Name, "Default Name");
            Assert.AreNotEqual(item.Name, "");
        }
Beispiel #6
0
        public void Can_SpendMoney_iF_balance_bigger_than_price()
        {
            Inventory inventory = new Inventory();

            inventory.Balance = 100;
            ItemFactory factory = new ItemFactory();
            Item        item    = factory.CreateArmor();

            item.Price = 10;

            Assert.IsTrue(inventory.canBuy(item.Price));
        }
        public override void ButtonBehavior8()
        {
            Session.ReplaceDisplayText("Now giving you armor!");

            Session.CurrentPlayer.AddEquipment(ItemFactory.CreateArmor(1, Arm.ArmFactory(false)));
            Session.CurrentPlayer.AddEquipment(ItemFactory.CreateArmor(1, Arm.ArmFactory(true)));
            Session.CurrentPlayer.AddEquipment(ItemFactory.CreateArmor(1, Leg.LegFactory(false)));
            Session.CurrentPlayer.AddEquipment(ItemFactory.CreateArmor(1, Leg.LegFactory(true)));

            Session.CurrentPlayer.AddEquipment(ItemFactory.CreateArmor(1, Torso.TorsoFactory()));
            Session.CurrentPlayer.AddEquipment(ItemFactory.CreateArmor(1, Head.HeadFactory()));
        }
Beispiel #8
0
        public void Transfer_Item_Beetween_Inventories()
        {
            Inventory   inventory1 = new Inventory();
            Inventory   inventory2 = new Inventory();
            ItemFactory factory    = new ItemFactory();

            Item newItem = factory.CreateArmor();

            inventory1.AddItem(newItem);
            inventory1.TransferItem(newItem, inventory2);


            Assert.IsTrue(inventory2.Items.Count == 1);
            Assert.IsTrue(inventory1.Items.Count == 0);
        }
Beispiel #9
0
 /// <summary>
 /// Initilizes the shop inventory
 /// </summary>
 void GenerateShopProducts()
 {
     for (int i = 0; i < 10; i++)
     {
         shopInventory.AddItem(itemFactory.CreateWeapon());
     }
     for (int i = 0; i < 10; i++)
     {
         shopInventory.AddItem(itemFactory.CreatePotion());
     }
     for (int i = 0; i < 10; i++)
     {
         shopInventory.AddItem(itemFactory.CreateArmor());
     }
 }
        public override void ButtonBehavior8()
        {
            Session.ReplaceDisplayText("Searching around...");
            if (RandomNumberGenerator.NumberBetween(0, 5) > 1)
            {
                Session.AddToDisplayText("\n...you found nothing");
                return;
            }


            Session.ReplaceDisplayText("You found a piece of armor!");

            BaseArmor BA;

            switch (RandomNumberGenerator.NumberBetween(0, 7))
            {
            case 1:
                BA = ItemFactory.CreateArmor(Session.CurrentPlayer.Level, Arm.ArmFactory(false), true);
                break;

            case 2:
                BA = ItemFactory.CreateArmor(Session.CurrentPlayer.Level, Arm.ArmFactory(true), true);
                break;

            case 3:
                BA = ItemFactory.CreateArmor(Session.CurrentPlayer.Level, Leg.LegFactory(false), true);
                break;

            case 4:
                BA = ItemFactory.CreateArmor(Session.CurrentPlayer.Level, Leg.LegFactory(true), true);
                break;

            case 5:
                BA = ItemFactory.CreateArmor(Session.CurrentPlayer.Level, Torso.TorsoFactory(), true);
                break;

            case 6:
                BA = ItemFactory.CreateArmor(Session.CurrentPlayer.Level, Torso.TorsoFactory(), true);
                break;

            default:
                BA = ItemFactory.CreateArmor(Session.CurrentPlayer.Level, Head.HeadFactory(), true);
                break;
            }
            Session.AddToDisplayText("\nYou found:\n" + BA.Name);
            Session.CurrentPlayer.AddEquipment(BA);
        }
Beispiel #11
0
        public void Get_Items_Returns_Only_ItemsOFType()
        {
            Inventory   inventory = new Inventory();
            ItemFactory factory   = new ItemFactory();

            for (int i = 0; i < 10; i++)
            {
                inventory.AddItem(factory.CreateArmor());
            }
            for (int i = 0; i < 15; i++)
            {
                inventory.AddItem(factory.CreatePotion());
            }
            for (int i = 0; i < 17; i++)
            {
                inventory.AddItem(factory.CreateWeapon());
            }

            Assert.IsTrue(inventory.GetItems(ItemsCategory.All).Count == 42);
            Assert.IsTrue(inventory.GetItems(ItemsCategory.Weapon).Count == 17);
            Assert.IsTrue(inventory.GetItems(ItemsCategory.Armor).Count == 10);
            Assert.IsTrue(inventory.GetItems(ItemsCategory.Potion).Count == 15);
        }
    private void PopulateShop()
    {
        // NEW ALGORITHM
        // (Player level / 3 * Random.Range(0,10)) * prev.enemy.stat

        int rand3 = Random.Range(0, 16);

        //GetRandomArmor();
        if (rand3 < 5)
        {
            shopItems[0] = factory.CreateWeapon(spawn1, "Sword");
        }
        else if (rand3 < 9)
        {
            shopItems[0] = factory.CreateWeapon(spawn1, "Hook");
        }
        else if (rand3 < 13)
        {
            shopItems[0] = factory.CreateWeapon(spawn1, "Club");
        }
        else
        {
            shopItems[0] = factory.CreateWeapon(spawn1, "Dagger");
        }
        shopItems[0].transform.parent = spawn1.transform;
        shopItems[0].SetDmgArm(GetRandomDamage(), GetRandomArmor());

        int rand1 = Random.Range(0, 12);

        if (rand1 < 5)
        {
            shopItems[1] = factory.CreateWeapon(spawn2, "Hammer");
        }
        else if (rand1 < 9)
        {
            shopItems[1] = factory.CreateWeapon(spawn2, "Axe");
        }
        else
        {
            shopItems[1] = factory.CreateWeapon(spawn2, "Spear");
        }
        shopItems[1].transform.parent = spawn2.transform;
        shopItems[1].SetDmgArm(GetRandomDamage(), GetRandomArmor());

        int rand2 = Random.Range(0, 10);

        if (rand2 < 4)
        {
            shopItems[2] = factory.CreateArmor(spawn3, "LightArmor");
        }
        else if (rand2 < 7)
        {
            shopItems[2] = factory.CreateArmor(spawn3, "MediumArmor");
        }
        else
        {
            shopItems[2] = factory.CreateArmor(spawn3, "HeavyArmor");
        }
        shopItems[2].transform.parent = spawn3.transform;
        Vector3 tempScale = shopItems[2].transform.localScale;

        tempScale *= 1.2f;
        shopItems[2].transform.localScale = tempScale;
        shopItems[2].SetDmgArm(GetRandomDamage(), GetRandomArmor());
        GameObject newArmourPrefab = Instantiate(armourPrefab, shopItems[2].transform.position, Quaternion.identity) as GameObject;

        newArmourPrefab.transform.parent = shopItems[2].gameObject.transform;

        /*shopItems[3] = factory.CreateArmor(spawn4, "LightArmor");
         * shopItems[3].transform.parent = spawn4.transform;
         * shopItems[3].SetDmgArm(GetRandomDamage(), GetRandomArmor());
         *
         * shopItems[4] = factory.CreateArmor(spawn5, "MediumArmor");
         * shopItems[4].transform.parent = spawn5.transform;
         * shopItems[4].SetDmgArm(GetRandomDamage(), GetRandomArmor());
         *
         * shopItems[5] = factory.CreateArmor(spawn6, "HeavyArmor");
         * shopItems[5].transform.parent = spawn6.transform;
         * shopItems[5].SetDmgArm(GetRandomDamage(), GetRandomArmor());*/
    }