public virtual ActionResult ReadSkillBook(int id) { var myMembershipId = User.Identity.GetUserId(); var me = PlayerProcedures.GetPlayerFromMembership(myMembershipId); // assert player is animate if (me.Mobility != PvPStatics.MobilityFull) { TempData["Error"] = "This curse is too strong to be lifted."; return(RedirectToAction(MVC.PvP.Play())); } // assert player has not already used an item this turn if (me.ItemsUsedThisTurn >= PvPStatics.MaxItemUsesPerUpdate) { TempData["Error"] = "You've already used an item this turn."; TempData["SubError"] = "You will be able to use another consumable next turn."; return(RedirectToAction(MVC.Item.MyInventory())); } var book = ItemProcedures.GetItemViewModel(id); // assert player owns this book if (book.dbItem.OwnerId != me.Id) { TempData["Error"] = "You do not own this book."; return(RedirectToAction(MVC.PvP.Play())); } // make sure that this is actually a book if (book.Item.ConsumableSubItemType != (int)ItemStatics.ConsumableSubItemTypes.Tome) { TempData["Error"] = "You can't read that item!"; TempData["SubError"] = "It's not a book."; return(RedirectToAction(MVC.PvP.Play())); } // assert player hasn't already read this book if (ItemProcedures.PlayerHasReadBook(me, book.dbItem.ItemSourceId)) { TempData["Error"] = "You have already absorbed the knowledge from this book and can learn nothing more from it."; TempData["SubError"] = "Perhaps a friend could use this tome more than you right now."; return(RedirectToAction(MVC.PvP.Play())); } ItemProcedures.DeleteItem(book.dbItem.Id); ItemProcedures.AddBookReading(me, book.dbItem.ItemSourceId); PlayerProcedures.GiveXP(me, 35); PlayerProcedures.AddItemUses(me.Id, 1); StatsProcedures.AddStat(me.MembershipId, StatsProcedures.Stat__LoreBooksRead, 1); TempData["Result"] = "You read your copy of " + book.Item.FriendlyName + ", absorbing its knowledge for 35 XP. The tome slips into thin air so it can provide its knowledge to another mage in a different time and place."; return(RedirectToAction(MVC.PvP.Play())); }
public static void CounterAttack(Player demon, Player attacker) { IPlayerRepository playerRepo = new EFPlayerRepository(); var dbDemon = playerRepo.Players.FirstOrDefault(f => f.Id == demon.Id); if (dbDemon.Mobility != PvPStatics.MobilityFull) { decimal xpGain = 30 + 5 * dbDemon.Level; decimal pointsGain = dbDemon.Level * 2; PlayerProcedures.GivePlayerPvPScore_NoLoser(attacker, pointsGain); var playerLog = "You absorb dark magic from your vanquished opponent, earning " + pointsGain + " points and " + xpGain + " XP. Unfortunately the demon's new form fades into mist, denying you any other trophies of your conquest."; PlayerLogProcedures.AddPlayerLog(attacker.Id, playerLog, true); PlayerProcedures.GiveXP(attacker, xpGain); var item = DomainRegistry.Repository.FindSingle(new GetItemByFormerPlayer { PlayerId = dbDemon.Id }); ItemProcedures.DeleteItem(item.Id); DomainRegistry.Repository.Execute(new DeletePlayer { PlayerId = demon.Id }); StatsProcedures.AddStat(attacker.MembershipId, StatsProcedures.Stat__DungeonDemonsDefeated, 1); } else if (dbDemon != null && dbDemon.Mobility == PvPStatics.MobilityFull && attacker.Mobility == PvPStatics.MobilityFull) { var(complete, _) = AttackProcedures.Attack(dbDemon, attacker, PvPStatics.Dungeon_VanquishSpellSourceId); if (!complete) { (complete, _) = AttackProcedures.Attack(dbDemon, attacker, PvPStatics.Dungeon_VanquishSpellSourceId); } var dbDemonBuffs = ItemProcedures.GetPlayerBuffs(dbDemon); if (dbDemon.Mana < PvPStatics.AttackManaCost * 6) { DomainRegistry.Repository.Execute(new Meditate { PlayerId = dbDemon.Id, Buffs = dbDemonBuffs, NoValidate = true }); } if (complete) { AIProcedures.EquipDefeatedPlayer(dbDemon, attacker); } } }
public virtual ActionResult RemoveCurseSend(int curseEffectSourceId, int id) { var myMembershipId = User.Identity.GetUserId(); var me = PlayerProcedures.GetPlayerFromMembership(myMembershipId); // assert player is animate if (me.Mobility != PvPStatics.MobilityFull) { TempData["Error"] = "You must be animate in order to use this."; return(RedirectToAction(MVC.PvP.Play())); } // assert player has not already used an item this turn if (me.ItemsUsedThisTurn >= PvPStatics.MaxItemUsesPerUpdate) { TempData["Error"] = "You've already used an item this turn."; TempData["SubError"] = "You will be able to use another consumable next turn."; return(RedirectToAction(MVC.Item.MyInventory())); } // assert player owns this item var itemToUse = ItemProcedures.GetItemViewModel(id); if (itemToUse == null || itemToUse.dbItem.OwnerId != me.Id) { TempData["Error"] = "You do not own the item needed to do this."; return(RedirectToAction(MVC.PvP.Play())); } // assert that the item can remove curses and is not any old item if (itemToUse.dbItem.ItemSourceId != ItemStatics.CurseLifterItemSourceId && itemToUse.dbItem.ItemSourceId != ItemStatics.ButtPlugItemSourceId) { TempData["Error"] = "This item cannot remove curses."; return(RedirectToAction(MVC.PvP.Play())); } var curseToRemove = EffectStatics.GetDbStaticEffect(curseEffectSourceId); // assert this curse is removable if (!curseToRemove.IsRemovable) { TempData["Error"] = "This curse is too strong to be lifted."; return(RedirectToAction(MVC.PvP.Play())); } // back on your feet curse/buff -- just delete outright if (curseToRemove.Id == PvPStatics.Effect_BackOnYourFeetSourceId) { EffectProcedures.RemovePerkFromPlayer(curseToRemove.Id, me); } // regular curse; set duration to 0 but keep cooldown else { EffectProcedures.SetPerkDurationToZero(curseToRemove.Id, me); } // if the item is a consumable type, delete it. Otherwise reset its cooldown if (itemToUse.Item.ItemType == PvPStatics.ItemType_Consumable) { ItemProcedures.DeleteItem(itemToUse.dbItem.Id); } // else if (itemToUse.Item.ItemType == PvPStatics.ItemType_Consumable_Reuseable) else { ItemProcedures.ResetUseCooldown(itemToUse); } PlayerProcedures.AddItemUses(me.Id, 1); var result = $"You have successfully removed the curse <b>{curseToRemove.FriendlyName}</b> from your body!"; TempData["Result"] = result; var playerMessage = itemToUse.Item.UsageMessage_Player; if (string.IsNullOrEmpty(playerMessage)) { PlayerLogProcedures.AddPlayerLog(me.Id, result, false); } else { PlayerLogProcedures.AddPlayerLog(me.Id, $"{playerMessage}<br />{result}", itemToUse.dbItem.FormerPlayerId != null); } if (itemToUse.dbItem.ItemSourceId == ItemStatics.ButtPlugItemSourceId && itemToUse.dbItem.FormerPlayerId != null) { var itemMessage = itemToUse.Item.UsageMessage_Item; var context = $"Your owner just used you to remove the curse <b>{curseToRemove.FriendlyName}</b>! Doesn't that make you feel all warm and tingly?"; itemMessage = string.IsNullOrEmpty(itemMessage) ? context : $"{itemMessage}<br />{context}"; PlayerLogProcedures.AddPlayerLog((int)itemToUse.dbItem.FormerPlayerId, itemMessage, true); } return(RedirectToAction(MVC.PvP.Play())); }
public virtual ActionResult SelfCastSend(int itemId, int skillSourceId) { var myMembershipId = User.Identity.GetUserId(); var me = PlayerProcedures.GetPlayerFromMembership(myMembershipId); // assert player is animate if (me.Mobility != PvPStatics.MobilityFull) { TempData["Error"] = "You must be animate in order to use this."; return(RedirectToAction(MVC.PvP.Play())); } // assert that this player is not in a duel if (me.InDuel > 0) { TempData["Error"] = "You must finish your duel before you use this item."; return(RedirectToAction(MVC.PvP.Play())); } // assert that this player is not in a quest if (me.InQuest > 0) { TempData["Error"] = "You must finish your quest before you use this item."; return(RedirectToAction(MVC.PvP.Play())); } // assert player has not already used an item this turn if (me.ItemsUsedThisTurn >= PvPStatics.MaxItemUsesPerUpdate) { TempData["Error"] = "You've already used an item this turn."; TempData["SubError"] = "You will be able to use another consumable type item next turn."; return(RedirectToAction(MVC.Item.MyInventory())); } var item = ItemProcedures.GetItemViewModel(itemId); // assert player does own this if (item.dbItem.OwnerId != me.Id) { TempData["Error"] = "You don't own that item."; return(RedirectToAction(MVC.PvP.Play())); } // assert that it is equipped if (!item.dbItem.IsEquipped) { TempData["Error"] = "You cannot use an item you do not have equipped."; return(RedirectToAction(MVC.PvP.Play())); } // assert this item is a transmog if (item.dbItem.ItemSourceId != ItemStatics.AutoTransmogItemSourceId) { TempData["Error"] = "You cannot change form with that item."; return(RedirectToAction(MVC.PvP.Play())); } // assert player does own this skill var skill = SkillProcedures.GetSkillViewModel(skillSourceId, me.Id); if (skill == null) { TempData["Error"] = "You do not own this spell."; return(RedirectToAction(MVC.PvP.Play())); } // assert desired form is animate if (skill.MobilityType != PvPStatics.MobilityFull) { TempData["Error"] = "The target form must be an animate form."; return(RedirectToAction(MVC.PvP.Play())); } // assert player is not already in the form of the spell if (me.FormSourceId == skill.StaticSkill.FormSourceId) { TempData["Error"] = "You are already in the target form of that spell, so doing this would do you no good."; return(RedirectToAction(MVC.PvP.Play())); } PlayerProcedures.InstantChangeToForm(me, skill.StaticSkill.FormSourceId.Value); ItemProcedures.DeleteItem(itemId); PlayerProcedures.SetTimestampToNow(me); PlayerProcedures.AddItemUses(me.Id, 1); var form = FormStatics.GetForm(skill.StaticSkill.FormSourceId.Value); TempData["Result"] = "You use a " + item.Item.FriendlyName + ", your spell bouncing through the device for a second before getting flung back at you and hitting you square in the chest, instantly transforming you into a " + form.FriendlyName + "!"; StatsProcedures.AddStat(me.MembershipId, StatsProcedures.Stat__TransmogsUsed, 1); return(RedirectToAction(MVC.PvP.Play())); }