Line 4: |
Line 4: |
| return { | | return { |
| | | |
− | hit = function(context) | + | hit = function(ship) |
− | return Stat.rate({ args = { context.cl1 + context.cl2, context.cl0 + context.cl1 + context.cl2 } }) .. "%" | + | return Stat.rate({ args = { ship.cl1 + ship.cl2, ship.cl0 + ship.cl1 + ship.cl2 } }) .. "%" |
| end, | | end, |
| | | |
− | crit = function(context) | + | crit = function(ship) |
− | return Stat.rate({ args = { context.cl2, context.cl0 + context.cl1 + context.cl2 } }) .. "%" | + | return Stat.rate({ args = { ship.cl2, ship.cl0 + ship.cl1 + ship.cl2 } }) .. "%" |
| end, | | end, |
| | | |
− | error = function(context) | + | error = function(ship) |
− | return Stat.error({ args = { context.cl1 + context.cl2, context.cl0 + context.cl1 + context.cl2 } }) .. "%" | + | return Stat.error({ args = { ship.cl1 + ship.cl2, ship.cl0 + ship.cl1 + ship.cl2 } }) .. "%" |
| end, | | end, |
| | | |
− | difference = function(context) | + | difference = function(ship) |
− | if context.hit_rate then | + | if ship.hit_rate then |
− | local diff = 100 * (context.cl1 + context.cl2) / (context.cl0 + context.cl1 + context.cl2) - context.hit_rate | + | local diff = 100 * (ship.cl1 + ship.cl2) / (ship.cl0 + ship.cl1 + ship.cl2) - ship.hit_rate |
| return string.format("%.2f%%", diff) | | return string.format("%.2f%%", diff) |
| else | | else |
Line 25: |
Line 25: |
| end, | | end, |
| | | |
− | critical_difference = function(context) | + | critical_difference = function(ship) |
− | if context.critical_hit_rate then | + | if ship.critical_hit_rate then |
− | local diff = 100 * (context.cl2) / (context.cl0 + context.cl1 + context.cl2) - context.critical_hit_rate | + | local diff = 100 * (ship.cl2) / (ship.cl0 + ship.cl1 + ship.cl2) - ship.critical_hit_rate |
| return string.format("%.2f%%", diff) | | return string.format("%.2f%%", diff) |
| else | | else |
Line 43: |
Line 43: |
| end, | | end, |
| | | |
− | fit = function(ship, target, context) | + | fit = function(ship, target) |
| + | local context = {} |
| context._ng = ship._ng | | context._ng = ship._ng |
− | context._ci, context._hit_rate = Stat.error_(context.cl1 + context.cl2, context.cl0 + context.cl1 + context.cl2) | + | context._ci, context._hit_rate = Stat.error_(ship.cl1 + ship.cl2, ship.cl0 + ship.cl1 + ship.cl2) |
| local fit, min_fit, max_fit = Combat2.find_fit(ship, target, context) | | local fit, min_fit, max_fit = Combat2.find_fit(ship, target, context) |
| if fit and min_fit and max_fit then | | if fit and min_fit and max_fit then |