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

From Kancolle Wiki
Jump to navigation Jump to search
com>Ckwng
(Equipment rarities are so messed up...)
com>Ckwng
(Refactor out formatting)
Line 2: Line 2:
 
local EquipmentData = BaseData()
 
local EquipmentData = BaseData()
  
function EquipmentData:name(raw)
+
function EquipmentData:name()
return self:format_stat(self._name, raw)
+
return self._name
 
end
 
end
  
function EquipmentData:link(raw)
+
function EquipmentData:link()
 
if self._page then
 
if self._page then
return mw.ustring.format(self._aliased_link, self._page, self:name())
+
return self._page, self:name()
 
else
 
else
return mw.ustring.format(self._simple_link, self:name())
+
return self:name()
 
end
 
end
 
end
 
end
  
function EquipmentData:id(raw)
+
function EquipmentData:id()
return self:format_stat(self._id, raw)
+
return self._id
 
end
 
end
  
function EquipmentData:japanese_name(raw)
+
function EquipmentData:japanese_name()
return self:format_stat(self._japanese_name, raw)
+
return self._japanese_name
 
end
 
end
  
function EquipmentData:type(raw)
+
function EquipmentData:type()
return self:format_type(self._type, raw)
+
return self._type
 
end
 
end
  
function EquipmentData:rarity(raw)
+
function EquipmentData:rarity()
return self:format_rarity(self._rarity, raw)
+
return self._rarity
 
end
 
end
  
 
function EquipmentData:stars()
 
function EquipmentData:stars()
return self._stars or self:rarity(true)
+
return self._stars or self:rarity()
 
end
 
end
  
Line 38: Line 38:
 
end
 
end
  
function EquipmentData:card(raw)
+
function EquipmentData:card()
return self:format_image(self._card, nil, raw)
+
return self._card
 
end
 
end
  
function EquipmentData:icon(raw)
+
function EquipmentData:icon()
return self:format_image(self:format_icon(self._icon, raw), nil, raw)
+
return self._icon
 
end
 
end
  
function EquipmentData:firepower(raw)
+
function EquipmentData:firepower()
return self:format_stat(self._firepower, raw)
+
return self._firepower
 
end
 
end
  
function EquipmentData:bombing(raw)
+
function EquipmentData:bombing()
return self:format_stat(self._bombing, raw)
+
return self._bombing
 
end
 
end
  
function EquipmentData:torpedo(raw)
+
function EquipmentData:torpedo()
return self:format_stat(self._torpedo, raw)
+
return self._torpedo
 
end
 
end
  
function EquipmentData:aa(raw)
+
function EquipmentData:aa()
return self:format_stat(self._aa, raw)
+
return self._aa
 
end
 
end
  
function EquipmentData:armor(raw)
+
function EquipmentData:armor()
return self:format_stat(self._armor, raw)
+
return self._armor
 
end
 
end
  
function EquipmentData:asw(raw)
+
function EquipmentData:asw()
return self:format_stat(self._asw, raw)
+
return self._asw
 
end
 
end
  
function EquipmentData:shelling_accuracy(raw)
+
function EquipmentData:shelling_accuracy()
return self:format_stat(self._shelling_accuracy, raw)
+
return self._shelling_accuracy
 
end
 
end
  
function EquipmentData:torpedo_accuracy(raw)
+
function EquipmentData:torpedo_accuracy()
return self:format_stat(self._torpedo_accuracy, raw)
+
return self._torpedo_accuracy
 
end
 
end
  
function EquipmentData:los(raw)
+
function EquipmentData:los()
return self:format_stat(self._los, raw)
+
return self._los
 
end
 
end
  
function EquipmentData:speed(raw)
+
function EquipmentData:speed()
return self:format_speed(self._speed, raw)
+
return self._speed
 
end
 
end
  
function EquipmentData:luck(raw)
+
function EquipmentData:luck()
return self:format_stat(self._luck, raw)
+
return self._luck
 
end
 
end
  
function EquipmentData:range(raw)
+
function EquipmentData:range()
return self:format_range(self._range, raw)
+
return self._range
 
end
 
end
  
function EquipmentData:scrap_fuel(raw)
+
function EquipmentData:scrap_fuel()
return self:format_stat(self._scrap_fuel, raw)
+
return self._scrap_fuel
 
end
 
end
  
function EquipmentData:scrap_ammo(raw)
+
function EquipmentData:scrap_ammo()
return self:format_stat(self._scrap_ammo, raw)
+
return self._scrap_ammo
 
end
 
end
  
function EquipmentData:scrap_steel(raw)
+
function EquipmentData:scrap_steel()
return self:format_stat(self._scrap_steel, raw)
+
return self._scrap_steel
 
end
 
end
  
function EquipmentData:scrap_bauxite(raw)
+
function EquipmentData:scrap_bauxite()
return self:format_stat(self._scrap_bauxite, raw)
+
return self._scrap_bauxite
 
end
 
end
  
function EquipmentData:upgradable(raw)
+
function EquipmentData:upgradable()
 
return not not self._upgradable
 
return not not self._upgradable
 
end
 
end
 
