예제 #1
0
 public Open()
 {
     Name = "open";
     Synonyms.Are("open, uncover, undo, unwrap");
     Grammars.Add("<noun>", OpenObject);
     Grammars.Add("<noun> with <held>", UnlockObject);
 }
예제 #2
0
 public SwitchOn()
 {
     Name = "switch";
     Grammars.Add("<noun>", SwitchOnObject);
     Grammars.Add("<noun> on", SwitchOnObject);
     Grammars.Add("on <noun>", SwitchOnObject);
 }
예제 #3
0
 public Pick()
 {
     Name = "pick up";
     Synonyms.Are("pick");
     Grammars.Add("up <multi>", PickUpObject);
     Grammars.Add("<multi> up", PickUpObject);
 }
예제 #4
0
 public Empty()
 {
     Name = "empty";
     Grammars.Add("<noun>", EmptyObject);
     Grammars.Add("out <noun>", EmptyObject);
     Grammars.Add("<noun> out", EmptyObject);
 }
예제 #5
0
 public Remove()
 {
     Name = "remove";
     //Synonyms.Are("take", "carry", "hold");
     Grammars.Add(K.HELD_TOKEN, Disrobe);
     Grammars.Add(K.MULTI_TOKEN, Take);
 }
예제 #6
0
 public Ask()
 {
     Name = "ask";
     //Grammars.Add("<creature> 'about' <topic>", AttackObject);
     Grammars.Add("<noun> 'about' <topic>", OnAsk);
     Grammars.Add("<noun> 'for' <noun>", OnAskFor);
 }
예제 #7
0
 public Close()
 {
     Name = "close";
     Synonyms.Are("cover", "shut");
     Grammars.Add("<noun>", CloseObject);
     Grammars.Add("up <noun>", CloseObject);
     Grammars.Add("off <noun>", SwitchOffObject);
 }
예제 #8
0
 public Look()
 {
     Name = "look";
     Synonyms.Are("l");
     Grammars.Add(Grammar.Empty, LookAtRoom);
     Grammars.Add("at <noun>", ExamineObject);
     Grammars.Add("<noun>", ExamineObject);
 }
예제 #9
0
 public Go()
 {
     Name = "go";
     Synonyms.Are("g", "walk", "run");
     Grammars.Add(Grammar.Empty, VagueGo);
     Grammars.Add(K.DIRECTION_TOKEN, () => false);
     Grammars.Add(K.NOUN_TOKEN, EnterIt);
 }
예제 #10
0
 public Put()
 {
     Name = "put";
     Grammars.Add("<multi> [in,inside,into] <noun>", InsertObject);
     Grammars.Add("<multiheld> [on,onto] <noun>", PutOnObject);
     Grammars.Add("on <held>", WearObject);
     Grammars.Add("down <multiheld>", DropObject);
     Grammars.Add("<multiheld> down", DropObject);
 }
예제 #11
0
 public Put()
 {
     Name = "put";
     Grammars.Add("<multi> in <noun>", InsertObject);
     Grammars.Add("<multiheld> on <noun>", PutOnObject);
     Grammars.Add("on <held>", WearObject);
     Grammars.Add("down <multiheld>", DropObject);
     Grammars.Add("<multiheld> down", DropObject);
 }
예제 #12
0
 public Turn()
 {
     Name = "turn";
     Synonyms.Are("turn", "rotate", "screw", "twist", "unscrew");
     Grammars.Add("<noun>", TurnObject);
     Grammars.Add("<noun> on", SwitchOnObject);
     Grammars.Add("<noun> off", SwitchOffObject);
     Grammars.Add("on <noun>", SwitchOnObject);
     Grammars.Add("off <noun>", SwitchOffObject);
 }
예제 #13
0
 public void Prepare(AttrTree tree)
 {
     Grammars.Clear();
     foreach (AttrTree g in tree)
     {
         Grammars.Add(g.Node, g);
     }
     foreach (AttrTree g in tree)
     {
         ScanLexicon(g);
     }
 }
예제 #14
0
 public Eat()
 {
     Name = "eat";
     Grammars.Add("<held>", EatObject);
 }
예제 #15
0
 public Enter()
 {
     Name = "enter";
     SetDirection(room => room.IN(), "in");
     Grammars.Add("<noun>", EnterObject);
 }
