- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
Changes
Jump to navigation
Jump to search
Line 1:
Line 1:
− local format = require("Module:StringInterpolation").format
− local ResourceIcons = require("Module:ResourceIcons")
−
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− end
−
− function ShipData:id(raw)
− return self:format_stat(self._id, raw)
− end
−
− function ShipData:true_id(raw)
− return self:format_stat(self._true_id, raw)
− end
−
− function ShipData:has_true_id()
− return self._true_id ~= false
− end
−
− function ShipData:rarity(raw)
− return self:format_rarity(self._rarity, raw)
− end
−
− function ShipData:class(raw)
− return self:format_stat(self._class, raw)
− end
−
− function ShipData:type(raw)
− return self:format_type(self._type, raw)
− end
−
− function ShipData:card(raw)
− return self:format_image(self._card, nil, raw)
− end
−
− function ShipData:hp(raw)
− return self:format_stat(self._hp, raw)
− end
−
− function ShipData:firepower(raw)
− return self:format_stat(self._firepower, raw)
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
− +
Line 161:
Line 122:
− +
− if raw then +
− return self._build_time
− elseif self._build_time then
− return format("${hours:2}:${minutes:2}:${seconds:2}", self:format_time(self._build_time * 60))
− else
− return "??"
− end
− +
− +
− +
− +
− +
− if raw then +
− return self._remodel_ammo, self._remodel_steel
− else
− return mw.ustring.format("%s %d %s %d", self:format_image(ResourceIcons.ammo), self:format_stat(self._remodel_ammo), self:format_image(ResourceIcons.steel), self:format_stat(self._remodel_steel))
− end
− function ShipData:remodel_blueprint(raw)+
− if raw then+
− return self._remodel_blueprint
− else
− return mw.ustring.format("%s %s", self:format_image(ResourceIcons.blueprint, "36px"), self._remodel_blueprint and "✓" or "✗")
− end
− end
−
−
−
− +
− +
− if not equipment_slot then +
− return not raw and "- Locked -" or nil
− end
− local equipment = equipment_slot["equipment"]
− if raw then
− return equipment
− elseif equipment == nil then
− return "??"
− elseif equipment == false then
− return "- Unequipped -"
− else
− return equipment:link()
− end
− end
−
− function ShipData:equipment_icon(slot, raw)
− local equipment_slot = self._equipment[slot]
− if not equipment_slot then
− return not raw and "" or nil
− end
− local equipment = equipment_slot["equipment"]
− if raw then
− return equipment:icon(raw)
− elseif equipment == nil then
− return "??"
− elseif equipment == false then
− return self:format_image("Xx_c.png")
− else
− return equipment:icon()
− end
− end
−
− function ShipData:equipment_rarity(slot, raw)
− local equipment_slot = self._equipment[slot]
− if not equipment_slot then
− return not raw and "" or nil
− end
− local equipment = equipment_slot["equipment"]
− if raw then
− return equipment:rarity(raw)
− elseif equipment == nil then
− return "??"
− elseif equipment == false then
− return "Unequipped"
− else
− return equipment:rarity()
− end
− end
−
− function ShipData:equipment_back(slot)
− local equipment_slot = self._equipment[slot]
− if not equipment_slot then
− return 0
− end
− local equipment = equipment_slot["equipment"]
− if not equipment then
− return 0
− else
− return equipment:back()
− end
− end
−
− function ShipData:slot_size(slot, raw)
− local equipment_slot = self._equipment[slot]
− if not equipment_slot then
− return not raw and "" or nil
− end
− local slot_size = equipment_slot["size"]
− if slot_size == nil then
− return "??"
− elseif slot_size == false then
− return "-"
− else
− return slot_size
− end
Line 292:
Line 161:
− +
Line 303:
Line 172:
− +
− +
− end
−
− ShipData.format_rarity = ShipData:create_formatter({
− [0] = "??",
− [1] = "Very Common",
− [2] = "Common",
− [3] = "Uncommon",
− [4] = "Rare",
− [5] = "Very Rare",
− [6] = "Holo",
− [7] = "S Holo",
− [8] = "SS Holo",
− [-1] = "Abyssal",
− [-2] = "Elite",
− [-3] = "Flagship",
− [-4] = "Kai",
− [-5] = "Kai Elite",
− [-6] = "Kai Flagship",
− [-7] = "Late Model",
− float = "Floating Fortress",
− demon = "Demon",
− princess = "Princess",
− war_demon = "War Demon",
− war_princess = "War Princess",
− })
−
− ShipData.format_type = ShipData:create_formatter({
− [0] = "??",
− [1] = "Coastal Defence Ship",
− [2] = "Destroyer",
− [3] = "Light Cruiser",
− [4] = "Torpedo Cruiser",
− [5] = "Heavy Cruiser",
− [6] = "Aviation Cruiser",
− [7] = "Light Carrier",
− [8] = "Battleship",
− [9] = "Battleship",
− [10] = "Aviation Battleship",
− [11] = "Standard Carrier",
− [12] = "Super Dreadnought",
− [13] = "Submarine",
− [14] = "Aircraft Carrying Submarine",
− [15] = "Replenishment Oiler",
− [16] = "Seaplane Tender",
− [17] = "Amphibious Assault Ship",
− [18] = "Armored Carrier",
− [19] = "Repair Ship",
− [20] = "Submarine Tender",
− })
−
− function ShipData:format_time(seconds)
− return {
− hours = math.floor(seconds / 3600),
− minutes = math.floor(seconds / 60) % 60,
− seconds = seconds % 60,
− }
Refactor out formatting
local BaseData = require("Module:BaseData")
local BaseData = require("Module:BaseData")
local ShipData = BaseData()
local ShipData = BaseData()
function ShipData:name(raw)
function ShipData:name()
if self._suffix and not raw then
if self._suffix then
return self:base_name() .. " " .. self._suffix
return self:base_name() .. " " .. self:suffix()
else
else
return self:base_name(raw)
return self:base_name()
end
end
end
end
function ShipData:base_name(raw)
function ShipData:base_name()
return self:format_stat(self._name, raw)
return self._name
end
end
function ShipData:link(raw)
function ShipData:link()
if self._suffix then
if self._suffix then
return mw.ustring.format(self._aliased_link, self:base_name(), self:name())
return self:base_name(), self:name()
else
else
return mw.ustring.format(self._simple_link, self:name())
return self:name()
end
end
end
end
function ShipData:japanese_name(raw)
function ShipData:japanese_name()
return self:format_stat(self._japanese_name, raw)
return self._japanese_name
end
end
function ShipData:firepower_max(raw)
function ShipData:id()
return self:format_stat(self._firepower_max, raw)
return self._id
end
end
function ShipData:has_firepower_max()
function ShipData:true_id()
return self._firepower_max ~= false
return self._true_id
end
end
function ShipData:torpedo(raw)
function ShipData:rarity()
return self:format_stat(self._torpedo, raw)
return self._rarity
end
end
function ShipData:torpedo_max(raw)
function ShipData:class()
return self:format_stat(self._torpedo_max, raw)
return self._class
end
end
function ShipData:has_torpedo_max()
function ShipData:type()
return self._torpedo_max ~= false
return self._type
end
end
function ShipData:aa(raw)
function ShipData:card()
return self:format_stat(self._aa, raw)
return self._card
end
end
function ShipData:aa_max(raw)
function ShipData:hp()
return self:format_stat(self._aa_max, raw)
return self._hp
end
end
function ShipData:has_aa_max()
function ShipData:firepower()
return self._aa_max ~= false
return self._firepower
end
end
function ShipData:armor(raw)
function ShipData:firepower_max()
return self:format_stat(self._armor, raw)
return self._firepower_max
end
end
function ShipData:armor_max(raw)
function ShipData:torpedo()
return self:format_stat(self._armor_max, raw)
return self._torpedo
end
end
function ShipData:has_armor_max()
function ShipData:torpedo_max()
return self._armor_max ~= false
return self._torpedo_max
end
end
function ShipData:asw(raw)
function ShipData:aa()
return self:format_stat(self._asw, raw)
return self._aa
end
end
function ShipData:asw_max(raw)
function ShipData:aa_max()
return self:format_stat(self._asw_max, raw)
return self._aa_max
end
end
function ShipData:has_asw_max()
function ShipData:armor()
return self._asw_max ~= false
return self._armor
end
end
function ShipData:evasion(raw)
function ShipData:armor_max()
return self:format_stat(self._evasion, raw)
return self._armor_max
end
end
function ShipData:evasion_max(raw)
function ShipData:asw()
return self:format_stat(self._evasion_max, raw)
return self._asw
end
end
function ShipData:has_evasion_max()
function ShipData:asw_max()
return self._evasion_max ~= false
return self._asw_max
end
end
function ShipData:los(raw)
function ShipData:evasion()
return self:format_stat(self._los, raw)
return self._evasion
end
end
function ShipData:los_max(raw)
function ShipData:evasion_max()
return self:format_stat(self._los_max, raw)
return self._evasion_max
end
end
function ShipData:has_los_max()
function ShipData:los()
return self._los_max ~= false
return self._los
end
end
function ShipData:luck(raw)
function ShipData:los_max()
return self:format_stat(self._luck, raw)
return self._los_max
end
end
function ShipData:luck_max(raw)
function ShipData:luck()
return self:format_stat(self._luck_max, raw)
return self._luck
end
end
function ShipData:has_luck_max()
function ShipData:luck_max()
return self._luck_max ~= false
return self._luck_max
end
end
end
end
function ShipData:build_time(raw)
function ShipData:build_time()
return self._build_time
end
end
function ShipData:remodeled()
function ShipData:remodel_level()
return not not self._remodel_level
return self._remodel_level
end
end
function ShipData:remodel_level(raw)
function ShipData:remodel_cost()
return self:format_stat(self._remodel_level, raw)
return {ammo = self._remodel_ammo, steel = self._remodel_steel}
end
end
function ShipData:remodel_cost(raw)
function ShipData:remodel_blueprint()
return self._remodel_blueprint
end
end
function ShipData:fuel()
return self._fuel
function ShipData:fuel(raw)
return self:format_stat(self._fuel, raw)
end
end
function ShipData:ammo(raw)
function ShipData:ammo(raw)
return self:format_stat(self._ammo, raw)
return self._ammo
end
end
function ShipData:equipment(slot, raw)
function ShipData:slot(slot)
local equipment_slot = self._equipment[slot]
local equipment_slot = self._equipment[slot]
return equipment_slot.equipment, equipment_slot.size
end
end
size = v["size"]
size = v["size"]
if size == nil then
if size == nil then
total_space = "??"
total_space = nil
break
break
elseif size == false then
elseif size == false then
function ShipData:speed()
function ShipData:speed()
return self:format_speed(self._speed)
return self._speed
end
end
function ShipData:range()
function ShipData:range()
return self:format_range(self._range)
return self._range
end
end