public static void EndEvent(Player donna)
        {
            PvPWorldStatProcedures.Boss_EndDonna();
            var damages = AIProcedures.GetTopAttackers(-4, 20);
            IPlayerRepository playerRepo = new EFPlayerRepository();

            // top player gets 800 XP, each player down the line receives 35 fewer
            var i         = 0;
            var maxReward = 800;

            for (var r = 0; r < damages.Count; r++)
            {
                var damage = damages.ElementAt(r);
                var victor = playerRepo.Players.FirstOrDefault(p => p.Id == damage.PlayerId);
                if (victor == null)
                {
                    continue;
                }
                var reward = maxReward - (i * 40);
                victor.XP += reward;
                i++;

                PlayerLogProcedures.AddPlayerLog(victor.Id, "<b>For your contribution in defeating " + donna.GetFullName() + ", you earn " + reward + " XP from your spells cast against the mythical sorceress.</b>", true);

                playerRepo.SavePlayer(victor);

                // top three get runes
                if (r <= 2 && victor.Mobility == PvPStatics.MobilityFull)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.DONNA_RUNE, PlayerId = victor.Id
                    });
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Attack an attacking player back.  There is a random chance to draw Narcissa's aggro from doing this if she has a target.  If she has no active target,
        /// the attacker instantly becomes her new target.
        /// </summary>
        /// <param name="attacker"></param>
        public static void CounterAttack(Player attacker)
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var faeboss = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.FaebossBotId);

            AIProcedures.DealBossDamage(faeboss, attacker, true, 1); // log attack for human on boss

            var spell = ChooseSpell(PvPWorldStatProcedures.GetWorldTurnNumber(), PvPStatics.MobilityInanimate);

            for (var i = 0; i < 3; i++)
            {
                AttackProcedures.Attack(faeboss, attacker, spell);
                AIProcedures.DealBossDamage(faeboss, attacker, false, 1); // log attack for boss on human
            }

            var directive = AIDirectiveProcedures.GetAIDirective(faeboss.Id);

            // random chance to aggro faeboss
            var rand = new Random(Guid.NewGuid().GetHashCode());
            var num  = rand.NextDouble();

            if (num < AggroChance || directive.Var1 == 0)
            {
                IAIDirectiveRepository aiRepo = new EFAIDirectiveRepository();
                var dbDirective = aiRepo.AIDirectives.FirstOrDefault(a => a.Id == directive.Id);

                dbDirective.Var1 = attacker.Id;
                aiRepo.SaveAIDirective(dbDirective);
            }
        }
        public static string TeleportToQuest(Player player, Random rand = null)
        {
            var lastAttackTimeAgo = Math.Abs(DateTime.UtcNow.Subtract(player.GetLastCombatTimestamp()).TotalMinutes);

            if (lastAttackTimeAgo < TurnTimesStatics.GetMinutesSinceLastCombatBeforeQuestingOrDuelling())
            {
                return(null);
            }

            var quests = QuestProcedures.GetAllAvailableQuestsForPlayer(player, PvPWorldStatProcedures.GetWorldTurnNumber());

            if (quests == null || !quests.Any())
            {
                return(null);
            }

            rand = rand ?? new Random();
            var index = rand.Next(quests.Count());
            var quest = quests.ToArray()[index];

            if (!Teleport(player, quest.dbName, rand.Next(2) == 0))
            {
                return(null);
            }

            return($"You notice a gold chalice on the shelf, its engraving obscured by dirt.  You decide to blow the dust off and a cloud fills the room.  A frail man with a long white beard and crooked staff emerges from the mist.  \"So, it's a quest you seek?\" comes his shrill, wheezing voice.  \"Well, I have just the thing.  Seek out your victory, young mage.\"  He hands you a scroll.  At the top it is written <b>{quest.Name}</b>.  As you take it you feel yourself transported to a far-off place...");
        }
        public virtual ActionResult DuelTimeout()
        {
            var myMembershipId = User.Identity.GetUserId();
            var me             = PlayerProcedures.GetPlayerFromMembership(myMembershipId);

            if (me.InDuel <= 0)
            {
                TempData["Error"] = "You are not in a duel.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            var duel = DuelProcedures.GetDuel(me.InDuel);

            var turnsLeft = PvPStatics.MaximumDuelTurnLength - (PvPWorldStatProcedures.GetWorldTurnNumber() - duel.StartTurn);

            if (turnsLeft > 0)
            {
                TempData["Error"] = "You cannot end this duel as there are still turns remaining.";
                return(RedirectToAction(MVC.PvP.Play()));
            }


            DuelProcedures.EndDuel(duel.Id, DuelProcedures.TIMEOUT);

            TempData["Result"] = "This duel has timed out in a no-winner result.";
            return(RedirectToAction(MVC.PvP.Play()));
        }
Exemple #5
0
        /// <summary>
        /// Cast 1 animate spell on each player in Narcissa's current location.  She will not change her aggro for this.
        /// </summary>
        /// <param name="faeboss">Player casting the spells.  In this case, always Narcissa.</param>
        private static void CastAnimateSpellsAtLocation(Player faeboss)
        {
            var playersHere = GetEligibleTargetsInLocation(faeboss);

            foreach (var p in playersHere)
            {
                var spell = ChooseSpell(PvPWorldStatProcedures.GetWorldTurnNumber(), PvPStatics.MobilityFull);
                AttackProcedures.Attack(faeboss, p, spell);
                AIProcedures.DealBossDamage(faeboss, p, false, 1); // log attack for human on boss
            }
        }
        public static void EndEvent(int newOwnerId)
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            IItemRepository   itemRepo   = new EFItemRepository();

            var valentine = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.ValentineBotId);


            var panties = itemRepo.Items.FirstOrDefault(i => i.ItemSourceId == QueensPantiesItemSourceId);

            panties.OwnerId = newOwnerId;
            itemRepo.SaveItem(panties);

            DomainRegistry.Repository.Execute(new DropAllItems {
                PlayerId = valentine.Id, IgnoreRunes = true
            });
            DomainRegistry.Repository.Execute(new DeletePlayer {
                PlayerId = valentine.Id
            });

            PvPWorldStatProcedures.Boss_EndValentine();

            // find the players who dealt the most damage and award them with XP
            var damages = AIProcedures.GetTopAttackers(valentine.BotId, 15);

            // top player gets 500 XP, each player down the line receives 25 fewer
            var l         = 0;
            var maxReward = 500;

            for (var r = 0; r < damages.Count; r++)
            {
                var damage = damages.ElementAt(r);
                var victor = playerRepo.Players.FirstOrDefault(p => p.Id == damage.PlayerId);
                if (victor == null)
                {
                    continue;
                }
                var reward = maxReward - (l * 30);
                victor.XP += reward;
                l++;

                PlayerLogProcedures.AddPlayerLog(victor.Id, "<b>For your valiant (maybe foolish?) efforts in challenging " + valentine.GetFullName() + " you receieve " + reward + " XP from your risky struggle!</b>", true);

                playerRepo.SavePlayer(victor);

                // top three get runes
                if (r <= 2 && victor.Mobility == PvPStatics.MobilityFull)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.VAMPIRE_RUNE, PlayerId = victor.Id
                    });
                }
            }
        }
