Beispiel #1
0
        private static ShowOrder ReadShowOrder(string s)
        {
            ShowOrder ord = new ShowOrder();

            string t1 = MyStrings.GetToken(ref s).ToLower();

            if (t1 == "faction")
            {
                string t2 = MyStrings.GetToken(ref s);
                if (!MyStrings.IsNumber(t2))
                {
                    throw new Exception("Bad faction");
                }
                ord.FactionNum = Convert.ToInt32(t2);
            }
            else if (t1 == "item")
            {
                string t2 = MyStrings.GetQuotedToken(ref s).ToLower();
                ord.ItemType = ItemType.GetByAnyName(t2);
                if (ord.ItemType == null)
                {
                    throw new Exception("Bad item");
                }
            }
            else if (t1 == "skill")
            {
                string t2 = MyStrings.GetQuotedToken(ref s).ToLower();
                ord.SkillType = SkillType.GetByAnyName(t2);
                if (ord.SkillType == null)
                {
                    throw new Exception("Bad skill");
                }
            }
            else if (t1 == "object")
            {
                string t2 = MyStrings.GetQuotedToken(ref s).ToLower();
                ord.BuildingType = BuildingType.GetByAnyName(t2);
                if (ord.BuildingType == null)
                {
                    throw new Exception("Bad object");
                }
            }
            else
            {
                throw new Exception("Bad parameter");
            }
            return(ord);
        }
Beispiel #2
0
        public static Order ParseOrder(Person person, Faction faction, string command, string arguments)
        {
            Order order;

            switch (command)
            {
            case "address":
                order = new AddressOrder(arguments);
                break;

            case "attack":
                order = new AttackOrder(arguments);
                break;

            case "avoid":
                order = new AvoidOrder(arguments);
                break;

            case "build":
                order = new BuildOrder(arguments);
                break;

            case "burn":
                order = new BurnOrder(arguments);
                break;

            case "consume":
                order = new ConsumeOrder(person, arguments);
                break;

            case "cure":
                order = new CureOrder(arguments);
                break;

            case "declare":
                order = new DeclareOrder(faction, arguments);
                break;

            case "describe":
                order = new DescribeOrder(arguments);
                break;

            case "drive":
                order = new DriveOrder(arguments);
                break;

            case "enter":
                order = new EnterOrder(arguments);
                break;

            case "equipment":
                order = new EquipmentOrder(arguments);
                break;

            case "evict":
                order = new EvictOrder(arguments);
                break;

            case "give":
                order = new GiveOrder(arguments);
                break;

            case "greedy":
                order = new GreedyOrder(arguments);
                break;

            case "hide":
                order = new HideOrder(arguments);
                break;

            case "install":
                order = new InstallOrder(arguments);
                break;

            case "kick":
                order = new KickOrder();
                break;

            case "leave":
                order = new LeaveOrder();
                break;

            case "move":
                order = new MoveOrder(arguments);
                break;

            case "name":
                order = new NameOrder(arguments);
                break;

            case "option":
                order = new OptionOrder(arguments);
                break;

            case "password":
                order = new PasswordOrder(arguments);
                break;

            case "patrol":
                order = new PatrolOrder();
                break;

            case "produce":
                order = new ProduceOrder(arguments);
                break;

            case "quit":
                order = new QuitOrder(faction, arguments);
                break;

            case "scavenge":
                order = new ScavengeOrder(arguments);
                break;

            case "show":
                order = new ShowOrder(arguments);
                break;

            case "spoils":
                order = new SpoilsOrder(arguments);
                break;

            case "team":
                order = new TeamOrder(arguments);
                break;

            case "trade":
                order = new TradeOrder(arguments);
                break;

            case "uninstall":
                order = new UninstallOrder(arguments);
                break;

            default:
                throw new Exception("Bad order " + command);
            }
            return(order);
        }