Line 842: |
Line 842: |
| local compatible = {} | | local compatible = {} |
| local incompatible = {} | | local incompatible = {} |
− | for ship_type, compatibility_value in ipairs(compatibility_table) do | + | local complex = false |
− | local code = Formatting:format_ship_code(ship_type) | + | for ship_type, value in ipairs(compatibility_table) do |
− | if type(compatibility_value) == "table" then | + | local ship_code = Formatting:format_ship_code(ship_type) |
− | code = compatibility_value.code
| + | local note = type(value) == "table" and value.note |
− | compatibility_value = compatibility_value.value
| + | value = type(value) == "table" and value.value or value |
− | end
| + | if value == 0 then |
− | if compatibility_value == 0 then | + | table.insert(incompatible, ship_code) |
− | table.insert(incompatible, code) | + | elseif value == 1 then |
− | elseif compatibility_value == 1 then | + | table.insert(compatible, ship_code) |
− | table.insert(compatible, code) | + | elseif value == 2 then |
− | elseif compatibility_value == 2 then | + | complex = true |
− | table.insert(compatible, code) | + | table.insert(compatible, string.format("%s (%s)", ship_code, note)) |
− | table.insert(incompatible, format{self._excluding_exception_template, ship_type = Formatting:format_ship_code(ship_type), exception = code})
| |
| end | | end |
| + | end |
| + | if complex then |
| + | return table.concat(compatible, ", ") |
| + | end |
| + | if #incompatible == 0 then |
| + | return self._all |
| end | | end |
| if #incompatible < 5 then | | if #incompatible < 5 then |
− | if #incompatible == 0 then
| |
− | return self._all
| |
− | end
| |
| return self._all_except .. table.concat(incompatible, ", ") | | return self._all_except .. table.concat(incompatible, ", ") |
− | else
| |
− | return table.concat(compatible, ", ")
| |
| end | | end |
| + | return table.concat(compatible, ", ") |
| end | | end |
| | | |