Line 264: |
Line 264: |
| end | | end |
| | | |
− | function getTitle(form, base_name, name, suffix) | + | function getTitle(form, base_name, name, suffix, short) |
| if form.seasonal then | | if form.seasonal then |
− | return form.season_suffix or not string.find(form.season, suffix) and suffix | + | if short then |
| + | if form.season_suffix then |
| + | return form.season_suffix |
| + | end |
| + | local suffixInSeason = string.find(form.season, suffix) |
| + | local seasonInSuffix = string.find(suffix, form.season) |
| + | if suffixInSeason then |
| + | return false |
| + | elseif seasonInSuffix then |
| + | return string.sub(suffix, 1, seasonInSuffix - 2) |
| + | else |
| + | return suffix |
| + | end |
| + | else |
| + | return name == base_name and suffix or name .. " " .. suffix |
| + | end |
| else | | else |
− | return suffix == "" and (name == base_name and "Base" or name) or suffix | + | return suffix ~= "" and suffix or name == base_name and "Base" or name |
| end | | end |
| end | | end |
Line 281: |
Line 296: |
| local name, suffix = Ship:process_ship_key(form.name) | | local name, suffix = Ship:process_ship_key(form.name) |
| suffix = suffix or "" | | suffix = suffix or "" |
− | local title = getTitle(form, ship_name, name, suffix) | + | local title = getTitle(form, ship_name, name, suffix, true) |
| if not first_seasonal and form.seasonal then | | if not first_seasonal and form.seasonal then |
| first_seasonal = true | | first_seasonal = true |
Line 327: |
Line 342: |
| local name, suffix = Ship:process_ship_key(form.name) | | local name, suffix = Ship:process_ship_key(form.name) |
| suffix = suffix or "" | | suffix = suffix or "" |
− | local title = form.seasonal and suffix or suffix == "" and (name == ship_name and "Base" or name) or suffix | + | local title = getTitle(form, ship_name, name, suffix) |
| table.insert(result, "{{!}}-{{!}}" .. title .. "=") | | table.insert(result, "{{!}}-{{!}}" .. title .. "=") |
| if form.normal and form.damaged then | | if form.normal and form.damaged then |