public IActionResult Details(Guid id) { var user = _userManager.GetByEmail(User.Identity.Name); var player = _playerManager.Get(new Guid(user.Id)); var c = _classManager.Get(player.ClassId.Value); if (c.Name == "Warrior") { var weapon = ServicesAutoMapperConfig.Mapped.Map <WeaponType>(_weaponTypeManager.Get(id)); var shield = ServicesAutoMapperConfig.Mapped.Map <WeaponType>(_weaponTypeManager.GetShield()); var warriorWeapons = new List <WeaponType> { weapon, shield }; var viewModel = new WeaponViewModel { WeaponTypes = warriorWeapons }; return(View(viewModel)); } else { var weapon = ServicesAutoMapperConfig.Mapped.Map <WeaponType>(_weaponTypeManager.Get(id)); var weapons = new List <WeaponType> { weapon }; var viewModel = new WeaponViewModel { WeaponTypes = weapons }; return(View(viewModel)); } }
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()); }