コード例 #1
0
ファイル: Weapon.cs プロジェクト: Deliagwath/FRPGC
 public Weapon(string name, string id, int singleRange, int flatDamage, Dice baseDamage, Dice additionalDamage, int shotsPerBurst, AttackRange classification, DamageTypes damageType, WeaponSkillType weaponType, bool pen)
 {
     this.Name = name;
     this.ID = id;
     this.Range = singleRange;
     this.FlatDamage = flatDamage;
     this.BaseDamage = baseDamage;
     this.AdditionalDamage = additionalDamage;
     this.ShotsPerBurst = shotsPerBurst;
     this.Classification = classification;
     this.DamageType = damageType;
     this.WeaponType = weaponType;
     this.Penetrating = pen;
 }
コード例 #2
0
ファイル: mainForm.cs プロジェクト: Deliagwath/FRPGC
        private int[] attackDamage(int attacks)
        {
            this.logger.writeLog("Beginning Attack Damage Calculation");
            this.logger.writeLog(String.Format("Number of attacks: {0}", attacks));

            int flatDamage = ((Weapon) this.comboWeapon.SelectedItem).FlatDamage;
            bool melee = (((Weapon) this.comboWeapon.SelectedItem).WeaponType == WeaponSkillType.Melee || ((Weapon) this.comboWeapon.SelectedItem).WeaponType == WeaponSkillType.Unarmed);
            flatDamage = (melee ? flatDamage + ((dynamic) this.comboAttackingUnit.SelectedItem).StatID.MeleeDamage : flatDamage);
            Dice BD = ((Weapon) this.comboWeapon.SelectedItem).BaseDamage;
            Dice AD = ((Weapon) this.comboWeapon.SelectedItem).AdditionalDamage;
            Dice BonusDamage = new Dice(this.bonusDamageTextBox.Text, this.logger);
            int ad, bd, bbd = -1;

            int[] damages = new int[attacks];
            for (int i = 0; i < attacks; i++)
            {
                bd = BD.getRoll();
                ad = AD.getRoll();
                bbd = BonusDamage.getRoll();
                // Burst Attack Modes (Excluding Shotguns) only do Additional Damage.
                damages[i] = (((AttackTypes) this.comboAttackingMethod.SelectedItem == AttackTypes.ShortRangeBurst) && !((Weapon) this.comboWeapon.SelectedItem).ID.Substring(0, 3).Equals("SGS")) ? ad + bbd : bd + ad + flatDamage + bbd;
                this.logger.writeLog(String.Format("Base Damage: {0} Additional Damage: {1} Flat Damage: {2}", bd.ToString(), ad.ToString(), flatDamage.ToString()));
            }
            this.logger.writeLog("Ending Attack Calculation");
            return damages;
        }
