Exemplo n.º 1
0
        public BusinessType(XmlNode node)
        {
            try
            {
                id    = node.Attributes["id"].Value;
                _name = node.Attributes["name"].Value;
                XmlElement account = (XmlElement)XmlUtil.selectSingleNode(node, "account");
                _acc_fixed = double.Parse(account.Attributes["fixed"].Value);
                XmlElement market = (XmlElement)XmlUtil.selectSingleNode(node, "market");
                _mkt_supplied = 0;
                _mkt_scale    = long.Parse(market.Attributes["scale"].Value);
                _cycle        = int.Parse(market.Attributes["cycle"].Value);
                _amp          = int.Parse(market.Attributes["amplitude"].Value);
                _depend       = int.Parse(market.Attributes["ex_dependency"].Value);
                _progress     = int.Parse(market.Attributes["progressivity"].Value);

                XmlElement weight = (XmlElement)XmlUtil.selectSingleNode(node, "weight");
                weightBrand     = int.Parse(weight.Attributes["brand"].Value);
                weightMarketing = int.Parse(weight.Attributes["marketing"].Value);
                weightQuality   = int.Parse(weight.Attributes["quality"].Value);
                weightTotal     = weightBrand + weightMarketing + weightQuality;
                if (weightTotal == 0)
                {
                    weightTotal = 1;
                }
            }
            catch
            {
                throw new XmlException("invalid business type definition : " + id + name, null);
            }
            _trend = Trend.randomGenerate(_amp * Trend.RANGE / 2, _amp * Trend.RANGE / 2, _cycle / 2);
        }
Exemplo n.º 2
0
 private Economy()
 {
     onUpdate      += new EconomyListener(StocksListHelper.onUpdateMarket);
     _businessTypes = new BusinessTypes();
     _companies     = new ListedCompanies();
     _events        = new EventManager();
     //_random = new RandomEx();
     businessTrend = Trend.randomGenerate(500, 500, 90);
 }
Exemplo n.º 3
0
        private void apptyVal(double v, Trend t)
        {
            int n = t.reasonableLevel;

            n += Trend.RANGE;
            if (byRatio)
            {
                n = (int)(v * n);
            }
            else
            {
                n = (int)(v + n);
            }
            t.setParams(n -= Trend.RANGE, days);
        }