Esempio n. 1
0
        private static OptionOrder ReadOptionOrder(string s)
        {
            OptionOrder ord = new OptionOrder();

            ord.Option = MyStrings.GetToken(ref s).ToLower();
            if (ord.Option == "text-report" || ord.Option == "xml-report")
            {
                ord.Val = MyStrings.GetToken(ref s).ToLower();
                if (ord.Val != "0" && ord.Val != "1")
                {
                    throw new Exception("Wrong option value");
                }
            }
            else if (ord.Option == "language")
            {
                ord.Val = MyStrings.GetToken(ref s).ToLower();
                if (ord.Val != "ru" && ord.Val != "en")
                {
                    throw new Exception("Wrong option value");
                }
            }
            else
            {
                throw new Exception("No such option");
            }

            return(ord);
        }
Esempio n. 2
0
        public void Parse(string arguments)
        {
            string targetToken = MyStrings.GetToken(ref arguments).ToLower();

            #region switch target
            switch (targetToken)
            {
            case "person":
                this.What = DescribeOrder.Target.Person;
                break;

            case "object":
                this.What = DescribeOrder.Target.Object;
                break;

            default:
                throw new Exception("Bad target " + targetToken);
            }
            #endregion
            string desc             = MyStrings.GetQuotedToken(ref arguments);
            string descriptionToken = MyStrings.GetValidString(desc);
            if (desc != descriptionToken)
            {
                throw new Exception("Invalid characters in description");
            }

            this.Description = descriptionToken.Trim();
        }
Esempio n. 3
0
        public void Parse(string arguments)
        {
            string targetToken = MyStrings.GetToken(ref arguments);

            if (!MyStrings.IsNumber(targetToken))
            {
                throw new Exception("Bad target " + targetToken);
            }
            this.Target = Convert.ToInt32(targetToken);

            string amountToken = MyStrings.GetToken(ref arguments).ToLower();

            if (amountToken == "all")
            {
                this.Amount = -1;
            }
            else
            {
                if (!MyStrings.IsNumber(amountToken))
                {
                    throw new Exception("Bad amount " + amountToken);
                }
                this.Amount = Convert.ToInt32(amountToken);
            }

            string itemToken = MyStrings.GetQuotedToken(ref arguments);

            this.What = ItemType.GetByAnyName(itemToken);
            if (this.What == null)
            {
                throw new Exception("Bad item " + itemToken);
            }
        }
Esempio n. 4
0
        public void Parse(string arguments)
        {
            string targetToken = MyStrings.GetToken(ref arguments).ToLower();

            switch (targetToken)
            {
            case "person":
                this.What = NameOrder.Target.Person;
                break;

            case "faction":
                this.What = NameOrder.Target.Faction;
                break;

            case "object":
                this.What = NameOrder.Target.Object;
                break;

            default:
                throw new Exception("Bad target " + targetToken);
            }

            string name      = MyStrings.GetQuotedToken(ref arguments);
            string nameToken = MyStrings.GetValidString(name);

            if (nameToken != name)
            {
                throw new Exception("Invalid characters in name");
            }
            if (nameToken.Trim() == "")
            {
                throw new Exception("Bad name");
            }
            this.Name = nameToken.Trim();
        }
Esempio n. 5
0
        private static NameOrder ReadNameOrder(string s)
        {
            NameOrder ord = new NameOrder();

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

            if (t1 == "person")
            {
                ord.What = NameOrder.Target.Person;
            }
            else if (t1 == "faction")
            {
                ord.What = NameOrder.Target.Faction;
            }
            else if (t1 == "object")
            {
                ord.What = NameOrder.Target.Object;
            }
            else
            {
                throw new Exception("Bad target");
            }

            string t2 = MyStrings.GetValidString(MyStrings.GetQuotedToken(ref s));

            if (t2.Trim() == "")
            {
                throw new Exception("Bad name");
            }

            ord.Name = t2;
            return(ord);
        }
Esempio n. 6
0
        public void Parse(string arguments)
        {
            string token = MyStrings.GetToken(ref arguments).ToLower();

            #region switch token
            switch (token)
            {
            case "":
            case "none":
                this.Variant = HideOrder.Variants.Not;
                break;

            case "faction":
                this.Variant = HideOrder.Variants.Faction;
                break;

            case "person":
                this.Variant = HideOrder.Variants.Person;
                break;

            default:
                throw new Exception("Bad parameter " + token);
            }
            #endregion
        }
