Changes

no edit summary
Line 429: Line 429:  
local shipsById = require("Module:Collection/ShipsByApiId")
 
local shipsById = require("Module:Collection/ShipsByApiId")
 
local Ship = require("Module:Ship")
 
local Ship = require("Module:Ship")
 +
 +
local function minMaxStats(a, b)
 +
  return (not a or a == 0) and (not b or b == 0) and 0 or {a or '', b or ''}
 +
end
 +
 +
local function trueIsOne(x)
 +
  return x == true and 1 or x
 +
end
    
local function loadShipData(no)
 
local function loadShipData(no)
Line 437: Line 445:  
   data.class = ship:class():name() or ""
 
   data.class = ship:class():name() or ""
 
   data.type = ship:formatted_type() or ""
 
   data.type = ship:formatted_type() or ""
  data.rarity = ship:rarity() or ""
  −
  data.hp = {ship:hp() or "", ship:hp_max() or ""}
  −
  data.fp = {ship:firepower() or "", ship:firepower_max() or ""}
  −
  data.armor = {ship:armor() or "", ship:armor_max() or ""}
  −
  data.torpedo = {ship:torpedo() or "", ship:torpedo_max() or ""}
  −
  data.evasion = {ship:evasion() or "", ship:evasion_max() or ""}
  −
  data.aa = {ship:aa() or "", ship:aa_max() or ""}
  −
  data.asw = {ship:asw() or "", ship:asw_max() or ""}
   
   data.spd = ship:formatted_speed() or ""
 
   data.spd = ship:formatted_speed() or ""
  data.los = {ship:los() or "", ship:los_max() or ""}
   
   data.range = ship:formatted_range() or ""
 
   data.range = ship:formatted_range() or ""
   data.luck = {ship:luck() or "", ship:luck_max() or ""}
+
   data.rarity = ship:rarity() or ""
 +
  data.hp = minMaxStats(ship:hp(), ship:hp_max())
 +
  data.fp = minMaxStats(ship:firepower(), ship:firepower_max())
 +
  data.armor = minMaxStats(ship:armor(), ship:armor_max())
 +
  data.torpedo = minMaxStats(ship:torpedo(), ship:torpedo_max())
 +
  data.aa = minMaxStats(ship:aa(), ship:aa_max())
 +
  data.luck = minMaxStats(ship:luck(), ship:luck_max())
 +
  data.evasion = minMaxStats(ship:evasion(), ship:evasion_max())
 +
  data.asw = minMaxStats(ship:asw(), ship:asw_max())
 +
  data.los = minMaxStats(ship:los(), ship:los_max())
 
   data.aircraft = {}
 
   data.aircraft = {}
 
   data.equip = {}
 
   data.equip = {}
Line 467: Line 475:  
   data.remodellv = ship:remodel_level() or ""
 
   data.remodellv = ship:remodel_level() or ""
 
   data.consumption = {ship:fuel() or "", ship:ammo() or ""}
 
   data.consumption = {ship:fuel() or "", ship:ammo() or ""}
   data.remodelreq = {ship._remodel_steel or 0, ship._remodel_ammo or 0}
+
   data.remodelreq = {ship._remodel_steel or "", ship._remodel_ammo or ""}
 
   data.dismantle = {
 
   data.dismantle = {
     ship._scrap_fuel or "",
+
     ship._scrap_fuel or 0,
     ship._scrap_ammo or "",
+
     ship._scrap_ammo or 0,
     ship._scrap_steel or "",
+
     ship._scrap_steel or 0,
     ship._scrap_baux or ""
+
     ship._scrap_baux or 0,
 
   }
 
   }
 
   data.modernization = {
 
   data.modernization = {
     ship._firepower_mod or "",
+
     ship._firepower_mod or 0,
     ship._torpedo_mod or "",
+
     ship._torpedo_mod or 0,
     ship._aa_mod or "",
+
     ship._aa_mod or 0,
     ship._armor_mod or "",
+
     ship._armor_mod or 0,
     ship._luck_mod or nil
+
     ship._luck_mod or '',
 
   }
 
   }
 +
  data.remodelbp = trueIsOne(ship._remodel_blueprint)
 +
  data.remodelcatapult = trueIsOne(ship._remodel_catapult)
 +
  data.remodelar = trueIsOne(ship._remodel_report)
 +
  data.remodelgunmat = trueIsOne(ship._remodel_gunmat)
 +
  data.remodelairmat = trueIsOne(ship._remodel_airmat)
 +
  data.remodeldevmat = trueIsOne(ship._remodel_development_material)
 +
  data.remodelconmat = trueIsOne(ship._remodel_construction_material)
 
   return data
 
   return data
 
end
 
end
cssedit, gkautomate
7,064

edits