Пример #1
0
        public async Task <IActionResult> Market(CCultivator cult)
        {
            TempData["Gold"]     = cult.Gold;
            TempData["Nickname"] = cult.Name;
            CMarket location = (CMarket)GLocationsList.GetById(cult.LocationId);

            return(View(location));
        }
Пример #2
0
 public override void Do(CCultivator c)
 {
     if (CanDo(c) > 0)
     {
         c.Gold -= Price;
         c.Equipments.AddEquip(EquipGenerator.Generate());
     }
 }
Пример #3
0
 public override void Do(CCultivator c)
 {
     if (CanDo(c) > 0)
     {
         c.Gold -= Price;
         foreach (var item in TraderItems)
         {
             c.Inventory.AddItem(item);
         }
     }
 }
Пример #4
0
 public override float IsSatisfied(CCultivator c)
 {
     if (c.Gold >= Price)
     {
         return(1);
     }
     else
     {
         return(0);
     }
 }
Пример #5
0
        public async Task <IActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                User user = new User {
                    Email = model.Email, UserName = model.Email, Nickname = model.Nickname, HeroType = model.HeroType
                };
                // добавляем пользователя
                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    // установка куки
                    await _signInManager.SignInAsync(user, false);

                    CCultivator newCultivator = new CCultivator()
                    {
                        LocationId = GWorld.World.SubLocations[0].Id
                    };
                    newCultivator.PlayerId  = CultivatorContext.getHex(user.UserName);
                    newCultivator.Name      = user.Nickname;
                    newCultivator.Inventory = new CCultivator.CInventory();
                    newCultivator.HeroType  = user.HeroType;
                    switch (user.HeroType)
                    {
                    case "/img/hero1.png":
                        newCultivator.Stats.MainStats.Strength += 5;
                        break;

                    case "/img/hero2.png":
                        newCultivator.Stats.MainStats.Agility += 5;
                        break;

                    case "/img/hero3.png":
                        newCultivator.Stats.MainStats.Intelligence += 5;
                        break;
                    }

                    await cultivatordb.Create(newCultivator);

                    return(RedirectToAction("Profile", "Account"));
                }
                else
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError(string.Empty, error.Description);
                    }
                }
            }
            return(View(model));
        }
Пример #6
0
        public async Task <ActionResult> IncreaseEndurance()
        {
            var cult = await cultivatordb.GetCultivator(User.Identity.Name);

            var statPrice = CCultivator.GetStatPrice(cult.Stats.MainStats.Endurance);

            if (cult.Gold >= statPrice)
            {
                cult.Gold -= statPrice;
                cult.Stats.MainStats.Endurance++;
                await cultivatordb.Update(cult);
            }
            else
            {
                TempData["Error"] = "Not enough money!";
            }
            return(RedirectToAction("Profile", "Account"));
        }
Пример #7
0
        public async Task <ActionResult> Index()
        {
            if (User.Identity.IsAuthenticated)
            {
                var c = await cultivatordb.GetCultivator(User.Identity.Name);

                if (c == null)
                {
                    CCultivator newCultivator = new CCultivator()
                    {
                        LocationId = GWorld.World.SubLocations[0].Id
                    };
                    newCultivator.PlayerId  = CultivatorContext.getHex(User.Identity.Name);
                    newCultivator.Name      = User.Identity.Name;
                    newCultivator.Inventory = new CCultivator.CInventory();
                    newCultivator.HeroType  = User.Identity.Name;
                    await cultivatordb.Create(newCultivator);
                }
                TempData["Nickname"] = c.Name;
                TempData["Gold"]     = c.Gold;
            }
            return(View());
        }
Пример #8
0
 public async Task <IActionResult> Shop(CCultivator cult)
 {
     TempData["Gold"]     = cult.Gold;
     TempData["Nickname"] = cult.Name;
     return(View((CBaseTrader)GLocationsList.GetById(cult.LocationId)));
 }
Пример #9
0
 public async Task Update(CCultivator c)
 {
     await Collection.ReplaceOneAsync(new BsonDocument("_id", c.PlayerId), c);
 }
Пример #10
0
 public async Task Create(CCultivator c)
 {
     await Collection.InsertOneAsync(c);
 }