Exemple #7
0
        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 virtual ActionResult QuestsAvailableHere()
        {
            var myMembershipId = User.Identity.GetUserId();
            var me             = PlayerProcedures.GetPlayerFromMembership(myMembershipId);

            var output = new QuestsAtLocationViewModel
            {
                AllQuests       = QuestProcedures.GetAllQuestStartsAtLocation(me.dbLocationName),
                AvailableQuests = QuestProcedures.GetAvailableQuestsAtLocation(me, PvPWorldStatProcedures.GetWorldTurnNumber()),
            };

            return(View(MVC.Quest.Views.QuestsAvailableHere, output));
        }
        public static void MoveToNewLocation()
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var fae = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.JewdewfaeBotId);

            IJewdewfaeEncounterRepository faeRepo = new EFJewdewfaeEncounterRepository();

            IAIDirectiveRepository aiRepo = new EFAIDirectiveRepository();
            var directive = aiRepo.AIDirectives.FirstOrDefault(i => i.OwnerId == fae.Id);

            // add fae's current location to the list of places visited
            directive.sVar2 += fae.dbLocationName + ";";

            var fairyLocations = faeRepo.JewdewfaeEncounters.Where(f => f.IsLive).Select(f => f.dbLocationName).ToList();

            var visitedFairyLocations = directive.sVar2.Split(';').Where(f => f.Length > 1).ToList();

            var possibleLocations = fairyLocations.Except(visitedFairyLocations).ToList();

            // if there are no locations left to visit, reset
            if (!possibleLocations.Any())
            {
                possibleLocations = fairyLocations;
                directive.sVar2   = "";
            }

            double max  = possibleLocations.Count();
            var    rand = new Random();
            var    num  = rand.NextDouble();

            var index       = Convert.ToInt32(Math.Floor(num * max));
            var newLocation = possibleLocations.ElementAt(index);


            directive.Var1  = 0;
            directive.Var2  = PvPWorldStatProcedures.GetWorldTurnNumber();
            directive.sVar1 = ";";

            aiRepo.SaveAIDirective(directive);

            LocationLogProcedures.AddLocationLog(fae.dbLocationName, "<b>Jewdewfae got bored and flew away from here.</b>");

            fae.dbLocationName = newLocation;
            playerRepo.SavePlayer(fae);

            LocationLogProcedures.AddLocationLog(fae.dbLocationName, "<b>Jewdewfae flew here.  She looks bored and wants to play with someone.</b>");
        }
        public static string GetStance()
        {
            var turnNum = PvPWorldStatProcedures.GetWorldTurnNumber();

            /* We don't really need the Krampus to change stances.
             * if (turnNum % (DayNightInterval * 2) < DayNightInterval)
             * {
             *  return DayStance;
             * }
             * else
             * {
             *  return NightStance;
             * }
             */

            return(DayStance);
        }
        public static void TalkToAndCastSpell(Player player, Player valentine)
        {
            var stance = GetStance();

            // Player should not be able to attack Krampus while another boss is active.
            // This check is also made here in the event someone attempts to use a bookmark to attack the Krampus.
            if (stance == BossProcedures_Valentine.DayStance && !PvPWorldStatProcedures.IsAnyBossActive())
            {
                if (player.FormSourceId != DayVampireFemaleFormSourceId && player.FormSourceId != DayVampireMaleFormSourceId)
                {
                    if (player.Gender == PvPStatics.GenderMale)
                    {
                        AttackProcedures.Attack(valentine, player, DayVampireFemaleSpellSourceId);
                    }
                    else
                    {
                        AttackProcedures.Attack(valentine, player, DayVampireMaleSpellSourceId);
                    }
                }
            }

            /* Only have the one stance.
             * else if (stance == BossProcedures_Valentine.NightStance)
             * {
             *  if (player.FormSourceId != NightVampireFemaleFormSourceId && player.FormSourceId != NightVampireMaleFormSourceId)
             *  {
             *      if (player.Gender == PvPStatics.GenderMale)
             *      {
             *          AttackProcedures.Attack(valentine, player, NightVampireFemaleSpellSourceId);
             *      }
             *      else
             *      {
             *          AttackProcedures.Attack(valentine, player, NightVampireMaleSpellSourceId);
             *      }
             *  }
             * }
             */
        }
        public virtual ActionResult DuelDetail(int id)
        {
            var myMembershipId = User.Identity.GetUserId();
            var me             = PlayerProcedures.GetPlayerFromMembership(myMembershipId);
            var duel           = DuelProcedures.GetDuel(id);

            if (me.InDuel != duel.Id)
            {
                TempData["Error"] = "You are not in this duel.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            var output = new DuelPlayersViewModel
            {
                Duel       = duel,
                Combatants = DuelProcedures.GetPlayerViewModelsInDuel(duel.Id)
            };

            ViewBag.CurrentTurn    = PvPWorldStatProcedures.GetWorldTurnNumber();
            ViewBag.TurnsRemaining = PvPStatics.MaximumDuelTurnLength - (ViewBag.CurrentTurn - duel.StartTurn);

            return(View(MVC.Duel.Views.DuelDetail, output));
        }
Exemple #13
0
        /// <summary>
        /// End the faeboss boss event and distribute XP to players who fought her
        /// </summary>
        public static void EndEvent()
        {
            PvPWorldStatProcedures.Boss_EndFaeBoss();
            IPlayerRepository playerRepo = new EFPlayerRepository();

            var damages = AIProcedures.GetTopAttackers(AIStatics.FaebossBotId, 25);

            // top player gets 1000 XP, each player down the line receives 35 fewer
            var l         = 0;
            var maxReward = 1000;

            for (var i = 0; i < damages.Count; i++)
            {
                var damage = damages.ElementAt(i);

                var victor = playerRepo.Players.FirstOrDefault(p => p.Id == damage.PlayerId);
                if (victor == null)
                {
                    continue;
                }
                var reward = maxReward - (l * 35);
                victor.XP += reward;
                l++;

                playerRepo.SavePlayer(victor);
                PlayerLogProcedures.AddPlayerLog(victor.Id, "<b>For your contribution in defeating " + FirstName + " " + LastName + ", you earn " + reward + " XP from your spells cast against traitorous fae.</b>", true);

                // top three get runes
                if (i <= 2 && victor.Mobility == PvPStatics.MobilityFull)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.NARCISSA_RUNE, PlayerId = victor.Id
                    });
                }
            }
        }
