public virtual void SetKit(WeaponKitData data, KitSlot slot)
        {
            for (int i = 0; i < WeaponKit.Count; i++)
            {
                if (kit[i] != null)
                {
                    Drop(WeaponKit.IndexToSlot(i));
                }
            }

            for (int i = 0; i < WeaponKit.Count; i++)
            {
                kit[i] = SpawnWeapon(data.Kit[i]);

                kit[i].Init(This);

                if (i == WeaponKit.SlotToIndex(slot))
                {
                    EquipInternal(slot);
                }
                else
                {
                    kit[i].UnEquip.Apply();
                }
            }
        }
Esempio n. 2
0
        public void WeaponUpgradeKitUnitTest()
        {
            Player player = new Player("test", PlayerClassType.Mage);

            player.Inventory.Add(new WeaponKit(KitLevel.Light, WeaponKit.WeaponKitType.Grindstone));
            GearHelper.EquipInitialGear(player);
            OutputHelper.Display.ClearUserOutput();
            int       weaponIndex = player.Inventory.FindIndex(f => f.Name.Contains("dagger"));
            Weapon    weapon      = player.Inventory[weaponIndex] as Weapon;
            TextInfo  textInfo    = new CultureInfo("en-US", false).TextInfo;
            string    weaponName  = textInfo.ToTitleCase(player.Inventory[weaponIndex].Name);
            WeaponKit weaponKit   = player.Inventory.Find(item => item is WeaponKit) as WeaponKit;
            int       kitAmount   = weaponKit.KitAugmentAmount;
            string    kitName     = weaponKit.Name;

            string[] input        = new[] { "enhance", "doesn't exist", kitName };
            int      weaponAmount = weapon.RegDamage;

            GearHelper.UseWeaponKit(player, input);
            const string upgradeFail = "What weapon did you want to upgrade?";

            Assert.AreEqual(upgradeFail, OutputHelper.Display.Output[0][2]);
            Assert.IsNotEmpty(player.Inventory);
            input = new[] { "enhance", weaponName, "doesn't exist" };
            GearHelper.UseWeaponKit(player, input);
            const string kitFail = "What weapon kit did you want to use?";

            Assert.AreEqual(kitFail, OutputHelper.Display.Output[1][2]);
            Assert.IsNotEmpty(player.Inventory);
            input = new[] { "enhance", weaponName, kitName };
            GearHelper.UseWeaponKit(player, input);
            string upgradeSuccess = $"You upgraded {weaponName} with a weapon kit.";

            Assert.AreEqual(upgradeSuccess, OutputHelper.Display.Output[2][2]);
            Assert.AreEqual(weaponAmount + kitAmount, weapon.RegDamage);
            Assert.AreEqual(0, player.Inventory.FindAll(item => item is IKit).Count);
            player.Inventory.Add(new WeaponKit(KitLevel.Light, WeaponKit.WeaponKitType.Bowstring));
            weaponKit = player.Inventory.Find(item => item is WeaponKit) as WeaponKit;
            kitName   = weaponKit.Name;
            input     = new[] { "enhance", weaponName, kitName };
            GearHelper.UseWeaponKit(player, input);
            string enhanceFail = $"You can't upgrade {weaponName} with that!";

            Assert.IsNotEmpty(player.Inventory);
            Assert.AreEqual(enhanceFail, OutputHelper.Display.Output[3][2]);
            player.Inventory.Add(new Weapon(1, WeaponType.Bow));
            weapon          = player.Inventory.Find(item => item is Weapon && item.Name.ToLower().Contains("bow")) as Weapon;
            weapon.Equipped = true;
            weaponName      = textInfo.ToTitleCase(weapon.Name);
            input           = new[] { "enhance", weaponName, kitName };
            GearHelper.UseWeaponKit(player, input);
            upgradeSuccess = $"You upgraded {weaponName} with a weapon kit.";
            Assert.AreEqual(0, player.Inventory.FindAll(item => item is IKit).Count);
            Assert.AreEqual(upgradeSuccess, OutputHelper.Display.Output[4][2]);
        }
Esempio n. 3
0
        public void BowstringKitAugmentAxeFails()
        {
            OutputHelper.Display.ClearUserOutput();
            _weaponKit = new WeaponKit(KitLevel.Light, WeaponKit.WeaponKitType.Bowstring);
            int    baseWeaponItemValue = _weapon.ItemValue;
            int    baseWeaponDamage    = _weapon.RegDamage;
            string displayMessage      = $"You can't upgrade {_textInfo.ToTitleCase(_weapon.Name)} with that!";

            _weaponKit.AttemptAugmentPlayerWeapon(_weapon);

            Assert.AreEqual(displayMessage, OutputHelper.Display.Output[0][2]);
            Assert.AreEqual(false, _weaponKit.KitHasBeenUsed);
            Assert.AreEqual(baseWeaponItemValue, _weapon.ItemValue);
            Assert.AreEqual(baseWeaponDamage, _weapon.RegDamage);
        }
