Пример #1
0
        public static WeaponDamageRoller ParseString(String myString)
        {
            myString = myString.ToUpper();
            String[]            myStrings = myString.Split(' ');
            List <WeaponDamage> myDamages = new List <WeaponDamage>();
            bool NormalDamageType         = false;
            int  charCounter = 0;

            for (int i = 0; i < myStrings.Length; i += 2)
            {
                WeaponDamage myNewDamageType = new WeaponDamage();
                //myNewDamageType.DamageType1 = myStrings[i].Replace(" ", "");
                if (!NormalDamageType)
                {
                    //NormalDamageType = ContainsNormalDamageType(myNewDamageType.DamageType1);
                }
                int numToRoll = 0;
                int dieToRoll = 0;
                int myBonus   = 0;
                DiceRoller.parseRollAndDiceAndBonus(myStrings[i + 1].Replace(" ", ""), ref numToRoll, ref dieToRoll, ref myBonus);
                myNewDamageType.MaxDamage = numToRoll * (dieToRoll + myBonus);
                myNewDamageType.MinDamage = numToRoll + (myBonus * numToRoll);
                myDamages.Add(myNewDamageType);
                //TODO: fix Debug.Log("Created item with damage type: " + myNewDamageType.DamageType1 + " with min damage: " + myNewDamageType.MinDamage + " and Max Damage: " + myNewDamageType.maxDamage);
            }

            Debug.Assert(NormalDamageType, "WEAPON DIDN'T ASSIGN NORMAL DAMAGE TYPE! DIDN'T ADD IT!");

            var MyNewRoller = new WeaponDamageRoller();

            MyNewRoller.setDamages(myDamages.ToArray());
            return(MyNewRoller);
        }
Пример #2
0
        public WeaponDamage GetRolledDamage(DamageAmountType myDamageType)
        {
            WeaponDamage myNewDamage = null;

            switch (myDamageType)
            {
            case DamageAmountType.MINIMUM:
                myNewDamage = new WeaponDamage(damageType, minDamage);
                break;

            case DamageAmountType.MAXIMUM:
                myNewDamage = new WeaponDamage(damageType, maxDamage);
                break;

            case DamageAmountType.NORMAL:
                myNewDamage = new WeaponDamage(damageType, RollDamage());
                break;
            }
            return(myNewDamage);
        }