Пример #1
0
        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 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!");
        }
Пример #3
0
        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 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);
        }
Пример #5
0
        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);
        }
Пример #7
0
        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 string WanderAimlessly(Player player, Random rand = 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);
            }

            rand = rand ?? new Random();

            IPlayerRepository playerRepo = new EFPlayerRepository();
            var target = playerRepo.Players.FirstOrDefault(p => p.Id == player.Id);
            var name   = target.GetFullName();

            var costPerTile  = Math.Max(0, 1 - target.MoveActionPointDiscount);
            var maxDistance  = (costPerTile == 0) ? 200 : Math.Floor(target.ActionPoints / costPerTile);
            var spacesToMove = (int)Math.Min(maxDistance, rand.Next(10, 16));

            string nextTileId = player.dbLocationName;
            var    nextTile   = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == nextTileId);

            for (var i = spacesToMove; i > 0; i--)
            {
                var currentTile = nextTile;

                switch (rand.Next(4))
                {
                case 0:
                    nextTileId = currentTile.Name_North ?? currentTile.Name_South ?? currentTile.Name_East ?? currentTile.Name_West;
                    break;

                case 1:
                    nextTileId = currentTile.Name_South ?? currentTile.Name_East ?? currentTile.Name_West ?? currentTile.Name_North;
                    break;

                case 2:
                    nextTileId = currentTile.Name_East ?? currentTile.Name_West ?? currentTile.Name_North ?? currentTile.Name_South;
                    break;

                case 3:
                    nextTileId = currentTile.Name_West ?? currentTile.Name_North ?? currentTile.Name_South ?? currentTile.Name_East;
                    break;
                }

                nextTile = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == nextTileId);

                LocationLogProcedures.AddLocationLog(currentTile.dbName, name + " left toward " + nextTile.Name);
                LocationLogProcedures.AddLocationLog(nextTileId, name + " entered from " + currentTile.Name);
            }

            target.ActionPoints  -= spacesToMove * costPerTile;
            target.dbLocationName = nextTileId;
            playerRepo.SavePlayer(target);

            return("The room starts to shake.  A waving cat on a nearby display rattles, edging forward before falling off the shelf and smashing to the ground.  The structure of the room creaks as the ceiling contorts.  All the clown faces seem to be staring at you.  Suddenly this feels a very unsettling place.  You get a bad feeling that something is about to happen to this sinister and claustrophobic shop.  There's only one thing for it:  You race out the door and run.  It doesn't matter which direction you go in, just so long as you get out of here!");
        }
        public static string RareFind(Player player, Random rand = null)
        {
            rand = rand ?? new Random();
            var roll = rand.Next(3);

            if (roll < 1)
            {
                // Quality consumable
                int[] itemTypes = { ItemStatics.CurseLifterItemSourceId,
                                    ItemStatics.AutoTransmogItemSourceId,
                                    ItemStatics.WillpowerBombVolatileItemSourceId,
                                    ItemStatics.SelfRestoreItemSourceId,
                                    ItemStatics.LullabyWhistleItemSourceId,
                                    ItemStatics.SpellbookLargeItemSourceId,
                                    ItemStatics.TeleportationScrollItemSourceId };

                var itemType = itemTypes[rand.Next(itemTypes.Count())];

                return(ItemProcedures.GiveNewItemToPlayer(player, itemType));
            }
            else if (roll < 2)
            {
                // Regular item
                var level    = (int)(rand.NextDouble() * rand.NextDouble() * 6 + 1);
                var itemType = ItemProcedures.GetRandomPlayableItem();
                var message  = ItemProcedures.GiveNewItemToPlayer(player, itemType, level);

                // Don't permit player to carry untamed pet (pet items aren't automatically tamed)
                if (itemType.ItemType == PvPStatics.ItemType_Pet)
                {
                    var unequippedPet = ItemProcedures.GetAllPlayerItems(player.Id).FirstOrDefault(i => i.Item.ItemType == PvPStatics.ItemType_Pet && !i.dbItem.IsEquipped);

                    if (unequippedPet != null)
                    {
                        ItemProcedures.DropItem(unequippedPet.dbItem.Id);
                    }
                }

                return(message);
            }
            else
            {
                // Rune
                var levelRoll = rand.Next(10);
                int level;

                if (levelRoll < 2)      // 20%
                {
                    level = 3;          // Standard
                }
                else if (levelRoll < 9) // 70%
                {
                    level = 5;          // Great
                }
                else  // 10%
                {
                    level = 7;  // Major
                }

                var runeId = DomainRegistry.Repository.FindSingle(new GetRandomRuneAtLevel {
                    RuneLevel = level, Random = rand
                });
                DomainRegistry.Repository.Execute(new GiveRune {
                    ItemSourceId = runeId, PlayerId = player.Id
                });

                return("You have found a rune!");
            }
        }
Пример #10
0
        public virtual ActionResult StripVictim(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__StripFormSourceId);

            if (errorsBox.HasError)
            {
                TempData["Error"]    = errorsBox.Error;
                TempData["SubError"] = errorsBox.SubError;
                return(RedirectToAction(MVC.MindControl.MindControlList()));
            }

            var victimItems = ItemProcedures.GetAllPlayerItems(victim.Id).ToList();

            if (victimItems.Any())
            {
                double max  = victimItems.Count();
                var    rand = new Random();
                var    num  = rand.NextDouble();

                var index      = Convert.ToInt32(Math.Floor(num * max));
                var itemToDrop = victimItems.ElementAt(index);

                MindControlProcedures.AddCommandUsedToMindControl(me, victim, MindControlStatics.MindControl__StripFormSourceId);

                var attackerMessage = "";

                if (itemToDrop.Item.ItemType != PvPStatics.ItemType_Pet)
                {
                    attackerMessage = "You commanded " + victim.GetFullName() + " to drop something.  They let go of a " + itemToDrop.Item.FriendlyName + " that they were carrying.";
                }
                else
                {
                    attackerMessage = "You commanded " + victim.GetFullName() + " to drop something.  They released their pet " + itemToDrop.Item.FriendlyName + " that they had tamed.";
                }

                PlayerLogProcedures.AddPlayerLog(me.Id, attackerMessage, false);
                TempData["Result"] = attackerMessage;

                var victimMessage = "";

                if (itemToDrop.Item.ItemType != PvPStatics.ItemType_Pet)
                {
                    victimMessage = me.GetFullName() + " commanded you to to drop something. You had no choice but to go of a " + itemToDrop.Item.FriendlyName + " that you were carrying.";
                }
                else
                {
                    victimMessage = me.GetFullName() + " commanded you to drop something. You had no choice but to release your pet " + itemToDrop.Item.FriendlyName + " that you had tamed.";
                }

                PlayerLogProcedures.AddPlayerLog(victim.Id, victimMessage, true);

                ItemProcedures.DropItem(itemToDrop.dbItem.Id);

                var locationLogMessage = victim.GetFullName() + " was forced to drop their <b>" + itemToDrop.Item.FriendlyName + "</b> by someone mind controlling them.";
                LocationLogProcedures.AddLocationLog(victim.dbLocationName, locationLogMessage);

                StatsProcedures.AddStat(me.MembershipId, StatsProcedures.Stat__MindControlCommandsIssued, 1);
            }
            else
            {
                TempData["Error"] = "It seems " + victim.GetFullName() + " was not carrying or wearing anything to drop!";
            }

            return(RedirectToAction(MVC.PvP.Play()));
        }