Line 29: |
Line 29: |
| | colspan="2" style="text-align: center; background-color: LightSkyBlue;" | '''Bonus''']], | | | colspan="2" style="text-align: center; background-color: LightSkyBlue;" | '''Bonus''']], |
| _bonus_row = [=[|- | | _bonus_row = [=[|- |
− | | style="width: 190px; text-align: center;" | ${ship} | + | | style="width: 190px; text-align: center;" | ${text} |
| | style="width: 190px; text-align: center;" | ${stats}]=], | | | style="width: 190px; text-align: center;" | ${stats}]=], |
| --|- | | --|- |
Line 326: |
Line 326: |
| end | | end |
| self._vars.compatibility_details = table.concat(result, "\n") | | self._vars.compatibility_details = table.concat(result, "\n") |
| + | end |
| + | |
| + | local function format_bonus_text(desc) |
| + | local with_formats = { |
| + | ["Radar"] = "[[File:Radar.png]", |
| + | } |
| + | local with = desc._with and with_formats[desc._with] and " " .. with_formats[desc._with] or "" |
| + | if desc._ship then |
| + | return string.format( |
| + | "[[%s]]%s", |
| + | desc._ship, |
| + | with |
| + | ) |
| + | end |
| + | if desc._class then |
| + | return string.format( |
| + | "[[:Category:%s Class|%s Class]]%s%s", |
| + | desc._class, |
| + | desc._class, |
| + | desc._suffix and " " .. desc._suffix or "", |
| + | with |
| + | ) |
| + | end |
| + | return "??" |
| + | end |
| + | |
| + | local function format_bonus_stat(desc, stat) |
| + | return type(desc[stat] == "table") and |
| + | Formatting:tooltip(U.isum(desc[stat]), U.ijoin(U.imap(desc[stat], function(e) return "+" .. e end), " ")) or |
| + | desc[stat] or |
| + | false |
| end | | end |
| | | |
Line 334: |
Line 365: |
| table.insert(result, format{ | | table.insert(result, format{ |
| self._bonus_row, | | self._bonus_row, |
− | ship = string.sub(ship, 1, 1) == "@" and string.sub(ship, 2) or ("[[" .. ship .. "]]"), | + | text = string.sub(ship, 1, 1) == "@" and string.sub(ship, 2) or ("[[" .. ship .. "]]"), |
| stats = Formatting:format_stat_bonuses({ | | stats = Formatting:format_stat_bonuses({ |
| firepower = s._firepower or false, | | firepower = s._firepower or false, |
Line 350: |
Line 381: |
| range = s._range or false, | | range = s._range or false, |
| special = s._special or false, | | special = s._special or false, |
| + | }) |
| + | }) |
| + | end |
| + | for _, desc in ipairs(self._equipment._bonuses or {}) do |
| + | table.insert(result, format{ |
| + | self._bonus_row, |
| + | text = format_bonus_text(desc), |
| + | stats = Formatting:format_stat_bonuses({ |
| + | firepower = format_bonus_stat(desc, "_firepower"), |
| + | bombing = format_bonus_stat(desc, "_bombing"), |
| + | torpedo = format_bonus_stat(desc, "_torpedo"), |
| + | aa = format_bonus_stat(desc, "_aa"), |
| + | armor = format_bonus_stat(desc, "_armor"), |
| + | asw = format_bonus_stat(desc, "_asw"), |
| + | shelling_accuracy = format_bonus_stat(desc, "_shelling_accuracy"), |
| + | torpedo_accuracy = format_bonus_stat(desc, "_torpedo_accuracy"), |
| + | evasion = format_bonus_stat(desc, "_evasion"), |
| + | los = format_bonus_stat(desc, "_los"), |
| + | speed = format_bonus_stat(desc, "_speed"), |
| + | luck = format_bonus_stat(desc, "_luck"), |
| + | range = format_bonus_stat(desc, "_range"), |
| + | special = format_bonus_stat(desc, "_special"), |
| }) | | }) |
| }) | | }) |