private static IEnumerable <InstinctData> MaidActions(IPlayerRepository playerRepo, IEnumerable <InstinctData> mcPlayers, Random rand) { // Maids - find places to clean var mcMaids = mcPlayers.Where(p => JokeShopProcedures.MAIDS.Any(maidForm => p.FormSourceId == maidForm)).ToList(); foreach (var maid in mcMaids) { var maidPlayer = playerRepo.Players.FirstOrDefault(p => p.Id == maid.Id); var maidLoc = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == maidPlayer.dbLocationName); if (maidLoc != null) { string nextLoc; string newContract = ""; string[] cleaningContracts = { "coffee_shop", "tavern", "oldoak_apartments", "mansion", "ranch_inside", "castle", "salon" }; if (cleaningContracts.Contains(maidLoc.Region)) { nextLoc = LocationsStatics.GetRandomLocation_InRegion(maidLoc.Region); } else { newContract = "One of the local facilities has just signed a new contract with you! "; nextLoc = LocationsStatics.GetRandomLocation_InRegion(cleaningContracts[rand.Next(cleaningContracts.Count())]); } var stoppedAt = EnvironmentPrankProcedures.MovePlayer(maidPlayer, nextLoc, 20, timestamp: false); if (stoppedAt == nextLoc || maidPlayer.dbLocationName == nextLoc) { var here = LocationsStatics.GetConnectionName(nextLoc); string[] activities = { "dusting away the cobwebs", "vaccuuming the floor", "washing up the dishes", "doing the laundry", "serving refreshments", "sweeping the trash", "handing out freshly baked cupcakes" }; var activity = activities[rand.Next(activities.Count())]; PlayerLogProcedures.AddPlayerLog(maidPlayer.Id, $"{newContract}You arrive at <b>{here}</b> and start {activity}!", true); LocationLogProcedures.AddLocationLog(nextLoc, $"{maidPlayer.GetFullName()} arrives here and starts <b>{activity}</b>."); } else if (stoppedAt != null) { var here = LocationsStatics.GetConnectionName(stoppedAt); PlayerLogProcedures.AddPlayerLog(maidPlayer.Id, $"{newContract}You quickly head to your new job but only get as far as <b>{here}</b>.", true); } } mcPlayers = mcPlayers.Where(p => p.Id != maid.Id); } return(mcPlayers); }
public static void Run(int turnNumber, MinibossData data) { IPlayerRepository playerRepo = new EFPlayerRepository(); var miniboss = playerRepo.Players.FirstOrDefault(p => p.BotId == data.BotId && p.Mobility == PvPStatics.MobilityFull); // spawn a new boss if last is null if (miniboss == null && rand.NextDouble() < ChanceToRespawn) { var spawnLocation = LocationsStatics.GetRandomLocation_InRegion(data.Region); var cmd = new CreatePlayer { FirstName = data.Title, LastName = NameService.GetRandomLastName(), Location = spawnLocation, Gender = PvPStatics.GenderFemale, Health = 100000, Mana = 100000, MaxHealth = 100000, MaxMana = 100000, FormSourceId = data.FormSourceId, Money = 2000, Mobility = PvPStatics.MobilityFull, Level = GetLevel(turnNumber), BotId = data.BotId }; var id = DomainRegistry.Repository.Execute(cmd); var minibossEF = playerRepo.Players.FirstOrDefault(p => p.Id == id); minibossEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(minibossEF)); playerRepo.SavePlayer(minibossEF); for (var i = 0; i < 2; i++) { DomainRegistry.Repository.Execute(new GiveRune { ItemSourceId = data.RuneIdToGive, PlayerId = minibossEF.Id }); } } if (miniboss != null && miniboss.Mobility == PvPStatics.MobilityFull) { // move to a randomn location in this region var nextLocation = LocationsStatics.GetRandomLocation_InRegion(data.Region); var actualNextLocation = AIProcedures.MoveTo(miniboss, nextLocation, 11); miniboss.dbLocationName = actualNextLocation; miniboss.Mana = miniboss.MaxMana; playerRepo.SavePlayer(miniboss); var playersHere = GetEligibleTargetsAtLocation(actualNextLocation); foreach (var target in playersHere) { var(complete, _) = AttackProcedures.Attack(miniboss, target, ChooseSpell(miniboss, turnNumber, data.Spells)); if (complete) { AIProcedures.EquipDefeatedPlayer(miniboss, target); } } } }
private static IEnumerable <InstinctData> GhostActions(IPlayerRepository playerRepo, IEnumerable <InstinctData> mcPlayers, Random rand) { // Ghosts - haunt old buildings var mcGhosts = mcPlayers.Where(p => JokeShopProcedures.GHOSTS.Any(ghostForm => p.FormSourceId == ghostForm)).ToList(); foreach (var ghost in mcGhosts) { var ghostPlayer = playerRepo.Players.FirstOrDefault(p => p.Id == ghost.Id); var ghostLoc = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == ghostPlayer.dbLocationName); if (ghostLoc != null) { string nextLoc; string[] haunts = { "mansion", "castle" }; if (haunts.Contains(ghostLoc.Region)) { nextLoc = LocationsStatics.GetRandomLocation_InRegion(ghostLoc.Region); } else { nextLoc = LocationsStatics.GetRandomLocation_InRegion(haunts[rand.Next(haunts.Count())]); } // Check whether we can haunt the current tile // An enhancement would be to allow ghosts to move through walls var stoppedAt = EnvironmentPrankProcedures.MovePlayer(ghostPlayer, nextLoc, 20, timestamp: false); var canHaunt = stoppedAt == nextLoc || ghostPlayer.dbLocationName == nextLoc; if (!canHaunt && stoppedAt != null) { var stoppedAtTile = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == stoppedAt); canHaunt = haunts.Contains(stoppedAtTile.Region); } if (canHaunt) { var here = LocationsStatics.GetConnectionName(nextLoc); var cutoff = DateTime.UtcNow.AddMinutes(-TurnTimesStatics.GetOfflineAfterXMinutes()); var candidates = playerRepo.Players .Where(p => p.dbLocationName == nextLoc && p.LastActionTimestamp >= cutoff && p.Id != ghostPlayer.Id && p.Mobility == PvPStatics.MobilityFull && p.InDuel <= 0 && p.InQuest <= 0 && p.BotId == AIStatics.ActivePlayerBotId) .ToList(); if (candidates.Any()) { var victim = candidates[rand.Next(candidates.Count())]; string[] calls = { "Boo!", "Whooo!" }; var call = calls[rand.Next(calls.Count())]; PlayerLogProcedures.AddPlayerLog(ghostPlayer.Id, $"After entering {here} you tap {victim.GetFullName()} on the shoulder and shout <b>\"{call}\"</b>!", true); PlayerLogProcedures.AddPlayerLog(victim.Id, $"{ghostPlayer.GetFullName()} taps you on the shoulder and shouts <b>\"{call}\"</b>!", true); LocationLogProcedures.AddLocationLog(nextLoc, $"{ghostPlayer.GetFullName()} shouts <b>\"{call}\"</b> at {victim.GetFullName()}."); } else { string[] activities = { "rattles some chains", "wails like a banshee", "floats through a wall", "lights a candle", "makes the lights flicker", "fades into the background", "knocks a book off a shelf", "melts into a pool of ectoplasm", "sends a a chill through the air" }; var activity = activities[rand.Next(activities.Count())]; PlayerLogProcedures.AddPlayerLog(ghostPlayer.Id, $"You begin haunting {here}!", true); LocationLogProcedures.AddLocationLog(nextLoc, $"<b>{ghostPlayer.GetFullName()} {activity}</b>."); } } else if (stoppedAt != null) { var here = LocationsStatics.GetConnectionName(stoppedAt); PlayerLogProcedures.AddPlayerLog(ghostPlayer.Id, $"The spirits call you to <b>{here}</b>.", true); } } mcPlayers = mcPlayers.Where(p => p.Id != ghost.Id); } return(mcPlayers); }
public static void RunPetMerchantActions(int turnNumber) { IPlayerRepository playerRepo = new EFPlayerRepository(); var petMerchant = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.WuffieBotId); if (petMerchant.Mobility == PvPStatics.MobilityFull) { if (petMerchant.Health < petMerchant.MaxHealth || petMerchant.Mana < petMerchant.MaxMana) { var buffs = ItemProcedures.GetPlayerBuffs(petMerchant); if (petMerchant.Health < petMerchant.MaxHealth) { petMerchant.Health += 200; var logmessage = "<span class='playerCleansingNotification'>" + petMerchant.GetFullName() + " cleansed here.</span>"; LocationLogProcedures.AddLocationLog(petMerchant.dbLocationName, logmessage); } if (petMerchant.Mana < petMerchant.MaxMana) { petMerchant.Mana += 200; var logmessage = "<span class='playerMediatingNotification'>" + petMerchant.GetFullName() + " meditated here.</span>"; LocationLogProcedures.AddLocationLog(petMerchant.dbLocationName, logmessage); } petMerchant.NormalizeHealthMana(); } IAIDirectiveRepository aiRepo = new EFAIDirectiveRepository(); var turnMod = turnNumber % (24 * 4); var regionIndex = turnMod / 24; var newLocation = ""; switch (regionIndex) { case 0: newLocation = LocationsStatics.GetRandomLocation_InRegion("ranch_outside"); break; case 1: newLocation = LocationsStatics.GetRandomLocation_InRegion("forest"); break; case 2: newLocation = LocationsStatics.GetRandomLocation_InRegion("campground"); break; default: newLocation = LocationsStatics.GetRandomLocation_InRegion("park"); break; } var actualNewLocation = AIProcedures.MoveTo(petMerchant, newLocation, 6); petMerchant.dbLocationName = actualNewLocation; playerRepo.SavePlayer(petMerchant); if (turnNumber % 11 == 5) { DomainRegistry.Repository.Execute(new MoveAbandonedPetsToWuffie { WuffieId = petMerchant.Id }); } } }