Example #1
0
        public async Task <ActionResult> GetMessagesMonster(Guid qId)
        {
            var user = await UserFacade.GetUserAccordingToUsernameAsync(User.Identity.Name);

            var quest = await QuestFacade.GetQuestAsync(qId);

            var result = await CombatFacade.FightAsync(user.Character, quest.Monster, quest);

            //update character if won
            if (result.Item1)
            {
                var messageText = $"Congratulations you won the match and your reward is: {quest.Gold} gold, {quest.Experience} experience.";
                if (quest.Item != null)
                {
                    var item = await EquipmentFacade.AddToInventoryAsync(user.Character.Inventory, quest.Item);

                    if (item)
                    {
                        messageText +=
                            $"\nYou also receieved an item called {quest.Item.Name}, which is in your inventory.";
                    }
                }

                await UserFacade.MessageCreateAsync(user, new MessageDto()
                {
                    MessageText = messageText, Arrived = DateTime.Now
                });
            }

            var list = result.Item2.Select(x => new { Message = x }).ToList();

            return(Json(new { Winner = result.Item1, List = list }, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        // GET: Admin/Monster
        public async Task <ActionResult> Index(int page = 1)
        {
            var list   = (await QuestFacade.GetAllQuestsAsync()).ToList();
            var toShow = list.Skip((page - 1) * 10).Take(10);

            ViewBag.Count   = list.Count;
            ViewBag.Current = page;
            return(View("~/Views/Admin/Quest/Index.cshtml", toShow));
        }
        // GET: DashBoard
        public async Task <ActionResult> Index()
        {
            var itemsList = (await EquipmentFacade.GetAllItemsAsync()).ToList();

            ViewBag.Items     = itemsList.Count(a => a.ShopId == null);
            ViewBag.ShopItems = itemsList.Count(a => a.ShopId != null);
            ViewBag.Monsters  = (await MonsterFacade.GetAllMonstersAsync()).Count();
            ViewBag.Quests    = (await QuestFacade.GetAllQuestsAsync()).Count();
            ViewBag.Mini      = (await MiniLocationFacade.GetAllItemsAsync()).Count();
            ViewBag.Locations = (await LocationFacade.GetAllAsync()).Count();
            return(View());
        }
Example #4
0
        public async Task <ActionResult> Create(QuestDto model)
        {
            var monster = new MonsterDto()
            {
                Id = model.MonsterId.GetValueOrDefault()
            };
            var item = new ItemDto()
            {
                Id = model.ItemId.GetValueOrDefault()
            };

            model.ItemId    = null;
            model.MonsterId = null;

            model.Id = await QuestFacade.CreateQuest(new QuestDto()
            {
                Experience = model.Experience, Gold = model.Gold
            });

            await QuestFacade.AssignAsync(model, monster, item);

            return(RedirectToAction("Index"));
        }
Example #5
0
        public async Task <ActionResult> Delete(Guid id)
        {
            await QuestFacade.DeleteQuestAsync(id);

            return(RedirectToAction("Index"));
        }