示例#1
0
        private static string CreatePhrase(string phrase, ICharacter target, ICharacter character, ICharacter victim)
        {
            phrase = phrase.Replace("$n", target.CanSee(character) ? character.Name : "someone"); // TODO: short description is NPC
            phrase = phrase.Replace("$N", target.CanSee(victim) ? victim.Name : "someone");       // TODO: short description is NPC
            phrase = phrase.Replace("$e", _subjects[character.Sex]);
            phrase = phrase.Replace("$E", _subjects[victim.Sex]);
            phrase = phrase.Replace("$m", _objectives[character.Sex]);
            phrase = phrase.Replace("$M", _objectives[victim.Sex]);
            phrase = phrase.Replace("$s", _possessives[character.Sex]);
            phrase = phrase.Replace("$S", _possessives[victim.Sex]);

            return(phrase);
        }
示例#2
0
        //// Search in room content, then in inventory, then in equipment
        //public static IItem FindItemHere(ICharacter character, CommandParameter parameter, bool perfectMatch = false) // equivalent to get_obj_here in handler.C:3680
        //{
        //    return FindByName(character.Room.Content.Where(character.CanSee), parameter, perfectMatch)
        //           ?? FindByName(character.Content.Where(character.CanSee), parameter, perfectMatch)
        //           ?? (FindByName(character.Equipments.Where(x => x.Item != null && character.CanSee(x.Item)), x => x.Item, parameter, perfectMatch) ?? EquipedItem.NullObject).Item;
        //}

        //// Concat room content, inventory and equipment, then search
        //public static IItem FindCharacterItemByNameInRoomAndInventoryAndEquipment(ICharacter character, CommandParameter parameter, bool perfectMatch = false) // should replace FindItemHere
        //{
        //    return FindByName(
        //        character.Room.Content.Where(character.CanSee)
        //            .Concat(character.Content.Where(character.CanSee))
        //            .Concat(character.Equipments.Where(x => x.Item != null && character.CanSee(x.Item)).Select(x => x.Item)),
        //        parameter, perfectMatch);
        //}

        // Concat room content, inventory and equipment, then search
        public static IItem FindItemHere(ICharacter character, CommandParameter parameter, bool perfectMatch = false) // equivalent to get_obj_here in handler.C:3680
        {
            return(FindByName(
                       character.Room.Content.Where(character.CanSee)
                       .Concat(character.Content.Where(character.CanSee))
                       .Concat(character.Equipments.Where(x => x.Item != null && character.CanSee(x.Item)).Select(x => x.Item)),
                       parameter, perfectMatch));
        }
示例#3
0
        // Give item victim
        protected virtual bool DoGive(string rawParameters, params CommandParameter[] parameters)
        {
            if (parameters.Length < 2)
            {
                Send("Give what to whom?");
                return(true);
            }

            IItem what = FindHelpers.FindByName(Content.Where(CanSee), parameters[0]);

            if (what == null)
            {
                Send(StringHelpers.ItemInventoryNotFound);
                return(true);
            }

            ICharacter whom = FindHelpers.FindByName(Room.People.Where(CanSee), parameters[1]);

            if (whom == null)
            {
                Send(StringHelpers.CharacterNotFound);
                return(true);
            }

            if (!whom.CanSee(what))
            {
                Act(ActOptions.ToCharacter, "{0:n} can't see it.", whom);
                return(true);
            }

            if (what is ItemQuest)
            {
                Act(ActOptions.ToCharacter, "You cannot give quest items.");
                return(true);
            }

            // Give item to victim
            what.ChangeContainer(whom);

            ActToNotVictim(whom, "{0} gives {1} to {2}.", this, what, whom);
            whom.Act(ActOptions.ToCharacter, "{0} gives you {1}.", this, what);
            Act(ActOptions.ToCharacter, "You give {0} to {1}.", what, whom);

            return(true);
        }
示例#4
0
        // TODO: use regex or manual parsing
        // $n and $N must check if target can see character (someone if not)
        // $e, $E, $m, $M, $s and $S must use sex mapping table
        private static string Format(string phrase, ICharacter target, ICharacter character, object param1, object param2)
        {
            //phrase = phrase.Replace("$t", (string) param1); // useless
            //phrase = phrase.Replace("$T", (string) param2); // useless
            phrase = phrase.Replace("$n", target.CanSee(character) ? character.Name : "someone"); // PERS(target, character)
            phrase = phrase.Replace("$N", ((ICharacter)param1).Name);                             //PERS(target, param1)
            phrase = phrase.Replace("$e", "he");                                                  // he or she (character.sex)
            phrase = phrase.Replace("$E", "he");                                                  // he or she (target.sex)
            phrase = phrase.Replace("$m", "him");                                                 // him or her (character.sex)
            phrase = phrase.Replace("$M", "him");                                                 // him or her (target.sex)
            phrase = phrase.Replace("$s", "his");                                                 // his or her (character.sex)
            phrase = phrase.Replace("$S", "his");                                                 // his or her (target.sex)
            phrase = phrase.Replace("$p", ((IItem)param1).DisplayName);
            phrase = phrase.Replace("$P", ((IItem)param2).DisplayName);
            phrase = phrase.Replace("$d", param2 == null ? "door" : ((IExit)param2).Name);

            return(phrase);
        }
示例#5
0
        public override string RelativeDisplayName(ICharacter beholder, bool capitalizeFirstLetter = false)
        {
            StringBuilder displayName = new StringBuilder();

            if (IsQuestObjective(beholder))
            {
                displayName.Append(StringHelpers.QuestPrefix);
            }
            if (beholder.CanSee(this))
            {
                displayName.Append(DisplayName);
            }
            // TODO: if player1 (without quest q1) is looking at player2 (with quest q1 and quest item qi1), player1 should not receive something
            else if (capitalizeFirstLetter)
            {
                displayName.Append("Something");
            }
            else
            {
                displayName.Append("something");
            }
            return(displayName.ToString());
        }
示例#6
0
        // FindCharacter
        public static ICharacter FindChararacterInWorld(ICharacter asker, CommandParameter parameter) // equivalent to get_char_world in handler.C:3511
        {
            // In room
            ICharacter inRoom = FindByName(asker.Room.People.Where(asker.CanSee), parameter);

            if (inRoom != null)
            {
                return(inRoom);
            }

            // In area
            //  players
            ICharacter inAreaPlayer = FindByName(asker.Room.Area.Characters.Where(x => x.ImpersonatedBy != null && asker.CanSee(x)), parameter);

            if (inAreaPlayer != null)
            {
                return(inAreaPlayer);
            }
            //  characters
            ICharacter inAreaCharacter = FindByName(asker.Room.Area.Characters.Where(asker.CanSee), parameter);

            if (inAreaCharacter != null)
            {
                return(inAreaCharacter);
            }

            // In world
            //  players
            ICharacter inWorldPlayer = FindByName(DependencyContainer.Instance.GetInstance <IWorld>().Characters.Where(x => x.ImpersonatedBy != null && asker.CanSee(x)), parameter);

            if (inWorldPlayer != null)
            {
                return(inWorldPlayer);
            }
            //  characters
            ICharacter inWorldCharacter = FindByName(DependencyContainer.Instance.GetInstance <IWorld>().Characters.Where(asker.CanSee), parameter);

            return(inWorldCharacter);
        }