コード例 #3
0
ファイル: mainForm.cs プロジェクト: Deliagwath/FRPGC
        private int attack(int attacksLaunched, AttackTypes attackType)
        {
            int chance = -1;
            int bonusHit = 0;
            bool bonusHitParseAttempt = int.TryParse(this.bonusHitChance.Text, out bonusHit);
            bool bonusDamageParseAttempt = Dice.parseable(this.bonusDamageTextBox.Text);
            if (!bonusHitParseAttempt)
            {
                this.logger.logBoth(String.Format("Bonus Hit Chance could not be parsed. Input: {0}, setting to 0", this.bonusHitChance.Text));
                this.bonusHitChance.Text = "0";
                bonusHit = 0;
            }
            if (!bonusDamageParseAttempt)
            {
                this.logger.logBoth(String.Format("Bonus Damage could not be parsed. Input: {0}, setting to 0", this.bonusDamageTextBox.Text));
                this.bonusDamageTextBox.Text = "0";
            }
            switch (attackType)
            {
                case (AttackTypes.Melee):
                    chance = meleeHitChance();
                    break;

                case (AttackTypes.ShortRangeSingle):
                    chance = shortRangeShotChance(true);
                    break;

                case (AttackTypes.ShortRangeBurst):
                    chance = shortRangeShotChance(false);
                    break;

                case (AttackTypes.LongRange):
                    chance = longRangeShotChance();
                    break;

                default:
                    this.logger.logBoth(String.Format("A weird error occured at the attack() function. The attackType is: {0}", attackType.ToString()));
                    return 0;
            }

            this.logger.logBoth(String.Format("Hit Chance: {0}, Bonus Hit Chance: {1}, Bonus Damage: {2}", chance.ToString(), bonusHit.ToString(), this.bonusDamageTextBox.Text));
            chance += bonusHit;
            attacksLaunched *= ((AttackTypes) this.comboAttackingMethod.SelectedItem).Equals(AttackTypes.ShortRangeBurst) ? ((Weapon) this.comboWeapon.SelectedItem).ShotsPerBurst : 1;
            int[] damages = attackDamage(attacksLaunched);
            int totalDamage = 0;
            Dice dice = new Dice(1, Math.Max(100, chance), this.logger);
            dynamic attacker = (dynamic) this.comboAttackingUnit.SelectedItem;
            int rolled = -1;

            foreach (int damage in damages)
            {
                rolled = dice.getRoll();

                if (rolled < attacker.StatID.CriticalChance) // Critical Hit
                {
                    this.logger.logBoth(String.Format("Critical Hit: {0} < {1}", rolled.ToString(), attacker.StatID.CriticalChance));
                    this.logger.logBoth(String.Format("Damage Taken: {0}", (damageReduction(damage) * 2).ToString()));
                    totalDamage += damageReduction(damage) * 2;
                    continue;
                }
                if (rolled > Math.Max(100, chance) - (10 - attacker.StatID.Luck)) // Critical Failure
                {
                    this.logger.logBoth(String.Format("Critical Failure: {0} > {1}", rolled.ToString(), (Math.Max(100, chance) - (10 - attacker.StatID.Luck)).ToString()));
                    this.logger.logBoth("Ending Calculations.");
                    return totalDamage;
                }
                if (rolled <= chance) // Hit
                {
                    this.logger.logBoth(String.Format("Hit: {0} < {1}", rolled.ToString(), chance.ToString()));
                    this.logger.logBoth(String.Format("Damage Taken: {0}", damageReduction(damage).ToString()));
                    totalDamage += damageReduction(damage);
                    continue;
                }
                else if (rolled > chance) // Miss
                {
                    this.logger.logBoth(String.Format("Miss: {0} > {1}", rolled.ToString(), chance.ToString()));
                    continue;
                }
                else
                {
                    this.logger.logBoth("There's a problem, contact the product owner and send the log file (It's in the same directory)");
                    return 0;
                }
            }
            this.textDamageDealt.Text = totalDamage.ToString();
            return totalDamage;
        }