Esempio n. 4
0
        public void BowstringKitAugmentBowSucceeds()
        {
            OutputHelper.Display.ClearUserOutput();
            _weapon    = new Weapon(3, WeaponType.Bow);
            _weaponKit = new WeaponKit(KitLevel.Light, WeaponKit.WeaponKitType.Bowstring);
            int    baseWeaponItemValue = _weapon.ItemValue;
            int    baseWeaponDamage    = _weapon.RegDamage;
            string displayMessage      = $"You upgraded {_textInfo.ToTitleCase(_weapon.Name)} with a weapon kit.";

            _weaponKit.AttemptAugmentPlayerWeapon(_weapon);

            Assert.AreEqual(displayMessage, OutputHelper.Display.Output[0][2]);
            Assert.AreEqual(true, _weaponKit.KitHasBeenUsed);
            Assert.AreEqual(baseWeaponItemValue + _weaponKit.ItemValue, _weapon.ItemValue);
            Assert.AreEqual(baseWeaponDamage + _weaponKit.KitAugmentAmount, _weapon.RegDamage);
        }
        public virtual void Update()
        {
            int count = WeaponKit.Count;

            if (count > MaxCount)
            {
                count = MaxCount;
            }

            KitSlot slot;

            for (int i = 0; i < count; i++)
            {
                if (Input.GetKeyDown(Keys[i]))
                {
                    slot = WeaponKit.IndexToSlot(i);

                    Controller.Equip(slot);
                }
            }
        }
Esempio n. 6
0
        public static void UseWeaponKit(Player player, string[] userInput)
        {
            int kitIndex = player.Inventory.FindIndex(f => f.Name.Contains(userInput[2]));

            if (kitIndex == -1)
            {
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatFailureOutputText(),
                    Settings.FormatDefaultBackground(),
                    "What weapon kit did you want to use?");
                return;
            }
            int weaponIndex = player.Inventory.FindIndex(f =>
                                                         f.Name.Contains(userInput[1].ToLower()));

            if (weaponIndex == -1)
            {
                OutputHelper.Display.StoreUserOutput(
                    Settings.FormatFailureOutputText(),
                    Settings.FormatDefaultBackground(),
                    "What weapon did you want to upgrade?");
                return;
            }
            Weapon   weapon     = player.Inventory[weaponIndex] as Weapon;
            TextInfo textInfo   = new CultureInfo("en-US", false).TextInfo;
            string   weaponName = textInfo.ToTitleCase(weapon.Name);

            if (!weapon.Equipped)
            {
                bool inputValid = false;
                while (!inputValid)
                {
                    string weaponString = $"{weaponName} is not equipped. Are you sure you want to upgrade that?";
                    OutputHelper.Display.StoreUserOutput(
                        Settings.FormatFailureOutputText(),
                        Settings.FormatDefaultBackground(),
                        weaponString);
                    OutputHelper.Display.RetrieveUserOutput();
                    OutputHelper.Display.ClearUserOutput();
                    string[] input = InputHelper.GetFormattedInput(Console.ReadLine());
                    if (input[0] == "no" || input[0] == "n")
                    {
                        return;
                    }

                    if (input[0] == "yes" || input[0] == "y")
                    {
                        inputValid = true;
                    }
                }
            }

            WeaponKit weaponKit = player.Inventory[kitIndex] as WeaponKit;

            weaponKit.AttemptAugmentPlayerWeapon(weapon);

            if (weaponKit.KitHasBeenUsed)
            {
                player.Inventory.RemoveAt(kitIndex);
            }
        }
Esempio n. 7
0
 public PlayerInfo(WeaponKit weaponKit)
 {
     this.equipment = new Equipment(weaponKit);
     this.inventory = new Inventory();
 }
Esempio n. 8
0
        public void HeavyKitCreationTest()
        {
            _weaponKit = new WeaponKit(KitLevel.Heavy, WeaponKit.WeaponKitType.Bowstring);

            Assert.AreEqual(3, _weaponKit.KitAugmentAmount);
        }
Esempio n. 9
0
        public void MediumKitCreationTest()
        {
            _weaponKit = new WeaponKit(KitLevel.Medium, WeaponKit.WeaponKitType.Bowstring);

            Assert.AreEqual(2, _weaponKit.KitAugmentAmount);
        }
Esempio n. 10
0
 public void Setup()
 {
     _weaponKit = new WeaponKit(KitLevel.Light, WeaponKit.WeaponKitType.Grindstone);
     _weapon    = new Weapon(3, WeaponType.Axe);
 }
Esempio n. 11
0
 public Equipment(WeaponKit weaponKit)
 {
     this.currentWeaponKit = weaponKit;
 }