示例#1
0
        public void should_print_out_three_items_correctly_with_bolding()
        {
            var list = new List <string> {
                "Bob", "Jane", "George"
            };

            Assert.That(ListifyHelper.Listify(list, true), Is.EqualTo("<b>Bob</b>, <b>Jane</b>, and <b>George</b>"));
        }
示例#2
0
        public void should_print_out_four_items_correctly()
        {
            var list = new List <string> {
                "Melissa", "Bob", "Jane", "George"
            };

            Assert.That(ListifyHelper.Listify(list), Is.EqualTo("Melissa, Bob, Jane, and George"));
        }
示例#3
0
        public void should_print_out_two_items_correctly()
        {
            var list = new List <string> {
                "Bob", "Jane"
            };

            Assert.That(ListifyHelper.Listify(list), Is.EqualTo("Bob and Jane"));
        }
示例#4
0
        public void should_print_out_one_item_correctly_with_bolding()
        {
            var list = new List <string> {
                "Bob"
            };

            Assert.That(ListifyHelper.Listify(list, true), Is.EqualTo("<b>Bob</b>"));
        }
示例#5
0
        public void should_print_out_one_item_correctly()
        {
            var list = new List <string> {
                "Bob"
            };

            Assert.That(ListifyHelper.Listify(list), Is.EqualTo("Bob"));
        }
        public static string UnlearnSpell(Player player, Random rand = null, int number = 1)
        {
            rand = rand ?? new Random();

            var skills = SkillProcedures.GetSkillViewModelsOwnedByPlayer(player.Id)
                         .Where(s => s.StaticSkill.IsPlayerLearnable &&
                                !s.StaticSkill.ExclusiveToFormSourceId.HasValue &&
                                !s.StaticSkill.ExclusiveToItemSourceId.HasValue &&
                                s.StaticSkill.Id != PvPStatics.Spell_WeakenId &&
                                s.StaticSkill.Id != PvPStatics.Dungeon_VanquishSpellSourceId &&
                                s.StaticSkill.Id != BossProcedures_FaeBoss.SpellUsedAgainstNarcissaSourceId &&
                                (s.StaticSkill.LearnedAtLocation ?? s.StaticSkill.LearnedAtRegion) != null);

            if (skills.IsEmpty())
            {
                return(null);
            }

            var toRemove  = new List <int>();
            var numSkills = skills.Count();

            while (toRemove.Count() < number && toRemove.Count() < numSkills)
            {
                var index = rand.Next(numSkills);

                if (!toRemove.Contains(index))
                {
                    toRemove.Add(index);
                }
            }

            var skillsToRemove = ListifyHelper.Listify(toRemove.Select(s => skills.ElementAt(s).StaticSkill.FriendlyName).ToList(), true);
            var message        = $"The strange aura of the Joke Shop causes you to forget how to cast {skillsToRemove}!";

            ISkillRepository skillRepo = new EFSkillRepository();

            toRemove.ForEach(s => skillRepo.DeleteSkill(skills.ElementAt(s).dbSkill.Id));

            return(message);
        }
示例#7
0
        public static string DescribeChallenge(Player player, Challenge challenge, Random rand = null)
        {
            if (challenge == null)
            {
                return(null);
            }

            rand = rand ?? new Random();  // RNG selects challenge text but NOT the challenge itself

            string[] adjectives = { "interdimensional", "dark", "tormented", "eternal", "cruel", "malevolent", "mischievous" };
            string[] subjects   = { "spirits", "souls", "entities", "apparitions", "beings" };
            string[] ambience   = { "strange", "magical", "haunted", "eerie", "unsettling", "lost" };
            string[] venues     = { "plane", "shop", "store", "realm" };
            string[] issues     = { "question whether you are worthy enough to be here",
                                    "laugh at your feeble powers",
                                    "are alarmed by your presence",
                                    "think you are too weak to stay here",
                                    "are angered by your intrusion into their domain" };

            var interdimensional       = adjectives[rand.Next(adjectives.Count())];
            var spirits                = subjects[rand.Next(subjects.Count())];
            var strange                = ambience[rand.Next(ambience.Count())];
            var plane                  = venues[rand.Next(venues.Count())];
            var questionYourWorthiness = issues[rand.Next(issues.Count())];

            var message = $"The {interdimensional} {spirits} that inhabit this {strange} {plane} {questionYourWorthiness}.  <b>They decide to set you a challenge!</b>  ";

            message += $"You must {ListifyHelper.Listify(challenge.Parts.Select(p => p.Description).ToList(), true)}.  ";
            message += $"If you succeed you will be rewarded with <b>{challenge.Reward}</b>";

            if (!challenge.Penalty.IsNullOrEmpty())
            {
                message += $" but if you fail you will suffer <b>a penalty of {challenge.Penalty}</b>";
            }

            message += $".<br />To pass the challenge you must be in the Joke Shop and meet all the success criteria by the end of <b>turn {challenge.ByEndOfTurn}</b>, about {challenge.GetTimeLeft()} from now.  You can check your progress with Rusty in the Tavern.";

            return(message);
        }
        public override string Execute(IDataContext context)
        {
            var output = String.Empty;

            ContextQuery = ctx =>
            {
                var player = ctx.AsQueryable <Player>()
                             .Include(p => p.Items)
                             .Include(p => p.Items.Select(i => i.ItemSource))
                             .SingleOrDefault(p => p.Id == PlayerId);

                if (player == null)
                {
                    throw new DomainException($"player with ID '{PlayerId}' could not be found");
                }

                var soulbindingNPC = ctx.AsQueryable <Player>()
                                     .Include(p => p.Items)
                                     .Include(p => p.Items.Select(i => i.SoulboundToPlayer))
                                     .Include(p => p.Items.Select(i => i.ItemSource))
                                     .Include(p => p.Items.Select(i => i.Runes))
                                     .SingleOrDefault(p => p.BotId == AIStatics.SoulbinderBotId);

                if (soulbindingNPC == null)
                {
                    throw new DomainException("Soulbinder has not yet spawned.");
                }

                if (player.Location != soulbindingNPC.Location)
                {
                    throw new DomainException($"You must be in the same location as {soulbindingNPC.GetFullName()} to retrieve your soulbound items.");
                }

                if (player.Mobility != PvPStatics.MobilityFull)
                {
                    throw new DomainException("You must be animate in order to do this.");
                }

                output = $"{soulbindingNPC.GetFullName()} returns your soulbound ";


                var itemsToTransfer = soulbindingNPC.Items
                                      .Where(i => i.SoulboundToPlayer != null && i.SoulboundToPlayer.Id == PlayerId).ToList();

                if (itemsToTransfer.Count > 0)
                {
                    var itemNames = new List <string>();

                    foreach (var item in itemsToTransfer)
                    {
                        if (item.ItemSource.ItemType == PvPStatics.ItemType_Pet &&
                            player.Items.Count(i => i.ItemSource.ItemType == PvPStatics.ItemType_Pet) > 0)
                        {
                            continue;
                        }

                        item.ChangeOwner(player);
                        itemNames.Add(item.ItemSource.FriendlyName);
                    }

                    output += $"{ListifyHelper.Listify(itemNames)}.";
                }
                else
                {
                    output = $"{soulbindingNPC.GetFullName()} isn't holding any of your soulbound items.";
                }


                ctx.Commit();
            };

            ExecuteInternal(context);

            return(output);
        }
        public static string LearnSpell(Player player, Random rand = null)
        {
            rand = rand ?? new Random();
            var num    = rand.Next(3) + 1;
            var learnt = SkillProcedures.GiveRandomFindableSkillsToPlayer(player, num);

            if (learnt.IsEmpty())
            {
                return(null);
            }

            return($"A spellbook flies off the shelf and lands open on the wooden desk in front of you.  As you look at it you discover the secret incantations for the spells {ListifyHelper.Listify(learnt, true)}!");
        }
