Changes

Add fit gun properties, make output more readable.
Line 54: Line 54:  
"slots",
 
"slots",
 
"slot_details",
 
"slot_details",
 +
"gun_fit_properties",
 
},
 
},
 
_slot_template = [[|- align=center style="background-color: whitesmoke; line-height: 1.1;"
 
_slot_template = [[|- align=center style="background-color: whitesmoke; line-height: 1.1;"
Line 119: Line 120:  
| colspan="6" style="text-align: center; padding: 0px;" | <div class="mw-collapsible mw-collapsed">
 
| colspan="6" style="text-align: center; padding: 0px;" | <div class="mw-collapsible mw-collapsed">
 
<div style="background-color: lightskyblue; text-align: center; margin: 0px;">'''Extra Statistics'''</div>
 
<div style="background-color: lightskyblue; text-align: center; margin: 0px;">'''Extra Statistics'''</div>
<div class="mw-collapsible-content">${remodel_cost}${reversion_cost}
+
<div class="mw-collapsible-content">
<div style="text-align: center; background-color: lightgrey; margin:2px 0px 2px;">'''Modernization Bonus'''</div>
+
${remodel_cost}${reversion_cost}<div style="text-align: center; background-color: lightgrey; margin:2px 0px 2px;">'''Modernization Bonus'''</div>
 
<div style="text-align: center; background-color: whitesmoke; margin:2px 0px 2px;">${modernization}</div>
 
<div style="text-align: center; background-color: whitesmoke; margin:2px 0px 2px;">${modernization}</div>
 
<div style="text-align: center; background-color: lightgrey; margin:2px 0px 2px;">'''Scrap Value'''</div>
 
<div style="text-align: center; background-color: lightgrey; margin:2px 0px 2px;">'''Scrap Value'''</div>
 
<div style="text-align: center; background-color: whitesmoke; margin:2px 0px 0px;">${scrap}</div>
 
<div style="text-align: center; background-color: whitesmoke; margin:2px 0px 0px;">${scrap}</div>
</div>
+
${gun_fit_properties}</div>
 
</div>
 
</div>
 
|}]],
 
|}]],
 
_remodel_cost_template = [[<div style="text-align: center; background-color: lightgrey; margin:2px 0px 2px;">'''Remodel Cost'''</div>
 
_remodel_cost_template = [[<div style="text-align: center; background-color: lightgrey; margin:2px 0px 2px;">'''Remodel Cost'''</div>
<div style="text-align: center; background-color: whitesmoke; margin:2px 0px 2px;">${remodel_cost}</div>]],
+
<div style="text-align: center; background-color: whitesmoke; margin:2px 0px 2px;">${remodel_cost}</div>
 +
]],
 
_reversion_cost_template = [[<div style="text-align: center; background-color: lightgrey; margin:2px 0px 2px;">'''Reversion to ${suffix}'''</div>
 
_reversion_cost_template = [[<div style="text-align: center; background-color: lightgrey; margin:2px 0px 2px;">'''Reversion to ${suffix}'''</div>
<div style="text-align: center; background-color: whitesmoke; margin:2px 0px 2px;">${level_items}<br />${resources}</div>]],
+
<div style="text-align: center; background-color: whitesmoke; margin:2px 0px 2px;">${level_items}<br />${resources}</div>
 +
]],
 +
_gun_fit_properties_template = format{[[<div style="text-align: center; background-color: lightgrey; margin:2px 0px 2px;"><b>${subtitle}</b></div>
 +
${gun_fit_groups}]], subtitle = Formatting:tooltip("Large Caliber Fit Gun Properties", "Based on experimental findings")},
 +
_gun_fit_group_template = [[
 +
<div style="text-align: left; display: flex; margin: 2px 0px;">
 +
<div style="margin-right: 1px; flex-shrink: 0; flex-basis: 140px; background-color: whitesmoke; display: flex; align-items: center;"><span>${fit_group}</span></div>
 +
<div style="margin-left: 1px; flex-grow: 1; background-color: whitesmoke; display: flex; align-items: center;"><b>${fit}</b></div>
 +
</div>
 +
]]
 
}
 
}
   Line 425: Line 436:  
function ShipInfoKai:scrap()
 
function ShipInfoKai:scrap()
 
self._vars.scrap = Formatting:format_resources(self._ship:scrap())
 
self._vars.scrap = Formatting:format_resources(self._ship:scrap())
 +
end
 +
 +
function ShipInfoKai:gun_fit_properties()
 +
local ship_type = self._ship:type()
 +
if ship_type == 8 or ship_type == 9 or ship_type == 10 then
 +
local rows = {}
 +
for _, fit_group in ipairs(require('Module:LargeCaliberMainGunFit').fit_groups) do
 +
table.insert(rows, format{self._gun_fit_group_template, fit_group = fit_group, fit = Formatting:format_fit_bonus(self._ship:gun_fit_properties(fit_group))})
 +
end
 +
self._vars.gun_fit_properties = format{self._gun_fit_properties_template, gun_fit_groups = table.concat(rows)}
 +
else
 +
self._vars.gun_fit_properties = ""
 +
end
 
end
 
end
  
Anonymous user