コード例 #1
0
        /// <summary>
        /// 识别人形建造字符串
        /// </summary>
        /// <param name="receive_msg">输入的指令</param>
        /// <returns>表示建造结果的字符串</returns>
        private List <GFLElements> Action_MakeTdoll(QQMessage receive_msg)
        {
            //Simulator simulator = new Simulator();

            string[]           order = receive_msg.Text.Split();
            List <GFLElements> tdoll_info;

            if (order.Length == 2)  // 输入的指令为建造公式
            {
                try
                {
                    string     formula   = order[1];
                    List <int> resources = Tdoll_FormulaDistinguish(formula);

                    if (resources.Count == 4)
                    {
                        tdoll_info = simulator.BuildElement(resources, BUILD_NUM);
                    }
                    else
                    {
                        throw new ArgumentException("建造公式错误");
                    }
                }
                catch (FormatException e1)
                {
                    throw e1;
                }
                catch (ArgumentException e2)
                {
                    throw new ArgumentException("建造公式错误", e2);
                }
            }
            else if (order.Length == 5)     //输入的指令为建造资源
            {
                try
                {
                    tdoll_info = this.simulator.BuildElement(int.Parse(order[1]), int.Parse(order[2]),
                                                             int.Parse(order[3]), int.Parse(order[4]), BUILD_NUM);
                }
                catch (FormatException e1)
                {
                    throw e1;
                }
                catch (ArgumentException e2)
                {
                    throw new ArgumentException("非法资源数目", e2);
                }
            }
            else
            {
                throw new ArrayTypeMismatchException("建造指令形式错误");
            }

            return(tdoll_info);
        }
コード例 #2
0
        public void Simulator_BuilElement_OK()
        {
            Simulator simulator = new Simulator();

            simulator.BuildElement(999, 999, 999, 999, 50);
        }