示例#1
0
        public void TestAddToCharactersInventory()
        {
            int initialItemsInInvetory = 0;
            int OneItemInInventory     = 1;

            Dictionary <Dungeons_and_Dragons.Attribute, int> dict = new Dictionary <Dungeons_and_Dragons.Attribute, int>();

            dict.Add(Dungeons_and_Dragons.Attribute.Strength, 12);
            dict.Add(Dungeons_and_Dragons.Attribute.Dexterity, 15);
            dict.Add(Dungeons_and_Dragons.Attribute.Intelligence, 17);
            dict.Add(Dungeons_and_Dragons.Attribute.Wisdom, 7);
            dict.Add(Dungeons_and_Dragons.Attribute.Constitution, 14);
            dict.Add(Dungeons_and_Dragons.Attribute.Charisma, 9);
            int       xp        = 0;
            int       hp        = 2;
            Character character = new MagicUser("Morris", Race.Halfling, dict, hp, xp);

            ShortSword shortSword = new ShortSword();

            Assert.AreEqual(initialItemsInInvetory, character.inventory.Count, "TEST1: The number of items in the character's inventory is not as expected");

            character.AddToCharactersInventory(shortSword);

            Assert.AreEqual(OneItemInInventory, character.inventory.Count, "TEST2: The number of items in the character's inventory is not as expected");
        }
        public void GivenADefaultAndAConditionalBinding_AllBindingsWillResolve()
        {
            var shortSword = new ShortSword();
            var shuriken = new Shuriken();

            kernel.Bind<IWeapon>().ToConstant(shortSword);
            kernel.Bind<IWeapon>().ToConstant(shuriken).When(_ => true);
            var result = kernel.GetAll<IWeapon>();
            result.Should().Contain(shortSword);
            result.Should().Contain(shuriken);
        }
示例#3
0
        static void Main(string[] args)
        {
            PotionString();
            ContainerFun();
            ShortSword mySword = new ShortSword();

            Console.WriteLine(mySword);
            mySword.Description = "New description";
            //mySword.Type = items.ItemType.Armor;
            Console.ReadLine();
        }
        public void GivenOnlyImplicitBindings_AllBindingsWillResolve()
        {
            var shortSword = new ShortSword();
            var shuriken   = new Shuriken();

            kernel.Bind <IWeapon>().ToConstant(shortSword).BindingConfiguration.IsImplicit = true;
            kernel.Bind <IWeapon>().ToConstant(shuriken).BindingConfiguration.IsImplicit   = true;
            var result = kernel.GetAll <IWeapon>();

            result.Should().Contain(shortSword);
            result.Should().Contain(shuriken);
        }
        public void GivenADefaultAndAConditionalBinding_AllBindingsWillResolve()
        {
            var shortSword = new ShortSword();
            var shuriken   = new Shuriken();

            kernel.Bind <IWeapon>().ToConstant(shortSword);
            kernel.Bind <IWeapon>().ToConstant(shuriken).When(_ => true);
            var result = kernel.GetAll <IWeapon>();

            result.Should().Contain(shortSword);
            result.Should().Contain(shuriken);
        }
        public void GivenAMixtureOfBindings_OnlyNonImplicitBindingsWillResolve()
        {
            var shortSword = new ShortSword();
            var sword = new Sword();
            var shuriken = new Shuriken();

            kernel.Bind<IWeapon>().ToConstant(shortSword);
            kernel.Bind<IWeapon>().ToConstant(sword);
            kernel.Bind<IWeapon>().ToConstant(shuriken).Binding.IsImplicit = true;
            var result = kernel.GetAll<IWeapon>();
            result.Should().Contain(shortSword);
            result.Should().Contain(sword);
            result.Should().NotContain(shuriken);
        }
        public void GivenAMixtureOfBindings_OnlyNonImplicitBindingsWillResolve()
        {
            var shortSword = new ShortSword();
            var sword      = new Sword();
            var shuriken   = new Shuriken();

            this.kernel.Bind <IWeapon>().ToConstant(shortSword);
            this.kernel.Bind <IWeapon>().ToConstant(sword);
            this.kernel.Bind <IWeapon>().ToConstant(shuriken).BindingConfiguration.IsImplicit = true;
            var result = this.kernel.GetAll <IWeapon>();

            result.Should().Contain(shortSword);
            result.Should().Contain(sword);
            result.Should().NotContain(shuriken);
        }