コード例 #4
0
ファイル: mainForm.cs プロジェクト: Deliagwath/FRPGC
        public void getWeapons(StreamReader reader)
        {
            string line = null, name = null, id = null;
            int singleRange = 0, constant = 0, multiplier = 0, roll = 0, shotPerBurst = 0;
            Dice baseDamage = null, additionalDamage = null;
            AttackRange weaponRange;
            DamageTypes damageType;
            WeaponSkillType weaponType;
            string[] splitted = null, constantSplit = null, diceSplit = null;
            bool penetrating = false;

            while ((line = reader.ReadLine()) != null)
            {
                // Weapons {"Name":0, "ID":1, "Range":2, "BD":3, "AD":4, "SPB"(Shots per burst):5, "DamageType":6}
                splitted = line.Trim().Split(',');
                name = splitted[0].Trim();
                this.logger.logBoth(String.Format("Parsing {0}", name));
                id = splitted[1].Trim();

                // Parse Range X\Y or X Format
                // Range X\Y is obsolete, new Range system uses one Optimal Range.
                try
                {
                    // Parsing X\Y Format
                    // Left to support legacy information
                    // Ignores second part
                    constantSplit = splitted[2].Trim().Split('\\');
                    singleRange = int.Parse(constantSplit[0].Trim());
                }
                catch
                {
                    try
                    {
                        singleRange = int.Parse(splitted[2].Trim());
                    }
                    catch
                    {
                        this.logger.logBoth(String.Format("Range could not be parsed. Expected int, got: {0}", splitted[2].Trim()));
                        continue;
                    }
                }
                
                // Parse Base Damage X+YdZ or XdY or X Format
                try
                {
                    // Parsing X+YdZ || XdY+Z Format
                    constantSplit = splitted[3].Trim().Split('+');
                    if (constantSplit[0].Length > constantSplit[1].Length)
                    {
                        diceSplit = constantSplit[0].Trim().ToLower().Split('d');
                        constant = int.Parse(constantSplit[1].Trim());
                        multiplier = int.Parse(diceSplit[0].Trim());
                        roll = int.Parse(diceSplit[1].Trim());
                    }
                    else
                    {
                        diceSplit = constantSplit[1].Trim().ToLower().Split('d');
                        constant = int.Parse(constantSplit[0].Trim());
                        multiplier = int.Parse(diceSplit[0].Trim());
                        roll = int.Parse(diceSplit[1].Trim());
                    }
                    baseDamage = new Dice(multiplier, roll, this.logger);
                }
                catch
                {
                    try
                    {
                        // Parsing XdY Format
                        diceSplit = splitted[3].Trim().ToLower().Split('d');
                        constant = 0;
                        multiplier = int.Parse(diceSplit[0].Trim());
                        roll = int.Parse(diceSplit[1].Trim());
                        baseDamage = new Dice(multiplier, roll, this.logger);
                    }
                    catch
                    {
                        try
                        {
                            // Parsing X Format
                            constant = 0;
                            multiplier = int.Parse(splitted[3]);
                            baseDamage = new Dice(multiplier, 1, this.logger);
                        }
                        catch
                        {
                            this.logger.logBoth(String.Format("Base Damage could not be parsed. Expected X+YdZ or XdY or X, got: {0}", splitted[3].Trim()));
                            continue;
                        }
                    }
                }

                // Parse Additional Damage X+YdZ or XdY or X Format
                try
                {
                    // Parsing X+YdZ || XdY+Z Format
                    constantSplit = splitted[4].Trim().Split('+');
                    if (constantSplit[0].Length > constantSplit[1].Length) {
                        diceSplit = constantSplit[0].Trim().ToLower().Split('d');
                        constant = int.Parse(constantSplit[1].Trim());
                        multiplier = int.Parse(diceSplit[0].Trim());
                        roll = int.Parse(diceSplit[1].Trim());
                    }
                    else {
                        diceSplit = constantSplit[1].Trim().ToLower().Split('d');
                        constant = int.Parse(constantSplit[0].Trim());
                        multiplier = int.Parse(diceSplit[0].Trim());
                        roll = int.Parse(diceSplit[1].Trim());
                    }
                    baseDamage = new Dice(multiplier, roll, this.logger);
                }
                catch
                {
                    try
                    {
                        // Parsing XdY Format
                        diceSplit = splitted[4].Trim().ToLower().Split('d');
                        constant = 0;
                        multiplier = int.Parse(diceSplit[0].Trim());
                        roll = int.Parse(diceSplit[1].Trim());
                        additionalDamage = new Dice(multiplier, roll, this.logger);
                    }
                    catch
                    {
                        try
                        {
                            // Parsing X Format
                            constant = 0;
                            multiplier = int.Parse(splitted[4]);
                            additionalDamage = new Dice(multiplier, 1, this.logger);
                        }
                        catch
                        {
                            this.logger.logBoth(String.Format("Additional Damage could not be parsed. Expected X+YdZ or XdY or X, got: {0}", splitted[4].Trim()));
                            continue;
                        }
                    }
                }

                try
                {
                    if (splitted[5].Trim().ToUpper().Equals("NA")) { shotPerBurst = 1; }
                    else { shotPerBurst = int.Parse(splitted[5].Trim()); }
                }
                catch
                {
                    this.logger.logBoth(String.Format("Shot Per Burst could not be parsed. Expected int, got: {0}", splitted[5].Trim()));
                    continue;
                }

                // Parsing Classification
                switch (splitted[6].Trim().ToUpper())
                {
                    case ("M"):
                        weaponRange = AttackRange.Melee;
                        break;
                    
                    case ("SR"):
                        weaponRange = AttackRange.ShortRange;
                        break;

                    case ("LR"):
                        weaponRange = AttackRange.LongRange;
                        break;

                    default:
                        this.logger.logBoth(String.Format("Classification could not be parsed. Expected M|SR|LR, got: {0}", splitted[6].Trim().ToUpper()));
                        continue;
                }

                // Parsing Damage Type
                switch (splitted[7].Trim().ToUpper())
                {
                    case ("N"):
                        damageType = DamageTypes.Normal;
                        break;

                    case ("LA"):
                        damageType = DamageTypes.Laser;
                        break;
                    
                    case ("PL"):
                        damageType = DamageTypes.Plasma;
                        break;
                    
                    case ("EL"):
                        damageType = DamageTypes.Electrical;
                        break;

                    case ("FR"):
                        damageType = DamageTypes.Fire;
                        break;

                    case ("EX"):
                        damageType = DamageTypes.Explosion;
                        break;
                    
                    default:
                        this.logger.logBoth(String.Format("DamageType could not be parsed. Expected N|LA|PL|EL|FR|EX, got: {0}", splitted[7].Trim().ToUpper()));
                        continue;
                }

                // Parsing Weapon Type (Which Skill it is dependant upon)
                switch (splitted[8].Trim().ToUpper())
                {
                    case ("BIGGUNS"):
                    case ("BG"):
                        weaponType = WeaponSkillType.BigGuns;
                        break;

                    case ("ENERGYWEAPONS"):
                    case ("EW"):
                        weaponType = WeaponSkillType.EnergyWeapons;
                        break;

                    case ("EXPLOSIVES"):
                    case ("EX"):
                        weaponType = WeaponSkillType.Explosives;
                        break;

                    case ("SMALLGUNS"):
                    case ("SG"):
                        weaponType = WeaponSkillType.SmallGuns;
                        break;

                    case ("UNARMED"):
                    case ("U"):
                        weaponType = WeaponSkillType.Unarmed;
                        break;

                    case ("MELEE"):
                    case ("M"):
                        weaponType = WeaponSkillType.Melee;
                        break;

                    default:
                        this.logger.logBoth(String.Format("WeaponType could not be parsed. Expected BigGuns|BG|EnergyWeapons|EW|Explosives|E|SmallGuns|SG|Unarmed|U|Melee|M, got: {0}", splitted[8].Trim().ToUpper()));
                        continue;
                }

                // Penetrating (P, N)
                try
                {
                    penetrating = (splitted[9].Trim().ToUpper().Equals("P")) ? true : false;
                }
                catch
                {
                    this.logger.logBoth(String.Format("Penetration could not be parsed. Expected P|N, received :{0}", splitted[9]));
                    continue;
                }
                // Creating Weapon Object and adding to List
                this.weapons.Add(new Weapon(name, id, singleRange, constant, baseDamage, additionalDamage, shotPerBurst, weaponRange, damageType, weaponType, penetrating));
            }

            // Binding to ComboBox
            this.comboWeapon.DataSource = this.weapons;
            this.comboWeapon.ValueMember = "ID";
            this.comboWeapon.DisplayMember = "Name";
        }
