- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
Difference between revisions of "Module:ShipData"
Jump to navigation
Jump to search
com>Ckwng |
com>Ckwng (load Equipment lazily (on slot() access)) |
||
Line 211: | Line 211: | ||
local equipment_slot = self._equipment[slot] | local equipment_slot = self._equipment[slot] | ||
if equipment_slot then | if equipment_slot then | ||
+ | if type(equipment_slot.equipment) == "string" then | ||
+ | equipment_slot.equipment = Equipment(equipment_slot.equipment) | ||
+ | end | ||
return equipment_slot.equipment, equipment_slot.size | return equipment_slot.equipment, equipment_slot.size | ||
end | end | ||
Line 255: | Line 258: | ||
if ship._class then | if ship._class then | ||
ship._class = ShipClass(ship._class) | ship._class = ShipClass(ship._class) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
setmetatable(ship, ship) | setmetatable(ship, ship) |
Revision as of 09:10, 24 April 2015
Documentation for this module may be created at Module:ShipData/doc
local Equipment = require('Module:Equipment')
local ShipClass = require('Module:ShipClass')
local BaseData = require("Module:BaseData")
local ShipData = BaseData()
function ShipData:name()
if self._suffix then
return self:base_name() .. " " .. self._suffix
else
return self:base_name()
end
end
function ShipData:base_name()
return self._name
end
function ShipData:link()
if self._page then
return self._page, self:name()
elseif self._suffix then
return self:base_name(), self:name()
else
return self:name()
end
end
function ShipData:localized_name()
return self._localized_name
end
function ShipData:nick()
return self._nick
end
function ShipData:japanese_name()
return self._japanese_name
end
function ShipData:japanese_nick()
return self._japanese_nick
end
function ShipData:reading()
return self._reading
end
function ShipData:reading_nick()
return self._reading_nick
end
function ShipData:id()
return self._id
end
function ShipData:true_id()
return self._true_id
end
function ShipData:rarity()
return self._rarity
end
function ShipData:back()
return self._back or self:rarity()
end
function ShipData:class()
return self._class
end
function ShipData:class_number()
return self._class_number
end
function ShipData:type()
return self._type
end
function ShipData:card()
return self._card
end
function ShipData:battle_card()
return self._battle_card
end
function ShipData:hp()
return self._hp
end
function ShipData:hp_max()
return self._hp_max
end
function ShipData:firepower()
return self._firepower
end
function ShipData:firepower_max()
return self._firepower_max
end
function ShipData:torpedo()
return self._torpedo
end
function ShipData:torpedo_max()
return self._torpedo_max
end
function ShipData:aa()
return self._aa
end
function ShipData:aa_max()
return self._aa_max
end
function ShipData:armor()
return self._armor
end
function ShipData:armor_max()
return self._armor_max
end
function ShipData:asw()
return self._asw
end
function ShipData:asw_max()
return self._asw_max
end
function ShipData:evasion()
return self._evasion
end
function ShipData:evasion_max()
return self._evasion_max
end
function ShipData:los()
return self._los
end
function ShipData:los_max()
return self._los_max
end
function ShipData:luck()
return self._luck
end
function ShipData:luck_max()
return self._luck_max
end
function ShipData:buildable()
return self._buildable
end
function ShipData:buildable_lsc()
return self._buildable_lsc
end
function ShipData:build_time()
return self._build_time
end
function ShipData:remodel_from()
return self._remodel_from
end
function ShipData:remodel_to()
return self._remodel_to
end
function ShipData:remodel_level()
return self._remodel_level
end
function ShipData:remodel_cost()
return {fuel = false, ammo = self._remodel_ammo, steel = self._remodel_steel, bauxite = false}
end
function ShipData:remodel_blueprint()
return self._remodel_blueprint
end
function ShipData:modernization()
return {firepower = self._firepower_mod, torpedo = self._torpedo_mod, aa = self._aa_mod, armor = self._armor_mod, luck = self._luck_mod}
end
function ShipData:scrap()
return {fuel = self._scrap_fuel, ammo = self._scrap_ammo, steel = self._scrap_steel, bauxite = self._scrap_baux}
end
function ShipData:fuel()
return self._fuel
end
function ShipData:ammo()
return self._ammo
end
function ShipData:slot(slot)
if self._equipment then
local equipment_slot = self._equipment[slot]
if equipment_slot then
if type(equipment_slot.equipment) == "string" then
equipment_slot.equipment = Equipment(equipment_slot.equipment)
end
return equipment_slot.equipment, equipment_slot.size
end
end
return nil
end
function ShipData:slots()
if self._equipment then
return #self._equipment
end
return nil
end
function ShipData:total_space()
if not self._equipment then
return nil
end
local total_space = 0
local size
for _, v in ipairs(self._equipment) do
size = v["size"]
if size == nil then
total_space = nil
break
elseif size == false then
else
total_space = total_space + size
end
end
return total_space
end
function ShipData:speed()
return self._speed
end
function ShipData:range()
return self._range
end
function ShipData:create(ship)
ship = ship or {}
if ship._class then
ship._class = ShipClass(ship._class)
end
setmetatable(ship, ship)
ship.__index = self
return ship
end
ShipData.__call = ShipData.create
return ShipData