public async Task <WeaponViewModel> CreateWeapon([FromBody] WeaponViewModel weaponVM) { var domainModel = weaponVM.ToDomainModel(); domainModel.CreatedAtMS = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); dbCtx.Attach(userSession.Player); domainModel.Player = userSession.Player; domainModel.Id = 0; var originalSpellsById = domainModel.Enchantments.ToDictionary(e => e.BaseSpellId, e => e.BaseSpell); domainModel.Enchantments.ForEach(e => e.BaseSpell = null); if (weaponVM.EquipmentId > 0) // editing an existing feature { //make sure they're the author of this feature var existingWeapon = await this.dbCtx.Weapons.FirstOrDefaultAsync(f => f.Player.Id == userSession.Player.Id && f.Id == weaponVM.EquipmentId); if (existingWeapon != null) { //yep, it's theirs existingWeapon.Delisted = true; domainModel.Enchantments.ForEach(e => e.Id = 0); } } dbCtx.Weapons.Add(domainModel); await dbCtx.SaveChangesAsync(); domainModel.Enchantments.ForEach(e => e.BaseSpell = originalSpellsById[e.BaseSpellId]); return(domainModel.ToViewModel()); }
public WeaponSave(WeaponViewModel from) { this.ModelSet = from.Set; this.ModelBase = from.Base; this.ModelVariant = from.Variant; this.DyeId = from.Dye; }
public void initEquipView(Hero hero) { this.View.PotionSV.Width = 450; this.View.ShieldSV.Width = 450; this.View.WeaponSV.Width = 450; this.View.ToShieldButton.Click += ToShieldEquipButton_Click; this.View.ToWeaponButton.Click += ToWeaponEquipButton_Click; this.View.ToPotionButton.Click += ToPotionEquipButton_Click; foreach (Shield shield in GameViewModel.Instance.MainCastle.ShieldStock) { ShieldViewModel newShieldViewModel = new ShieldViewModel(shield, hero); newShieldViewModel.InitEquipView(); this.View.BuyShieldSP.Children.Add(newShieldViewModel.View); } foreach (Weapon weapon in GameViewModel.Instance.MainCastle.WeaponStock) { WeaponViewModel newWeaponViewModel = new WeaponViewModel(weapon, hero); newWeaponViewModel.InitEquipView(); this.View.BuyWeaponSP.Children.Add(newWeaponViewModel.View); } foreach (Potion potion in GameViewModel.Instance.MainCastle.PotionStock) { PotionViewModel newPotionViewModel = new PotionViewModel(potion, hero); newPotionViewModel.InitEquipView(); this.View.BuyPotionSP.Children.Add(newPotionViewModel.View); } }
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 ActionResult View(int id = 0) { try { WeaponViewModel model = new WeaponViewModel(uow.WeaponRepository.GetByID(id)); if (model.Weapon == null) { //product not found return(RedirectToAction("Index", "Home")); } return(View(model)); } catch (Exception e) { return(RedirectToAction("Index", "Home")); } }
public ActionResult Edit(WeaponViewModel ReturnedWeapon) { Weapon CreatedWeapon = new Weapon() { ID = ReturnedWeapon.ID, Name = ReturnedWeapon.Name, Damage = ReturnedWeapon.Damage, Magazine = ReturnedWeapon.Magazine, Critical = ReturnedWeapon.Critical, Status = ReturnedWeapon.Status }; weapon.Save(CreatedWeapon); return(RedirectToAction("Weapons")); }
public static Weapon ToDomainModel(this WeaponViewModel weapon) { return(new Weapon { AttackAbility = weapon.AttackAbility, DamageAbility = weapon.DamageAbility, Range = weapon.Range, Damage = weapon.Damage, WeightInPounds = weapon.WeightInPounds, Name = weapon.Name, Description = weapon.Description, Cost = weapon.Cost, Enchantments = weapon.Enchantments.Select(e => e.ToDomainModel()).ToList() }); }
public void initBlacksmithView() { this.View.ToShieldButton.Click += ToShieldEquipButton_Click; this.View.ToWeaponButton.Click += ToWeaponEquipButton_Click; this.View.ToPotionButton.Visibility = System.Windows.Visibility.Collapsed; foreach (Shield shield in this.Blacksmith.ShieldList) { ShieldViewModel newShieldViewModel = new ShieldViewModel(shield); newShieldViewModel.InitBuyView(); this.View.BuyShieldSP.Children.Add(newShieldViewModel.View); } foreach (Weapon weapon in this.Blacksmith.WeaponList) { WeaponViewModel newWeaponViewModel = new WeaponViewModel(weapon); newWeaponViewModel.InitBuyView(); this.View.BuyWeaponSP.Children.Add(newWeaponViewModel.View); } }
public ActionResult CalculateEquipBurden(int vit, int adp, int end, int?rWeapon1 = null, int?lWeapon1 = null, int?helm = null, int?chest = null, int?gauntlet = null, int?legging = null, int?ring1 = null, int?ring2 = null, int?ring3 = null, int?ring4 = null) { double maxEquipLoad = vit > 29 ? (38.5 + (1.5 * 29) + 1 * (vit - 29)) : (38.5 + (1.5 * vit)); decimal currentEquipLoad = 0; double equipPercentage = 0; double poise = 0; int relevantPoiseStat = Math.Min(adp, end); if (relevantPoiseStat > 50) { poise = 30 * .3 + 20 * .2 + .1 * (relevantPoiseStat - 50); } else if (relevantPoiseStat > 30) { poise = 30 * .3 + .2 * (relevantPoiseStat - 50); } else { poise = relevantPoiseStat * .3; } List <Ring> rings = new List <Ring>(); if (ring1 > 0) { rings.Add(_ringsHelper.GetRing(ring1.Value)); } if (ring2 > 0) { rings.Add(_ringsHelper.GetRing(ring2.Value)); } if (ring3 > 0) { rings.Add(_ringsHelper.GetRing(ring3.Value)); } if (ring4 > 0) { rings.Add(_ringsHelper.GetRing(ring4.Value)); } foreach (Ring ring in rings) { currentEquipLoad += ring.Weight; if (ring.Effects != null) { foreach (Effect effect in ring.Effects) { if (effect.Affects == Effect.Modifies.EquipLoad) { maxEquipLoad = (maxEquipLoad * effect.Amount); } } } } if (rWeapon1 != null) { WeaponViewModel rW1 = _weaponsHelper.WeaponSearch(weaponId: rWeapon1).First(); currentEquipLoad += rW1.Weight.Value; } if (lWeapon1 != null) { WeaponViewModel lW1 = _weaponsHelper.WeaponSearch(weaponId: lWeapon1).First(); currentEquipLoad += lW1.Weight.Value; } if (helm != null) { ArmorViewModel hlm = _armorHelper.ArmorSearch(armorId: helm).First(); currentEquipLoad += (decimal)hlm.Weight; poise += hlm.Poise; } if (chest != null) { ArmorViewModel cht = _armorHelper.ArmorSearch(armorId: chest).First(); currentEquipLoad += (decimal)cht.Weight; poise += cht.Poise; } if (gauntlet != null) { ArmorViewModel glt = _armorHelper.ArmorSearch(armorId: gauntlet).First(); currentEquipLoad += (decimal)glt.Weight; poise += glt.Poise; } if (legging != null) { ArmorViewModel lgg = _armorHelper.ArmorSearch(armorId: legging).First(); currentEquipLoad += (decimal)lgg.Weight; poise += lgg.Poise; } equipPercentage = (double)currentEquipLoad / maxEquipLoad; string equipLoad = String.Format("{0} / {1} ({2:P2})", currentEquipLoad, maxEquipLoad, equipPercentage); return(Json(new { equipLoad = equipLoad, poise = poise }, JsonRequestBehavior.AllowGet)); }