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

From Kancolle Wiki
Jump to navigation Jump to search
com>Ckwng
com>Ckwng
Line 2: Line 2:
 
local ShipInfoKai = require('Module:ShipInfoKai')
 
local ShipInfoKai = require('Module:ShipInfoKai')
 
local Formatting = require('Module:Formatting')
 
local Formatting = require('Module:Formatting')
 +
 +
local format = require('Module:StringInterpolation').format
  
 
local EnemyShipInfoKai = ShipInfoKai{
 
local EnemyShipInfoKai = ShipInfoKai{
 
_template = [[{|class="${table_class}" id="${table_id}" style="border: 1px solid darkgray; width: 320px;"
 
_template = [[{|class="${table_class}" id="${table_id}" style="border: 1px solid darkgray; width: 320px;"
 
|-
 
|-
| colspan="6" style="position: relative; text-align: center; padding: 1px 40px; background-color: ${top_bg_color};${top_extra_style}" | <div style="position: absolute; right: 5px;">${edit_link}</div>
+
| colspan="6" style="position: relative; text-align: center; padding: 1px 40px; background-color: ${top_bg_color};" | <div style="position: absolute; right: 5px;">${edit_link}</div>
<p style="font-size:20px">'''${name}'''</p>${localized_name}
+
<p style="font-size:20px; text-shadow: ${text_shadow}">'''${name}'''</p>${localized_name}
 
<p style="font-size:15px">'''No.${id} ${japanese_name}${nick}'''</p>
 
<p style="font-size:15px">'''No.${id} ${japanese_name}${nick}'''</p>
 
<p>'''${class} ${type}'''</p>
 
<p>'''${class} ${type}'''</p>
Line 56: Line 58:
 
|}]],
 
|}]],
 
_abyssal_class = "Abyssal",
 
_abyssal_class = "Abyssal",
 +
_background_color = "darkgrey",
 +
_link_color = "black",
 +
_text_shadow_template = "0 0 ${radius} ${color}",
 +
_text_shadows = {
 +
"0.1em",
 +
"0.3em",
 +
"0.6em",
 +
"0.9em",
 +
},
 +
_kai_glow_colors = {
 +
"darkturquoise",
 +
"dodgerblue",
 +
},
 +
_link_color_template = [[<span style="color: ${color};">${text}</color>]]
 
}
 
}
  
 
function EnemyShipInfoKai:bg_color()
 
function EnemyShipInfoKai:bg_color()
 
local back = self._ship:back()
 
local back = self._ship:back()
self._vars.top_bg_color, self._vars.top_extra_style = Formatting:format_ship_back(back), ""
+
local back_color = Formatting:format_ship_back(back)
 +
local text_shadows = {}
 +
for index, radius in ipairs(self._text_shadows) do
 +
local color = back_color
 +
if index <= #self._kai_glow_colors then
 +
if back and back > -7 and back < -3 then
 +
color = self._kai_glow_colors[index]
 +
end
 +
end
 +
table.insert(text_shadows, format{self._text_shadow_template, radius = radius, color = color})
 +
end
 +
self._vars.top_bg_color, self._vars.text_shadow = self._background_color, table.concat(text_shadows, ", ")
 +
end
 +
 
 +
function EnemyShipInfoKai:name()
 +
local link, text, section = self._ship:link()
 +
text = format{self._link_color_template, color = self._link_color, text = text or link}
 +
self._vars.name = Formatting:format_link(link, text, section)
 
end
 
end
  
function ShipInfoKai:id()
+
function EnemyShipInfoKai:id()
 
self._vars.id = Formatting:format_stat(self._ship:id())
 
self._vars.id = Formatting:format_stat(self._ship:id())
 
end
 
end

Revision as of 08:32, 23 April 2015

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

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

local format = require('Module:StringInterpolation').format