Exemple #14
0
        /// <summary>
        /// End the boss event and distribute XP to players who fought
        /// </summary>
        public static void EndEvent()
        {
            PvPWorldStatProcedures.Boss_EndMotorcycleGang();
            IPlayerRepository playerRepo = new EFPlayerRepository();

            var damages = AIProcedures.GetTopAttackers(AIStatics.MotorcycleGangLeaderBotId, 25);

            // top player gets 1000 XP, each player down the line receives 35 fewer
            var l         = 0;
            var maxReward = 1000;

            for (var i = 0; i < damages.Count; i++)
            {
                var damage = damages.ElementAt(i);

                var victor = playerRepo.Players.FirstOrDefault(p => p.Id == damage.PlayerId);
                if (victor == null)
                {
                    continue;
                }
                var reward = maxReward - (l * 35);
                victor.XP += reward;
                l++;

                playerRepo.SavePlayer(victor);
                PlayerLogProcedures.AddPlayerLog(victor.Id, $"<b>For your contribution in defeating {BossFirstName} {BossLastName}, you earn {reward} XP from your spells cast against her</b>", true);

                // top three get runes
                if (i <= 2 && victor.Mobility == PvPStatics.MobilityFull)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.MOTORCYCLE_RUNE, PlayerId = victor.Id
                    });                                                                                                                   // TODO:  Make new rune for this boss
                }
            }
        }
Exemple #15
0
        public static void SpawnThieves()
        {
            var malethief = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId {
                BotId = AIStatics.MaleRatBotId
            });

            if (malethief == null)
            {
                var cmd = new CreatePlayer
                {
                    FirstName    = MaleBossFirstName,
                    LastName     = MaleBossLastName,
                    Location     = "tavern_pool",
                    Gender       = PvPStatics.GenderMale,
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    FormSourceId = MaleBossFormSourceId,
                    Money        = 0,
                    Mobility     = PvPStatics.MobilityFull,
                    Level        = 5,
                    BotId        = AIStatics.MaleRatBotId
                };

                var id = DomainRegistry.Repository.Execute(cmd);

                var playerRepo  = new EFPlayerRepository();
                var malethiefEF = playerRepo.Players.FirstOrDefault(p => p.Id == id);
                malethiefEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(malethiefEF));
                playerRepo.SavePlayer(malethiefEF);


                var aiRepo        = new EFAIDirectiveRepository();
                var maleDirective = new AIDirective
                {
                    OwnerId        = id,
                    DoNotRecycleMe = true,
                    Timestamp      = DateTime.UtcNow,
                    SpawnTurn      = PvPWorldStatProcedures.GetWorldTurnNumber(),
                    sVar1          = GetRichestPlayerIds(),
                    Var1           = 0,
                };
                aiRepo.SaveAIDirective(maleDirective);

                for (var i = 0; i < 2; i++)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.RAT_THIEF_RUNE, PlayerId = malethiefEF.Id
                    });
                }
            }


            var femalethief = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId {
                BotId = AIStatics.FemaleRatBotId
            });

            if (femalethief == null)
            {
                var cmd = new CreatePlayer
                {
                    FirstName    = FemaleBossFirstName,
                    LastName     = FemaleBossLastName,
                    Location     = "tavern_pool",
                    Gender       = PvPStatics.GenderFemale,
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    FormSourceId = FemaleBossFormSourceId,
                    Money        = 0,
                    Mobility     = PvPStatics.MobilityFull,
                    Level        = 7,
                    BotId        = AIStatics.FemaleRatBotId,
                };
                var id = DomainRegistry.Repository.Execute(cmd);

                var playerRepo    = new EFPlayerRepository();
                var femalethiefEF = playerRepo.Players.FirstOrDefault(p => p.Id == id);
                femalethiefEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(femalethiefEF));
                playerRepo.SavePlayer(femalethiefEF);

                var aiRepo          = new EFAIDirectiveRepository();
                var femaleDirective = new AIDirective
                {
                    OwnerId        = id,
                    DoNotRecycleMe = true,
                    Timestamp      = DateTime.UtcNow,
                    SpawnTurn      = PvPWorldStatProcedures.GetWorldTurnNumber(),
                    sVar1          = GetRichestPlayerIds(),
                    Var1           = 0,
                };
                aiRepo.SaveAIDirective(femaleDirective);

                for (var i = 0; i < 2; i++)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.RAT_THIEF_RUNE, PlayerId = femalethiefEF.Id
                    });
                }
            }
        }
Exemple #16
0
        public static void EndEvent()
        {
            PvPWorldStatProcedures.Boss_EndSisters();

            IPlayerRepository playerRepo = new EFPlayerRepository();
            var nerdBoss  = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.MouseNerdBotId);
            var bimboBoss = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.MouseBimboBotId);

            var winner = "";

            if (nerdBoss.FormSourceId != NerdBossFormSourceId)
            {
                winner = "bimbo";
            }
            else if (bimboBoss.FormSourceId != BimboBossFormSourceId)
            {
                winner = "nerd";
            }
            else
            {
                return;
            }

            // find the players who dealt the most damage and award them with XP
            List <BossDamage> damages = null;

            if (winner == "bimbo")
            {
                damages = AIProcedures.GetTopAttackers(nerdBoss.BotId, 10);
            }
            else if (winner == "nerd")
            {
                damages = AIProcedures.GetTopAttackers(bimboBoss.BotId, 10);
            }

            // top player gets maximum XP reward, each player down the line receives a little less
            var i         = 0;
            var maxReward = 1000;

            for (var r = 0; r < damages.Count; r++)
            {
                var damage = damages.ElementAt(r);
                var victor = playerRepo.Players.FirstOrDefault(p => p.Id == damage.PlayerId);
                if (victor == null)
                {
                    continue;
                }
                var reward = maxReward - (i * 50);
                victor.XP += reward;
                i++;

                if (winner == "bimbo")
                {
                    PlayerLogProcedures.AddPlayerLog(victor.Id, "<b>For your contribution in defeating " + nerdBoss.GetFullName() + ", " + bimboBoss.GetFullName() + " gifts you with " + reward + " XP from her powerful magic of seduction!</b>", true);

                    // top three get runes
                    if (r <= 2 && victor.Mobility == PvPStatics.MobilityFull)
                    {
                        DomainRegistry.Repository.Execute(new GiveRune {
                            ItemSourceId = RuneStatics.HEADMISTRESS_RUNE, PlayerId = victor.Id
                        });
                    }
                }
                else
                {
                    PlayerLogProcedures.AddPlayerLog(victor.Id, "<b>For your contribution in defeating " + bimboBoss.GetFullName() + ", " + nerdBoss.GetFullName() + " gifts you with " + reward + " XP from her unchallenged mastery of the natural world!</b>", true);

                    // top three get runes
                    if (r <= 2 && victor.Mobility == PvPStatics.MobilityFull)
                    {
                        DomainRegistry.Repository.Execute(new GiveRune {
                            ItemSourceId = RuneStatics.BIMBO_RUNE, PlayerId = victor.Id
                        });
                    }
                }

                playerRepo.SavePlayer(victor);
            }

            DomainRegistry.Repository.Execute(new DeletePlayer {
                PlayerId = nerdBoss.Id
            });
            DomainRegistry.Repository.Execute(new DeletePlayer {
                PlayerId = bimboBoss.Id
            });
        }
