Example #1
0
        public Player()
        {
            Variables = new PlayerVariables(this);

            SingleObjVerbs = new Dictionary <string, Action <string> >
            {
                { "等", Wait },

                { "把", ParseInversedCmd }, { "将", ParseInversedCmd },
                { "用", ParseInversedCmd },

                { "穿衣", PutOnClothes }, { "穿上", PutOnClothes },
                { "脱衣", Undress }, { "脱下", Undress },

                { "走进", GoTo }, { "进入", GoTo }, { "去", GoTo },
                { "进", GoTo }, { "回到", GoTo }, { "回", GoTo },
                { "出去", GoOut }, { "出", GoOut }, { "逃脱", GoOut }, { "逃出", GoOut },

                // special functions to handle ambiguous Chinese
                { "拧开", TurnOnOrOpen }, { "拉开", TurnOnOrOpen },
                { "打开", TurnOnOrOpen }, { "旋开", TurnOnOrOpen },
                { "开启", TurnOnOrOpen }, { "开", TurnOnOrOpen },

                { "关闭", TurnOffOrClose }, { "关上", TurnOffOrClose },
                { "关", TurnOffOrClose },

                { "拿起", Take }, { "拿走", Take }, { "拿", Take },
                { "取", Take }, { "取走", Take }, { "捉", Take }, { "捞", Take },

                { "放下", Drop }, { "扔下", Drop }, { "丢下", Drop },
                { "扔", Drop }, { "丢", Drop },

                { "看物品", Inventory }, { "物品", Inventory },

                { "看", LookAt }, { "观察", LookAt },

                { "检查", Examine },

                { "闻", Smell }, { "触摸", Touch }, { "触碰", Touch },
                { "摸", Touch }, { "碰", Touch }, { "听", Listen }
                // TODO: 砸 打 攻击
            };

            DoubleObjVerbs = new Dictionary <string, Action <string, string> >
            {
                { "放进", PutIn }, { "放上", PutIn }
            };
        }
Example #2
0
        public AObject FindObject(string name, PlayerVariables v)
        {
            List <AObject> matches = new List <AObject>();

            foreach (var obj in Objects)
            {
                if (CurrentArea != null && CurrentArea.FilterObject(obj) == ObjectVisibility.NotVisible)
                {
                    continue;
                }
                if (obj.Name == name || obj.Alias.Contains(name))
                {
                    matches.Add(obj);
                }
                FindSubObjectIn(obj, name, matches);
            }

            if (matches.Count > 1)
            {
                Print("你所说的“" + name + "”引起了歧义,它可以指:\n");
                foreach (var match in matches)
                {
                    Print(" * " + match.Name + "\n");
                }
            }
            else if (matches.Count == 1)
            {
                if (CurrentArea != null &&
                    CurrentArea.FilterObject(matches[0]) == ObjectVisibility.Unclear)
                {
                    Print("你在远处只能隐约看见它的剪影。\n\n");
                }
                else
                {
                    return(matches[0]);
                }
            }
            return(null);
        }