Example #1
0
        public ActionResult Classes()
        {
            var classes = classManager.GetAll()
                          .Select(c => new MyWebApp.WebSite.Models.ClassModel
            {
                Id          = c.Id,
                Name        = c.Name,
                Description = c.Description,
                Price       = c.Price
            }).ToArray();

            var model = new ClassViewModel
            {
                Classes = classes
            };

            return(View(model));
        }
Example #2
0
        public IActionResult Index(Guid?id, bool?flag)
        {
            if (User.Identity.IsAuthenticated)
            {
                var user   = _userManager.GetByEmail(User.Identity.Name);
                var player = _playerManager.Get(new Guid(user.Id));
                ViewData["Player"] = player.Username;
                var weapons = _weaponManager.GetWeaponOfThePlayer(new Guid(player.UserId));

                var viewModel = new CharacterInformation();

                if (player.ClassId != null)
                {
                    ViewData["HasClass"]  = "true";
                    viewModel.PlayerClass = ServicesAutoMapperConfig.Mapped.Map <Class>(_classManager.Get(player.ClassId.Value));
                    viewModel.Character   = ServicesAutoMapperConfig.Mapped.Map <Player>(player);
                    if (weapons.Count > 0)
                    {
                        ViewData["HasWeapon"]   = "true";
                        viewModel.Quests        = ServicesAutoMapperConfig.Mapped.Map <List <Quest> >(_questManager.GetAllByLevel(player.Level));
                        viewModel.PlayerWeapons = ServicesAutoMapperConfig.Mapped.Map <List <Weapon> >(weapons);

                        // Shows all weapons;
                        foreach (var item in viewModel.PlayerWeapons)
                        {
                            item.WeaponType = ServicesAutoMapperConfig.Mapped.Map <WeaponType>(_weaponTypeManager.Get(item.WeaponTypeId));
                            // Adds weapon skills;
                            var weaponSkillList = ServicesAutoMapperConfig.Mapped.Map <List <Skill> >(
                                _skillManager.GetAllByWeaponType(item.WeaponTypeId));
                            foreach (var skill in weaponSkillList)
                            {
                                viewModel.Skills.Add(skill);
                            }
                        }
                        // Adds class skills;
                        var classSkillList = ServicesAutoMapperConfig.Mapped.Map <List <Skill> >(
                            _skillManager.GetAllByClass(player.ClassId.Value));

                        foreach (var skill in classSkillList)
                        {
                            viewModel.Skills.Add(skill);
                        }
                    }
                    else
                    {
                        viewModel.Weapons = ServicesAutoMapperConfig.Mapped.Map <List <WeaponType> >(_weaponTypeManager.GetAllByClass(player.ClassId.Value));
                    }
                }
                else
                {
                    viewModel.Classes = ServicesAutoMapperConfig.Mapped.Map <List <Class> >(_classManager.GetAll());
                }

                if (id != null)
                {
                    viewModel.Reward      = ServicesAutoMapperConfig.Mapped.Map <Reward>(_rewardManager.GetByQuest(id.Value));
                    viewModel.ItemRewards = ServicesAutoMapperConfig.Mapped.Map <List <ItemReward> >(_itemRewardManager.GetAllByReward(viewModel.Reward.RewardId));

                    foreach (var item in viewModel.ItemRewards)
                    {
                        item.Item = ServicesAutoMapperConfig.Mapped.Map <Item>(_itemManager.Get(item.ItemId));
                    }
                }



                //var allQuests = _questManager.CheckTimers();

                //if (allQuests.Count > 0)
                //{
                //    foreach (var quest in allQuests)
                //    {
                //        if (quest.DateToComplete == null)
                //        {
                //            quest.DateToComplete = DateTime.Now;

                //            if (quest.Hours > 0)
                //                quest.DateToComplete = quest.DateToComplete.Value.AddHours(quest.Hours);

                //            if (quest.Minutes > 0)
                //                quest.DateToComplete = quest.DateToComplete.Value.AddMinutes(quest.Minutes);

                //            if (quest.Seconds > 0)
                //                quest.DateToComplete = quest.DateToComplete.Value.AddSeconds(quest.Seconds);

                //            _questManager.Update(quest);
                //        }

                //        ViewData["Hours"] = quest.DateToComplete.Value.Hour;
                //        ViewData["Minutes"] = quest.DateToComplete.Value.Minute;
                //        ViewData["Seconds"] = quest.DateToComplete.Value.Second;
                //    }
                //}
                return(View(viewModel));
            }
            return(View());
        }