Example #1
0
        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);
        }
Example #2
0
        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;
        }
Example #3
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;
        }
Example #4
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);
        }