Модуль:UnitData/getter
local p = {} local data = require('Module:UnitData/data') local rarity = require('Module:HeroData/rarities') local race = require('Module:HeroData/races') local class = require('Module:HeroData/classes') local alliance = require('Module:HeroData/alliances') local type = require('Module:HeroData/types') local ability = require('Module:HeroData/abilities') local source = require('Module:ItemData/source')
function p.name(unit)
return data[unit].unit or unit
end
function p.icon(unit) return data[unit].icon end
function p.rarity(unit)
return rarity[data[unit].rarity]
end
function p.race(unit)
return race[data[unit].race]
end
function p.class(unit)
return class[data[unit].class]
end
function p.alliance(unit) local str if data[unit].alliance == nil then str = "" else str = alliance[data[unit].alliance] end
return str
end
function p.type(unit)
return type[data[unit].type]
end
-- Table: [stats] function p.stats(unit)
return data[unit].stats
end
function p.total_stats(unit)
return data[unit].stats.total
end
function p.hp_base(unit)
return data[unit].stats.hp_base
end
function p.def_base(unit)
return data[unit].stats.def_base
end
function p.atk_base(unit)
return data[unit].stats.atk_base
end
function p.wis_base(unit)
return data[unit].stats.wis_base
end
function p.agi_base(hero)
return data[hero].stats.agi_base
end
-- Table: [abilities] function p.abilities(unit) local tbl = {} for _, v in ipairs(data[unit].abilities) do table.insert(tbl, p.ability(v)) end return tbl end
function p.ability(ability_value) return ability[ability_value] end
function p.dislike(unit) return data[unit].dislike end
function p.feature(unit) return data[unit].feature end
function p.description(unit) return data[unit].description end
function p.min_cost(unit)
return data[unit].min_cost
end
function p.deposit(unit)
return data[unit].deposit
end
function p.source(unit) return source[data[unit].source] end
return p