• 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:EnemyShipInfoMini"

From Kancolle Wiki
Jump to navigation Jump to search
m (17 revisions imported)
 
(8 intermediate revisions by one other user not shown)
Line 1: Line 1:
local format = require('Module:StringInterpolation').format
 
local getArgs = require('Module:GetArgs')
 
 
local Formatting = require('Module:Formatting')
 
local Formatting = require('Module:Formatting')
local EnemyShipInfoKai = require('Module:EnemyShipInfoKai')
+
local ShipInfoKai = require('Module:ShipInfoKai')
local ShipBattleCardKai = require('Module:ShipBattleCardKai')
 
  
local EnemyShipInfoMini = EnemyShipInfoKai{
+
local EnemyShipInfoMini = ShipInfoKai{
 
_template = [[{|class="typography-xl-optout ${table_class}" style="margin: auto; float: none; border: 1px solid darkgray; width: 160px;"
 
_template = [[{|class="typography-xl-optout ${table_class}" style="margin: auto; float: none; border: 1px solid darkgray; width: 160px;"
 
|-
 
|-
Line 31: Line 28:
 
| colspan="4" style="text-align: center;" | ${slot_details}
 
| colspan="4" style="text-align: center;" | ${slot_details}
 
|-
 
|-
| colspan="4" style="padding: 0px;" | <div class="mw-collapsible mw-collapsed">
+
| colspan="4" style="padding: 0px;" |<div style="background-color: lightskyblue; cursor: pointer; text-align: center; margin: 0px;" class="mw-customtoggle-extra">'''Extra'''</div>
<div style="background-color: lightskyblue; text-align: center; margin: 0px;">'''Extra Statistics'''</div>
+
<div class="mw-collapsible mw-collapsed" id="mw-customcollapsible-extra" style="padding: 2px; font-size: 12px;">
<div class="mw-collapsible-content" style="padding: 2px">
+
Some notes maybe
<p style="display: ${opening_airstrike_display};">Airstrike: ${opening_airstrike}</p>
 
<p>${day_battle}</p>
 
<p style="display: ${artillery_spotting_display};">${artillery_spotting}</p>
 
<p style="display: ${opening_torpedo_display};">Opening Salvo</p>
 
<p style="display: ${closing_torpedo_display};">Torpedo: ${closing_torpedo}</p>
 
<p>ASW ${asw_attack}</p>
 
<p>NB ${night_battle}</p>
 
</div>
 
 
</div>
 
</div>
 
|}]],
 
|}]],
Line 49: Line 38:
 
local link, text, section = self._ship:link()
 
local link, text, section = self._ship:link()
 
self._vars.name = Formatting:format_link(link, text, section)
 
self._vars.name = Formatting:format_link(link, text, section)
 +
end
 +
 +
function EnemyShipInfoMini:firepower()
 +
self._vars.firepower = Formatting:format_stat(self._ship:firepower())
 +
end
 +
 +
function EnemyShipInfoMini:armor()
 +
self._vars.armor = Formatting:format_stat(self._ship:armor())
 +
end
 +
 +
function EnemyShipInfoMini:torpedo()
 +
self._vars.torpedo = Formatting:format_stat(self._ship:torpedo())
 +
end
 +
 +
function EnemyShipInfoMini:aa()
 +
self._vars.aa = Formatting:format_stat(self._ship:aa(), self._ship:aa())
 +
end
 +
 +
function EnemyShipInfoMini:asw()
 +
self._vars.asw = Formatting:format_stat(self._ship:asw(), self._ship:asw())
 
end
 
end
  
Line 76: Line 85:
 
end
 
end
  
local collapsible_template = [[<div style="display:inline-block;">
+
-- EnemyShipInfoMini.test = EnemyShipInfoMini:Infobox({"Destroyer I-Class"})
<div class="mw-customtoggle-${toggle_id}">
 
{|class="wikitable" style="cursor: pointer; margin: auto; border: 1px solid darkgray;"
 
| ${card_image}
 
|}
 
</div>
 
<div class="mw-collapsible mw-collapsed" id="mw-customcollapsible-${toggle_id}">
 
${table}
 
</div>
 
</div>]]
 
 
 
function EnemyShipInfoMini.EnemyInfoboxMini(frame, args)
 
local args = args or getArgs{frame = frame:getParent()}
 
if args.id then
 
args.link = "nil"
 
return format{
 
collapsible_template,
 
toggle_id = args.id,
 
card_image = ShipBattleCardKai:Asset(args),
 
table = EnemyShipInfoMini:Infobox(args),
 
}
 
else
 
return EnemyShipInfoMini:Infobox(args)
 
end
 
end
 
 
 
EnemyShipInfoMini.test = EnemyShipInfoMini.EnemyInfoboxMini(nil, {"Destroyer I-Class"})
 
  
 
return EnemyShipInfoMini
 
return EnemyShipInfoMini

Latest revision as of 12:41, 12 May 2021

Documentation for this module may be created at Module:EnemyShipInfoMini/doc

local Formatting = require('Module:Formatting')
local ShipInfoKai = require('Module:ShipInfoKai')

local EnemyShipInfoMini = ShipInfoKai{
	_template = [[{|class="typography-xl-optout ${table_class}" style="margin: auto; float: none; border: 1px solid darkgray; width: 160px;"
|-
! colspan="4" style="height: 80px;" | ${name}<br />${japanese_name}
|-
! colspan="4" style="background-color: LightSkyBlue;" | Statistics
|- style="background-color: whitesmoke;"
| style="text-align: center;" | ${icons.hp}
| style="text-align: center;" | ${hp}
| style="text-align: center;" | ${icons.armor}
| style="text-align: center;" | ${armor}
|- style="background-color: whitesmoke;"
| style="text-align: center;" | ${icons.firepower}
| style="text-align: center;" | ${firepower}
| style="text-align: center;" | ${icons.torpedo}
| style="text-align: center;" | ${torpedo}
|- style="background-color: whitesmoke;"
| style="text-align: center;" | ${icons.asw}
| style="text-align: center;" | ${asw}
| style="text-align: center;" | ${icons.aa}
| style="text-align: center;" | ${aa}
|-
! colspan="4" style="background-color: LightSkyBlue;" | '''Equipment'''
|- style="background-color: whitesmoke;"
| colspan="4" style="text-align: center;" | ${slot_details}
|-
| colspan="4" style="padding: 0px;" |<div style="background-color: lightskyblue; cursor: pointer; text-align: center; margin: 0px;" class="mw-customtoggle-extra">'''Extra'''</div>
<div class="mw-collapsible mw-collapsed" id="mw-customcollapsible-extra" style="padding: 2px; font-size: 12px;">
Some notes maybe
</div>
|}]],
}

function EnemyShipInfoMini:name()
	local link, text, section = self._ship:link()
	self._vars.name = Formatting:format_link(link, text, section)
end

function EnemyShipInfoMini:firepower()
	self._vars.firepower = Formatting:format_stat(self._ship:firepower())
end
 
function EnemyShipInfoMini:armor()
	self._vars.armor = Formatting:format_stat(self._ship:armor())
end
 
function EnemyShipInfoMini:torpedo()
	self._vars.torpedo = Formatting:format_stat(self._ship:torpedo())
end

function EnemyShipInfoMini:aa()
	self._vars.aa = Formatting:format_stat(self._ship:aa(), self._ship:aa())
end

function EnemyShipInfoMini:asw()
	self._vars.asw = Formatting:format_stat(self._ship:asw(), self._ship:asw())
end

function EnemyShipInfoMini:slot_details()
	local slots = {}
	for i = 1, self._default_slot_num do
		local num_of_slots, num_of_enabled_slots = self._ship:slots_length(), self._ship:slots()
		local locked = num_of_enabled_slots and i > num_of_enabled_slots
		local icon = ""
		if num_of_slots and i > num_of_slots then

		else
			local equipment, link = self._ship:slot(i), nil
			if equipment then
				icon = equipment:icon()
				link = equipment:link()
			else
				icon = locked and "" or false
			end
			if icon ~= "" then
				icon = Formatting:format_image{Formatting:format_equipment_icon(icon), caption = link, link = link}
			end
		end
		table.insert(slots, icon)
	end
	self._vars.slot_details = table.concat(slots)
end

-- EnemyShipInfoMini.test = EnemyShipInfoMini:Infobox({"Destroyer I-Class"})

return EnemyShipInfoMini