コード例 #5
0
        private int attack(int attacksLaunched, AttackTypes attackType)
        {
            int  chance                  = -1;
            int  bonusHit                = 0;
            bool bonusHitParseAttempt    = int.TryParse(this.bonusHitChance.Text, out bonusHit);
            bool bonusDamageParseAttempt = Dice.parseable(this.bonusDamageTextBox.Text);

            if (!bonusHitParseAttempt)
            {
                this.logger.logBoth(String.Format("Bonus Hit Chance could not be parsed. Input: {0}, setting to 0", this.bonusHitChance.Text));
                this.bonusHitChance.Text = "0";
                bonusHit = 0;
            }
            if (!bonusDamageParseAttempt)
            {
                this.logger.logBoth(String.Format("Bonus Damage could not be parsed. Input: {0}, setting to 0", this.bonusDamageTextBox.Text));
                this.bonusDamageTextBox.Text = "0";
            }
            switch (attackType)
            {
            case (AttackTypes.Melee):
                chance = meleeHitChance();
                break;

            case (AttackTypes.ShortRangeSingle):
                chance = shortRangeShotChance(true);
                break;

            case (AttackTypes.ShortRangeBurst):
                chance = shortRangeShotChance(false);
                break;

            case (AttackTypes.LongRange):
                chance = longRangeShotChance();
                break;

            default:
                this.logger.logBoth(String.Format("A weird error occured at the attack() function. The attackType is: {0}", attackType.ToString()));
                return(0);
            }

            this.logger.logBoth(String.Format("Hit Chance: {0}, Bonus Hit Chance: {1}, Bonus Damage: {2}", chance.ToString(), bonusHit.ToString(), this.bonusDamageTextBox.Text));
            chance          += bonusHit;
            attacksLaunched *= ((AttackTypes)this.comboAttackingMethod.SelectedItem).Equals(AttackTypes.ShortRangeBurst) ? ((Weapon)this.comboWeapon.SelectedItem).ShotsPerBurst : 1;
            int[]   damages     = attackDamage(attacksLaunched);
            int     totalDamage = 0;
            Dice    dice        = new Dice(1, Math.Max(100, chance), this.logger);
            dynamic attacker    = (dynamic)this.comboAttackingUnit.SelectedItem;
            int     rolled      = -1;

            foreach (int damage in damages)
            {
                rolled = dice.getRoll();

                if (rolled < attacker.StatID.CriticalChance) // Critical Hit
                {
                    this.logger.logBoth(String.Format("Critical Hit: {0} < {1}", rolled.ToString(), attacker.StatID.CriticalChance));
                    this.logger.logBoth(String.Format("Damage Taken: {0}", (damageReduction(damage) * 2).ToString()));
                    totalDamage += damageReduction(damage) * 2;
                    continue;
                }
                if (rolled > Math.Max(100, chance) - (10 - attacker.StatID.Luck)) // Critical Failure
                {
                    this.logger.logBoth(String.Format("Critical Failure: {0} > {1}", rolled.ToString(), (Math.Max(100, chance) - (10 - attacker.StatID.Luck)).ToString()));
                    this.logger.logBoth("Ending Calculations.");
                    return(totalDamage);
                }
                if (rolled <= chance) // Hit
                {
                    this.logger.logBoth(String.Format("Hit: {0} < {1}", rolled.ToString(), chance.ToString()));
                    this.logger.logBoth(String.Format("Damage Taken: {0}", damageReduction(damage).ToString()));
                    totalDamage += damageReduction(damage);
                    continue;
                }
                else if (rolled > chance) // Miss
                {
                    this.logger.logBoth(String.Format("Miss: {0} > {1}", rolled.ToString(), chance.ToString()));
                    continue;
                }
                else
                {
                    this.logger.logBoth("There's a problem, contact the product owner and send the log file (It's in the same directory)");
                    return(0);
                }
            }
            this.textDamageDealt.Text = totalDamage.ToString();
            return(totalDamage);
        }