Exemple #17
0
        public static string SummonPsychopath(Player player, Random rand = null, int?strengthOverride = null, bool?aggro = null)
        {
            rand = rand ?? new Random();

            var baseStrength = Math.Min(Math.Max(0, (player.Level - 1) / 3), 3);
            var strength     = strengthOverride ?? (baseStrength + Math.Max(0, rand.Next(6) - 1));

            var prefix = "";
            int level;
            int perk;
            int?extraPerk = null;
            var gender    = rand.Next(2);
            int form;

            var turnNumber = PvPWorldStatProcedures.GetWorldTurnNumber();

            if (strength <= 0 || (turnNumber < 300 && !strengthOverride.HasValue))
            {
                strength = 0;
                level    = 1;
                perk     = AIProcedures.PsychopathicForLevelOneEffectSourceId;
                form     = gender == 0 ? AIProcedures.Psycho1MId : AIProcedures.Psycho1FId;
            }
            else if (strength == 1 || (turnNumber < 600 && !strengthOverride.HasValue))
            {
                strength = 1;
                level    = 3;
                prefix   = "Fierce";
                perk     = AIProcedures.PsychopathicForLevelThreeEffectSourceId;
                form     = gender == 0 ? AIProcedures.Psycho3MId : AIProcedures.Psycho3FId;
            }
            else if (strength == 2 || (turnNumber < 900 && !strengthOverride.HasValue))
            {
                strength = 2;
                level    = 5;
                prefix   = "Wrathful";
                perk     = AIProcedures.PsychopathicForLevelFiveEffectSourceId;
                form     = gender == 0 ? AIProcedures.Psycho5MId : AIProcedures.Psycho5FId;
            }
            else if (strength == 3 || (turnNumber < 1500 && !strengthOverride.HasValue))
            {
                strength = 3;
                level    = 7;
                prefix   = "Loathful";
                perk     = AIProcedures.PsychopathicForLevelSevenEffectSourceId;
                form     = gender == 0 ? AIProcedures.Psycho7MId : AIProcedures.Psycho7FId;
            }
            else if (strength == 4 || (turnNumber < 2400 && !strengthOverride.HasValue))
            {
                strength = 4;
                level    = 9;
                prefix   = "Soulless";
                perk     = AIProcedures.PsychopathicForLevelNineEffectSourceId;
                form     = gender == 0 ? AIProcedures.Psycho9MId : AIProcedures.Psycho9FId;
            }
            else if (strength == 5 || (turnNumber < 3600 && !strengthOverride.HasValue))
            {
                strength  = 5;
                level     = 11;
                prefix    = "Ruthless";
                perk      = AIProcedures.PsychopathicForLevelNineEffectSourceId;
                extraPerk = AIProcedures.PsychopathicForLevelThreeEffectSourceId;
                form      = gender == 0 ? AIProcedures.Psycho9MId : AIProcedures.Psycho9FId;
            }
            else
            {
                strength  = 6;
                level     = 13;
                prefix    = "Eternal";
                perk      = AIProcedures.PsychopathicForLevelNineEffectSourceId;
                extraPerk = AIProcedures.PsychopathicForLevelFiveEffectSourceId;
                form      = gender == 0 ? AIProcedures.Psycho9MId : AIProcedures.Psycho9FId;
            }

            var firstName = "Psychopath";
            var lastName  = NameService.GetRandomLastName();

            if (!prefix.IsEmpty())
            {
                firstName = $"{prefix} {firstName}";
            }

            IPlayerRepository playerRepo = new EFPlayerRepository();
            var cmd = new CreatePlayer
            {
                FirstName          = firstName,
                LastName           = lastName,
                Location           = player.dbLocationName,
                FormSourceId       = form,
                Level              = level,
                Health             = 100000,
                MaxHealth          = 100000,
                Mana               = 100000,
                MaxMana            = 100000,
                BotId              = AIStatics.PsychopathBotId,
                UnusedLevelUpPerks = 0,
                XP     = 0,
                Money  = (strength + 1) * 50,
                Gender = gender == 0 ? PvPStatics.GenderMale : PvPStatics.GenderFemale,
            };

            var botId = DomainRegistry.Repository.Execute(cmd);

            // Give spells
            var eligibleSkills = SkillStatics.GetLearnablePsychopathSkills().ToList();

            SkillProcedures.GiveSkillToPlayer(botId, eligibleSkills[rand.Next(eligibleSkills.Count())].Id);

            if (strength >= 5)
            {
                SkillProcedures.GiveSkillToPlayer(botId, PvPStatics.Spell_WeakenId);
            }

            if (strength >= 6)
            {
                var limitedMobilityForms = JokeShopProcedures.AnimateForms().Where(f => f.Category == JokeShopProcedures.LIMITED_MOBILITY).ToArray();

                if (limitedMobilityForms.Any())
                {
                    IDbStaticSkillRepository skillsRepo = new EFDbStaticSkillRepository();

                    var formId        = limitedMobilityForms[rand.Next(limitedMobilityForms.Count())].FormSourceId;
                    var immobileSkill = skillsRepo.DbStaticSkills.FirstOrDefault(spell => spell.FormSourceId == formId);

                    if (immobileSkill != null)
                    {
                        SkillProcedures.GiveSkillToPlayer(botId, immobileSkill.Id);
                    }
                }
            }

            // Give bonuses
            EffectProcedures.GivePerkToPlayer(perk, botId);

            if (extraPerk.HasValue)
            {
                EffectProcedures.GivePerkToPlayer(extraPerk.Value, botId);
            }

            // Give runes
            var quantity = rand.Next(1, 3);

            for (var c = 0; c < quantity; c++)
            {
                var runeId = DomainRegistry.Repository.FindSingle(new GetRandomRuneAtLevel {
                    RuneLevel = strength * 2 + 1, Random = rand
                });
                DomainRegistry.Repository.Execute(new GiveRune {
                    ItemSourceId = runeId, PlayerId = botId
                });
            }

            // Balance stats
            var psychoEF = playerRepo.Players.FirstOrDefault(p => p.Id == botId);

            psychoEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(psychoEF));
            playerRepo.SavePlayer(psychoEF);

            // Tell the bot to attack the player
            if (!aggro.HasValue || aggro.Value)
            {
                AIDirectiveProcedures.SetAIDirective_Attack(botId, player.Id);
            }

            PlayerLogProcedures.AddPlayerLog(player.Id, $"<b>You have summoned {firstName} {lastName}!</b>  Beware!  They are not friendly!!", true);
            LocationLogProcedures.AddLocationLog(player.dbLocationName, $"{player.GetFullName()} has summoned <b>{firstName} {lastName}</b>!");

            return("Near the counter is an altar with a leather-bound book resting open upon it.  You take a look and try to read one of the jokes aloud.  It seems to be some consonant-heavy tongue twister that soon leaves you faltering.  You're not quite sure what the set up means, but hope the punchline will be worth it.  As you spurt out the last syllable a puff of red smoke explodes out from the book with an audible bang.  You're not laughing, and that remains the case when you close the book to see a large pentagram seared into the cover.  As the smoke subsides there seems to be a strange neon flicker to the light and a crackling to the air.  You turn sharply to see the psychopath you just summoned readying their attack against you!");
        }
        public virtual ActionResult StartQuest(int Id)
        {
            var myMembershipId = User.Identity.GetUserId();

            if (PvPStatics.AnimateUpdateInProgress)
            {
                TempData["Error"]    = "Player update portion of the world update is still in progress.";
                TempData["SubError"] = "Try again a bit later when the update has progressed farther along.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            var me = PlayerProcedures.GetPlayerFromMembership(myMembershipId);

            // assert player is in an okay form to do this
            if (me.Mobility != PvPStatics.MobilityFull)
            {
                TempData["Error"] = "You must be animate in order to begin a quest.";
                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 begin a quest.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            // assert that this player is not in a quest
            if (me.InQuest > 0)
            {
                TempData["Error"] = "You must finish your current quest before you start another.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            // assert player has not been in combat recently
            var lastAttackTimeAgo = Math.Abs(Math.Floor(me.GetLastCombatTimestamp().Subtract(DateTime.UtcNow).TotalMinutes));

            if (lastAttackTimeAgo < TurnTimesStatics.GetMinutesSinceLastCombatBeforeQuestingOrDuelling())
            {
                TempData["Error"]    = "You have been in combat too recently in order to begin this quest.";
                TempData["SubError"] = "You must stay out of combat for another " + (TurnTimesStatics.GetMinutesSinceLastCombatBeforeQuestingOrDuelling() - lastAttackTimeAgo) + " minutes.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            var questStart = QuestProcedures.GetQuest(Id);

            // assert player is in the correct place
            if (me.dbLocationName != questStart.Location)
            {
                TempData["Error"] = "You are not in the correct location to begin this quest.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            var gameTurnNum = PvPWorldStatProcedures.GetWorldTurnNumber();

            // assert player did not fail or abandon this quest too soon ago
            var lastTurnAttempted = QuestProcedures.GetLastTurnQuestEnded(me, questStart.Id);

            if (PvPWorldStatProcedures.GetWorldTurnNumber() - lastTurnAttempted < QuestStatics.QuestFailCooldownTurnLength)
            {
                TempData["Error"]    = "You recently failed or abandoned this quest.";
                TempData["SubError"] = "You must wait another " + (QuestStatics.QuestFailCooldownTurnLength - (gameTurnNum - lastTurnAttempted)) + " turns before you can attempt this quest again.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            var questPlayerStatuses = QuestProcedures.GetQuestPlayerStatuses(me);

            var canStartQuest = QuestProcedures.PlayerCanBeginQuest(me, questStart, questPlayerStatuses, gameTurnNum);

            // assert player meets level / game turn requirements for this quest
            if (!canStartQuest)
            {
                TempData["Error"] = "You do not meet all of the criteria to begin this quest.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            // all checks have passed; start the player on this quest
            QuestProcedures.PlayerBeginQuest(me, questStart);
            LocationLogProcedures.AddLocationLog(me.dbLocationName, "<span class='playerMediatingNotification'><b>" + me.GetFullName() + "</b> began the quest <b>" + questStart.Name + "</b> here.</span>");

            TempData["Result"] = "You started the quest " + questStart.Name + ".";
            return(RedirectToAction(MVC.Quest.Questing()));
        }
Exemple #19
0
        /// <summary>
        /// Perform Narcissa's regular actions when a new turn has started.  If Narcissa has no aggroed target, she seeks to transform random people into
        /// certain animate forms.  If she has aggro, she will attempt to chase them and cast a pet spell on them.  If she can't catch up, she'll cast the animate
        /// spells in the area instead and resume pursuit next turn.
        /// </summary>
        public static void RunTurnLogic()
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var faeboss = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.FaebossBotId);

            // fae boss is no longer animate; end the event
            if (faeboss.Mobility != PvPStatics.MobilityFull)
            {
                EndEvent();
                return;
            }

            // have Narcissa periodically drop all of her pets/belongings so she doesn't get OP with them
            if (PvPWorldStatProcedures.GetWorldTurnNumber() % 12 == 0)
            {
                DomainRegistry.Repository.Execute(new DropAllItems {
                    PlayerId = faeboss.Id, IgnoreRunes = true
                });
            }

            // have Narcissa meditate to get her mana back up
            faeboss.Mana = faeboss.MaxMana;


            var directive = AIDirectiveProcedures.GetAIDirective(faeboss.Id);

            // no target, go out and hit some random people with animate spells
            if (!HasValidTarget(directive))
            {
                ResetTarget(directive);
                var newTargetLocation = GetLocationWithMostEligibleTargets();
                var newActualLocation = AIProcedures.MoveTo(faeboss, newTargetLocation, GetRandomChaseDistance());
                faeboss.dbLocationName = newActualLocation;
                playerRepo.SavePlayer(faeboss);

                CastAnimateSpellsAtLocation(faeboss);
            }

            // Narcissa has a valid target, go for them
            else
            {
                var target            = PlayerProcedures.GetPlayer((int)directive.Var1);
                var newTargetLocation = target.dbLocationName;
                var newActualLocation = AIProcedures.MoveTo(faeboss, newTargetLocation, GetRandomChaseDistance());
                faeboss.dbLocationName = newActualLocation;
                playerRepo.SavePlayer(faeboss);

                if (faeboss.dbLocationName == target.dbLocationName)
                {
                    var spell = ChooseSpell(PvPWorldStatProcedures.GetWorldTurnNumber(), PvPStatics.MobilityPet);

                    for (var i = 0; i < 4; i++)
                    {
                        AttackProcedures.Attack(faeboss, target, spell);
                    }
                }
                else
                {
                    CastAnimateSpellsAtLocation(faeboss);
                }
            }
        }
        public static void RunDonnaActions()
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();

            var worldTurnNumber = PvPWorldStatProcedures.GetWorldTurnNumber() - 1;

            var donna = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.DonnaBotId);

            if (donna.Mobility != PvPStatics.MobilityFull)
            {
                EndEvent(donna);
            }

            else if (donna.Mobility == PvPStatics.MobilityFull)
            {
                var donnasBuffs = ItemProcedures.GetPlayerBuffs(donna);

                // have donna meditate
                if (donna.Mana < donna.MaxMana)
                {
                    DomainRegistry.Repository.Execute(new Meditate {
                        PlayerId = donna.Id, Buffs = donnasBuffs, NoValidate = true
                    });
                    DomainRegistry.Repository.Execute(new Meditate {
                        PlayerId = donna.Id, Buffs = donnasBuffs, NoValidate = true
                    });
                }

                var directive = AIDirectiveProcedures.GetAIDirective(donna.Id);

                if (directive.State == "attack" || directive.State == "idle")
                {
                    var target = playerRepo.Players.FirstOrDefault(p => p.Id == directive.TargetPlayerId);

                    // if Donna's target goes offline, is inanimate, or in the dungeon, have her teleport back to the ranch
                    if (target == null ||
                        target.Mobility != PvPStatics.MobilityFull ||
                        PlayerProcedures.PlayerIsOffline(target) ||
                        target.IsInDungeon() ||
                        target.InDuel > 0 ||
                        target.InQuest > 0)
                    {
                        if (donna.dbLocationName != "ranch_bedroom")
                        {
                            LocationLogProcedures.AddLocationLog(donna.dbLocationName, donna.FirstName + " " + donna.LastName + " vanished from here in a flash of smoke.");
                            donna.dbLocationName = "ranch_bedroom";
                            LocationLogProcedures.AddLocationLog(donna.dbLocationName, donna.FirstName + " " + donna.LastName + " appeared here in a flash of smoke.");
                            playerRepo.SavePlayer(donna);
                        }


                        AIDirectiveProcedures.SetAIDirective_Idle(donna.Id);
                    }

                    // Donna has a valid target; go chase it down and attack.  Donna does not look for new targets.
                    else
                    {
                        var newplace = AIProcedures.MoveTo(donna, target.dbLocationName, 10);
                        donna.dbLocationName = newplace;
                        playerRepo.SavePlayer(donna);

                        if (target.dbLocationName == newplace)
                        {
                            var rand = new Random();
                            var roll = rand.NextDouble() * 3 + 2;
                            for (var i = 0; i < roll; i++)
                            {
                                AttackProcedures.Attack(donna, target, ChooseSpell(PvPStatics.LastGameTurn));
                            }
                            AIProcedures.DealBossDamage(donna, target, false, (int)roll);
                        }
                        else
                        {
                        }
                    }
                }
                else
                {
                }

                // have Donna equip all the pets she owns
                IItemRepository    itemRepo    = new EFItemRepository();
                IEnumerable <Item> donnasItems = itemRepo.Items.Where(i => i.OwnerId == donna.Id && !i.IsEquipped && i.Level > 3);
                var itemsToEquip = new List <Item>();
                foreach (var i in donnasItems)
                {
                    itemsToEquip.Add(i);
                }
                foreach (var i in itemsToEquip)
                {
                    i.IsEquipped     = true;
                    i.dbLocationName = donna.dbLocationName;
                    itemRepo.SaveItem(i);
                }

                //The list should only look at pets.
                var donnasPlayerPets = DomainRegistry.Repository.Find(new GetItemsOwnedByPlayer {
                    OwnerId = donna.Id
                }).Where(i => i.ItemSource.ItemType == PvPStatics.ItemType_Pet).OrderBy(i => i.Level).ToList();

                // have Donna release her weakest pet every so often
                if (worldTurnNumber % 6 == 0 && donnasPlayerPets.Any())
                {
                    var weakestItem = donnasPlayerPets.First();
                    ItemProcedures.DropItem(weakestItem.Id, donna.dbLocationName);
                    LocationLogProcedures.AddLocationLog(donna.dbLocationName, "Donna released one of her weaker pets, " + weakestItem.FormerPlayer.FullName + ", here.");
                    var luckyVictim = PlayerProcedures.GetPlayerWithExactName(weakestItem.FormerPlayer.FullName);
                    PlayerLogProcedures.AddPlayerLog(luckyVictim.Id, "Donna has released you, allowing you to wander about or be tamed by a new owner.", true);
                }
            }
        }
        public static void SpawnValentine()
        {
            var valentine = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId {
                BotId = AIStatics.ValentineBotId
            });

            if (valentine == null)
            {
                var cmd = new CreatePlayer
                {
                    FirstName    = ValentineFirstName,
                    LastName     = ValentineLastName,
                    Location     = GetStanceLocation(),
                    Gender       = PvPStatics.GenderMale,
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    FormSourceId = ValentineFormSourceId,
                    Money        = 1000,
                    Mobility     = PvPStatics.MobilityFull,
                    Level        = 30,
                    BotId        = AIStatics.ValentineBotId,
                };
                var id = DomainRegistry.Repository.Execute(cmd);

                var playerRepo  = new EFPlayerRepository();
                var valentineEF = playerRepo.Players.FirstOrDefault(p => p.Id == id);
                valentineEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(valentineEF));
                playerRepo.SavePlayer(valentineEF);

                // give Valentine his reward item drop
                var createItemCmd = new CreateItem
                {
                    dbLocationName   = "",
                    EquippedThisTurn = false,
                    IsEquipped       = false,
                    IsPermanent      = false,
                    Level            = 6,
                    OwnerId          = id,
                    PvPEnabled       = -1,
                    ItemSourceId     = ItemStatics.GetStaticItem(QueensPantiesItemSourceId).Id
                };

                DomainRegistry.Repository.Execute(createItemCmd);

                // save his aiDirective, just for the sake of knowing his spawn turn
                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.VAMPIRE_RUNE, PlayerId = valentineEF.Id
                    });
                }
            }
        }
