Exemplo n.º 1
0
        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()));
        }
Exemplo n.º 2
0
        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()));
        }
Exemplo n.º 3
0
        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);
                }
            }
        }
Exemplo n.º 4
0
        public virtual ActionResult ViewBio(string id)
        {
            var player = PlayerProcedures.GetPlayerFromMembership(id);

            ViewBag.Name = player.GetFullName();

            var output = new BioPageViewModel();

            output.Player    = player;
            output.PlayerBio = SettingsProcedures.GetPlayerBioFromMembershipId(id);
            if (output.PlayerBio == null)
            {
                TempData["Error"] = "It seems that this player has not written a player biography yet.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            output.Badges  = StatsProcedures.GetPlayerBadges(player.MembershipId);
            output.IsMyBio = User.Identity.GetUserId() == player.MembershipId;

            IContributionRepository contributionRepo = new EFContributionRepository();

            IEnumerable <BioPageContributionViewModel> mySpells = from c in contributionRepo.Contributions
                                                                  where c.OwnerMembershipId == player.MembershipId && c.ProofreadingCopy && c.IsLive
                                                                  select new BioPageContributionViewModel
            {
                SpellName = c.Skill_FriendlyName,
                FormName  = c.Form_FriendlyName,
            };

            IEffectContributionRepository effectContribtionRepo = new EFEffectContributionRepository();

            IEnumerable <BioPageEffectContributionViewModel> myEffects = from c in effectContribtionRepo.EffectContributions
                                                                         where c.OwnerMemberhipId == player.MembershipId && c.ProofreadingCopy && c.IsLive
                                                                         select new BioPageEffectContributionViewModel
            {
                EffectName = c.Effect_FriendlyName,
                SpellName  = c.Skill_FriendlyName
            };

            myEffects = myEffects.ToList();

            ViewBag.MyContributions       = mySpells.ToList();
            ViewBag.MyEffectContributions = myEffects.ToList();

            return(View(MVC.Settings.Views.ViewBio, output));
        }
Exemplo n.º 5
0
        public static string PlaceBountyOnPlayersHead(Player player, Random rand = null)
        {
            // Only place bounties on PvP players
            if (player.GameMode != (int)GameModeStatics.GameModes.PvP)
            {
                return(null);
            }

            rand = rand ?? new Random();
            var bountyEffectSourceId = BountyProcedures.PlaceBounty(player, rand);

            if (!bountyEffectSourceId.HasValue)
            {
                return(null);
            }

            var details = BountyProcedures.BountyDetails(player, bountyEffectSourceId.Value);

            if (details == null)
            {
                return(null);
            }

            StatsProcedures.AddStat(player.MembershipId, StatsProcedures.Stat__BountyCount, 1);

            // Put up some wanted posters
            var locations       = LocationsStatics.LocationList.GetLocation.Select(l => l.dbName).ToList();
            var locationMessage = $"<b>Wanted:</b>  A reward is on offer to whoever turns <b>{player.GetFullName()}</b> into a <b>{details.Form?.FriendlyName}</b>!";

            for (var i = 0; i < 10; i++)
            {
                var loc = locations[rand.Next(locations.Count())];
                LocationLogProcedures.AddLocationLog(loc, locationMessage);
                locations.Remove(loc);
            }

            var playerMessage = $"The spirits in the store are enraged by your actions!  They are too out of phase to attack you directly and instead choose to place a bounty on your head!  Beware of the townspeople trying to turn you into a <b>{details.Form?.FriendlyName}</b>!";

            PlayerLogProcedures.AddPlayerLog(player.Id, playerMessage, true);

            return(playerMessage);
        }
Exemplo n.º 6
0
        public static string DiceGame(Player player)
        {
            var target = 69;

            // /roll 4d20
            var die1  = PlayerProcedures.RollDie(20);
            var die2  = PlayerProcedures.RollDie(20);
            var die3  = PlayerProcedures.RollDie(20);
            var die4  = PlayerProcedures.RollDie(20);
            var total = die1 + die2 + die3 + die4;

            // Arbitrary score calculation, trying to avoid any big advantage for those who roll more often
            int score;

            if (total == target)
            {
                score = total;
            }
            else
            {
                var distance = Math.Abs(total - target);

                if (distance <= 11)
                {
                    score = (11 - distance) * 4;
                }
                else
                {
                    score = (11 - distance) / 10;
                }
            }

            StatsProcedures.AddStat(player.MembershipId, StatsProcedures.Stat__DiceGameScore, score);

            LocationLogProcedures.AddLocationLog(player.dbLocationName, $"{player.GetFullName()} rolls {die1}, {die2}, {die3} and {die4}, giving a total of <b>{total}</b>.");

            return($"You pick up four 20-sided dice and roll {die1}, {die2}, {die3} and {die4}, giving a total of <b>{total}</b>.  Your score is <b>{score}</b>.");
        }
Exemplo n.º 7
0
        public virtual ActionResult PlayerStatsTopOfType(string type)
        {
            var output = StatsProcedures.GetLeaderPlayersInStat(type);

            return(PartialView(MVC.Settings.Views.partial.PlayerStatsTopOfType, output));
        }
Exemplo n.º 8
0
        public virtual ActionResult PlayerStatsLeaders()
        {
            var output = StatsProcedures.GetPlayerMaxStats().ToList();

            return(View(MVC.Leaderboard.Views.PlayerStatsLeaders, output));
        }
Exemplo n.º 9
0
        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()));
        }