예제 #16
0
        protected void ReadFromXml(XmlReader reader)
        {
            bool     inGrammar = false;
            Resource resource  = null;
            Response response  = null;

            while (reader.Read())
            {
                switch (reader.Name)
                {
                case "grammars":
                    inGrammar = reader.IsStartElement();
                    break;

                case "include":
                    if (inGrammar && reader.IsStartElement())
                    {
                        Grammars.Add(new Include()
                        {
                            Href = reader.GetAttribute("href")
                        });
                    }
                    break;

                case "resources":
                    if (reader.IsStartElement())
                    {
                        resource = new Resource();
                        BaseURL  = reader.GetAttribute("base");
                    }
                    else
                    {
                        Resources.Add(resource);
                        resource = null;
                    }
                    break;

                case "resource":
                    if (reader.IsStartElement())
                    {
                        resource.Path = reader.GetAttribute("path");
                    }
                    break;

                case "method":
                    if (reader.IsStartElement())
                    {
                        resource.method      = new Method();
                        resource.method.Name = reader.GetAttribute("name");
                        resource.method.Id   = reader.GetAttribute("id");
                    }
                    break;

                case "request":
                    if (reader.IsStartElement())
                    {
                        resource.method.request = new Request();
                    }
                    break;

                case "param":
                    if (reader.IsStartElement())
                    {
                        if (resource.method.request.Params == null)
                        {
                            resource.method.request.Params = new List <Param>();
                        }

                        resource.method.request.Params.Add(new Param()
                        {
                            Name     = reader.GetAttribute("name"),
                            Style    = reader.GetAttribute("style"),
                            Type     = reader.GetAttribute("type"),
                            Required = reader.GetAttribute("required") == "true"
                        });
                    }
                    break;

                case "response":
                    if (reader.IsStartElement())
                    {
                        response        = new Response();
                        response.Status = Convert.ToInt32(reader.GetAttribute("status"));
                    }
                    else
                    {
                        if (resource.method.response == null)
                        {
                            resource.method.response = new List <Response>();
                        }

                        resource.method.response.Add(response);
                    }
                    break;

                case "representation":
                    if (reader.IsStartElement())
                    {
                        response.representation = new Representation()
                        {
                            MediaType = reader.GetAttribute("mediaType"),
                            Element   = reader.GetAttribute("element")
                        };
                    }
                    break;
                }
            }
        }
예제 #17
0
 public Drop()
 {
     Name = "drop";
     Synonyms.Are("drop", "discard", "throw");
     Grammars.Add("<multiheld>", DropObject);
 }
예제 #18
0
 public Release()
 {
     Name = "release";
     Synonyms.Are("free");
     Grammars.Add("<noun>", ReleaseObject);
 }
예제 #19
0
 public Insert()
 {
     Name = "insert";
     Grammars.Add("<multi> in <noun>", InsertObject);
 }
예제 #20
0
 public SwitchOff()
 {
     Name = "switch";
     Grammars.Add("<noun> off", SwitchOffObject);
     Grammars.Add("off <noun>", SwitchOffObject);
 }
예제 #21
0
 public Drink()
 {
     Name = "drink";
     Synonyms.Are("sip", "swallow");
     Grammars.Add("<noun>", DrinkObject);
 }
예제 #22
0
 public Lock()
 {
     Name = "lock";
     Grammars.Add("<noun>", LockObject);
     Grammars.Add("<noun> with <held>", LockObject);
 }
예제 #23
0
 public Fill()
 {
     Name = "fill";
     Grammars.Add("<noun>", FillObject);
 }
예제 #24
0
 public Rub()
 {
     Name = "rub";
     Grammars.Add("<noun>", RubObject);
 }
예제 #25
0
 public Catch()
 {
     Name = "catch";
     Synonyms.Are("capture");
     Grammars.Add("<noun>", CatchObject);
 }
예제 #26
0
 public Get()
 {
     Name = "get";
     Grammars.Add("<multi>", TakeSingle);
 }
예제 #27
0
 public Attack()
 {
     Name = "attack";
     Synonyms.Are("break, crack, destroy, fight, hit, kill, murder, punch, smash, thump, torture, wreck");
     Grammars.Add(K.NOUN_TOKEN, AttackObject);
 }
예제 #28
0
 public Inv()
 {
     Name = "inventory";
     Synonyms.Are("i", "inv", "inventory");
     Grammars.Add(Grammar.Empty, DisplayInventory);
 }
예제 #29
0
 public Disrobe()
 {
     Synonyms.Are("doff", "shed");
     Grammars.Add(K.HELD_TOKEN, OnDisrobe);
 }
예제 #30
0
 public Examine()
 {
     Name = "examine";
     Synonyms.Are("examine", "x", "check", "describe", "watch");
     Grammars.Add("<noun>", ExamineObject);
 }