Exemplo n.º 1
0
        public void Init()
        {
            w = new World(loadingfile);
            Room bank = new Room(w, "the bank",
            @"Long room. Allong the sides are many cosics with
            tellers sleeping behind their desks. At at the north
            end is a row of tall, narrow, plain wooden doors
            leading outside, at the south end a big, itricately
            carved wooden door") {w.player};
            Room sidewalk = new Room(w, "The sidewalk",
                @"Long line of rought stone tiles allong a street")
                {
                    new Item("golden candlestick","elegant white-golden candlestick",new string[] {"golden","white-golden","elagent"},new string[] {"candlestick","stick"})
                };
            Room safe = new Room(w, "The safe",
                @"inside of a big metal cube. This safe is no longer in use, but some left over coins still lie on the floor.") {
                new Item("teddy bear","Small furry creature, staring at you with its glassy eyes...",new string[] {"teddy","furry"},
                    new string[] {"creature","bear"},new CantPickUp("The bear appears to be glued to the floor.")),
                new Item("plastic fish","Hideous yellow blob, bought cheaply from some low-level toy shop",new string[] {"plastic","yellow"},new string[] {"fish","blob"},
                    new MessageBeforeAndAfter())
            };

            safe.Connect(bank,direction.North);
            sidewalk.Connect(bank, direction.South);
        }
Exemplo n.º 2
0
 public override bool match(string s, World g)
 {
     List<Anything> f = g.FilterItems(s,room,inv);
     if (f.Count == 1)
     {
         itm = f[0];
         return true;
     }
     else
     {
         return false;
     }
 }
Exemplo n.º 3
0
 public override bool match(string s, World g)
 {
     bool result = s.Equals(Text);
     if (result)
     {
         //Debugger.Log(1, "parser", ", sucsess");
     }
     else
     {
         //Debugger.Log(1, "parser", ", failure");
     }
     return result;
 }
Exemplo n.º 4
0
 public override bool match(string s, World g)
 {
     value = s;
     return true;
 }
Exemplo n.º 5
0
 public override bool match(string s, World g)
 {
     switch (s)
     {
         case "n":
         case "north":
             d = direction.North;
             return true;
         case "e":
         case "east":
             d = direction.East;
             return true;
         case "s":
         case "south":
             d = direction.South;
             return true;
         case "w":
         case "west":
             d = direction.West;
             return true;
         case "in":
             d = direction.In;
             return true;
         case "out":
             d = direction.Out;
             return true;
         case "u":
         case "up":
             d = direction.Up;
             return true;
         case "d":
         case "down":
             d = direction.Down;
             return true;
         case "northeast":
         case "ne":
             d = direction.Northeast;
             return true;
         case "northwest":
         case "nw":
             d = direction.Northwest;
             return true;
         case "sw":
         case "southwest":
             d = direction.Southwest;
             return true;
         case "se":
         case "southeast":
             d = direction.Southeast;
             return true;
         default:
             return false;
     }
 }
Exemplo n.º 6
0
        public override bool match(string s, World g)
        {
            string[] words = s.Split(Util.splits);

            bool suc = true;
            if (words.Length < prob.Length)
            {
                return false;
            }
            int istart = 0;
            int iend = words.Length;
            int j = 0;
            string[] xwords;
            while (istart < words.Length)
            {
                suc = false;
                while (iend > istart)
                {
                    xwords = Util.slice(words, istart, iend);
                    if (prob[j].match(string.Join(" ", xwords),g))
                    {
                        suc = true;
                        istart = iend;
                        iend = words.Length;
                        j += 1;
                        if (j>=prob.Length && istart<words.Length){
                            //Console.WriteLine("I understood you untill " + words[istart]);
                            return false;
                        }
                        break;
                    }
                    else
                    {
                        iend -= 1;
                    }
                }

                if (!suc)
                {
                    //Debugger.Log(1, "parser", "failure due to iend>words.length");
                    return false;
                }

            }
            if (j == prob.Length)
            {
                return true;
            }
            else
            {
                //Debugger.Log(1, "parser", "failure due to prob <= j");
                return false;
            }
        }
Exemplo n.º 7
0
 public override bool match(string s, World g)
 {
     selected = null;
     foreach (Matcher f in m)
     {
         if (f.match(s,g)){
             selected=f;
         }
     }
     if (selected==null){
         return false;
     }
     else{
         return true;
     }
 }
Exemplo n.º 8
0
 public abstract bool match(string s, World g);
Exemplo n.º 9
0
 public override bool CheckEv(string ev, Dictionary<string, object> args, Role r, World g)
 {
     if (ev.Equals("take") && r == Role.PrimObj){
         Console.WriteLine(msg);
         return true;
     }
     return false;
 }
Exemplo n.º 10
0
 public bool match(string s, World g)
 {
     return(matcher.match(s, g));
 }
Exemplo n.º 11
0
 public override bool match(string s, World g)
 {
     value = s;
     return(true);
 }
Exemplo n.º 12
0
 abstract public bool match(string s, World g);
Exemplo n.º 13
0
 public bool DoEv(string ev, Dictionary<string, object> args, Role r, World g)
 {
     switch (ev)
     {
         case "quit":
             g.quit();
             return true;
         case "say":
             Console.WriteLine("you say " + args["name"].ToString());
             return true;
         case "go":
             direction i = (direction)args["direction"];
             Dictionary<direction, Room> directions = ((Room)g.player.getParent()).directions;
             if (directions.ContainsKey(i))
             {
                 g.player.moveTo(directions[i]);
                 Console.Write("you go ");
                 Console.WriteLine(i);
                 g.interpretLine("look");
                 return true;
             }
             else
             {
                 Console.WriteLine("you run into a wall");
                 return true;
             }
         case "look_room":
             Console.BackgroundColor = ConsoleColor.White;
             Console.ForegroundColor = ConsoleColor.Black;
             IContainer v = g.player.getParent();
             Util.centerText(v.getName(), Console.WindowWidth);
             Console.ResetColor();
             Console.WriteLine(v.getDescription());
             if (v.Length > 1)
             {
                 Console.Write("there is a ");
             }
             int index = 0;
             foreach (Anything l in v)
             {
                 if (l != g.player)
                 {
                     Console.Write(l);
                     index += 1;
                     if (index == v.Length - 2)
                     {
                         Console.Write(" and a ");
                     }
                     else if (index < v.Length - 2)
                     {
                         Console.Write(", a ");
                     }
                 }
                 else
                 {
                 }
             }
             if (v.Length > 1)
             {
                 Console.WriteLine(" here");
             }
             return true;
         case "take":
             Item t = (Item)args["item"];
             t.moveTo(g.player);
             Console.WriteLine("you take the " + t.ToString() + ".");
             return true;
         case "drop":
             Item n = (Item)args["item"];
             n.moveTo(g.player.getParent());
             Console.WriteLine("you drop the " + n.ToString() + ".");
             return true;
         case "inventory":
             if (g.player.Length != 0)
             {
                 Console.WriteLine("You are carying: ");
                 foreach (Anything l in g.player)
                 {
                     Console.WriteLine("- a " + l.ToString());
                 }
                 return true;
             }
             else
             {
                 Console.WriteLine("You arn't carying anything.");
                 return true;
             }
         case "examine":
             Anything o = (Anything)args["item"];
             Console.WriteLine(o);
             Console.WriteLine(o.getDescription());
             return true;
         default:
             return false;
     }
 }
Exemplo n.º 14
0
 public bool CheckEv(string ev, Dictionary<string, object> args, Role r, World g)
 {
     return false;
 }
Exemplo n.º 15
0
 public override bool BeforeEv(string ev, Dictionary<string, object> args, Role r, World g)
 {
     if (ev.Equals("examine") && r == Role.PrimObj)
     {
         Console.WriteLine("before");
         return true;
     }
     return false;
 }
Exemplo n.º 16
0
 public bool match(string s, World g)
 {
     return matcher.match(s, g);
 }
Exemplo n.º 17
0
        public override bool match(string s, World g)
        {
            switch (s)
            {
            case "n":
            case "north":
                d = direction.North;
                return(true);

            case "e":
            case "east":
                d = direction.East;
                return(true);

            case "s":
            case "south":
                d = direction.South;
                return(true);

            case "w":
            case "west":
                d = direction.West;
                return(true);

            case "in":
                d = direction.In;
                return(true);

            case "out":
                d = direction.Out;
                return(true);

            case "u":
            case "up":
                d = direction.Up;
                return(true);

            case "d":
            case "down":
                d = direction.Down;
                return(true);

            case "northeast":
            case "ne":
                d = direction.Northeast;
                return(true);

            case "northwest":
            case "nw":
                d = direction.Northwest;
                return(true);

            case "sw":
            case "southwest":
                d = direction.Southwest;
                return(true);

            case "se":
            case "southeast":
                d = direction.Southeast;
                return(true);

            default:
                return(false);
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// Called after "before" and before "after".
 /// Return if you did something. If you return
 /// true, the normal behovior will not happen
 /// </summary>
 /// <param name="ev"></param>
 /// <param name="args"></param>
 /// <param name="r"></param>
 /// <param name="g"></param>
 /// <returns></returns>
 public virtual bool InsteadEv(string ev, Dictionary<string, object> args, Role r, World g)
 {
     return false;
 }