EquipmentData.format_type = EquipmentData:create_formatter({
 
[1] = "Small Caliber Main Gun",
 
[2] = "Medium Caliber Main Gun",
 
[3] = "Large Caliber Main Gun",
 
[4] = "Secondary Gun",
 
[5] = "Torpedo",
 
[6] = "Carrier-based Fighter Aircraft",
 
[7] = "Carrier-based Dive Bomber",
 
[8] = "Carrier-based Torpedo Bomber",
 
[9] = "Carrier-based Reconnaissance Aircraft",
 
[10] = "Reconnaissance Seaplane",
 
[11] = "Seaplane Bomber",
 
[12] = "Small Radar",
 
[13] = "Large Radar",
 
[14] = "Sonar",
 
[15] = "Depth Charge",
 
[16] = "Extra Armor",
 
[17] = "Engine Improvement",
 
[18] = "Anti-Aircraft Shell",
 
[19] = "Armor Piercing Shell",
 
[20] = "VT Fuze",
 
[21] = "Anti-Aircraft Machine Gun",
 
[22] = "Midget Submarine",
 
[23] = "Damage Control Personnel",
 
[24] = "Landing Craft",
 
[25] = "Autogyro",
 
[26] = "Anti-submarine Patrol Aircraft",
 
[27] = "Extra Armor (Medium)",
 
[28] = "Extra Armor (Large)",
 
[29] = "Searchlight",
 
[30] = "Supply Transport Container",
 
[31] = "Ship Repair Facility",
 
[32] = "Submarine Torpedo",
 
[33] = "Star Shell",
 
[34] = "Command Facility",
 
[35] = "Aviation Personnel",
 
[36] = "Anti-Aircraft Fire Director",
 
})
 
 
EquipmentData.format_icon = EquipmentData:create_formatter({
 
[false] = "Xx_c.png",
 
[1] = "RedGunLight.png",
 
[2] = "RedGunMedium.png",
 
[3] = "RedGunHeavy.png",
 
[4] = "YellowGun.png",
 
[5] = "Torpedo.png",
 
[6] = "GreenPlane.png",
 
[7] = "RedPlane.png",
 
[8] = "BluePlane.png",
 
[9] = "YellowPlane.png",
 
[10] = "Seaplane.png",
 
[11] = "Radar.png",
 
[12] = "GreenAmmo.png",
 
[13] = "RedAmmo.png",
 
[14] = "EmergencyRepair.png",
 
[15] = "GreenGunMG.png",
 
[16] = "GreenGunDP.png",
 
[17] = "DepthCharge.png",
 
[18] = "Sonar.png",
 
[19] = "Turbine.png",
 
[20] = "LandingCraft.png",
 
[21] = "Heli.png",
 
[22] = "Subplane.png",
 
[23] = "Expansion Bulge (Medium).png",
 
[24] = "Searchlight.png",
 
[25] = "Drum.png",
 
[26] = "Facility.png",
 
[27] = "FlareIcon.png",
 
[28] = "Cf_c.png",
 
[29] = "Ap_c.png",
 
[30] = "Aafd_c.png",
 
})
 
 
EquipmentData.format_rarity = EquipmentData:create_formatter({
 
[0] = "Common",
 
[1] = "Rare",
 
[2] = "Holo",
 
[3] = "S Holo",
 
[4] = "SS Holo",
 
[5] = "SS Holo",
 
})
 
  
 
function EquipmentData:create(equip)
 
function EquipmentData:create(equip)

Revision as of 22:46, 12 February 2015

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

local BaseData = require("Module:BaseData")
local EquipmentData = BaseData()

function EquipmentData:name()
	return self._name
end

function EquipmentData:link()
	if self._page then
		return self._page, self:name()
	else
		return self:name()
	end
end

function EquipmentData:id()
	return self._id
end

function EquipmentData:japanese_name()
	return self._japanese_name
end

function EquipmentData:type()
	return self._type
end

function EquipmentData:rarity()
	return self._rarity
end

function EquipmentData:stars()
	return self._stars or self:rarity()
end

function EquipmentData:back()
	return self._back or self:stars()
end

function EquipmentData:card()
	return self._card
end

function EquipmentData:icon()
	return self._icon
end

function EquipmentData:firepower()
	return self._firepower
end

function EquipmentData:bombing()
	return self._bombing
end

function EquipmentData:torpedo()
	return self._torpedo
end

function EquipmentData:aa()
	return self._aa
end

function EquipmentData:armor()
	return self._armor
end

function EquipmentData:asw()
	return self._asw
end

function EquipmentData:shelling_accuracy()
	return self._shelling_accuracy
end

function EquipmentData:torpedo_accuracy()
	return self._torpedo_accuracy
end

function EquipmentData:los()
	return self._los
end

function EquipmentData:speed()
	return self._speed
end

function EquipmentData:luck()
	return self._luck
end

function EquipmentData:range()
	return self._range
end

function EquipmentData:scrap_fuel()
	return self._scrap_fuel
end

function EquipmentData:scrap_ammo()
	return self._scrap_ammo
end

function EquipmentData:scrap_steel()
	return self._scrap_steel
end

function EquipmentData:scrap_bauxite()
	return self._scrap_bauxite
end

function EquipmentData:upgradable()
	return not not self._upgradable
end

function EquipmentData:create(equip)
	equip = equip or {}
	setmetatable(equip, equip)
	equip.__index = self
	return equip
end

EquipmentData.__call = EquipmentData.create

return EquipmentData