Ejemplo n.º 1
0
        public override void PushEntry(string entry)
        {
            List <string> list;

            switch (this.ParamType)
            {
            case FuncParamType.Array:
            {
                list = ParserTools.StringIntoArray(entry, this.FunctionName);
                ListIntoControl(list);
                break;
            }

            case FuncParamType.ORList:
            {
                list = ParserTools.StringIntoORList(entry, this.FunctionName);
                ListIntoControl(list);
                break;
            }

            case FuncParamType.Mapping:
            {
                Dictionary <string, string> pairs = ParserTools.StringIntoMap(entry, this.FunctionName);
                PairsIntoControl(pairs);
                break;
            }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Parses a string into it's component parts for use in the control's native format.
        /// </summary>
        public override void PushEntry(string entry)
        {
            EntryList.Items.Clear();
            Entry.Text = "";

            if (this.ParameterType == FuncParamType.Array)
            {
                List <string> temp = ParserTools.StringIntoArray(entry, this.FunctionName);
                ListIntoControl(temp);
            }

            if (this.ParameterType == FuncParamType.ORList)
            {
                List <string> temp = ParserTools.StringIntoORList(entry, this.FunctionName);
                ListIntoControl(temp);
            }
        }
Ejemplo n.º 3
0
        private void CalculateCost_Click(object sender, EventArgs e)
        {
            string agentName = "CreateItemForm->CalculatCost_Click";
            List <IFunctionControl> functionControls = this.Manager.CompileFunctionControlsList(this);
            FunctionCallsCollection functions        = this.Manager.CompileFunctioCallsList(functionControls);
            FunctionCallsCollection inherits         = this.Manager.CompileIheritList(functionControls);
            double HpValue = 0.15;


            int totalCost = 0;

            //is it a gun?
            if (CheckParams(inherits, "inherit LIB_FIREARM;") != null)
            {
                //check firearm damage
                string gunDamage = CheckParams(functions, "SetGunClass");
                if (gunDamage != null)
                {
                    totalCost += 10 * Convert.ToInt32(gunDamage);
                }

                //reduced melee value
                string meleeDamage = CheckParams(functions, "SetClass");
                if (meleeDamage != null)
                {
                    totalCost += 2 * Convert.ToInt32(meleeDamage);
                }

                //tally up number of damagetypes for gun
                string damageType = CheckParams(functions, "SetGunDamageType");
                if (damageType != null)
                {
                    foreach (string value in ParserTools.StringIntoORList(damageType, agentName))
                    {
                        //adds 12 for each type of damage it does
                        totalCost += 12;
                    }
                }

                string hp = CheckParams(functions, "SetDamagePoints");
                if (hp != null)
                {
                    totalCost += (int)System.Math.Round((double)Convert.ToDouble(hp) * HpValue);
                }

                string accuracy = CheckParams(functions, "SetAccuracy");
                if (accuracy != null)
                {
                    totalCost -= 5 * (100 - Convert.ToInt32(accuracy));
                }

                string accuracyDrop = CheckParams(functions, "SetAccuracyDropoff");
                if (accuracyDrop != null)
                {
                    totalCost -= Convert.ToInt32(accuracyDrop);
                }
            }



            //else, is it ammo?
            else if (CheckParams(inherits, "inherit LIB_MAGAZINE;") != null)
            {
                string damageType = CheckParams(functions, "SetDamageTypeBonus");
                if (damageType != null)
                {
                    foreach (string value in ParserTools.StringIntoORList(damageType, agentName))
                    {
                        totalCost += 1;
                    }
                }


                //we assume that if there is more than one for max ammo, that it is a clip
                //and if there is only one, it is a round
                string maxAmmo = CheckParams(functions, "SetMaxAmmo");
                if (maxAmmo != null)
                {
                    int ammo = Convert.ToInt32(maxAmmo);
                    //round based
                    if (ammo == 1)
                    {
                        totalCost += 1;
                        double AccuracyBonusValue = 0.10;
                        double ClassBonusValue    = 0.10;

                        string classBonus = CheckParams(functions, "SetClassBonus");
                        if (classBonus != null)
                        {
                            totalCost += (int)System.Math.Floor((double)Convert.ToDouble(classBonus) * ClassBonusValue);
                        }

                        string accuracyBonus = CheckParams(functions, "SetAccuracyBonus");
                        if (accuracyBonus != null)
                        {
                            totalCost += (int)System.Math.Floor((double)Convert.ToDouble(accuracyBonus) * AccuracyBonusValue);
                        }
                    }
                    //magazine based
                    else
                    {
                        totalCost += (int)System.Math.Round((double)ammo * (double)0.4f);
                        double AccuracyBonusValue = 0.5;
                        double ClassBonusValue    = 0.5;

                        string classBonus = CheckParams(functions, "SetClassBonus");
                        if (classBonus != null)
                        {
                            totalCost += (int)System.Math.Floor((double)Convert.ToDouble(classBonus) * ClassBonusValue);
                        }

                        string accuracyBonus = CheckParams(functions, "SetAccuracyBonus");
                        if (accuracyBonus != null)
                        {
                            totalCost += (int)System.Math.Floor((double)Convert.ToDouble(accuracyBonus) * AccuracyBonusValue);
                        }
                    }
                }
            }



            //must be a regular item, maybe a weapon?
            else
            {
                //otherwise check melee at regular value
                string meleeDamage = CheckParams(functions, "SetClass");
                if (meleeDamage != null)
                {
                    totalCost += 8 * Convert.ToInt32(meleeDamage);
                }

                //tally up number of damagetypes for gun
                string damageType = CheckParams(functions, "SetDamageType");
                if (damageType != null)
                {
                    foreach (string value in ParserTools.StringIntoORList(damageType, agentName))
                    {
                        //adds 12 for each type of damage it does
                        totalCost += 12;
                    }
                }

                //is it a weapon?
                if (Convert.ToInt32(meleeDamage) > 1)
                {
                    string hp = CheckParams(functions, "SetDamagePoints");
                    if (hp != null)
                    {
                        totalCost += (int)System.Math.Round((double)Convert.ToDouble(hp) * HpValue);
                    }
                }
            }



            if (CheckParams(inherits, "inherit LIB_STORAGE;") != null)
            {
                string carry = CheckParams(functions, "SetMaxCarry");

                //divide by ten since weights are in hundreths of a pound
                if (carry != null)
                {
                    totalCost += 2 * Convert.ToInt32(carry) / 10;
                }
            }


            //divide by ten since weights are in hundreths of a pound
            string mass = CheckParams(functions, "SetMass");

            if (mass != null)
            {
                totalCost -= Convert.ToInt32(mass) / 10;
            }



            this.SetBaseCost.EntryValue = totalCost;
            return;
        }