Exemple #22
0
        public static void EndEvent()
        {
            PvPWorldStatProcedures.Boss_EndBimbo();

            // delete all bimbo effects, both the kiss and the cure
            IEffectRepository effectRepo = new EFEffectRepository();
            var effectsToDelete          = effectRepo.Effects.Where(e => e.EffectSourceId == KissEffectSourceId || e.EffectSourceId == CureEffectSourceId).ToList();

            foreach (var e in effectsToDelete)
            {
                effectRepo.DeleteEffect(e.Id);
            }

            // delete all the cure vials
            var cmd = new GetAllItemsOfType {
                ItemSourceId = CureItemSourceId
            };
            var cures = DomainRegistry.Repository.Find(cmd);

            foreach (var cure in cures)
            {
                var deleteCmd = new DeleteItem {
                    ItemId = cure.Id
                };
                DomainRegistry.Repository.Execute(deleteCmd);
            }

            // restore any bimbos back to their base form and notify them

            var message = "Your body suddenly returns to normal as the bimbonic virus in your body suddenly goes into submission, the psychic link between you and your plague mother separated for good.  Due to the bravery of your fellow mages the Bimbocalypse has been thwarted... for now.";

            IPlayerRepository playerRepo = new EFPlayerRepository();
            var infected = playerRepo.Players.Where(p => p.FormSourceId == RegularBimboFormSourceId).ToList();

            foreach (var p in infected)
            {
                PlayerProcedures.InstantRestoreToBase(p);
                if (p.BotId == AIStatics.ActivePlayerBotId)
                {
                    PlayerLogProcedures.AddPlayerLog(p.Id, message, true);
                }
            }

            var damages = AIProcedures.GetTopAttackers(-7, 17);

            // top player gets 800 XP, each player down the line receives 35 fewer
            var l         = 0;
            var maxReward = 650;

            for (var i = 0; i < damages.Count; i++)
            {
                var damage = damages.ElementAt(i);
                var victor = playerRepo.Players.FirstOrDefault(p => p.Id == damage.PlayerId);
                if (victor == null)
                {
                    continue;
                }
                var reward = maxReward - (l * 35);
                victor.XP += reward;
                l++;

                PlayerLogProcedures.AddPlayerLog(victor.Id, "<b>For your contribution in defeating " + BossFirstName + " " + BossLastName + ", you earn " + reward + " XP from your spells cast against the plague mother.</b>", true);

                playerRepo.SavePlayer(victor);

                // top three get runes
                if (i <= 2 && victor.Mobility == PvPStatics.MobilityFull)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.BIMBO_RUNE, PlayerId = victor.Id
                    });
                }
            }
        }
        public static void RunValentineActions()
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var valentine = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.ValentineBotId);

            // if valentine is not in the right place have him move to the other location
            var locationToBe = GetStanceLocation();

            if (valentine.dbLocationName != locationToBe)
            {
                AIProcedures.MoveTo(valentine, locationToBe, 100000);
                valentine.dbLocationName = locationToBe;
                playerRepo.SavePlayer(valentine);
            }

            // get all of the players in the room
            var playersHere = PlayerProcedures.GetPlayersAtLocation(valentine.dbLocationName).ToList();

            playersHere = playersHere.Where(p => p.Mobility == PvPStatics.MobilityFull &&
                                            !PlayerProcedures.PlayerIsOffline(p) &&
                                            p.Level >= 3 &&
                                            p.BotId == AIStatics.ActivePlayerBotId &&
                                            p.Id != valentine.Id &&
                                            p.InDuel <= 0 &&
                                            p.InQuest <= 0).ToList();

            var turnNo = PvPWorldStatProcedures.GetWorldTurnNumber();

            if (valentine.Mana < valentine.MaxMana / 3)
            {
                var valentineBuffs = ItemProcedures.GetPlayerBuffs(valentine);
                DomainRegistry.Repository.Execute(new Meditate {
                    PlayerId = valentine.Id, Buffs = valentineBuffs, NoValidate = true
                });
                DomainRegistry.Repository.Execute(new Meditate {
                    PlayerId = valentine.Id, Buffs = valentineBuffs, NoValidate = true
                });
            }

            foreach (var p in playersHere)
            {
                // give this player the vampire curse if they do not yet have it
                if (!EffectProcedures.PlayerHasEffect(p, BloodyKissEffectSourceId))
                {
                    AttackProcedures.Attack(valentine, p, BloodyCurseSpellSourceId);
                    AIProcedures.DealBossDamage(valentine, p, false, 1);
                }

                // give this player the immobility curse if they do not yet have it
                if (!EffectProcedures.PlayerHasEffect(p, ValentinesPresenceEffectSourceId))
                {
                    AttackProcedures.Attack(valentine, p, ValentinesPresenceSpellSourceId);
                    AIProcedures.DealBossDamage(valentine, p, false, 1);
                }
            }

            // have Valentine equip his two strongest swords
            IItemRepository    itemRepo        = new EFItemRepository();
            IEnumerable <Item> valentineSwords = itemRepo.Items.Where(i => i.OwnerId == valentine.Id && i.ItemSourceId != QueensPantiesItemSourceId).OrderByDescending(i => i.Level);
            var swordsToSave = new List <Item>();

            var counter = 1;

            foreach (var sword in valentineSwords)
            {
                if (!sword.IsEquipped && counter < 3)
                {
                    sword.IsEquipped = true;
                    swordsToSave.Add(sword);
                }
                else if (sword.IsEquipped && counter >= 3)
                {
                    sword.IsEquipped = false;
                    swordsToSave.Add(sword);
                }
                counter++;
            }

            foreach (var sword in swordsToSave)
            {
                itemRepo.SaveItem(sword);
            }
        }
