Ejemplo n.º 1
0
        public async Task <string> Sell(int id)
        {
            ShopEquipment shopEquipment = await this.context.ShopEquipments.FindAsync(id);

            int heroLevel = await this.levelService.GetCurrentHeroLevel();

            this.CheckIfRequiredLevelIsMet(shopEquipment, heroLevel);

            await this.resourcePouchService.DecreaseResource(ResourceNames.Gold, shopEquipment.Price);

            HeroEquipment heroEquipment = new HeroEquipment
            {
                Name          = shopEquipment.Name,
                Type          = shopEquipment.Type,
                RequiredLevel = shopEquipment.RequiredLevel,
                ImageUrl      = shopEquipment.ImageUrl,
                Attack        = shopEquipment.Attack,
                Defense       = shopEquipment.Defense,
                Mastery       = shopEquipment.Mastery,
            };

            await this.inventoryService.InsertEquipment(heroEquipment);

            this.tempDataDictionaryFactory
            .GetTempData(this.httpContext.HttpContext)
            .Add("Alert", $"You bought {heroEquipment.Name}.");

            return(heroEquipment.Type.ToString());
        }
Ejemplo n.º 2
0
        public async Task SeedAsync(FarmHeroesDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (!dbContext.ShopEquipments.Where(x => x.Type == EquipmentType.Weapon).Any())
            {
                ShopEquipment[] shopWeapons = new ShopEquipment[]
                {
                    new ShopEquipment()
                    {
                        Name = "Rolling-pin", Type = EquipmentType.Weapon, Price = 45, RequiredLevel = 1, Attack = 2, ImageUrl = "/images/equipment/weapons/weapon1.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Ladle", Type = EquipmentType.Weapon, Price = 80, RequiredLevel = 3, Attack = 3, ImageUrl = "/images/equipment/weapons/weapon2.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Enormous Handlebar", Type = EquipmentType.Weapon, Price = 150, RequiredLevel = 4, Attack = 4, ImageUrl = "/images/equipment/weapons/weapon3.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Big Fork", Type = EquipmentType.Weapon, Price = 240, RequiredLevel = 5, Attack = 6, ImageUrl = "/images/equipment/weapons/weapon4.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Nail Hammer", Type = EquipmentType.Weapon, Price = 470, RequiredLevel = 6, Attack = 8, ImageUrl = "/images/equipment/weapons/weapon5.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Wooden Sword", Type = EquipmentType.Weapon, Price = 750, RequiredLevel = 7, Attack = 10, Mastery = 3, ImageUrl = "/images/equipment/weapons/weapon6.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Farm Trident", Type = EquipmentType.Weapon, Price = 1050, RequiredLevel = 8, Attack = 10, Mastery = 6, ImageUrl = "/images/equipment/weapons/weapon7.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Saber", Type = EquipmentType.Weapon, Price = 1680, RequiredLevel = 9, Attack = 15, ImageUrl = "/images/equipment/weapons/weapon8.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Bat", Type = EquipmentType.Weapon, Price = 2675, RequiredLevel = 10, Attack = 21, ImageUrl = "/images/equipment/weapons/weapon9.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Knife", Type = EquipmentType.Weapon, Price = 3200, RequiredLevel = 12, Attack = 10, Mastery = 21, ImageUrl = "/images/equipment/weapons/weapon10.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Scythe", Type = EquipmentType.Weapon, Price = 4716, RequiredLevel = 14, Attack = 27, Mastery = 10, ImageUrl = "/images/equipment/weapons/weapon11.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Sickle", Type = EquipmentType.Weapon, Price = 6666, RequiredLevel = 16, Attack = 16, Mastery = 34, ImageUrl = "/images/equipment/weapons/weapon12.jpg"
                    },
                };

                await dbContext.ShopEquipments.AddRangeAsync(shopWeapons);
            }
        }
Ejemplo n.º 3
0
 private void CheckIfRequiredLevelIsMet(ShopEquipment shopEquipment, int heroLevel)
 {
     if (heroLevel < shopEquipment.RequiredLevel)
     {
         throw new FarmHeroesException(
                   ShopExceptionMessages.RequiredLevelNotMetMessage,
                   ShopExceptionMessages.RequiredLevelNotMetInstruction,
                   string.Format(Redirects.ShopRedirect, shopEquipment.Type));
     }
 }