Exemplo n.º 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()));
        }
Exemplo n.º 11
0
        public static void ClaimReward(Player attacker, Player victim, DbStaticForm victimNewForm)
        {
            if (attacker == null || victim == null || victimNewForm == null)
            {
                return;
            }

            // Ensure victim is still in PvP, or not a player (in case we want to support bounties on NPCs)
            if (victim.BotId == AIStatics.ActivePlayerBotId && victim.GameMode != (int)GameModeStatics.GameModes.PvP)
            {
                return;
            }

            // NPCs are not eligible to claim bounties
            if (attacker.BotId != AIStatics.ActivePlayerBotId)
            {
                return;
            }

            // Only reward PvP players to avoid friend list/alt abuse
            if (attacker.GameMode != (int)GameModeStatics.GameModes.PvP)
            {
                return;
            }

            var bountyStaticEffectIds = MAPPINGS.Select(se => se.EffectSourceId);
            var victimEffects         = EffectProcedures.GetPlayerEffects2(victim.Id).Where(e => bountyStaticEffectIds.Contains(e.dbEffect.EffectSourceId));
            var award = 0;

            foreach (var victimEffect in victimEffects)
            {
                var bounty = BountyDetails(victim, victimEffect.dbEffect.EffectSourceId);

                if (bounty == null)
                {
                    continue;
                }

                if (victimNewForm.Id == bounty.Form?.Id)
                {
                    // Victim has been turned into the requested form - full reward
                    award = bounty.CurrentReward;
                }
                else if (victimNewForm.ItemSourceId.HasValue)
                {
                    // Award half bounty for a different inanimate form of the same type
                    IDbStaticItemRepository itemsRepo = new EFDbStaticItemRepository();
                    var itemForm = itemsRepo.DbStaticItems.FirstOrDefault(i => i.Id == victimNewForm.ItemSourceId.Value);

                    if (itemForm?.ItemType == bounty.Category)
                    {
                        award = bounty.CurrentReward / 2;
                    }
                }

                if (award > 0)
                {
                    // Release the victim from the claimed bounty
                    EffectProcedures.SetPerkDurationToZero(victimEffect.dbEffect.EffectSourceId, victim);

                    // Award bounty funds to attacker
                    PlayerLogProcedures.AddPlayerLog(attacker.Id, $"For turning {victim.GetFullName()} into a {victimNewForm.FriendlyName} you claim a bounty of {award} arpeyjis.", true);
                    PlayerProcedures.GiveMoneyToPlayer(attacker, award);

                    StatsProcedures.AddStat(attacker.MembershipId, StatsProcedures.Stat__BountiesClaimed, award);

                    break;
                }
            }
        }
Exemplo n.º 12
0
        public virtual ActionResult EndQuest(bool restore)
        {
            var myMembershipId = User.Identity.GetUserId();
            var me             = PlayerProcedures.GetPlayerFromMembership(myMembershipId);

            // assert that this player is in a quest
            if (me.InQuest <= 0)
            {
                TempData["Error"] = "You are not in a quest.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            var quest = QuestProcedures.GetQuest(me.InQuest);
            var state = QuestProcedures.GetQuestState(me.InQuestState);

            // assert that there is an end state to this quest state
            if (!state.QuestEnds.Any())
            {
                TempData["Error"]    = "You are not yet at the end of your quest!";
                TempData["SubError"] = "If it is impossible for you to continue with this quest, you may abandon it.";
                return(RedirectToAction(MVC.Quest.Quest()));
            }

            var endType = state.QuestEnds.First().EndType;

            // if the player is not animate, either restore them or create a new item for them to exist as
            if (me.Mobility != PvPStatics.MobilityFull)
            {
                if (restore && me.Mobility != PvPStatics.MobilityFull)
                {
                    PlayerProcedures.InstantRestoreToBase(me);
                }
                else if (!restore)
                {
                    var newform = FormStatics.GetForm(me.FormSourceId);
                    ItemProcedures.PlayerBecomesItem(me, newform, null);
                }
            }

            // fail!
            if (endType == (int)QuestStatics.QuestOutcomes.Failed)
            {
                QuestProcedures.PlayerEndQuest(me, (int)QuestStatics.QuestOutcomes.Failed);
                QuestProcedures.ClearQuestPlayerVariables(me.Id, me.InQuest);

                StatsProcedures.AddStat(me.MembershipId, StatsProcedures.Stat__QuestsFailed, 1);

                TempData["Result"] = "You unfortunately failed the quest <b>" + quest.Name + "</b>.  Better luck next time!  If there is one...";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            // pass!
            var victoryMessage = QuestProcedures.PlayerEndQuest(me, (int)QuestStatics.QuestOutcomes.Completed);

            QuestProcedures.ClearQuestPlayerVariables(me.Id, me.InQuest);

            StatsProcedures.AddStat(me.MembershipId, StatsProcedures.Stat__QuestsPassed, 1);

            TempData["Result"] = "Congratulations, you completed the quest <b>" + quest.Name + "</b>!" + victoryMessage;

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