Beispiel #1
0
    private RangedCombatResult processCombat(BaseUnit attacker, Weapon weapon, BaseUnit defender)
    {
        int hitCount = 0;
        int hitDifficulty = getHitDifficulty (attacker.getBallisticSkills());
        int woundDifficulty = getWoundDifficulty(weapon.getStrength(), defender.getToughness());
        bool isSaveable = isSaveableAgainstWeapon(defender, weapon);
        RangedCombatResult result = new RangedCombatResult();

        for(int i = 0; i < weapon.getShots(); i++){
            int hitRoll = Dice.roll(1)[0];
            if(hitRoll >= hitDifficulty) {
                int woundRoll = Dice.roll(1)[0];
                if(woundRoll >= woundDifficulty){
                    if(isSaveableAgainstWeapon(defender, weapon))
                        result.saveableWounds++;
                    else
                        result.automaticWounds++;
                }
            }
        }
        return result;
    }