示例#8
0
        public static void ShortSwordDemo()
        {
            // create an object of type Short Sword
            ShortSword mySword = new ShortSword();

            // by overridding the ToString method we can print whatever we want
            Console.WriteLine(mySword);

            // I can change Description because the setter is public
            mySword.Description = "Some new description";
            Console.WriteLine(mySword);

            // I cannot change the Type because the setter is protected
            // Only inside the Item class or a child class can I set it.
            // Program does not inherit from Item
            //mySword.Type = Items.ItemType.Armor;
        }
示例#9
0
        public void IsInstanceOf_NotTransparentProxy_IsAnInstanceOf()
        {
            var instance  = new ShortSword();
            var reference = new InstanceReference {
                Instance = instance
            };

            Assert.True(reference.IsInstanceOf <ShortSword>(out var shortSword));
            Assert.Same(instance, shortSword);

            Assert.True(reference.IsInstanceOf <Sword>(out var sword));
            Assert.Same(instance, sword);

            Assert.True(reference.IsInstanceOf <IWeapon>(out var weapon));
            Assert.Same(instance, weapon);

            Assert.True(reference.IsInstanceOf <IWeapon>(out var obj));
            Assert.Same(instance, obj);
        }
示例#10
0
        public Item CreateItem(string name)
        {
            {
                Item item;

                switch (name)
                {
                case "BroadAxe":
                    item = new BroadAxe();
                    break;

                case "Flail":
                    item = new Flail();
                    break;

                case "Scepter":
                    item = new Scepter();
                    break;

                case "ShortSword":
                    item = new ShortSword();
                    break;

                case "Occulus":
                    item = new Occulus();
                    break;

                case "BoneShield":
                    item = new BoneShield();
                    break;

                default:
                    throw new ArgumentException($"invalid item \"{name}\"");
                }

                return(item);
            }
        }
        public void GivenOnlyImplicitBindings_AllBindingsWillResolve()
        {
            var shortSword = new ShortSword();
            var shuriken = new Shuriken();

            kernel.Bind<IWeapon>().ToConstant(shortSword).BindingConfiguration.IsImplicit = true;
            kernel.Bind<IWeapon>().ToConstant(shuriken).BindingConfiguration.IsImplicit = true;
            var result = kernel.GetAll<IWeapon>();
            result.Should().Contain(shortSword);
            result.Should().Contain(shuriken);
        }
示例#12
0
        public static InventoryItem CreateInventoryItem(string key, TeamType team, string region, Vector2 location, ContentManager content, GraphicsDevice graphics)
        {
            InventoryItem item          = null;
            int           amountStacked = 1;

            switch (key)
            {
            case ("tribalTokens"):
                item = new TribalTokens(team, region, location, content, graphics);
                break;

            case ("basePlank"):
                item = new BasePlank(team, region, location, content, graphics);
                break;

            case ("shortSword"):
                item = new ShortSword(team, region, location, content, graphics);
                break;

            case ("softWood"):
                item = new SoftWood(team, region, location, content, graphics);
                break;

            case ("islandGrass"):
                item = new IslandGrass(team, region, location, content, graphics);
                break;

            case ("coal"):
                item = new Coal(team, region, location, content, graphics);
                break;

            case ("ironOre"):
                item = new IronOre(team, region, location, content, graphics);
                break;

            case ("baseSword"):
                item = new BaseSword(team, region, location, content, graphics);
                break;

            case ("anvilItem"):
                item = new AnvilItem(team, region, location, content, graphics);
                item.placeableVersion = new CraftingAnvil(team, region, location, content, graphics);
                break;

            case ("baseChestItem"):
                item = new BaseChestItem(team, region, location, content, graphics);
                item.placeableVersion = new BaseChest(team, region, location, content, graphics);
                break;

            case ("nails"):
                item          = new Nails(team, region, location, content, graphics);
                amountStacked = 5;
                break;

            case ("cannonBallItem"):
                item          = new CannonBallItem(team, region, location, content, graphics);
                amountStacked = 3;
                break;

            case ("pistolShotItem"):
                item          = new PistolShotItem(team, region, location, content, graphics);
                amountStacked = 5;
                break;

            case ("ironBar"):
                item = new IronBar(team, region, location, content, graphics);
                break;

            case ("treasureMapItem"):
                item = new TreasureMapItem(null, team, region, location, content, graphics);
                break;

            case ("chiliFish"):
                item = new ChiliFish(team, region, location, content, graphics);
                break;

            case ("chiliPepper"):
                item = new ChiliPepper(team, region, location, content, graphics);
                break;

            case ("cookedFish"):
                item = new CookedFish(team, region, location, content, graphics);
                break;

            case ("cookedMeat"):
                item = new CookedMeat(team, region, location, content, graphics);
                break;

            case ("rawFish"):
                item = new RawFish(team, region, location, content, graphics);
                break;

            case ("rawMeat"):
                item = new RawMeat(team, region, location, content, graphics);
                break;

            case ("spoiledFish"):
                item = new SpoiledFish(team, region, location, content, graphics);
                break;

            case ("spoiledMeat"):
                item = new SpoiledMeat(team, region, location, content, graphics);
                break;

            case ("feather"):
                item = new Feather(team, region, location, content, graphics);
                break;

            case ("scales"):
                item = new Scales(team, region, location, content, graphics);
                break;

            case ("fishOil"):
                item = new FishOil(team, region, location, content, graphics);
                break;

            case ("goldCoins"):
                item = new GoldCoins(team, region, location, content, graphics);
                break;
            }
            item.itemKey       = key;
            item.amountStacked = amountStacked;
            return(item);
        }