Ejemplo n.º 4
0
        public async Task SeedAsync(FarmHeroesDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (!dbContext.ShopEquipments.Where(x => x.Type == EquipmentType.Shield).Any())
            {
                ShopEquipment[] shopShields = new ShopEquipment[]
                {
                    new ShopEquipment()
                    {
                        Name = "Wooden Shield", Type = EquipmentType.Shield, Price = 545, RequiredLevel = 2, Defense = 5, ImageUrl = "/images/equipment/shields/shield_1.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Fluffster", Type = EquipmentType.Shield, Price = 2678, RequiredLevel = 5, Attack = 3, Defense = 10, ImageUrl = "/images/equipment/shields/shield_2.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Spiky", Type = EquipmentType.Shield, Price = 4512, RequiredLevel = 7, Attack = 10, Defense = 16, ImageUrl = "/images/equipment/shields/shield_3.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Antique", Type = EquipmentType.Shield, Price = 12365, RequiredLevel = 13, Defense = 20, Mastery = 12, ImageUrl = "/images/equipment/shields/shield_4.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Gramadan", Type = EquipmentType.Shield, Price = 34575, RequiredLevel = 18, Defense = 48, Mastery = -15, ImageUrl = "/images/equipment/shields/shield_5.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Fabricco", Type = EquipmentType.Shield, Price = 78054, RequiredLevel = 22, Defense = 33, Mastery = 27, ImageUrl = "/images/equipment/shields/shield_6.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Berr", Type = EquipmentType.Shield, Price = 167985, RequiredLevel = 26, Attack = 10, Defense = 44, Mastery = 8, ImageUrl = "/images/equipment/shields/shield_7.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "BonFish", Type = EquipmentType.Shield, Price = 338833, RequiredLevel = 30, Attack = 20, Defense = 29, Mastery = 24, ImageUrl = "/images/equipment/shields/shield_8.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Spikster", Type = EquipmentType.Shield, Price = 699785, RequiredLevel = 35, Attack = 54, Defense = 32, Mastery = -20, ImageUrl = "/images/equipment/shields/shield_9.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Druid", Type = EquipmentType.Shield, Price = 845788, RequiredLevel = 38, Defense = 72, Mastery = 28, ImageUrl = "/images/equipment/shields/shield_10.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Smiley", Type = EquipmentType.Shield, Price = 1145789, RequiredLevel = 42, Attack = 30, Defense = 60, Mastery = 30, ImageUrl = "/images/equipment/shields/shield_11.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Lunari", Type = EquipmentType.Shield, Price = 1789242, RequiredLevel = 46, Attack = 46, Defense = 42, Mastery = 50, ImageUrl = "/images/equipment/shields/shield_12.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Rogn", Type = EquipmentType.Shield, Price = 2589752, RequiredLevel = 50, Attack = 88, Defense = 99, Mastery = -30, ImageUrl = "/images/equipment/shields/shield_13.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "X", Type = EquipmentType.Shield, Price = 2899452, RequiredLevel = 52, Attack = 22, Defense = 68, Mastery = 112, ImageUrl = "/images/equipment/shields/shield_14.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Monstro", Type = EquipmentType.Shield, Price = 3386424, RequiredLevel = 54, Attack = 51, Defense = 133, Mastery = 18, ImageUrl = "/images/equipment/shields/shield_15.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Cancroid", Type = EquipmentType.Shield, Price = 3755378, RequiredLevel = 57, Attack = 112, Defense = 138, ImageUrl = "/images/equipment/shields/shield_16.jpg"
                    },
                };

                await dbContext.ShopEquipments.AddRangeAsync(shopShields);
            }
        }
Ejemplo n.º 5
0
        public async Task SeedAsync(FarmHeroesDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (!dbContext.ShopEquipments.Where(x => x.Type == EquipmentType.Armor).Any())
            {
                ShopEquipment[] shopArmor = new ShopEquipment[]
                {
                    new ShopEquipment()
                    {
                        Name = "Chafty", Type = EquipmentType.Armor, Price = 230, RequiredLevel = 2, Mastery = 3, Defense = 1, ImageUrl = "/images/equipment/armors/armor_1.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Scrapster", Type = EquipmentType.Armor, Price = 846, RequiredLevel = 3, Mastery = 5, Attack = 2, ImageUrl = "/images/equipment/armors/armor_2.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Cask", Type = EquipmentType.Armor, Price = 5489, RequiredLevel = 5, Defense = 10, Attack = 8, ImageUrl = "/images/equipment/armors/armor_3.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Holley", Type = EquipmentType.Armor, Price = 8426, RequiredLevel = 7, Defense = 10, Mastery = 15, ImageUrl = "/images/equipment/armors/armor_4.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Metzo", Type = EquipmentType.Armor, Price = 10875, RequiredLevel = 9, Attack = 15, Mastery = 15, ImageUrl = "/images/equipment/armors/armor_5.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Modern Cask", Type = EquipmentType.Armor, Price = 14752, RequiredLevel = 11, Attack = 15, Mastery = 15, Defense = 15, ImageUrl = "/images/equipment/armors/armor_6.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Rivvr", Type = EquipmentType.Armor, Price = 21589, RequiredLevel = 13, Defense = 48, ImageUrl = "/images/equipment/armors/armor_7.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Abster", Type = EquipmentType.Armor, Price = 28555, RequiredLevel = 15, Attack = 43, ImageUrl = "/images/equipment/armors/armor_9.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Crimа", Type = EquipmentType.Armor, Price = 49872, RequiredLevel = 20, Defense = 47, Attack = 11, Mastery = 38, ImageUrl = "/images/equipment/armors/armor_10.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "V", Type = EquipmentType.Armor, Price = 62357, RequiredLevel = 24, Defense = 57, Mastery = 74, ImageUrl = "/images/equipment/armors/armor_11.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Angelo", Type = EquipmentType.Armor, Price = 83675, RequiredLevel = 27, Attack = 60, Defense = 120, ImageUrl = "/images/equipment/armors/armor_12.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Sunn", Type = EquipmentType.Armor, Price = 109306, RequiredLevel = 29, Mastery = 168, ImageUrl = "/images/equipment/armors/armor_13.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "OM-88", Type = EquipmentType.Armor, Price = 148388, RequiredLevel = 31, Attack = 138, Defense = 33, ImageUrl = "/images/equipment/armors/armor_14.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Saharum", Type = EquipmentType.Armor, Price = 178462, RequiredLevel = 34, Attack = 120, Defense = 60, Mastery = 30, ImageUrl = "/images/equipment/armors/armor_15.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Skelto", Type = EquipmentType.Armor, Price = 217850, RequiredLevel = 36, Attack = 155, Defense = 155, ImageUrl = "/images/equipment/armors/armor_16.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Aquavoz", Type = EquipmentType.Armor, Price = 258762, RequiredLevel = 38, Attack = 33, Defense = 57, Mastery = 194, ImageUrl = "/images/equipment/armors/armor_17.jpg"
                    },
                };

                await dbContext.ShopEquipments.AddRangeAsync(shopArmor);
            }
        }
