private static IEnumerable <InstinctData> StripperActions(IPlayerRepository playerRepo, IEnumerable <InstinctData> mcPlayers, Random rand) { // Strippers - remove random item var mcStrippers = mcPlayers.Where(p => JokeShopProcedures.STRIPPERS.Any(stripperForm => p.FormSourceId == stripperForm)).ToList(); foreach (var stripper in mcStrippers) { var stripperPlayer = playerRepo.Players.FirstOrDefault(p => p.Id == stripper.Id); var stripperItems = ItemProcedures.GetAllPlayerItems(stripperPlayer.Id) .Where(i => i.dbItem.IsEquipped && i.Item.ItemType != PvPStatics.ItemType_Pet && i.Item.ItemType != PvPStatics.ItemType_Consumable && i.Item.ItemType != PvPStatics.ItemType_Consumable_Reuseable).ToList(); if (stripperItems.Any()) { string[] adverbs = { "seductively", "cautiously", "flirtatiously", "cheekily", "obediently", "enthusiastically", "reluctantly", "hesitantly", "energetically", "sheepishly" }; var adverb = adverbs[rand.Next(adverbs.Count())]; var itemToDrop = stripperItems[rand.Next(stripperItems.Count())]; PlayerLogProcedures.AddPlayerLog(stripper.Id, $"You {adverb} remove your <b>{itemToDrop.Item.FriendlyName}</b>!", true); LocationLogProcedures.AddLocationLog(stripper.dbLocationName, $"{stripperPlayer.GetFullName()} {adverb} removes their <b>{itemToDrop.Item.FriendlyName}</b>!"); ItemProcedures.DropItem(itemToDrop.dbItem.Id); } mcPlayers = mcPlayers.Where(p => p.Id != stripper.Id); } return(mcPlayers); }
public virtual ActionResult Quest() { IQuestRepository repo = new EFQuestRepository(); var myMembershipId = User.Identity.GetUserId(); var me = PlayerProcedures.GetPlayerFromMembership(myMembershipId); var unopenedMessageCount = DomainRegistry.Repository.FindSingle(new GetUnreadMessageCountByPlayer { OwnerId = me.Id }); var openedUnreadMessageCount = DomainRegistry.Repository.FindSingle(new GetReadAndMarkedAsUnreadMessageCountByPlayer { OwnerId = me.Id }); var output = new QuestPlayPageViewModel(); output.Player = PlayerProcedures.GetPlayerFormViewModel(me.Id); output.QuestStart = QuestProcedures.GetQuest(me.InQuest); output.QuestState = QuestProcedures.GetQuestState(me.InQuestState); output.QuestConnections = QuestProcedures.GetChildQuestConnections(me.InQuestState); output.BuffBox = ItemProcedures.GetPlayerBuffs(me); output.QuestPlayerVariables = QuestProcedures.GetAllQuestPlayerVariablesFromQuest(output.QuestStart.Id, me.Id); output.HasNewMessages = unopenedMessageCount != 0; output.UnreadMessageCount = unopenedMessageCount + openedUnreadMessageCount; ViewBag.ErrorMessage = TempData["Error"]; ViewBag.SubErrorMessage = TempData["SubError"]; ViewBag.Result = TempData["Result"]; output.SetConnectionText((string)TempData["ConnectionText"]); return(PartialView(MVC.Quest.Views.Quest, output)); }
public virtual ActionResult DeMeditateVictim(int id) { var myMembershipId = User.Identity.GetUserId(); var me = PlayerProcedures.GetPlayerFromMembership(myMembershipId); var victim = PlayerProcedures.GetPlayer(id); // run generic MC checks var errorsBox = MindControlProcedures.AssertBasicMindControlConditions(me, victim, MindControlStatics.MindControl__MeditateFormSourceId); if (errorsBox.HasError) { TempData["Error"] = errorsBox.Error; TempData["SubError"] = errorsBox.SubError; return(RedirectToAction(MVC.MindControl.MindControlList())); } var buffs = ItemProcedures.GetPlayerBuffs(victim); var result = PlayerProcedures.DeMeditate(victim, me, buffs); MindControlProcedures.AddCommandUsedToMindControl(me, victim, MindControlStatics.MindControl__MeditateFormSourceId); TempData["Result"] = "You force " + victim.GetFullName() + " to meditate while filling their mind with nonsense instead of relaxation, lowering their mana instead of increasing it!"; StatsProcedures.AddStat(me.MembershipId, StatsProcedures.Stat__MindControlCommandsIssued, 1); return(RedirectToAction(MVC.PvP.Play())); }
public virtual ActionResult SelfCast(int itemId) { var myMembershipId = User.Identity.GetUserId(); var me = PlayerProcedures.GetPlayerFromMembership(myMembershipId); 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 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())); } // 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())); } var model = new SelfCastViewModel { ItemId = itemId, Skills = DomainRegistry.Repository.Find(new GetSkillsOwnedByPlayer { playerId = me.Id }).Where(s => s.SkillSource.MobilityType == PvPStatics.MobilityFull) }; return(View(MVC.Item.Views.SelfCast, model)); }
public static void SpawnLoremaster() { var loremaster = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId { BotId = AIStatics.LoremasterBotId }); if (loremaster == null) { var cmd = new CreatePlayer { BotId = AIStatics.LoremasterBotId, Level = 5, FirstName = FirstName, LastName = LastName, Health = 100000, Mana = 100000, MaxHealth = 100000, MaxMana = 100000, Mobility = PvPStatics.MobilityFull, Money = 1000, FormSourceId = LoremasterFormId, Location = "bookstore_back", Gender = PvPStatics.GenderMale, }; var id = DomainRegistry.Repository.Execute(cmd); var playerRepo = new EFPlayerRepository(); var lorekeeperEF = playerRepo.Players.FirstOrDefault(p => p.Id == id); lorekeeperEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(lorekeeperEF)); playerRepo.SavePlayer(lorekeeperEF); } }
public static void SpawnBartender() { var bartender = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId { BotId = AIStatics.DonnaBotId }); if (bartender == null) { var cmd = new CreatePlayer { FirstName = "Rusty", LastName = "Steamstein the Automaton Bartender", Location = "tavern_counter", Gender = PvPStatics.GenderMale, Health = 100000, Mana = 100000, MaxHealth = 100000, MaxMana = 100000, FormSourceId = BartenderFormId, Money = 0, Mobility = PvPStatics.MobilityFull, Level = 15, BotId = AIStatics.BartenderBotId, }; var id = DomainRegistry.Repository.Execute(cmd); IPlayerRepository playerRepo = new EFPlayerRepository(); var newBartender = playerRepo.Players.FirstOrDefault(p => p.Id == id); newBartender.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(newBartender)); playerRepo.SavePlayer(newBartender); } }
public static void SpawnPetMerchant() { var petMerchant = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId { BotId = AIStatics.WuffieBotId }); if (petMerchant == null) { var cmd = new CreatePlayer { BotId = AIStatics.WuffieBotId, Level = 5, FirstName = "Wüffie", LastName = "the Soul Pet Vendor", Health = 100000, Mana = 100000, MaxHealth = 100000, MaxMana = 100000, Mobility = PvPStatics.MobilityFull, Money = 1000, FormSourceId = WuffieFormId, Location = "270_west_9th_ave", // Lindella starts her rounds here Gender = PvPStatics.GenderFemale, }; var id = DomainRegistry.Repository.Execute(cmd); var playerRepo = new EFPlayerRepository(); var petMerchantEF = playerRepo.Players.FirstOrDefault(p => p.Id == id); petMerchantEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(petMerchantEF)); playerRepo.SavePlayer(petMerchantEF); } }
public static string FillInventory(Player player, bool overflow, Random rand = null) { var itemsEquipped = ItemProcedures.GetAllPlayerItems(player.Id).Count(i => !i.dbItem.IsEquipped); var inventorySlots = PvPStatics.MaxCarryableItemCountBase + player.ExtraInventory; if (overflow) { inventorySlots++; } if (itemsEquipped >= inventorySlots) { return(null); } rand = rand ?? new Random(); for (; itemsEquipped < inventorySlots; itemsEquipped++) { // Low value consumable int[] itemTypes = { ItemStatics.SpellWeaverDryItemSourceId, ItemStatics.WillflowerDryItemSourceId }; var itemType = itemTypes[rand.Next(itemTypes.Count())]; ItemProcedures.GiveNewItemToPlayer(player, itemType); } return("While browsing through a clothes rail you find a fab pair of psychedelic flares and for a moment you are transported to the groovy era of peace and love, full of hippies, daisy chains and flower power. You could almost reach out and grab those blooms!"); }
public static void SpawnLindella() { var merchant = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId { BotId = AIStatics.LindellaBotId }); if (merchant == null) { var cmd = new CreatePlayer { BotId = AIStatics.LindellaBotId, Level = 5, FirstName = "Lindella", LastName = "the Soul Vendor", Health = 100000, Mana = 100000, MaxHealth = 100000, MaxMana = 100000, Mobility = PvPStatics.MobilityFull, Money = 1000, FormSourceId = LindellaFormId, Location = "270_west_9th_ave", // Lindella starts her rounds here Gender = PvPStatics.GenderFemale, }; var id = DomainRegistry.Repository.Execute(cmd); IPlayerRepository playerRepo = new EFPlayerRepository(); var newMerchant = playerRepo.Players.FirstOrDefault(p => p.Id == id); newMerchant.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(newMerchant)); playerRepo.SavePlayer(newMerchant); AIDirectiveProcedures.GetAIDirective(id); AIDirectiveProcedures.SetAIDirective_MoveTo(id, "street_15th_south"); } }
public static string GetProspectsMessage(Player player) { IInanimateXPRepository inanimXpRepo = new EFInanimateXPRepository(); IItemRepository itemRep = new EFItemRepository(); var inanimateMe = DomainRegistry.Repository.FindSingle(new GetItemByFormerPlayer { PlayerId = player.Id }); if (inanimateMe == null) { return(""); } var meItem = itemRep.Items.FirstOrDefault(i => i.Id == inanimateMe.Id); var myItemXP = inanimXpRepo.InanimateXPs.FirstOrDefault(i => i.OwnerId == player.Id); if (meItem == null || myItemXP == null) { return(null); } var turnsSinceLastAction = Math.Max(0, PvPWorldStatProcedures.GetWorldTurnNumber() - myItemXP.LastActionTurnstamp); // Time until lock - at 2% per turn (negative threshold) var turnsUntilLocked = (myItemXP.TimesStruggled - TurnTimesStatics.GetStruggleXPBeforeItemPermanentLock()) / 2 - turnsSinceLastAction; if (!meItem.IsPermanent && turnsUntilLocked <= TurnTimesStatics.GetItemMaxTurnsBuildup()) { if (turnsUntilLocked <= 1) { return("<b style=\"color: red;\">Be careful!</b> Just one more move and you might never be human again!"); } else { var time = turnsUntilLocked * TurnTimesStatics.GetTurnLengthInSeconds(); return($"If you keep enjoying your current form you might find yourself locked into it forever! That could happen in as little as <b>{SecondsToDurationString(time)}</b> or so!"); } } // Time until chance of escaping - at 1% per turn outside Chaos var turnsUntilAbleToStruggle = 1 - myItemXP.TimesStruggled - turnsSinceLastAction; if (ItemProcedures.ItemIncursDungeonPenalty(inanimateMe)) { turnsUntilAbleToStruggle *= 3; } if (!PvPStatics.ChaosMode && turnsUntilAbleToStruggle > 1 && turnsUntilAbleToStruggle <= TurnTimesStatics.GetItemMaxTurnsBuildup()) { var time = turnsUntilAbleToStruggle * TurnTimesStatics.GetTurnLengthInSeconds(); return($"You could be free in approximately <b>{SecondsToDurationString(time)}</b> if you keep fighting!"); } return(null); }
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 SpawnBimboBoss() { var bimboBoss = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId { BotId = AIStatics.BimboBossBotId }); if (bimboBoss == null) { var cmd = new CreatePlayer { FirstName = BossFirstName, LastName = BossLastName, Location = "stripclub_bar_seats", Gender = PvPStatics.GenderFemale, Health = 100000, Mana = 100000, MaxHealth = 100000, MaxMana = 100000, FormSourceId = BimboBossFormSourceId, Money = 2500, Level = 15, BotId = AIStatics.BimboBossBotId, }; var id = DomainRegistry.Repository.Execute(cmd); var playerRepo = new EFPlayerRepository(); var bimboEF = playerRepo.Players.FirstOrDefault(p => p.Id == id); bimboEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(bimboEF)); playerRepo.SavePlayer(bimboEF); // set up her AI directive so it is not deleted IAIDirectiveRepository aiRepo = new EFAIDirectiveRepository(); var directive = new AIDirective { OwnerId = id, Timestamp = DateTime.UtcNow, SpawnTurn = PvPWorldStatProcedures.GetWorldTurnNumber(), DoNotRecycleMe = true, }; aiRepo.SaveAIDirective(directive); for (var i = 0; i < 2; i++) { DomainRegistry.Repository.Execute(new GiveRune { ItemSourceId = RuneStatics.BIMBO_RUNE, PlayerId = bimboEF.Id }); } } }
public static string UseFurniture(int furnitureId, Player user) { IFurnitureRepository furnRepo = new EFFurnitureRepository(); var dbFurniture = furnRepo.Furnitures.FirstOrDefault(f => f.Id == furnitureId); dbFurniture.LastUseTimestamp = DateTime.UtcNow; dbFurniture.LastUsersIds = user.Id.ToString(); furnRepo.SaveFurniture(dbFurniture); var furnitureStatic = furnRepo.DbStaticFurniture.FirstOrDefault(f => f.dbType == dbFurniture.dbType); var logMessage = "<b>" + user.GetFullName() + "</b> used <b>" + dbFurniture.HumanName + "</b>."; CovenantProcedures.WriteCovenantLog(logMessage, (int)user.Covenant, false); // furniture gives AP reserve bonus if (furnitureStatic.APReserveRefillAmount > 0) { IPlayerRepository playerRepo = new EFPlayerRepository(); var dbPlayer = playerRepo.Players.FirstOrDefault(p => p.Id == user.Id); dbPlayer.ActionPoints_Refill += furnitureStatic.APReserveRefillAmount; if (dbPlayer.ActionPoints_Refill > TurnTimesStatics.GetActionPointReserveLimit()) { dbPlayer.ActionPoints_Refill = TurnTimesStatics.GetActionPointReserveLimit(); } dbPlayer.LastActionTimestamp = DateTime.UtcNow; playerRepo.SavePlayer(dbPlayer); return("You used " + dbFurniture.HumanName + ", a human voluntarily transformed into furniture and leased by your covenant, and gained " + furnitureStatic.APReserveRefillAmount + " reserve action points."); } // furniture gives effect else if (furnitureStatic.GivesEffectSourceId != null) { EffectProcedures.GivePerkToPlayer(furnitureStatic.GivesEffectSourceId.Value, user); PlayerProcedures.SetTimestampToNow(user); return("You used " + dbFurniture.HumanName + ", a human voluntarily transformed into furniture and leased by your covenant, and gained the " + EffectStatics.GetDbStaticEffect(furnitureStatic.GivesEffectSourceId.Value).FriendlyName + " effect."); } //furniture gives item else if (furnitureStatic.GivesItemSourceId != null) { ItemProcedures.GiveNewItemToPlayer(user, furnitureStatic.GivesItemSourceId.Value); PlayerProcedures.SetTimestampToNow(user); var itemGained = ItemStatics.GetStaticItem(furnitureStatic.GivesItemSourceId.Value); return("You used " + dbFurniture.HumanName + ", a human voluntarily transformed into furniture and leased by your covenant, gaining a " + itemGained.FriendlyName + "."); } return("ERROR"); }
public virtual ActionResult Index(int offset = 0) { var myMembershipId = User.Identity.GetUserId(); var me = PlayerProcedures.GetPlayerFromMembership(myMembershipId); if (DomainRegistry.Repository.FindSingle(new IsAccountLockedOut { userId = me.MembershipId })) { return(RedirectToAction(MVC.PvP.Play())); } DomainRegistry.Repository.Execute(new DeletePlayerExpiredMessages { OwnerId = me.Id }); var output = MessageProcedures.GetPlayerMessages(me, offset); output.InboxSize = 150; // if you are inanimate and are being worn, grab the data on who is wearing you if (me.Mobility == PvPStatics.MobilityInanimate) { var personWearingMe = ItemProcedures.BeingWornBy(me); if (personWearingMe != null) { output.WearerId = personWearingMe.Player.Id; output.WearerBotId = personWearingMe.Player.BotId; output.WearerName = personWearingMe.Player.GetFullName(); } } var isDonator = me.DonatorGetsMessagesRewards(); ViewBag.IsDonator = isDonator; if (isDonator) { output.InboxSize = 500; } ViewBag.ErrorMessage = TempData["Error"]; ViewBag.SubErrorMessage = TempData["SubError"]; ViewBag.Result = TempData["Result"]; return(View(MVC.Messages.Views.Messages, output)); }
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 static void TransferBooksFromLindellaToLorekeeper(Player lorekeeper) { var lindella = PlayerProcedures.GetPlayerFromBotId(AIStatics.LindellaBotId); var allLindellaItems = ItemProcedures.GetAllPlayerItems(lindella.Id).Where(i => i.Item.ConsumableSubItemType == (int)ItemStatics.ConsumableSubItemTypes.Spellbook || i.Item.ConsumableSubItemType == (int)ItemStatics.ConsumableSubItemTypes.Tome); foreach (var i in allLindellaItems) { var cmd = new ChangeItemOwner { ItemId = i.dbItem.Id, OwnerId = lorekeeper.Id }; DomainRegistry.Repository.Execute(cmd); } }
private static void PerformAnimateTransformation(Player victim, Player attacker, DbStaticForm targetForm, LogBox output) { var playerRepo = new EFPlayerRepository(); var dbVictim = playerRepo.Players.FirstOrDefault(p => p.Id == victim.Id); SkillProcedures.UpdateFormSpecificSkillsToPlayer(dbVictim, targetForm.Id); DomainRegistry.Repository.Execute(new ChangeForm { PlayerId = dbVictim.Id, FormSourceId = targetForm.Id }); // wipe out half of the target's mana dbVictim.Mana -= dbVictim.MaxMana / 2; if (dbVictim.Mana < 0) { dbVictim.Mana = 0; } // Remove any Self Restore entires. RemoveSelfRestore(dbVictim); var targetbuffs = ItemProcedures.GetPlayerBuffs(dbVictim); dbVictim = PlayerProcedures.ReadjustMaxes(dbVictim, targetbuffs); // take away some of the victim's XP based on the their level // target.XP += -2.5M * target.Level; playerRepo.SavePlayer(dbVictim); output.LocationLog += $"<br><b>{dbVictim.GetFullName()} was completely transformed into a {targetForm.FriendlyName} here.</b>"; output.AttackerLog += $"<br><b>You fully transformed {dbVictim.GetFullName()} into a {targetForm.FriendlyName}</b>!"; output.VictimLog += $"<br><b>You have been fully transformed into a {targetForm.FriendlyName}!</b>"; // Let the target know they are best friends with the angel plush. if (attacker.BotId == AIStatics.MinibossPlushAngelId) { output.VictimLog += $"<br><br><b>{attacker.GetFullName()}</b> was happy to make you into a new friend!<br>"; } TFEnergyProcedures.DeleteAllPlayerTFEnergiesOfFormSourceId(dbVictim.Id, targetForm.Id); StatsProcedures.AddStat(dbVictim.MembershipId, StatsProcedures.Stat__TimesAnimateTFed, 1); StatsProcedures.AddStat(attacker.MembershipId, StatsProcedures.Stat__TimesAnimateTFing, 1); }
public static void SpawnFae() { var fae = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId { BotId = AIStatics.JewdewfaeBotId }); if (fae == null) { var cmd = new CreatePlayer { FirstName = FirstName, LastName = LastName, Location = "apartment_dog_park", Gender = PvPStatics.GenderFemale, Health = 100000, Mana = 100000, MaxHealth = 100000, MaxMana = 100000, FormSourceId = FaeFormId, Money = 1000, Level = 7, BotId = AIStatics.JewdewfaeBotId }; var id = DomainRegistry.Repository.Execute(cmd); var playerRepo = new EFPlayerRepository(); var faeEF = playerRepo.Players.FirstOrDefault(p => p.Id == id); faeEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(faeEF)); playerRepo.SavePlayer(faeEF); // set up her AI directive so it is not deleted IAIDirectiveRepository aiRepo = new EFAIDirectiveRepository(); var directive = new AIDirective { OwnerId = id, Timestamp = DateTime.UtcNow, SpawnTurn = 0, DoNotRecycleMe = true, sVar1 = ";", // this is used to keep track of which players have interacted with her by appending their id to this string sVar2 = "", // this is used to keep track of which locations Jewdewfae has been in during the past cycle Var1 = 0, // this keeps track of how many people she has played with in the current location Var2 = 0 // this stores the turn number of Jewdewfae's last move }; aiRepo.SaveAIDirective(directive); } }
/// <summary> /// Delete any curses/blessing gained by items/pets from a player that they no longer posses, then give them any curses unique to a new item/pet. Psychopathic spellslingers make an exception and should never learn any new curses from items/pets they have gained. /// </summary> /// <param name="owner">The Player who owns/owned the item</param> /// <param name="newItemSourceId">The id of a new item that the player is gaining, if any.</param> public static void UpdateItemSpecificSkillsToPlayer(Player owner, int?newItemSourceId) { ISkillRepository skillRepo = new EFSkillRepository(); // delete all of the old item specific skills for the player IEnumerable <SkillViewModel> itemSpecificSkills = GetSkillViewModelsOwnedByPlayer__CursesOnly(owner.Id).ToList(); List <int> equippedItemSourceIds = ItemProcedures.GetAllPlayerItems_ItemOnly(owner.Id).Where(i => i.IsEquipped && i.ItemSourceId != newItemSourceId).Select(s => s.ItemSourceId).ToList(); var itemSpecificSkillsIds = new List <int>(); foreach (var s in itemSpecificSkills) { if (s.StaticSkill.ExclusiveToItemSourceId != null && !equippedItemSourceIds.Contains(s.StaticSkill.ExclusiveToItemSourceId.Value)) { itemSpecificSkillsIds.Add(s.dbSkill.Id); } } foreach (var id in itemSpecificSkillsIds) { skillRepo.DeleteSkill(id); } // don't give psychos any curses. Quit automatically if (owner.BotId == AIStatics.PsychopathBotId) { return; } // now give the player any skills they are missing if (newItemSourceId != null) { var itemSpecificSkillsToGive = SkillStatics.GetItemSpecificSkills(newItemSourceId.Value).ToList(); foreach (var skill in itemSpecificSkillsToGive) { // make sure player does not already have this skill due to some bug or othher var possibledbSkill = skillRepo.Skills.FirstOrDefault(s => s.OwnerId == owner.Id && s.SkillSourceId == skill.Id); if (possibledbSkill == null) { DomainRegistry.Repository.Execute(new CreateSkill { ownerId = owner.Id, skillSourceId = skill.Id }); } } } }
private static bool Teleport(Player player, string location, bool logLocations) { if (location == null) { return(false); } var destination = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == location); if (destination == null) { return(false); } if (player.InDuel > 0 || player.InQuest > 0 || player.MindControlIsActive || player.MoveActionPointDiscount < -TurnTimesStatics.GetActionPointReserveLimit()) { return(false); } if (ItemProcedures.GetAllPlayerItems(player.Id).Count(i => !i.dbItem.IsEquipped) > PvPStatics.MaxCarryableItemCountBase + player.ExtraInventory) { // Carryiing too much return(false); } if (destination.dbName.Contains("dungeon_")) { SkillProcedures.GiveSkillToPlayer(player.Id, PvPStatics.Dungeon_VanquishSpellSourceId); } PlayerProcedures.MovePlayer_InstantNoLog(player.Id, location); if (logLocations) { LocationLogProcedures.AddLocationLog(player.dbLocationName, $"Strange forces propel {player.GetFullName()} off to {destination.Name}!"); } else { LocationLogProcedures.AddLocationLog(player.dbLocationName, $"{player.GetFullName()} is whisked off to a faraway place!"); } LocationLogProcedures.AddLocationLog(location, $"{player.GetFullName()} is surprised to find they are suddenly here!"); PlayerLogProcedures.AddPlayerLog(player.Id, $"You are sent to {destination.Name}", false); return(true); }
public virtual ActionResult RemoveCurse(int itemId) { 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 at least one of the type of item needed var itemToUse = ItemProcedures.GetAllPlayerItems(me.Id).FirstOrDefault(i => i.dbItem.Id == itemId); if (itemToUse == null) { TempData["Error"] = "You do not own the item needed to do this."; return(RedirectToAction(MVC.PvP.Play())); } if (itemToUse.dbItem.ItemSourceId != ItemStatics.CurseLifterItemSourceId && itemToUse.dbItem.ItemSourceId != ItemStatics.ButtPlugItemSourceId) { TempData["Error"] = "This type of item cannot lift curses."; return(RedirectToAction(MVC.PvP.Play())); } IEnumerable <EffectViewModel2> effects = EffectProcedures.GetPlayerEffects2(me.Id).Where(e => e.Effect.IsRemovable && e.dbEffect.Duration > 0).ToList(); RemoveCurseViewModel output = new RemoveCurseViewModel { Effects = effects, Item = itemToUse }; return(View(MVC.Item.Views.RemoveCurse, output)); }
internal static string MovePlayer(Player player, string destination, int maxSpacesToMove, Action <Player, string> callback = null, bool timestamp = true) { var start = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == player.dbLocationName); var end = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == destination); if (destination == null || start == null || end == null) { return(null); } if (player.InDuel > 0 || player.InQuest > 0 || player.MindControlIsActive || player.MoveActionPointDiscount < -TurnTimesStatics.GetActionPointReserveLimit()) { return(null); } if (ItemProcedures.GetAllPlayerItems(player.Id).Count(i => !i.dbItem.IsEquipped) > PvPStatics.MaxCarryableItemCountBase + player.ExtraInventory) { // Carryiing too much return(null); } IPlayerRepository playerRepo = new EFPlayerRepository(); var target = playerRepo.Players.FirstOrDefault(p => p.Id == player.Id); var pathTiles = PathfindingProcedures.GetMovementPath(start, end); var costPerTile = Math.Max(0, 1 - target.MoveActionPointDiscount); // Cap distance, plus don't exceed number of tiles or available AP var maxDistance = (costPerTile == 0) ? 200 : Math.Floor(target.ActionPoints / costPerTile); var spacesToMove = (int)Math.Min(maxDistance, pathTiles.Count()); spacesToMove = Math.Min(maxSpacesToMove, spacesToMove); if (spacesToMove <= 0) { return(null); } var stoppingTile = pathTiles[spacesToMove - 1]; PlayerProcedures.MovePlayerMultipleLocations(player, stoppingTile, spacesToMove * costPerTile, timestamp: timestamp, callback: callback); return(stoppingTile); }
private static decimal CalculateTFEBonusBuff(Player victim, Player attacker) { var attackerTFEnergyBonus = ItemProcedures.GetPlayerBuffs(attacker).SpellExtraTFEnergyPercent(); var victimTFEnergyReduction = ItemProcedures.GetPlayerBuffs(victim).SpellTFEnergyDamageResistance(); // Collect the attacker ExtraTFEnergyPercent and modify it by the defenders TFEnergyDamageResistance var modifiedTFEnergyPercent = 1 + ((attackerTFEnergyBonus - victimTFEnergyReduction) / 100M); // Cap the damage modifier at 0.5 / 2.0 if (modifiedTFEnergyPercent < 0.5M) { modifiedTFEnergyPercent = 0.5M; } if (modifiedTFEnergyPercent > 2.0M) { modifiedTFEnergyPercent = 2.0M; } return(modifiedTFEnergyPercent); }
/// <summary> /// Spawns Narcissa into the world and sets her initial blank AI Directive /// </summary> public static void SpawnFaeBoss() { var faeboss = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId { BotId = AIStatics.FaebossBotId }); if (faeboss == null) { var cmd = new CreatePlayer { FirstName = FirstName, LastName = LastName, Location = SpawnLocation, Gender = PvPStatics.GenderFemale, Health = 100000, Mana = 100000, MaxHealth = 100000, MaxMana = 100000, FormSourceId = FaeBossFormId, Money = 1000, Mobility = PvPStatics.MobilityFull, Level = 25, BotId = AIStatics.FaebossBotId, }; var id = DomainRegistry.Repository.Execute(cmd); var playerRepo = new EFPlayerRepository(); var faebossEF = playerRepo.Players.FirstOrDefault(p => p.Id == id); faebossEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(faebossEF)); playerRepo.SavePlayer(faebossEF); AIDirectiveProcedures.GetAIDirective(id); for (var i = 0; i < 2; i++) { DomainRegistry.Repository.Execute(new GiveRune { ItemSourceId = RuneStatics.NARCISSA_RUNE, PlayerId = faebossEF.Id }); } } }
public virtual ActionResult MyInventory() { var myMembershipId = User.Identity.GetUserId(); var me = PlayerProcedures.GetPlayerFromMembership(myMembershipId); if (me.MembershipId == myMembershipId) { ViewBag.BelongsToPlayer = "block"; } else { ViewBag.BelongsToPlayer = "none"; } var output = new InventoryBonusesViewModel { Items = DomainRegistry.Repository.Find(new GetItemsOwnedByPlayer { OwnerId = me.Id }).Where(i => i.EmbeddedOnItem == null), Bonuses = ItemProcedures.GetPlayerBuffs(me), Health = me.Health, MaxHealth = me.MaxHealth, Mana = me.Mana, MaxMana = me.MaxMana, CurrentCarryCount = DomainRegistry.Repository.FindSingle(new GetCurrentCarryWeight { PlayerId = me.Id }), MaxInventorySize = ItemProcedures.GetInventoryMaxSize(me) }; ViewBag.ErrorMessage = TempData["Error"]; ViewBag.SubErrorMessage = TempData["SubError"]; ViewBag.Result = TempData["Result"]; ViewBag.ShowDetailLinks = true; ViewBag.ItemsUsedThisTurn = me.ItemsUsedThisTurn; return(View(MVC.PvP.Views.Inventory, output)); }
public virtual ActionResult UnembedRunes() { var me = PlayerProcedures.GetPlayerFromMembership(User.Identity.GetUserId()); try { TempData["Result"] = DomainRegistry.Repository.Execute(new UnembedAllRunes { PlayerId = me.Id }); IPlayerRepository playerRepo = new EFPlayerRepository(); var newMe = playerRepo.Players.FirstOrDefault(p => p.Id == me.Id); newMe.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(newMe)); playerRepo.SavePlayer(newMe); } catch (DomainException e) { TempData["Error"] = e.Message; } return(RedirectToAction(MVC.Item.MyInventory())); }
public static void Spawn() { var boss = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId { BotId = AIStatics.MotorcycleGangLeaderBotId }); if (boss == null) { var cmd = new CreatePlayer { FirstName = BossFirstName, LastName = BossLastName, Location = SpawnLocation, Gender = PvPStatics.GenderFemale, Health = 100000, Mana = 100000, MaxHealth = 100000, MaxMana = 100000, FormSourceId = BossFormId, Money = 2000, Mobility = PvPStatics.MobilityFull, Level = 20, BotId = AIStatics.MotorcycleGangLeaderBotId, }; var id = DomainRegistry.Repository.Execute(cmd); var playerRepo = new EFPlayerRepository(); var bossEF = playerRepo.Players.FirstOrDefault(p => p.Id == id); bossEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(bossEF)); playerRepo.SavePlayer(bossEF); for (var i = 0; i < 2; i++) { DomainRegistry.Repository.Execute(new GiveRune { ItemSourceId = RuneStatics.MOTORCYCLE_RUNE, PlayerId = bossEF.Id }); } } }
public static void EquipDefeatedPlayer(Player owner, Player defeatedPlayer) { var playerIsBot = owner.BotId <= AIStatics.PsychopathBotId; if (owner.BotId == AIStatics.PsychopathBotId && EffectProcedures.PlayerHasActiveEffect(owner.Id, JokeShopProcedures.PSYCHOTIC_EFFECT)) { // Do not apply to temporary psychos to avoid circumventing inventory rules playerIsBot = false; } if (playerIsBot) { // have the bot equip any new item they are carrying (psychos take off duplicates later in world update) var item = ItemProcedures.GetAllPlayerItems(owner.Id) .FirstOrDefault(i => i.dbItem.FormerPlayerId == defeatedPlayer.Id); if (item != null) { ItemProcedures.EquipItem(item.dbItem.Id, true); } } }
public static void SpawnDonna() { var donna = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId { BotId = AIStatics.DonnaBotId }); if (donna == null) { var cmd = new CreatePlayer { FirstName = FirstName, LastName = LastName, Location = "ranch_bedroom", Gender = PvPStatics.GenderFemale, Health = 100000, Mana = 100000, MaxHealth = 100000, MaxMana = 100000, FormSourceId = DonnaFormSourceId, Money = 1000, Level = 20, BotId = AIStatics.DonnaBotId, }; var id = DomainRegistry.Repository.Execute(cmd); var playerRepo = new EFPlayerRepository(); var donnaEF = playerRepo.Players.FirstOrDefault(p => p.Id == id); donnaEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(donnaEF)); playerRepo.SavePlayer(donnaEF); for (var i = 0; i < 2; i++) { DomainRegistry.Repository.Execute(new GiveRune { ItemSourceId = RuneStatics.DONNA_RUNE, PlayerId = donnaEF.Id }); } } }
public void Should_retrieve_correct_xp_requirement_for_inanimate_levelup(int level, int expectedXp) { Assert.That(ItemProcedures.GetXPRequiredForItemPetLevelup(level), Is.EqualTo(expectedXp)); }