Example #1
0
        protected override bool ExecuteWithData(string cmd, IRepository repo, Player player)
        {
            string[] cmdArray = cmd.Split(new[] { ' ' }, 2);

            string name = "";
            if (cmdArray.GetUpperBound(0) >= 1)
                name = cmdArray[1].Trim();

            GameObject target;

            switch (name.ToLower())
            {
                case "here":
                case "":
                    target = player.Location;
                    break;
                default:
                    target = queries.FindNearPlayer(repo, player, name);
                    break;
            }

            if (target == null)
            {
                console.WriteLine(STR_NoSuchObject, name);
                return false;
            }

            formatters.OfType<LookFormatter>().First().Format(target);
            formatters.OfType<InventoryFormatter>().First().Format(target);
            return false;
        }
Example #2
0
 protected override bool ExecuteWithData(string cmd, IRepository repo, Player player)
 {
     var name = cmd.Split(new[] { ' ' }, 2)[1];
     repo.Add(new GameObject { Name = name, Location = player });
     console.WriteLine("You create a {0}.", name);
     return true;
 }
Example #3
0
        protected override bool ExecuteWithData(string cmd, IRepository repo, Player player)
        {
            SetParameters setParams = ParseCommand(cmd);
            GameObject go;
            if (setParams.GameObjectName == "here")
                go = player.Location;
            else
                go = queries.FindNearPlayer(repo, player, setParams.GameObjectName);

            if (go == null)
            {
                console.WriteLine(STR_NoSuchObject, setParams.GameObjectName);
            }

            switch (setParams.Property.ToLower())
            {
                case "name":
                    go.Name = setParams.Value;
                    formatters.OfType<LookFormatter>().First().Format(go);
                    return true;
                case "desc":
                case "description":
                    go.Description = setParams.Value;
                    formatters.OfType<LookFormatter>().First().Format(go);
                    return true;
                default:
                    console.WriteLine("You cannot set {0} on {1}.", setParams.Property, setParams.GameObjectName);
                    return false;
            }
        }
Example #4
0
 protected override bool ExecuteWithData(string cmd, IRepository repo, Player player)
 {
     var name = cmd.Split(' ')[1];
     var go = queries.FindInLocation(repo, player.Location, name);
     if (go != null)
     {
         go.Location = player;
         console.WriteLine("You pickup {0}.", name);
         return true;
     }
     else
     {
         console.WriteLine(STR_NoSuchObject, name);
         return false;
     }
 }
Example #5
0
 protected abstract bool ExecuteWithData(string cmd, IRepository repo, Player player);
Example #6
0
 protected override bool ExecuteWithData(string cmd, IRepository repo, Player player)
 {
     formatters.OfType<InventoryFormatter>().First().Format(player);
     return false;
 }