Esempio n. 7
0
        private static DriveOrder ReadDriveOrder(string s)
        {
            DriveOrder ord   = new DriveOrder();
            string     token = MyStrings.GetToken(ref s).ToLower();

            if (token == "attack")
            {
                ord.Attack = true;
                token      = MyStrings.GetToken(ref s).ToLower();
            }
            while (token != "")
            {
                switch (token)
                {
                case "n": ord.Directions.Add(Direction.North); break;

                case "nw": ord.Directions.Add(Direction.Northwest); break;

                case "ne": ord.Directions.Add(Direction.Northeast); break;

                case "s": ord.Directions.Add(Direction.South); break;

                case "sw": ord.Directions.Add(Direction.Southwest); break;

                case "se": ord.Directions.Add(Direction.Southeast); break;

                default: throw new Exception("Bad direction");
                }
                token = MyStrings.GetToken(ref s).ToLower();
            }
            return(ord);
        }
Esempio n. 8
0
        private static DescribeOrder ReadDescribeOrder(string s)
        {
            DescribeOrder ord = new DescribeOrder();

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

            if (t1 == "person")
            {
                ord.What = DescribeOrder.Target.Person;
            }
            else if (t1 == "object")
            {
                ord.What = DescribeOrder.Target.Object;
            }
            else
            {
                throw new Exception("Bad target");
            }

            string t2 = MyStrings.GetValidString(MyStrings.GetQuotedToken(ref s));

            if (t2.Trim() == "")
            {
                throw new Exception("Bad description");
            }

            ord.Description = t2;
            return(ord);
        }
Esempio n. 9
0
        private static DeclareOrder ReadDeclareOrder(Faction faction, string s)
        {
            // declare 12 neutral
            DeclareOrder ord = new DeclareOrder();

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

            if (t1 == "default")
            {
                ord.FactionNum = faction.Num;
            }
            else if (!MyStrings.IsNumber(t1))
            {
                throw new Exception("Bad faction");
            }
            ord.FactionNum = Convert.ToInt32(t1);

            string   t2 = MyStrings.GetQuotedToken(ref s);
            Attitude a  = Attitude.Hostile;

            while (a <= Attitude.Ally && a.ToString().ToLower() != t2)
            {
                a++;
            }
            if (a > Attitude.Ally)
            {
                throw new Exception("Bad attitude");
            }
            ord.Attitude = a;

            return(ord);
        }
Esempio n. 10
0
        public void Parse(Faction faction, string arguments)
        {
            // declare 12 neutral
            string factionToken = MyStrings.GetToken(ref arguments).ToLower();

            if (factionToken == "default")
            {
                // TODO: correct the logic
                // the logic here is mangled, it does work but I don't like it
                // it would be better to have class element public bool default instead
                this.FactionNum = faction.Num;
            }
            else
            {
                if (!MyStrings.IsNumber(factionToken))
                {
                    throw new Exception("Bad faction");
                }
                // TODO: missing check for existance of faction
                this.FactionNum = Convert.ToInt32(factionToken);
            }

            string   attitudeToken = MyStrings.GetQuotedToken(ref arguments).ToLower();
            Attitude attitude      = Attitude.Hostile;

            while (attitude <= Attitude.Ally && attitude.ToString().ToLower() != attitudeToken)
            {
                attitude++;
            }
            if (attitude > Attitude.Ally)
            {
                throw new Exception("Bad attitude " + attitudeToken);
            }
            this.Attitude = attitude;
        }
Esempio n. 11
0
        public void Parse(string arguments)
        {
            string token = MyStrings.GetToken(ref arguments);

            if (!MyStrings.IsNumber(token))
            {
                throw new Exception("Bad object");
            }
            this.BuildingNum = Convert.ToInt32(token);
        }
Esempio n. 12
0
        public void Parse(string arguments)
        {
            string token = MyStrings.GetToken(ref arguments);

            if (token != "0" && token != "1")
            {
                throw new Exception("Bad parameter " + token);
            }
            this.Flag = (token == "1");
        }
