Module:EquipmentData

Revision as of 10:46, 16 December 2014 by com>Ckwng (Re-fix)

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

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

function EquipmentData:name(raw)
	return self:format_stat(self._name, raw)
end

function EquipmentData:link(raw)
	if self._page then
		return mw.ustring.format(self._aliased_link, self._page, self:name())
	else
		return mw.ustring.format(self._simple_link, self:name())
	end
end

function EquipmentData:id(raw)
	return self:format_stat(self._id, raw)
end

function EquipmentData:japanese_name(raw)
	return self:format_stat(self._japanese_name, raw)
end

function EquipmentData:type(raw)
	return self:format_type(self._type, raw)
end

function EquipmentData:rarity(raw)
	return self:format_rarity(self._rarity, raw)
end

function EquipmentData:card(raw)
	return self:format_image(self._card, nil, raw)
end

function EquipmentData:firepower(raw)
	return self:format_stat(self._firepower, raw)
end

function EquipmentData:bombing(raw)
	return self:format_stat(self._bombing, raw)
end

function EquipmentData:torpedo(raw)
	return self:format_stat(self._torpedo, raw)
end

function EquipmentData:aa(raw)
	return self:format_stat(self._aa, raw)
end

function EquipmentData:armor(raw)
	return self:format_stat(self._armor, raw)
end

function EquipmentData:asw(raw)
	return self:format_stat(self._asw, raw)
end

function EquipmentData:shelling_accuracy(raw)
	return self:format_stat(self._shelling_accuracy, raw)
end

function EquipmentData:torpedo_accuracy(raw)
	return self:format_stat(self._torpedo_accuracy, raw)
end

function EquipmentData:los(raw)
	return self:format_stat(self._los, raw)
end

function EquipmentData:speed(raw)
	return self:format_speed(self._speed, raw)
end

function EquipmentData:luck(raw)
	return self:format_stat(self._luck, raw)
end

function EquipmentData:range(raw)
	return self:format_range(self._range, raw)
end

function EquipmentData:scrap_fuel(raw)
	return self:format_stat(self._scrap_fuel, raw)
end

function EquipmentData:scrap_ammo(raw)
	return self:format_stat(self._scrap_ammo, raw)
end

function EquipmentData:scrap_steel(raw)
	return self:format_stat(self._scrap_steel, raw)
end

function EquipmentData:scrap_bauxite(raw)
	return self:format_stat(self._scrap_bauxite, raw)
end

function EquipmentData:upgradable(raw)
	return not not self._upgradable
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_rarity = EquipmentData.create_formatter({
	[0] = "Common",
	[1] = "Rare",
	[2] = "Holo",
	[3] = "S Holo",
	[4] = "SS Holo",
	})

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

EquipmentData.__call = EquipmentData.create

return EquipmentData