/*
 ====================================================================
 Evaluate a unit's attack against target.
   score_base: basic score for attacking
   score_rugged: score added for each rugged def point (0-100)
                 of target
   score_kill: score unit receives for each (expected) point of
               strength damage done to target
   score_loss: score that is substracted per strength point
               unit is expected to loose
 The final score is stored to 'result' and True if returned if the
 attack may be performed else False.
 ====================================================================
 */
 static bool unit_evaluate_attack(Unit unit, Unit target, int score_base, int score_rugged, int score_kill, int score_loss, out int result)
 {
     int unit_dam = 0, target_dam = 0, rugged_def = 0;
     result = 0;
     if (!unit.CheckAttack(  target, Unit.UNIT_ATTACK.UNIT_ACTIVE_ATTACK)) return false;
     Unit.GetExpectedLosses(unit, target, out unit_dam, out target_dam);
     if (unit.CheckRuggedDefense( target))
         rugged_def = unit.GetRuggedDefenseChance( target);
     if (rugged_def < 0) rugged_def = 0;
     result = score_base + rugged_def * score_rugged + target_dam * score_kill + unit_dam * score_loss;
     #if DEBUG
     Console.WriteLine("  {0}: {1}: bas:{2}, rug:{3}, kil:{4}, los: {5} = {6}", unit.name, target.name,
     score_base,
     rugged_def * score_rugged,
     target_dam * score_kill,
     unit_dam * score_loss, result);
     #endif
     /* if target is a df unit give a small bonus */
     if (((target.sel_prop.flags & UnitFlags.ARTILLERY) == UnitFlags.ARTILLERY) ||
         ((target.sel_prop.flags & UnitFlags.AIR_DEFENSE) == UnitFlags.AIR_DEFENSE))
         result += score_kill;
     return true;
 }