Esempio n. 13
0
        public virtual void Parse(string arguments)
        {
            string token = MyStrings.GetToken(ref arguments);

            if (!MyStrings.IsNumber(token))
            {
                throw new Exception("Bad target " + token);
            }
            // TODO: missing check for existance of a person
            this.PersonNum = Convert.ToInt32(token);
        }
Esempio n. 14
0
        private static Order ReadPersonNumOrder(string s, PersonNumOrder ord)
        {
            string t1 = MyStrings.GetToken(ref s);

            if (!MyStrings.IsNumber(t1))
            {
                throw new Exception("Bad target");
            }
            ord.PersonNum = Convert.ToInt32(t1);
            return(ord);
        }
Esempio n. 15
0
        private static EnterOrder ReadEnterOrder(string s)
        {
            EnterOrder ord = new EnterOrder();
            string     t1  = MyStrings.GetToken(ref s);

            if (!MyStrings.IsNumber(t1))
            {
                throw new Exception("Bad object");
            }
            ord.BuildingNum = Convert.ToInt32(t1);
            return(ord);
        }
Esempio n. 16
0
 public void Parse(string arguments)
 {
     while (arguments != "")
     {
         string token = MyStrings.GetToken(ref arguments);
         if (!MyStrings.IsNumber(token))
         {
             throw new Exception("Bad target " + token);
         }
         this.PatientNums.Add(Convert.ToInt32(token));
     }
 }
Esempio n. 17
0
        private static AvoidOrder ReadAvoidOrder(string s)
        {
            string t1 = MyStrings.GetToken(ref s);

            if (t1 != "0" && t1 != "1")
            {
                throw new Exception("Bad parameter");
            }
            AvoidOrder ord = new AvoidOrder();

            ord.Flag = (t1 == "1");
            return(ord);
        }
Esempio n. 18
0
        public void Parse(string arguments)
        {
            string targetToken = MyStrings.GetToken(ref arguments).ToLower();

            #region target token switch
            switch (targetToken)
            {
            case "faction":
                string factionToken = MyStrings.GetToken(ref arguments);
                if (!MyStrings.IsNumber(factionToken))
                {
                    throw new Exception("Bad faction " + factionToken);
                }
                this.FactionNum = Convert.ToInt32(factionToken);
                break;

            case "item":
                string   itemToken = MyStrings.GetQuotedToken(ref arguments).ToLower();
                ItemType itemType  = ItemType.GetByAnyName(itemToken);
                if (itemType == null)
                {
                    throw new Exception("Bad item " + itemToken);
                }
                this.ItemType = itemType;
                break;

            case "skill":
                string    skillToken = MyStrings.GetQuotedToken(ref arguments).ToLower();
                SkillType skillType  = SkillType.GetByAnyName(skillToken);
                if (skillType == null)
                {
                    throw new Exception("Bad skill " + skillToken);
                }
                this.SkillType = skillType;
                break;

            case "object":
                string       objectToken  = MyStrings.GetQuotedToken(ref arguments).ToLower();
                BuildingType buildingType = BuildingType.GetByAnyName(objectToken);
                if (buildingType == null)
                {
                    throw new Exception("Bad object");
                }
                this.BuildingType = buildingType;
                break;

            default:
                throw new Exception("Bad parameter " + targetToken);
            }
            #endregion
        }
Esempio n. 19
0
        private static CureOrder ReadCureOrder(string s)
        {
            CureOrder ord = new CureOrder();

            while (s != "")
            {
                string t = MyStrings.GetToken(ref s);
                if (!MyStrings.IsNumber(t))
                {
                    throw new Exception("Bad target");
                }
                ord.PatientNums.Add(Convert.ToInt32(t));
            }
            return(ord);
        }
Esempio n. 20
0
        public void Parse(string arguments)
        {
            string token = MyStrings.GetToken(ref arguments).ToLower();

            if (token == "attack")
            {
                this.Attack = true;
                token       = MyStrings.GetToken(ref arguments).ToLower();
            }
            while (token != "")
            {
                Directions.Add(GetDirection(token));
                token = MyStrings.GetToken(ref arguments).ToLower();
            }
        }
Esempio n. 21
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);
        }