local EnemyShipInfoKai = ShipInfoKai{
	_template = [[{|class="${table_class}" id="${table_id}" style="border: 1px solid darkgray; width: 320px;"
|-
| colspan="6" style="position: relative; text-align: center; padding: 1px 40px; background-color: ${top_bg_color};" | <div style="position: absolute; right: 5px;">${edit_link}</div>
<p style="font-size:20px; text-shadow: ${text_shadow}">'''${name}'''</p>${localized_name}
<p style="font-size:15px">'''No.${id} ${japanese_name}${nick}'''</p>
<p>'''${class} ${type}'''</p>
|- style="background-color: whitesmoke;"
| align=center colspan="6" | ${image}
|-
| colspan="6" style="text-align: center; background-color: LightSkyBlue;"|'''Statistics'''
|- style="background-color: whitesmoke;"
| colspan="2" style="width: 88px;" | ${icons.hp} ${labels.hp}
| style="width: 66px;" | '''${hp}'''
| style="width: 88px;" | ${icons.firepower} ${labels.firepower}
| colspan="2" style="width: 60px;" | '''${firepower}'''
|- style="background-color: whitesmoke;"
| colspan="2" style="width: 88px;" | ${icons.armor} ${labels.armor}
| style="width: 66px;" | '''${armor}'''
| style="width: 88px;" | ${icons.torpedo} ${labels.torpedo}
| colspan="2" style="width: 66px;" | '''${torpedo}'''
|- style="background-color: whitesmoke;"
| colspan="2" style="width: 88px;" | ${icons.evasion} ${labels.evasion}
| style="width: 66px;" | '''${evasion}'''
| style="width: 88px;" | ${icons.aa} ${labels.aa}
| colspan="2" style="width: 66px;" | '''${aa}'''
|- style="background-color: whitesmoke;"
| colspan="2" style="width: 88px;" | ${icons.aircraft} ${labels.aircraft}
| style="width: 66px;" | '''${aircraft}'''
| style="width: 88px;" | ${icons.asw} ${labels.asw}
| colspan="2" style="width: 66px;" | '''${asw}'''
|- style="background-color: whitesmoke;"
| colspan="2" style="width: 88px;" | ${icons.speed} ${labels.speed}
| style="width: 66px;" | '''${speed}'''
| style="width: 88px;" | ${icons.los} ${labels.los}
| colspan="2" style="width: 66px;" | '''${los}'''
|- style="background-color: whitesmoke;"
| colspan="2" style="width: 88px;" | ${icons.range} ${labels.range}
| style="width: 66px;" | '''${range}'''
| style="width: 88px;" | ${icons.luck} ${labels.luck}
| colspan="2" style="width: 66px;" | '''${luck}'''
|-
| colspan="5" style="text-align: center; background-color: LightSkyBlue;"| '''Air Power'''
| style="text-align: center; background-color: LightSkyBlue; width: 50px;" | '''Slots'''
|-  style="background-color: whitesmoke;"
| colspan="5" style="text-align: center;"| ${air_power}
| align=center style="width: 50px;" | ${slots}
|-
| colspan="5" style="text-align: center; background-color: LightSkyBlue;"| '''Equipment'''
| style="text-align: center; background-color: LightSkyBlue; width: 50px;" | '''Space'''
${slot_details}
|}]],
	_abyssal_class = "Abyssal",
	_background_color = "darkgrey",
	_link_color = "black",
	_text_shadow_template = "0 0 ${radius} ${color}",
	_text_shadows = {
		"0.1em",
		"0.3em",
		"0.6em",
		"0.9em",
	},
	_kai_glow_colors = {
		"darkturquoise",
		"dodgerblue",
	},
	_link_color_template = [[<span style="color: ${color};">${text}</color>]]
}

function EnemyShipInfoKai:bg_color()
	local back = self._ship:back()
	local back_color = Formatting:format_ship_back(back)
	local text_shadows = {}
	for index, radius in ipairs(self._text_shadows) do
		local color = back_color
		if index <= #self._kai_glow_colors then
			if back and back > -7 and back < -3 then
				color = self._kai_glow_colors[index]
			end
		end
		table.insert(text_shadows, format{self._text_shadow_template, radius = radius, color = color})
	end
	self._vars.top_bg_color, self._vars.text_shadow = self._background_color, table.concat(text_shadows, ", ")
end

function EnemyShipInfoKai:name()
	local link, text, section = self._ship:link()
	text = format{self._link_color_template, color = self._link_color, text = text or link}
	self._vars.name = Formatting:format_link(link, text, section)
end

function EnemyShipInfoKai:id()
	self._vars.id = Formatting:format_stat(self._ship:id())
end

function EnemyShipInfoKai:class()
	self._vars.class = self._abyssal_class
end

function EnemyShipInfoKai:image()
	self._vars.image = Formatting:format_image{"Empty ship slot.png"} --placeholder
end

function EnemyShipInfoKai:firepower()
	self._vars.firepower = Formatting:format_stat(self._ship:firepower())
end

function EnemyShipInfoKai:armor()
	self._vars.armor = Formatting:format_stat(self._ship:armor())
end

function EnemyShipInfoKai:torpedo()
	self._vars.torpedo = Formatting:format_stat(self._ship:torpedo())
end

function EnemyShipInfoKai:evasion()
	local evasion
	local override = self._args.evasion
	local overridden = false
	if override and override ~= "auto" then
		evasion = override
		overridden = true
	else
		evasion = self._ship:evasion()
	end
	local result = Formatting:format_stat(evasion)
	if overridden then
		result = result .. self._overridden_category_template
	end
	self._vars.evasion = result
end

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

function EnemyShipInfoKai:asw()
	local asw
	local overridden = false
	local override = self._args.asw
	if override and override ~= "auto" then
		asw = override
		overridden = true
	else
		asw = self._ship:asw()
	end
	local result = Formatting:format_stat(asw)
	if overridden then
		result = result .. self._overridden_category_template
	end
	self._vars.asw = result
end

function EnemyShipInfoKai:los()
	local los
	local override = self._args.los
	local overridden = false
	if override and override ~= "auto" then
		los = override
		overridden = true
	else
		los = self._ship:los()
	end
	local result = Formatting:format_stat(los)
	if overridden then
		result = result .. self._overridden_category_template
	end
	self._vars.los = result
end

function EnemyShipInfoKai:luck()
	self._vars.luck = Formatting:format_stat(self._ship:luck())
end

function EnemyShipInfoKai:air_power()
	self._vars.air_power = Formatting:format_stat(self._ship:air_power())
end

function EnemyShipInfoKai:create_item()
	self._ship = EnemyShip(self._args.name, self._args.model)
end

function EnemyShipInfoKai:add_fields()
	table.insert(self._fields, "air_power")
end

return EnemyShipInfoKai