示例#13
0
        public static void Weapon()
        {
            string prefixName;
            int    prefixValue;
            string prefixStat;

            (prefixName, prefixStat, prefixValue) = Prefix.Generate("Weapon");

            string suffixName;
            string suffixStat;
            int    suffixValue;

            (suffixName, suffixStat, suffixValue) = Suffix.Generate("Weapon");


            int _weaponType = random.Next(1, 27); //26 weapons

            switch (_weaponType)
            {
            case 1:
                Axe axe = new Axe(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                // Console.WriteLine("prefixName: " + prefixName + ", prefixStat: " + prefixStat + ", prefixValue: " + prefixValue + ", suffixName: " + suffixName + ", suffixStat: " + suffixStat + ", suffixVallue: " + suffixValue);
                axe.WeaponAddToInventory();
                break;

            case 2:
                BastardSword bastardSword = new BastardSword(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                bastardSword.WeaponAddToInventory();
                break;

            case 3:
                BattleAxe battleAxe = new BattleAxe(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                battleAxe.WeaponAddToInventory();
                break;

            case 4:
                Blade blade = new Blade(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                blade.WeaponAddToInventory();
                break;

            case 5:
                BroadAxe broadAxe = new BroadAxe(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                broadAxe.WeaponAddToInventory();
                break;

            case 6:
                BroadSword broadSword = new BroadSword(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                broadSword.WeaponAddToInventory();
                break;

            case 7:
                Claymore claymore = new Claymore(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                claymore.WeaponAddToInventory();
                break;

            case 8:
                Club club = new Club(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                club.WeaponAddToInventory();
                break;

            case 9:
                Dagger dagger = new Dagger(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                dagger.WeaponAddToInventory();
                break;

            case 10:
                Falchion falchion = new Falchion(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                falchion.WeaponAddToInventory();
                break;

            case 11:
                Flail flail = new Flail(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                flail.WeaponAddToInventory();
                break;

            case 12:
                GreatAxe greatAxe = new GreatAxe(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                greatAxe.WeaponAddToInventory();
                break;

            case 13:
                GreatSword greatSword = new GreatSword(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                greatSword.WeaponAddToInventory();
                break;

            case 14:
                LargeAxe largeAxe = new LargeAxe(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                largeAxe.WeaponAddToInventory();
                break;

            case 15:
                LongSword longSword = new LongSword(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                longSword.WeaponAddToInventory();
                break;

            case 16:
                Mace mace = new Mace(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                mace.WeaponAddToInventory();
                break;

            case 17:
                Maul maul = new Maul(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                maul.WeaponAddToInventory();
                break;

            case 19:
                MorningStar morningStar = new MorningStar(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                morningStar.WeaponAddToInventory();
                break;

            case 20:
                Sabre sabre = new Sabre(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                sabre.WeaponAddToInventory();
                break;

            case 21:
                Scimitar scimitar = new Scimitar(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                scimitar.WeaponAddToInventory();
                break;

            case 22:
                ShortSword shortSword = new ShortSword(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                shortSword.WeaponAddToInventory();
                break;

            case 23:
                SmallAxe smallAxe = new SmallAxe(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                smallAxe.WeaponAddToInventory();
                break;

            case 24:
                SpikedClub spikedClub = new SpikedClub(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                spikedClub.WeaponAddToInventory();
                break;

            case 25:
                TwoHandedSword twoHandedSword = new TwoHandedSword(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                twoHandedSword.WeaponAddToInventory();
                break;

            case 26:
                WarHammer warHammer = new WarHammer(prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue);
                warHammer.WeaponAddToInventory();
                break;
            }
        }