コード例 #6
0
        public void getWeapons(StreamReader reader)
        {
            string          line = null, name = null, id = null;
            int             singleRange = 0, constant = 0, multiplier = 0, roll = 0, shotPerBurst = 0;
            Dice            baseDamage = null, additionalDamage = null;
            AttackRange     weaponRange;
            DamageTypes     damageType;
            WeaponSkillType weaponType;

            string[] splitted    = null, constantSplit = null, diceSplit = null;
            bool     penetrating = false;

            while ((line = reader.ReadLine()) != null)
            {
                // Weapons {"Name":0, "ID":1, "Range":2, "BD":3, "AD":4, "SPB"(Shots per burst):5, "DamageType":6}
                splitted = line.Trim().Split(',');
                name     = splitted[0].Trim();
                this.logger.logBoth(String.Format("Parsing {0}", name));
                id = splitted[1].Trim();

                // Parse Range X\Y or X Format
                // Range X\Y is obsolete, new Range system uses one Optimal Range.
                try
                {
                    // Parsing X\Y Format
                    // Left to support legacy information
                    // Ignores second part
                    constantSplit = splitted[2].Trim().Split('\\');
                    singleRange   = int.Parse(constantSplit[0].Trim());
                }
                catch
                {
                    try
                    {
                        singleRange = int.Parse(splitted[2].Trim());
                    }
                    catch
                    {
                        this.logger.logBoth(String.Format("Range could not be parsed. Expected int, got: {0}", splitted[2].Trim()));
                        continue;
                    }
                }

                // Parse Base Damage X+YdZ or XdY or X Format
                try
                {
                    // Parsing X+YdZ || XdY+Z Format
                    constantSplit = splitted[3].Trim().Split('+');
                    if (constantSplit[0].Length > constantSplit[1].Length)
                    {
                        diceSplit  = constantSplit[0].Trim().ToLower().Split('d');
                        constant   = int.Parse(constantSplit[1].Trim());
                        multiplier = int.Parse(diceSplit[0].Trim());
                        roll       = int.Parse(diceSplit[1].Trim());
                    }
                    else
                    {
                        diceSplit  = constantSplit[1].Trim().ToLower().Split('d');
                        constant   = int.Parse(constantSplit[0].Trim());
                        multiplier = int.Parse(diceSplit[0].Trim());
                        roll       = int.Parse(diceSplit[1].Trim());
                    }
                    baseDamage = new Dice(multiplier, roll, this.logger);
                }
                catch
                {
                    try
                    {
                        // Parsing XdY Format
                        diceSplit  = splitted[3].Trim().ToLower().Split('d');
                        constant   = 0;
                        multiplier = int.Parse(diceSplit[0].Trim());
                        roll       = int.Parse(diceSplit[1].Trim());
                        baseDamage = new Dice(multiplier, roll, this.logger);
                    }
                    catch
                    {
                        try
                        {
                            // Parsing X Format
                            constant   = 0;
                            multiplier = int.Parse(splitted[3]);
                            baseDamage = new Dice(multiplier, 1, this.logger);
                        }
                        catch
                        {
                            this.logger.logBoth(String.Format("Base Damage could not be parsed. Expected X+YdZ or XdY or X, got: {0}", splitted[3].Trim()));
                            continue;
                        }
                    }
                }

                // Parse Additional Damage X+YdZ or XdY or X Format
                try
                {
                    // Parsing X+YdZ || XdY+Z Format
                    constantSplit = splitted[4].Trim().Split('+');
                    if (constantSplit[0].Length > constantSplit[1].Length)
                    {
                        diceSplit  = constantSplit[0].Trim().ToLower().Split('d');
                        constant   = int.Parse(constantSplit[1].Trim());
                        multiplier = int.Parse(diceSplit[0].Trim());
                        roll       = int.Parse(diceSplit[1].Trim());
                    }
                    else
                    {
                        diceSplit  = constantSplit[1].Trim().ToLower().Split('d');
                        constant   = int.Parse(constantSplit[0].Trim());
                        multiplier = int.Parse(diceSplit[0].Trim());
                        roll       = int.Parse(diceSplit[1].Trim());
                    }
                    baseDamage = new Dice(multiplier, roll, this.logger);
                }
                catch
                {
                    try
                    {
                        // Parsing XdY Format
                        diceSplit        = splitted[4].Trim().ToLower().Split('d');
                        constant         = 0;
                        multiplier       = int.Parse(diceSplit[0].Trim());
                        roll             = int.Parse(diceSplit[1].Trim());
                        additionalDamage = new Dice(multiplier, roll, this.logger);
                    }
                    catch
                    {
                        try
                        {
                            // Parsing X Format
                            constant         = 0;
                            multiplier       = int.Parse(splitted[4]);
                            additionalDamage = new Dice(multiplier, 1, this.logger);
                        }
                        catch
                        {
                            this.logger.logBoth(String.Format("Additional Damage could not be parsed. Expected X+YdZ or XdY or X, got: {0}", splitted[4].Trim()));
                            continue;
                        }
                    }
                }

                try
                {
                    if (splitted[5].Trim().ToUpper().Equals("NA"))
                    {
                        shotPerBurst = 1;
                    }
                    else
                    {
                        shotPerBurst = int.Parse(splitted[5].Trim());
                    }
                }
                catch
                {
                    this.logger.logBoth(String.Format("Shot Per Burst could not be parsed. Expected int, got: {0}", splitted[5].Trim()));
                    continue;
                }

                // Parsing Classification
                switch (splitted[6].Trim().ToUpper())
                {
                case ("M"):
                    weaponRange = AttackRange.Melee;
                    break;

                case ("SR"):
                    weaponRange = AttackRange.ShortRange;
                    break;

                case ("LR"):
                    weaponRange = AttackRange.LongRange;
                    break;

                default:
                    this.logger.logBoth(String.Format("Classification could not be parsed. Expected M|SR|LR, got: {0}", splitted[6].Trim().ToUpper()));
                    continue;
                }

                // Parsing Damage Type
                switch (splitted[7].Trim().ToUpper())
                {
                case ("N"):
                    damageType = DamageTypes.Normal;
                    break;

                case ("LA"):
                    damageType = DamageTypes.Laser;
                    break;

                case ("PL"):
                    damageType = DamageTypes.Plasma;
                    break;

                case ("EL"):
                    damageType = DamageTypes.Electrical;
                    break;

                case ("FR"):
                    damageType = DamageTypes.Fire;
                    break;

                case ("EX"):
                    damageType = DamageTypes.Explosion;
                    break;

                default:
                    this.logger.logBoth(String.Format("DamageType could not be parsed. Expected N|LA|PL|EL|FR|EX, got: {0}", splitted[7].Trim().ToUpper()));
                    continue;
                }

                // Parsing Weapon Type (Which Skill it is dependant upon)
                switch (splitted[8].Trim().ToUpper())
                {
                case ("BIGGUNS"):
                case ("BG"):
                    weaponType = WeaponSkillType.BigGuns;
                    break;

                case ("ENERGYWEAPONS"):
                case ("EW"):
                    weaponType = WeaponSkillType.EnergyWeapons;
                    break;

                case ("EXPLOSIVES"):
                case ("EX"):
                    weaponType = WeaponSkillType.Explosives;
                    break;

                case ("SMALLGUNS"):
                case ("SG"):
                    weaponType = WeaponSkillType.SmallGuns;
                    break;

                case ("UNARMED"):
                case ("U"):
                    weaponType = WeaponSkillType.Unarmed;
                    break;

                case ("MELEE"):
                case ("M"):
                    weaponType = WeaponSkillType.Melee;
                    break;

                default:
                    this.logger.logBoth(String.Format("WeaponType could not be parsed. Expected BigGuns|BG|EnergyWeapons|EW|Explosives|E|SmallGuns|SG|Unarmed|U|Melee|M, got: {0}", splitted[8].Trim().ToUpper()));
                    continue;
                }

                // Penetrating (P, N)
                try
                {
                    penetrating = (splitted[9].Trim().ToUpper().Equals("P")) ? true : false;
                }
                catch
                {
                    this.logger.logBoth(String.Format("Penetration could not be parsed. Expected P|N, received :{0}", splitted[9]));
                    continue;
                }
                // Creating Weapon Object and adding to List
                this.weapons.Add(new Weapon(name, id, singleRange, constant, baseDamage, additionalDamage, shotPerBurst, weaponRange, damageType, weaponType, penetrating));
            }

            // Binding to ComboBox
            this.comboWeapon.DataSource    = this.weapons;
            this.comboWeapon.ValueMember   = "ID";
            this.comboWeapon.DisplayMember = "Name";
        }
コード例 #7
0
ファイル: Weapon.cs プロジェクト: Deliagwath/FRPGC
 public Weapon(string name, string id, int singleRange, int flatDamage, Dice baseDamage, Dice additionalDamage, int shotsPerBurst, AttackRange classification, DamageTypes damageType, WeaponSkillType weaponType, bool pen)
 {
     this.Name             = name;
     this.ID               = id;
     this.Range            = singleRange;
     this.FlatDamage       = flatDamage;
     this.BaseDamage       = baseDamage;
     this.AdditionalDamage = additionalDamage;
     this.ShotsPerBurst    = shotsPerBurst;
     this.Classification   = classification;
     this.DamageType       = damageType;
     this.WeaponType       = weaponType;
     this.Penetrating      = pen;
 }