Esempio n. 22
0
        private static MoveOrder ReadMoveOrder(string s)
        {
            MoveOrder ord   = new MoveOrder();
            string    token = MyStrings.GetToken(ref s).ToLower();

            if (token == "attack")
            {
                ord.Attack = true;
                token      = MyStrings.GetToken(ref s).ToLower();
            }
            while (token != "")
            {
                switch (token)
                {
                case "n": ord.Directions.Add(Direction.North); break;

                case "nw": ord.Directions.Add(Direction.Northwest); break;

                case "ne": ord.Directions.Add(Direction.Northeast); break;

                case "s": ord.Directions.Add(Direction.South); break;

                case "sw": ord.Directions.Add(Direction.Southwest); break;

                case "se": ord.Directions.Add(Direction.Southeast); break;

                case "out": ord.Directions.Add(0); break;

                default:                         // move in building
                {
                    try
                    {
                        ord.Directions.Add(Convert.ToInt32(token));
                    }
                    catch (FormatException)
                    {
                        throw new Exception("Bad direction");
                    }
                    break;
                }
                }
                token = MyStrings.GetToken(ref s).ToLower();
            }
            return(ord);
        }
Esempio n. 23
0
        public void Parse(string arguments)
        {
            string valueToken;
            string optionToken = MyStrings.GetToken(ref arguments).ToLower();

            switch (optionToken)
            {
            case "text-report":
            case "xml-report":
                valueToken = MyStrings.GetToken(ref arguments).ToLower();
                if (valueToken != "0" && valueToken != "1")
                {
                    throw new Exception("Wrong option value " + valueToken);
                }
                this.Val = valueToken;
                break;

            case "language":
                valueToken = MyStrings.GetToken(ref arguments).ToLower();
                if (valueToken != "ru" && valueToken != "en")
                {
                    throw new Exception("Wrong option value");
                }
                this.Val = valueToken;
                break;

            case "template":
                valueToken = MyStrings.GetToken(ref arguments).ToLower();
                if (valueToken != "long" && valueToken != "short")
                {
                    throw new Exception("Wrong option value");
                }
                this.Val = valueToken;
                break;

            default:
                throw new Exception("No such option");
            }
            this.Option = optionToken;
        }
Esempio n. 24
0
        public void Parse(string arguments)
        {
            string token = MyStrings.GetToken(ref arguments).ToLower();

            if (token == "kick")
            {
                this.Kick = true;
                token     = MyStrings.GetToken(ref arguments).ToLower();
            }
            if (token == string.Empty || token == "none")
            {
                this.LeaderNum = 0;
            }
            else
            {
                if (!MyStrings.IsNumber(token))
                {
                    throw new Exception("Bad target " + token);
                }
                this.LeaderNum = Convert.ToInt32(token);
            }
        }
Esempio n. 25
0
        private static HideOrder ReadHideOrder(string s)
        {
            string    t1  = MyStrings.GetToken(ref s).ToLower();
            HideOrder ord = new HideOrder();

            if (t1 == "" || t1 == "none")
            {
                ord.Variant = HideOrder.Variants.Not;
            }
            else if (t1 == "faction")
            {
                ord.Variant = HideOrder.Variants.Faction;
            }
            else if (t1 == "person")
            {
                ord.Variant = HideOrder.Variants.Person;
            }
            else
            {
                throw new Exception("Bad parameter");
            }
            return(ord);
        }
Esempio n. 26
0
        private static GiveOrder ReadGiveOrder(string s)
        {
            GiveOrder ord = new GiveOrder();

            string t1 = MyStrings.GetToken(ref s);

            if (!MyStrings.IsNumber(t1))
            {
                throw new Exception("Bad target");
            }
            ord.Target = Convert.ToInt32(t1);

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

            if (t2 == "all")
            {
                ord.Amount = -1;
            }
            else
            {
                if (!MyStrings.IsNumber(t2))
                {
                    throw new Exception("Bad amount");
                }
                ord.Amount = Convert.ToInt32(t2);
            }

            string t3 = MyStrings.GetQuotedToken(ref s);

            ord.What = ItemType.GetByAnyName(t3);
            if (ord.What == null)
            {
                throw new Exception("Bad item");
            }

            return(ord);
        }