示例#10
0
        public override string Execute(IDataContext context)
        {
            var result = "";

            ContextQuery = ctx =>
            {
                var player = ctx.AsQueryable <Player>()
                             .Include(p => p.Items)
                             .Include(p => p.Item.ItemSource)
                             .Include(p => p.User)
                             .Include(p => p.User.Stats)
                             .FirstOrDefault(p => p.Id == PlayerId);

                if (player == null)
                {
                    throw new DomainException($"player with ID {PlayerId} could not be found.");
                }

                var item = player.Items.FirstOrDefault(i => i.Id == ItemId);

                if (item == null)
                {
                    throw new DomainException($"Item with ID {ItemId} could not be found or does not belong to you.");
                }

                var cutoff = DateTime.UtcNow.AddMinutes(-TurnTimesStatics.GetOfflineAfterXMinutes());

                var affectedPlayers = ctx.AsQueryable <Player>()
                                      .Where(p => p.Location == player.Location &&
                                             p.Id != PlayerId &&
                                             p.GameMode != (int)GameModeStatics.GameModes.Superprotection &&
                                             p.InDuel <= 0 &&
                                             p.InQuest <= 0 &&
                                             p.FormSource.AltSexFormSource != null &&
                                             p.LastActionTimestamp > cutoff
                                             ).Include(p => p.FormSource)
                                      .Include(p => p.FormSource.AltSexFormSource)
                                      .ToList();

                foreach (var p in affectedPlayers)
                {
                    p.ChangeForm(p.FormSource.AltSexFormSource);
                    p.AddLog($"You yelp and feel your body change to that of the opposite sex from <b>{player.GetFullName()}</b>'s use of a TG Splash Orb in your location!", true);
                }

                player.SetOnlineActivityToNow();
                player.UpdateItemUseCounter(1);

                if (affectedPlayers.Any())
                {
                    var xpGained = affectedPlayers.Where(p => p.Level >= player.Level - 2).Sum(p => p.Level < 3 ? 3 : p.Level);

                    player.AddXP(xpGained);

                    // can't do this as a LINQ select due to calling the a.GetFullName() method
                    var playerNames = new List <string>();
                    foreach (var a in affectedPlayers)
                    {
                        playerNames.Add(a.GetFullName());
                    }

                    result = $"You throw your TG Splash Orb and swap the sex of {affectedPlayers.Count()} other mages near you: {ListifyHelper.Listify(playerNames, true)} and gain <b>{xpGained}</b> XP!";
                    player.AddLog(result, false);

                    // log statistics only for human players
                    if (player.BotId == AIStatics.ActivePlayerBotId)
                    {
                        player.User.AddStat(StatsProcedures.Stat__TgOrbVictims, affectedPlayers.Count());
                    }
                }
                else
                {
                    result = "You throw your TG Splash Orb, but unfortunately nobody is affected in this location.";
                }
                var locationLog = LocationLog.Create(player.Location, $"{player.GetFullName()} threw a TG splash orb, affecting {affectedPlayers.Count()} mages.");
                ctx.Add(locationLog);
                ctx.Update(player);
                ctx.Remove(item);

                ctx.Commit();
            };

            ExecuteInternal(context);
            return(result); // TODO: use event handler
        }