Line 1: |
Line 1: |
− | local BaseData = require("Module:BaseData") | + | local ShipData = require("Module:ShipData") |
− | local EnemyShipData = BaseData() | + | local EnemyShipData = ShipData() |
− |
| |
− | function EnemyShipData:name()
| |
− | if self._suffix then
| |
− | return self:base_name() .. " " .. self._suffix
| |
− | else
| |
− | return self:base_name()
| |
− | end
| |
− | end
| |
− |
| |
− | function EnemyShipData:base_name()
| |
− | return self._name
| |
− | end
| |
− |
| |
− | function EnemyShipData: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 EnemyShipData:localized_name()
| |
− | return self._localized_name
| |
− | end
| |
− |
| |
− | function EnemyShipData:nick()
| |
− | return self._nick
| |
− | end
| |
− |
| |
− | function EnemyShipData:japanese_name()
| |
− | return self._japanese_name
| |
− | end
| |
− |
| |
− | function EnemyShipData:japanese_nick()
| |
− | return self._japanese_nick
| |
− | end
| |
− |
| |
− | function EnemyShipData:reading()
| |
− | return self._reading
| |
− | end
| |
− |
| |
− | function EnemyShipData:reading_nick()
| |
− | return self._reading_nick
| |
− | end
| |
| | | |
− | function EnemyShipData:battle_card() | + | function EnemyShipData:air_power() |
− | return self._battle_card
| + | local air_power = 0 |
− | end
| + | for i=1, self:slots() do |
− |
| + | local slot_equipment, slot_space = self:slot(i) |
− | function EnemyShipData:hp()
| + | if slot_equipment == nil or slot_space == nil then |
− | return self._hp
| + | --we have missing information, fall back to hard-coded air power |
− | end
| + | air_power = self._as_rating |
− | | + | break |
− | function EnemyShipData:firepower()
| + | elseif slot_equipment ~= false then |
− | return self._firepower
| + | --if there is an equipment |
− | end
| + | local slot_equipment_type = slot_equipment:type() |
− | | + | local slot_equipment_aa = slot_equipment:aa() |
− | function EnemyShipData:torpedo()
| + | if slot_equipment_aa and |
− | return self._torpedo
| + | (slot_equipment_type == 6 or |
− | end
| + | slot_equipment_type == 7 or |
− | | + | slot_equipment_type == 8 or |
− | function EnemyShipData:aa()
| + | slot_equipment_type == 11) then |
− | return self._aa
| + | air_power = air_power + |
− | end
| + | math.floor(math.sqrt(slot_space) * slot_equipment_aa) |
− | | + | elseif slot_equipment_aa == nil then |
− | function EnemyShipData:armor()
| + | --we have missing information, fall back to hard-coded air power |
− | return self._armor
| + | air_power = self._as_rating |
− | end
| + | break |
− | | + | end |
− | function EnemyShipData:asw()
| + | end |
− | return self._asw
| + | end |
− | end
| + | return air_power |
− | | |
− | function EnemyShipData:evasion()
| |
− | return self._evasion
| |
− | end
| |
− | | |
− | function EnemyShipData:los()
| |
− | return self._los
| |
− | end
| |
− | | |
− | function EnemyShipData:luck()
| |
− | return self._luck
| |
− | end
| |
− | | |
− | function EnemyShipData:slot(slot)
| |
− | if self._equipment then
| |
− | local equipment_slot = self._equipment[slot]
| |
− | if equipment_slot then
| |
− | return equipment_slot.equipment, equipment_slot.size
| |
− | end
| |
− | end
| |
− | return nil
| |
− | end
| |
− |
| |
− | function EnemyShipData:slots()
| |
− | if self._equipment then
| |
− | return #self._equipment
| |
− | end
| |
− | return nil
| |
− | end
| |
− |
| |
− | function EnemyShipData: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 EnemyShipData:speed()
| |
− | return self._speed
| |
− | end
| |
− |
| |
− | function EnemyShipData:range()
| |
− | return self._range
| |
− | end
| |
− | | |
− | function EnemyShipData:as_rating()
| |
− | return self._as_rating
| |
− | end | |
− |
| |
− | function EnemyShipData:create(ship)
| |
− | ship = ship or {}
| |
− | setmetatable(ship, ship)
| |
− | ship.__index = self
| |
− | return ship
| |
| end | | end |
| | | |