Esempio n. 27
0
        private static TeamOrder ReadTeamOrder(string s)
        {
            TeamOrder ord = new TeamOrder();
            string    t2  = MyStrings.GetToken(ref s).ToLower();

            if (t2 == "kick")
            {
                ord.Kick = true;
                t2       = MyStrings.GetToken(ref s).ToLower();
            }
            if (t2 == "" || t2 == "none")
            {
                ord.LeaderNum = 0;
            }
            else
            {
                if (!MyStrings.IsNumber(t2))
                {
                    throw new Exception("Bad target");
                }
                ord.LeaderNum = Convert.ToInt32(t2);
            }
            return(ord);
        }
Esempio n. 28
0
        public static void Load(string filename, bool checker)
        {
            TextReader tr = new StreamReader(filename, System.Text.Encoding.GetEncoding(1251));

            bool      do_read       = false;
            Person    person        = null;
            Faction   faction       = null;
            bool      errors        = false;
            ArrayList CheckerOutput = new ArrayList();

            while (true)
            {
                try
                {
                    string line = tr.ReadLine();
                    string s    = line;
                    if (s == null)
                    {
                        break;
                    }

                    // Store repeating lines
                    if (s.Length > 0 && s[0] == '@')
                    {
                        if (person != null)
                        {
                            person.RepeatingLines.Add(line);
                        }
                        s = s.Substring(1);
                    }

                    // Strip comments
                    s = MyStrings.Uncomment(s).Trim();

                    // Get first word as command
                    string cmd = MyStrings.GetToken(ref s).ToLower();

                    // Directives
                    if (cmd == "#orders")
                    {
                        string t2 = MyStrings.GetToken(ref s);
                        if (!MyStrings.IsNumber(t2))
                        {
                            throw new Exception("Bad faction");
                        }
                        int    num      = Convert.ToInt32(t2);
                        string password = MyStrings.GetQuotedToken(ref s);
                        faction = (Faction)Faction.Get(num);
                        if (faction == null)
                        {
                            throw new Exception("No such faction");
                        }
                        if (password != faction.Password || faction.IsNPC)
                        {
                            throw new Exception("Wrong password");
                        }

                        Console.WriteLine("..orders for " + faction.Num.ToString());

                        CheckerOutput.Add("To: " + faction.Email);
                        CheckerOutput.Add("Subject: [Wasteland] Checker Output");
                        CheckerOutput.Add("");
                        CheckerOutput.Add(line);

                        do_read = true;
                        continue;
                    }
                    if (cmd == "#end")
                    {
                        do_read = false;
                    }
                    if (!do_read || cmd == "")
                    {
                        continue;
                    }
                    if (cmd == "person")
                    {
                        string t2 = MyStrings.GetToken(ref s);
                        if (!MyStrings.IsNumber(t2))
                        {
                            throw new Exception("Bad person");
                        }
                        int num = Convert.ToInt32(t2);
                        person = faction.Persons.GetByNumber(num);
                        if (person == null)
                        {
                            throw new Exception("This person is not in your faction");
                        }
                        CheckerOutput.Add("\r\n" + line);
                        continue;
                    }

                    CheckerOutput.Add(line);

                    if (person == null)
                    {
                        throw new Exception("Order given with no person specified");
                    }

                    Order order = OrdersReader.ParseOrder(person, faction, cmd, s);

                    // Overwrite monthlong order
                    if (order.IsMonthlong)
                    {
                        int i = 0;
                        while (i < person.Orders.Count)
                        {
                            if (((Order)person.Orders[i]).IsMonthlong)
                            {
                                person.Orders.RemoveAt(i);
                                CheckerOutput.Add("; **** Overwriting previous monthlong order ****\r\n");
                                errors = true;
                            }
                            else
                            {
                                i++;
                            }
                        }
                    }

                    // Overwrite trade order
                    if (order.GetType() == typeof(TradeOrder))
                    {
                        int i = 0;
                        while (i < person.Orders.Count)
                        {
                            if (person.Orders[i].GetType() == typeof(TradeOrder))
                            {
                                person.Orders.RemoveAt(i);
                                CheckerOutput.Add("; **** Overwriting previous trade order ****\r\n");
                                errors = true;
                            }
                            else
                            {
                                i++;
                            }
                        }
                    }

                    person.Orders.Add(order);
                }
                catch (Exception ex)
                {
                    CheckerOutput.Add("; **** " + ex.Message + " ****\r\n");
                    errors = true;
                }
            }

            tr.Close();

            if (checker)
            {
                string checkername = Path.Combine(Path.GetDirectoryName(filename),
                                                  "checker." + Path.GetFileName(filename));
                TextWriter tw = new StreamWriter(checkername, false, System.Text.Encoding.GetEncoding(1251));
                if (errors)
                {
                    foreach (string s in CheckerOutput)
                    {
                        tw.WriteLine(s);
                    }
                }
                else
                {
                    // Write only message header
                    foreach (string s in CheckerOutput)
                    {
                        tw.WriteLine(s);
                        if (s == "")
                        {
                            break;
                        }
                    }
                    tw.WriteLine("Your order was accepted without errors.");
                }
                tw.Close();
            }
        }