Ejemplo n.º 6
0
        public async Task SeedAsync(FarmHeroesDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (!dbContext.ShopEquipments.Where(x => x.Type == EquipmentType.Helmet).Any())
            {
                ShopEquipment[] shopHelmets = new ShopEquipment[]
                {
                    new ShopEquipment()
                    {
                        Name = "Mask", Type = EquipmentType.Helmet, Price = 420, RequiredLevel = 3, Defense = 7, ImageUrl = "/images/equipment/helmets/helmet_1.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Trough", Type = EquipmentType.Helmet, Price = 1333, RequiredLevel = 5, Defense = 11, ImageUrl = "/images/equipment/helmets/helmet_2.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Strainer", Type = EquipmentType.Helmet, Price = 4155, RequiredLevel = 7, Defense = 18, ImageUrl = "/images/equipment/helmets/helmet_3.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Metal Trough", Type = EquipmentType.Helmet, Price = 5252, RequiredLevel = 9, Defense = 25, ImageUrl = "/images/equipment/helmets/helmet_4.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Fancy Mask", Type = EquipmentType.Helmet, Price = 5750, RequiredLevel = 10, Defense = 25, Attack = 5, ImageUrl = "/images/equipment/helmets/helmet_5.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Enforcer", Type = EquipmentType.Helmet, Price = 6666, RequiredLevel = 12, Attack = 25, ImageUrl = "/images/equipment/helmets/helmet_6.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Rush", Type = EquipmentType.Helmet, Price = 8400, RequiredLevel = 15, Defense = 25, Mastery = 15, ImageUrl = "/images/equipment/helmets/helmet_7.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Fuzzy", Type = EquipmentType.Helmet, Price = 13480, RequiredLevel = 17, Defense = 32, Attack = 12, ImageUrl = "/images/equipment/helmets/helmet_8.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Crimson Knight", Type = EquipmentType.Helmet, Price = 16200, RequiredLevel = 19, Defense = 37, Attack = 14, ImageUrl = "/images/equipment/helmets/helmet_9.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Cyclopus", Type = EquipmentType.Helmet, Price = 21475, RequiredLevel = 22, Defense = 46, Attack = 21, ImageUrl = "/images/equipment/helmets/helmet_10.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Heavy Metal", Type = EquipmentType.Helmet, Price = 57810, RequiredLevel = 25, Defense = 65, ImageUrl = "/images/equipment/helmets/helmet_11.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Feather", Type = EquipmentType.Helmet, Price = 87890, RequiredLevel = 29, Defense = 15, Attack = 24, Mastery = 33, ImageUrl = "/images/equipment/helmets/helmet_13.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Punisher", Type = EquipmentType.Helmet, Price = 114880, RequiredLevel = 31, Defense = 40, Attack = 40, ImageUrl = "/images/equipment/helmets/helmet_14.jpg"
                    },
                    new ShopEquipment()
                    {
                        Name = "Monster Skull", Type = EquipmentType.Helmet, Price = 147577, RequiredLevel = 34, Defense = 33, Attack = 33, Mastery = 33, ImageUrl = "/images/equipment/helmets/helmet_15.jpg"
                    },
                };

                await dbContext.ShopEquipments.AddRangeAsync(shopHelmets);
            }
        }
Ejemplo n.º 7
0
 public static void SetChoosenEquipment(ShopEquipment equipment)
 {
     BuyEquipment.choosen_ShopEquipment = equipment;
 }