Exemple #24
0
        private static void EndEvent()
        {
            PvPWorldStatProcedures.Boss_EndThieves();

            IPlayerRepository playerRepo = new EFPlayerRepository();
            var malethief   = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.MaleRatBotId);
            var femalethief = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.FemaleRatBotId);

            AIDirectiveProcedures.DeleteAIDirectiveByPlayerId(malethief.Id);
            AIDirectiveProcedures.DeleteAIDirectiveByPlayerId(femalethief.Id);

            // find the players who dealt the most damage and award them with money
            var damages_male   = AIProcedures.GetTopAttackers(malethief.BotId, 10);
            var damages_female = AIProcedures.GetTopAttackers(femalethief.BotId, 10);

            // top player gets 500 XP, each player down the line receives 25 fewer
            var maxReward_Female = 1000 + Math.Floor(femalethief.Money);
            var maxReward_Male   = 300 + Math.Floor(malethief.Money);

            for (var i = 0; i < damages_male.Count; i++)
            {
                var damage = damages_male.ElementAt(i);
                var victor = playerRepo.Players.FirstOrDefault(p => p.Id == damage.PlayerId);
                if (victor == null)
                {
                    continue;
                }
                var reward = Math.Floor(maxReward_Male);
                victor.Money += maxReward_Male;

                PlayerLogProcedures.AddPlayerLog(victor.Id, "<b>For your contribution in defeating " + MaleBossFirstName + " you have been given " + (int)reward + " Arpeyjis from an old bounty placed on him.</b>", true);

                playerRepo.SavePlayer(victor);
                maxReward_Male *= .75M;

                // top two get runes
                if (i <= 1 && victor.Mobility == PvPStatics.MobilityFull)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.RAT_THIEF_RUNE, PlayerId = victor.Id
                    });
                }
            }

            for (var i = 0; i < damages_female.Count; i++)
            {
                var damage = damages_female.ElementAt(i);
                var victor = playerRepo.Players.FirstOrDefault(p => p.Id == damage.PlayerId);
                var reward = Math.Floor(maxReward_Female);
                victor.Money += maxReward_Female;

                PlayerLogProcedures.AddPlayerLog(victor.Id, "<b>For your contribution in defeating " + FemaleBossFirstName + " you have been given " + (int)reward + " Arpeyjis from an old bounty placed on her.</b>", true);

                playerRepo.SavePlayer(victor);
                maxReward_Female *= .75M;

                // top two get runes
                if (i <= 1 && victor.Mobility == PvPStatics.MobilityFull)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.RAT_THIEF_RUNE, PlayerId = victor.Id
                    });
                }
            }
        }
        public virtual ActionResult AcceptChallenge(int id)
        {
            var myMembershipId = User.Identity.GetUserId();

            if (PvPStatics.AnimateUpdateInProgress)
            {
                TempData["Error"]    = "Player update portion of the world update is still in progress.";
                TempData["SubError"] = "Try again a bit later when the update has progressed farther along.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            var duel = DuelProcedures.GetDuel(id);
            var me   = PlayerProcedures.GetPlayerFromMembership(myMembershipId);

            // assert duel challenge is not too old
            if (duel.ProposalTurn > PvPWorldStatProcedures.GetWorldTurnNumber() + 1)
            {
                TempData["Error"]    = "This challenge to a duel has expired.";
                TempData["SubError"] = "Offers for a duel must be accpted within the same turn or in the next.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            // assert duel is still active
            if (duel.Status != DuelProcedures.PENDING)
            {
                TempData["Error"] = "This duel has already started, has been completed, or was rejected.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            var participants = DuelProcedures.GetPlayerViewModelsInDuel(duel.Id);
            var duelLocation = participants.First().Player.dbLocationName;

            var errorMessages = new List <string>();

            foreach (var p in participants)
            {
                // assert player is not a bot... somehow
                if (p.Player.BotId < AIStatics.ActivePlayerBotId)
                {
                    errorMessages.Add(p.Player.GetFullName() + " is an NPC and thus cannot engage in a duel.");
                }

                // assert player is animate
                if (p.Player.Mobility != PvPStatics.MobilityFull)
                {
                    errorMessages.Add("Duel cannot start yet.  " + p.Player.GetFullName() + " must be animate in order to challenge someone to a duel.");
                }

                // assert player is not already in a duel
                if (p.Player.InDuel > 0)
                {
                    errorMessages.Add("Duel cannot start yet.  " + p.Player.GetFullName() + " is already participating in a duel.  Each player must not be in an active duel in order to start a new one.");
                }

                // assert player is at the duel location
                if (p.Player.dbLocationName != duelLocation)
                {
                    errorMessages.Add("Duel cannot start yet.  All players must be in the same location to begin a duel.");
                }

                // assert player has sufficient WP to start
                if (p.Player.Health < p.Player.MaxHealth * .8M)
                {
                    errorMessages.Add("Duel cannot start yet.  " + p.Player.GetFullName() + " has too low willpower.  Each player must be at least 80% willpower in order to begin dueling.");
                }

                // assert player has sufficient Mana to start
                if (p.Player.Mana < p.Player.MaxMana * .8M)
                {
                    errorMessages.Add("Duel cannot start yet.  " + p.Player.GetFullName() + " has too low mana.  Each player must be at least 80% mana in order to begin dueling.");
                }

                // assert all players are in an okay game mode
                var weAreFriends = FriendProcedures.PlayerIsMyFriend(me, p.Player.ToDbPlayer());
                if (!weAreFriends)
                {
                    // player is in PvP; target is not
                    if (me.GameMode == (int)GameModeStatics.GameModes.PvP && p.Player.GameMode < (int)GameModeStatics.GameModes.PvP)
                    {
                        errorMessages.Add("You must either be friends with " + p.Player.GetFullName() + " or in the same game mode to challenge them to a duel.");
                    }

                    // player is not in PvP; target is
                    else if (me.GameMode < (int)GameModeStatics.GameModes.PvP && p.Player.GameMode == (int)GameModeStatics.GameModes.PvP)
                    {
                        errorMessages.Add("You must either be friends with " + p.Player.GetFullName() + " or in the same game mode to challenge them to a duel.");
                    }
                }

                // assert that the player has not been in recent combat
                var minutesAgo = Math.Abs(Math.Floor(p.Player.GetLastCombatTimestamp().Subtract(DateTime.UtcNow).TotalMinutes));
                if (minutesAgo < TurnTimesStatics.GetMinutesSinceLastCombatBeforeQuestingOrDuelling())
                {
                    errorMessages.Add("Duel cannot start yet.  " + p.Player.GetFullName() + " must wait another " + (TurnTimesStatics.GetMinutesSinceLastCombatBeforeQuestingOrDuelling() - minutesAgo) + " minutes without being in combat in order accept this challenge to a duel.");
                }

                // assert that both players are still online
                minutesAgo = Math.Abs(Math.Floor(p.Player.LastActionTimestamp.Subtract(DateTime.UtcNow).TotalMinutes));
                if (minutesAgo > TurnTimesStatics.GetMinutesSinceLastCombatBeforeQuestingOrDuelling())
                {
                    errorMessages.Add("Duel cannot start yet.  " + p.Player.GetFullName() + " has been inactive for " + (TurnTimesStatics.GetMinutesSinceLastCombatBeforeQuestingOrDuelling() - minutesAgo) + " minutes.  " + p.Player.GetFullName() + " can become active again and eligible for the duel performing any action which takes AP.  Do not attack as this will reset their no combat timer.");
                }
            }

            if (errorMessages.Any())
            {
                var errors = "";
                foreach (var s in errorMessages)
                {
                    errors += s + "<br>";
                }
                TempData["Error"] = errors;
                return(RedirectToAction(MVC.PvP.Play()));
            }

            TempData["Result"] = "Your duel has started!";
            DuelProcedures.BeginDuel(duel.Id);

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