Esempio n. 29
0
        public void Parse(string arguments)
        {
            string token = MyStrings.GetToken(ref arguments).ToLower();

            string   itemToken;
            ItemType itemType;

            // TODO: refactor needed, this logic isn't very clear
            if (token == "with")
            {
                token = MyStrings.GetToken(ref arguments);
                if (!MyStrings.IsNumber(token))
                {
                    throw new Exception("Bad target " + token);
                }
                this.PersonNum = Convert.ToInt32(token);
                token          = MyStrings.GetToken(ref arguments).ToLower();
            }
            else
            {
                this.PersonNum = 0;
            }

            if (token == "all")
            {
                this.SellAmount = -1;
            }
            else
            {
                if (!MyStrings.IsNumber(token))
                {
                    throw new Exception("Bad sell amount " + token);
                }
                this.SellAmount = Convert.ToInt32(token);
            }

            itemToken = MyStrings.GetQuotedToken(ref arguments);
            itemType  = ItemType.GetByAnyName(itemToken);
            if (itemType == null)
            {
                throw new Exception("Bad sell item " + itemToken);
            }
            this.SellWhat = itemType;

            token = MyStrings.GetToken(ref arguments).ToLower();
            if (token == "all")
            {
                this.BuyAmount = -1;
            }
            else
            {
                if (!MyStrings.IsNumber(token))
                {
                    throw new Exception("Bad buy amount " + token);
                }
                this.BuyAmount = Convert.ToInt32(token);
            }

            itemToken = MyStrings.GetQuotedToken(ref arguments);
            itemType  = ItemType.GetByAnyName(itemToken);
            if (itemType == null)
            {
                throw new Exception("Bad buy item " + itemToken);
            }
            this.BuyWhat = itemType;
        }
Esempio n. 30
0
        private static TradeOrder ReadTradeOrder(string s)
        {
            TradeOrder ord = new TradeOrder();

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

            if (t1 == "with")
            {
                string num = MyStrings.GetToken(ref s);
                if (!MyStrings.IsNumber(num))
                {
                    throw new Exception("Bad target");
                }
                ord.PersonNum = Convert.ToInt32(num);
                t1            = MyStrings.GetToken(ref s).ToLower();
            }
            else
            {
                ord.PersonNum = 0;
            }

            if (t1 == "all")
            {
                ord.SellAmount = -1;
            }
            else
            {
                if (!MyStrings.IsNumber(t1))
                {
                    throw new Exception("Bad sell amount");
                }
                ord.SellAmount = Convert.ToInt32(t1);
            }

            ord.SellWhat = ItemType.GetByAnyName(MyStrings.GetQuotedToken(ref s));
            if (ord.SellWhat == null)
            {
                throw new Exception("Bad sell item");
            }

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

            if (t2 == "all")
            {
                ord.BuyAmount = -1;
            }
            else
            {
                if (!MyStrings.IsNumber(t2))
                {
                    throw new Exception("Bad buy amount");
                }
                ord.BuyAmount = Convert.ToInt32(t2);
            }

            ord.BuyWhat = ItemType.GetByAnyName(MyStrings.GetQuotedToken(ref s));
            if (ord.BuyWhat == null)
            {
                throw new Exception("Bad buy item");
            }

            return(ord);
        }