Modifiche

Jump to navigation Jump to search
31 963 byte aggiunti ,  23:34, 11 lug 2020
m
nessun oggetto della modifica
local p = {}

function p.pagecat(frame)
return '[[Category:Pokémon]]'
end

function p.nomepoke(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
return data.name
end

function p.intro(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
local pkmnNo = tonumber(modname)
local pkmnPrec = tonumber(data.ordering.prev.dexNumber)
local pkmnSucc = tonumber(data.ordering.next.dexNumber)
local t = {}
table.insert(t, frame:expandTemplate{ title = 'Pokemon_TypeTableBubbleIntro', args = { tipo = string.lower(data.types.primary) } } )
if(data.types.secondary ~= nil) then table.insert(t, frame:expandTemplate{ title = 'Pokemon_TypeTableBubbleIntro', args = { tipo = string.lower(data.types.secondary) } } ) end
local prevImg = '[[File:PKMN_Sprite_' .. string.format("%03d", pkmnPrec) .. '.png]]'
local succImg = '[[File:PKMN_Sprite_' .. string.format("%03d", pkmnSucc) .. '.png]]'
return frame:expandTemplate{ title='Pokemon_Intro', args = {
PrecNome = data.ordering.prev.name,
PrecSprite = prevImg,
PrecDex = '#' .. string.format("%03d", pkmnPrec),
SuccNome = data.ordering.next.name,
SuccSprite = succImg,
SuccDex = '#' .. string.format("%03d", pkmnSucc),
PokeNome = data.name,
PokeDex = '#' .. string.format("%03d", data.dexNumber),
PokeArtwork = '[[File:PKMN_Artwork_' .. string.format("%03d", data.dexNumber) .. '.png]]',
PokeSpecie = '',
PokeTipi = table.concat(t,"\n")
} }
end

function p.infodex(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
return frame:expandTemplate{ title='Pokemon_Info_Dex', args = {
NomeJap=data.nameLang.jap,
NomeJapRom=data.nameLang.japRom,
Peso=data.basicPokemonInfo.weight,
Altezza=data.basicPokemonInfo.height,
TassoCattura=data.basicPokemonInfo.catchRate,
TassoCatturaVal=data.basicPokemonInfo.catchRateValue,
TassoMaschio=data.basicPokemonInfo.male,
TassoFemmina=data.basicPokemonInfo.female,
} }
end

function selectStatColor(stat, arr)
local minimum = math.min(arr.hp.baseValue, arr.atk.baseValue, arr.def.baseValue, arr.spa.baseValue, arr.spd.baseValue, arr.spe.baseValue)
local maximum = math.max(arr.hp.baseValue, arr.atk.baseValue, arr.def.baseValue, arr.spa.baseValue, arr.spd.baseValue, arr.spe.baseValue)
local statColor = 'verde'
if stat >= 100 then statColor = 'arancio' end
if stat == minimum then statColor = 'blu' end
if stat == maximum then statColor = 'rosso' end
return statColor
end

function p.datigioco(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
local t = {}
local deb4 = {}
local deb2 = {}
local res2 = {}
local res4 = {}
local imm = {}
if data.weaknessTable.quadrupleDamage ~= nil then
for index, entry in ipairs(data.weaknessTable.quadrupleDamage) do
table.insert(deb4, frame:expandTemplate{ title='Template:Pokemon_TypeTableBubble', args = {tipo=string.lower(entry)}})
end
end
if data.weaknessTable.doubleDamage ~= nil then
for index, entry in ipairs(data.weaknessTable.doubleDamage) do
table.insert(deb2, frame:expandTemplate{ title='Template:Pokemon_TypeTableBubble', args = {tipo=string.lower(entry)}})
end
end
if data.weaknessTable.halfDamage ~= nil then
for index, entry in ipairs(data.weaknessTable.halfDamage) do
table.insert(res2, frame:expandTemplate{ title='Template:Pokemon_TypeTableBubble', args = {tipo=string.lower(entry)}})
end
end
if data.weaknessTable.quarterDamage ~= nil then
for index, entry in ipairs(data.weaknessTable.quarterDamage) do
table.insert(res4, frame:expandTemplate{ title='Template:Pokemon_TypeTableBubble', args = {tipo=string.lower(entry)}})
end
end
if data.weaknessTable.uneffective ~= nil then
for index, entry in ipairs(data.weaknessTable.uneffective) do
table.insert(imm, frame:expandTemplate{ title='Template:Pokemon_TypeTableBubble', args = {tipo=string.lower(entry)}})
end
end
return frame:expandTemplate{ title='Pokemon_Stats', args = {
NomePkmn=data.name,
Debolezze4=(data.weaknessTable.quadrupleDamage ~= nil) and (table.concat(deb4, '')) or nil,
Debolezze2=(data.weaknessTable.doubleDamage ~= nil) and (table.concat(deb2, '')) or nil,
Resistenze2=(data.weaknessTable.halfDamage ~= nil) and (table.concat(res2, '')) or nil,
Resistenze4=(data.weaknessTable.quarterDamage ~= nil) and (table.concat(res4, '')) or nil,
Immunita=(data.weaknessTable.uneffective ~= nil) and (table.concat(imm, '')) or nil,
PSVal=data.statistics.hp.baseValue,
PSMin50=data.statistics.hp.minLv50,
PSMax50=data.statistics.hp.maxLv50,
PSMin100=data.statistics.hp.minLv100,
PSMax100=data.statistics.hp.maxLv100,
PSPerc=math.ceil(data.statistics.hp.baseValue * 100 / 255),
PSColore=selectStatColor(data.statistics.hp.baseValue, data.statistics),
AttVal=data.statistics.atk.baseValue,
AttMin50=data.statistics.atk.minLv50,
AttMax50=data.statistics.atk.maxLv50,
AttMin100=data.statistics.atk.minLv100,
AttMax100=data.statistics.atk.maxLv100,
AttPerc=math.ceil(data.statistics.atk.baseValue * 100 / 255),
AttColore=selectStatColor(data.statistics.atk.baseValue, data.statistics),
DifVal=data.statistics.def.baseValue,
DifMin50=data.statistics.def.minLv50,
DifMax50=data.statistics.def.maxLv50,
DifMin100=data.statistics.def.minLv100,
DifMax100=data.statistics.def.maxLv100,
DifPerc=math.ceil(data.statistics.def.baseValue * 100 / 255),
DifColore=selectStatColor(data.statistics.def.baseValue, data.statistics),
AttSpVal=data.statistics.spa.baseValue,
AttSpMin50=data.statistics.spa.minLv50,
AttSpMax50=data.statistics.spa.maxLv50,
AttSpMin100=data.statistics.spa.minLv100,
AttSpMax100=data.statistics.spa.maxLv100,
AttSpPerc=math.ceil(data.statistics.spa.baseValue * 100 / 255),
AttSpColore=selectStatColor(data.statistics.spa.baseValue, data.statistics),
DifSpVal=data.statistics.spd.baseValue,
DifSpMin50=data.statistics.spd.minLv50,
DifSpMax50=data.statistics.spd.maxLv50,
DifSpMin100=data.statistics.spd.minLv100,
DifSpMax100=data.statistics.spd.maxLv100,
DifSpPerc=math.ceil(data.statistics.spd.baseValue * 100 / 255),
DifSpColore=selectStatColor(data.statistics.spd.baseValue, data.statistics),
VelVal=data.statistics.spe.baseValue,
VelMin50=data.statistics.spe.minLv50,
VelMax50=data.statistics.spe.maxLv50,
VelMin100=data.statistics.spe.minLv100,
VelMax100=data.statistics.spe.maxLv100,
VelPerc=math.ceil(data.statistics.spe.baseValue * 100 / 255),
VelColore=selectStatColor(data.statistics.spe.baseValue, data.statistics),
StatTot= data.statistics.hp.baseValue + data.statistics.atk.baseValue + data.statistics.def.baseValue + data.statistics.spa.baseValue + data.statistics.spd.baseValue + data.statistics.spe.baseValue,
Abilita1=data.abilities.primary,
Abilita2=data.abilities.secondary,
AbilitaNascosta=data.abilities.hidden
} }
end

function buildEvoLineMethod(entry)
local look = {
[1] = function(entry) return {name = 'Al livello '..entry.detail, condition = entry.condition, img = '[[File:Caramella_Rara.png]]'} end,
[2] = function(entry) return {name = 'Al passaggio di livello', condition = 'Amicizia alta', img = '[[File:Caramella_Rara.png]]'} end,
[3] = function(entry) return {name = 'Al passaggio di livello', condition = 'Conoscendo ' .. entry.detail, img = '[[File:Caramella_Rara.png]]'} end,
[4] = function(entry) return {name = 'Al passaggio di livello', condition = 'In un luogo specifico', img = ''} end,
[5] = function(entry) return {name = 'Al passaggio di livello', condition = 'In una regione specifica', img = ''} end,
[6] = function(entry) return {name = 'Al passaggio di livello', condition = entry.condition, img = '[[File:Caramella_Rara.png]]'} end,
[7] = function(entry) return {name = entry.detail, condition = entry.condition, img = '[[File:'..(entry.detail)..'.png]]'} end,
[8] = function(entry)
local cond = '♀ '
if(entry.condition == 'Maschio') then cond = '♂ ' end
return {name = 'Al livello '..entry.detail, condition = 'Solo se: '..cond..string.lower(entry.condition), img = '[[File:Caramella_Rara.png]]'} end,
[9] = function(entry) return {name = 'Al livello '..entry.detail, condition = entry.condition, img = '[[File:Caramella_Rara.png]]'} end,
[10] = function(entry) return {name = (entry.detail ~= nil) and 'Al livello '..entry.detail or 'Al passaggio di livello', condition = entry.condition, img = '[[File:Caramella_Rara.png]]'} end,
[11] = function(entry) return {name = entry.detail, condition = entry.condition, img = ''} end,
[12] = function(entry) return {name = entry.detail, condition = entry.condition, img = '[[File:'..(entry.detail)..'.png]]'} end,
[13] = function(entry) return {name = entry.detail, condition = entry.condition, img = '[[File:'..(entry.detail)..'.png]]'} end,
[14] = function(entry) return {name = entry.detail, condition = entry.condition, img = '[[File:'..(entry.detail)..'.png]]'} end,
[15] = function(entry) return {name = entry.detail, condition = entry.condition, img = '[[File:'..(entry.detail)..'.png]]'} end,
[16] = function(entry) return {name = 'Scambio', condition = entry.condition, img = ''} end,
[17] = function(entry) return {name = 'Tenendo '..(entry.detail), condition = 'durante uno scambio', img = '[[File:'..(entry.detail)..'.png]]'} end,
[18] = function(entry)
if entry.detail == 'Karrablast' then
return {name = 'Scambio', condition = 'Per [[File:PKMN_Sprite_588.png|30px]] [[Karrablast]]', img = ''}
else if entry.detail == 'Shelmet' then
return {name = 'Scambio', condition = 'Per [[File:PKMN_Sprite_616.png|30px]] [[Shelmet]]', img = ''}
end end
end,
[19] = function(entry) return {name = 'Al livello '..entry.detail, condition = entry.condition, img = '[[File:Caramella_Rara.png]]'} end,
[20] = function(entry) return {name = 'Evolve in altri giochi', condition = entry.condition, img = ''} end,
}
return look[entry.id](entry)
end

function buildEvoLineTypes(primary, secondary, frame)
if secondary == nil then
return frame:expandTemplate{ title='Template:Pokemon_TypeTableBubble', args = {tipo=string.lower(primary)}}
else
return frame:expandTemplate{ title='Template:Pokemon_TypeTableBubble', args = {tipo=string.lower(primary)}} .. frame:expandTemplate{ title='Template:Pokemon_TypeTableBubble', args = {tipo=string.lower(secondary)}}
end
end

function buildEvoLine(entry, frame)
if entry.stages == 2 then
local method1 = buildEvoLineMethod(entry.firstEvolutionMethod)
local evo1ImgName = entry.firstStageDexNumber;
if (entry.firstStageFormName ~= nil) then
evo1ImgName = evo1ImgName .. '-' .. entry.firstStageFormName;
end
local evo2ImgName = entry.secondStageDexNumber;
if (entry.secondStageFormName ~= nil) then
evo2ImgName = evo2ImgName .. '-' .. entry.secondStageFormName;
end
return frame:expandTemplate{ title = 'Pokemon_Evo2', args = {
EVO1_INFO = entry.firstStageName,
EVO1_IMG = '[[File:PKMN_Artwork_'..evo1ImgName..'.png]]',
EVO1_TIPI = buildEvoLineTypes(entry.firstStageTypes.primary, entry.firstStageTypes.secondary, frame),
STRUM_NOME = method1.name,
STRUM_IMG = method1.img,
STRUM_COND = method1.condition,
EVO2_INFO = entry.secondStageName,
EVO2_IMG = '[[File:PKMN_Artwork_'..evo2ImgName..'.png]]',
EVO2_TIPI = buildEvoLineTypes(entry.secondStageTypes.primary, entry.secondStageTypes.secondary, frame),
} }
end
if entry.stages == 3 then
local method1 = buildEvoLineMethod(entry.firstEvolutionMethod)
local method2 = buildEvoLineMethod(entry.secondEvolutionMethod)
local evo1ImgName = entry.firstStageDexNumber;
if (entry.firstStageFormName ~= nil) then
evo1ImgName = evo1ImgName .. '-' .. entry.firstStageFormName;
end
local evo2ImgName = entry.secondStageDexNumber;
if (entry.secondStageFormName ~= nil) then
evo2ImgName = evo2ImgName .. '-' .. entry.secondStageFormName;
end
local evo3ImgName = entry.thirdStageDexNumber;
if (entry.thirdStageFormName ~= nil) then
evo3ImgName = evo3ImgName .. '-' .. entry.thirdStageFormName;
end
return frame:expandTemplate{ title = 'Pokemon_Evo3', args = {
EVO1_INFO = entry.firstStageName,
EVO1_IMG = '[[File:PKMN_Artwork_'..evo1ImgName..'.png]]',
EVO1_TIPI = buildEvoLineTypes(entry.firstStageTypes.primary, entry.firstStageTypes.secondary, frame),
STRUM_NOME = method1.name,
STRUM_IMG = method1.img,
STRUM_COND = method1.condition,
EVO2_INFO = entry.secondStageName,
EVO2_IMG = '[[File:PKMN_Artwork_'..evo2ImgName..'.png]]',
EVO2_TIPI = buildEvoLineTypes(entry.secondStageTypes.primary, entry.secondStageTypes.secondary, frame),
STRUM2_NOME = method2.name,
STRUM2_IMG = method2.img,
STRUM2_COND = method2.condition,
EVO3_INFO = entry.thirdStageName,
EVO3_IMG = '[[File:PKMN_Artwork_'..evo3ImgName..'.png]]',
EVO3_TIPI = buildEvoLineTypes(entry.thirdStageTypes.primary, entry.thirdStageTypes.secondary, frame),
} }
end
end

function p.lineaevo(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
local t = {}
if data.evolutions ~= nil then
for index, entry in ipairs(data.evolutions) do
table.insert(t, buildEvoLine(entry, frame))
end
end
return table.concat(t,"\n")
end

function p.allevamento(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
local t = {}
local groups = {}
if (data.breed.evs.hp > 0) then
table.insert(t, frame:expandTemplate{ title = 'Pokemon_Breed_EV', args = {EVNome="PS", EVValore=data.breed.evs.hp} } )
end
if (data.breed.evs.atk > 0) then
table.insert(t, frame:expandTemplate{ title = 'Pokemon_Breed_EV', args = {EVNome="Att", EVValore=data.breed.evs.atk} } )
end
if (data.breed.evs.def > 0) then
table.insert(t, frame:expandTemplate{ title = 'Pokemon_Breed_EV', args = {EVNome="Dif", EVValore=data.breed.evs.def} } )
end
if (data.breed.evs.spa > 0) then
table.insert(t, frame:expandTemplate{ title = 'Pokemon_Breed_EV', args = {EVNome="Att. Sp.", EVValore=data.breed.evs.spa} } )
end
if (data.breed.evs.spd > 0) then
table.insert(t, frame:expandTemplate{ title = 'Pokemon_Breed_EV', args = {EVNome="Dif. Sp.", EVValore=data.breed.evs.spd} } )
end
if (data.breed.evs.spe > 0) then
table.insert(t, frame:expandTemplate{ title = 'Pokemon_Breed_EV', args = {EVNome="Vel", EVValore=data.breed.evs.spe} } )
end
for index, entry in ipairs(data.breed.egg.group) do
table.insert(groups, entry)
end
return frame:expandTemplate{ title='Pokemon_Breed', args = {
TassoCrescita = data.breed.growth,
AffettoBase = data.breed.affection,
ExpBase = data.breed.baseExp,
ListaGruppiUova = table.concat(groups, ", "),
NumCicli = data.breed.egg.cycles,
MinPassi = data.breed.egg.stepRangeMin,
MaxPassi = data.breed.egg.stepRangeMax,
EVCedute = table.concat(t, ""),
} }
end

function p.dexregionali(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
local t = {}

return frame:expandTemplate{ title='Pokemon_DexRegionali', args = {
Kanto=data.regionalDexNumber.kanto ,
KantoRemake=data.regionalDexNumber.kantoExtended,
KantoGo=data.regionalDexNumber.kantoLetsGO,
Johto=data.regionalDexNumber.johto,
JohtoRemake=data.regionalDexNumber.johtoExtended,
Hoenn=data.regionalDexNumber.hoenn,
HoennRemake=data.regionalDexNumber.hoennExtended,
Sinnoh=data.regionalDexNumber.sinnoh,
Sinnoh2=data.regionalDexNumber.sinnohExtended,
Unima=data.regionalDexNumber.unima,
Unima2=data.regionalDexNumber.unimaExtended,
Kalos=data.regionalDexNumber.kalos,
KalosZona=data.regionalDexNumber.kalosZone,
Alola=data.regionalDexNumber.alola,
Alola2=data.regionalDexNumber.alolaExtended,
Galar=data.regionalDexNumber.galar,
GalarArmatura=data.regionalDexNumber.galarArmor
} }
end

function p.dexvoci(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
local t = {}
if data.pokedexEntries ~= nil then
for index, entry in ipairs(data.pokedexEntries) do
table.insert(t, frame:expandTemplate{ title = 'Bubble_Table_Riga', args = {
CHIAVE=entry.game,
VALORE=entry.entry
} } )
end
end
return frame:expandTemplate{ title='Bubble_Table', args = {RIGHE=table.concat(t,"\n")} }
end

function p.zone(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
local t = {}
if data.locations ~= nil then
for index, entry in ipairs(data.locations) do
if entry.routes == nil and entry.others == nil then

else
local links = {}
if entry.routes ~= nil then
for k,v in ipairs(entry.routes) do
table.insert(links, '[[' .. v.link .. '|' .. v.name .. ']]')
end
end
if entry.others ~= nil then
for k,v in ipairs(entry.others) do
table.insert(links, '[[' .. v.link .. '|' .. v.name .. ']]')
end
end
table.insert(t, frame:expandTemplate{ title = 'Bubble_Table_Riga', args = {
CHIAVE=entry.game,
VALORE=table.concat(links,", ")
} } )
end
end
end
return frame:expandTemplate{ title='Bubble_Table', args = {RIGHE=table.concat(t,"\n")} }
end

function p.distribuzioni(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
local utils = require('Module:Utils')
local t = {}
if data.events ~= nil then
for index, entry in ipairs(data.events) do
local ab = {}
local moves = {}
for k1,v1 in ipairs(entry.abilities) do
table.insert(ab, v1)
end
for k2,v2 in ipairs(entry.moves) do
table.insert(moves, v2)
end
table.insert(t, frame:expandTemplate{ title = 'Pokemon_Distro', args = {
Giochi = entry.games,
DexNumber = string.format("%03d", data.dexNumber),
Nome = entry.name,
Natura = entry.nature,
Abilita = table.concat(ab,"<br>"),
Strumento = entry.item,
Livello = entry.level,
Mosse = table.concat(moves,"<br>"),
DataInizio = entry.startDate,
DataFine = entry.endDate,
NomeAllenatore = entry.trainerName,
IDAllenatore = entry.trainerID,
Luogo = utils.flagEmojiFromNameIta(entry.region)
} } )
end
end
local sp = frame:expandTemplate{ title = 'Generic_Row', args = {CONT = table.concat(t,"\n")} }
return frame:expandTemplate{ title = 'Spoiler', args = { Titolo="Lista distribuzioni", Corpo=sp } }
end

function p.strumenti(frame)
return frame:expandTemplate{ title = 'ComingSoon', args = {} }
end

function p.minigiochi(frame)
return frame:expandTemplate{ title = 'ComingSoon', args = {} }
end

function lookupMovesFirstColumn(lookup, entry)
local look = {
[1] = function(entry) return entry.level end,
[2] = function(entry) return nil end,
}
return look[lookup](entry)
end

function lookupMovesFirstColumnHead(lookup)
local look = {
[1] = 'LV',
[2] = 'COD.',
}
return look[lookup]
end

function fillMovesTable(frame, obj, lookup)
local t = {}
if (obj ~= nil) then
for index, entry in ipairs(obj) do
local lt = lookupMovesFirstColumn(lookup, entry)
table.insert(t, frame:expandTemplate{ title = 'Pokemon_TabellaMosseRiga', args = {
PrimaColonna = lt,
Nome = (entry.stab) and ("'''" .. entry.name .. "'''") or (entry.name),
Tipo = frame:expandTemplate{ title='Template:Pokemon_TypeTableBubbleEX', args = {tipo=string.lower(entry.moveType)}},
Categoria = frame:expandTemplate{ title='Template:Pokemon_TypeTableBubbleCL', args = {tipo=string.lower(entry.category)}},
Potenza = entry.power,
Precisione = entry.accuracy,
PP = entry.pp .. '/' .. entry.maxPP
} } )
end
end
return frame:expandTemplate{ title='Template:Pokemon_TabellaMosse', args = {RIGHE=table.concat(t,"\n"), FC = lookupMovesFirstColumnHead(lookup)} }
end

function p.mosse_livello(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
return frame:expandTemplate{ title='GenSwitchMin', args = {
IDU = 'mosselivello',
SEZIONE = 'Mosse apprese (aumentando di livello)',
GEN1 = fillMovesTable(frame, data.levelMoves.firstGen, 1),
GEN2 = fillMovesTable(frame, data.levelMoves.secondGen, 1),
GEN3 = fillMovesTable(frame, data.levelMoves.thirdGen, 1),
GEN4 = fillMovesTable(frame, data.levelMoves.fourthGen, 1),
GEN5 = fillMovesTable(frame, data.levelMoves.fifthGen, 1),
GEN6 = fillMovesTable(frame, data.levelMoves.sixthGen, 1),
GEN7 = fillMovesTable(frame, data.levelMoves.seventhGen, 1),
GEN8 = fillMovesTable(frame, data.levelMoves.eighthGen, 1)
} }
end

function p.mosse_mtdt(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
return frame:expandTemplate{ title='GenSwitchMin', args = {
IDU = 'mossemtdt',
SEZIONE = 'Tramite MT/DT',
GEN1 = fillMovesTable(frame, data.machineMoves.firstGen, 2),
GEN2 = fillMovesTable(frame, data.machineMoves.secondGen, 2),
GEN3 = fillMovesTable(frame, data.machineMoves.thirdGen, 2),
GEN4 = fillMovesTable(frame, data.machineMoves.fourthGen, 2),
GEN5 = fillMovesTable(frame, data.machineMoves.fifthGen, 2),
GEN6 = fillMovesTable(frame, data.machineMoves.sixthGen, 2),
GEN7 = fillMovesTable(frame, data.machineMoves.seventhGen, 2),
GEN8 = fillMovesTable(frame, data.machineMoves.eighthGen, 2)
} }
end

function p.mosse_allevamento(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
return frame:expandTemplate{ title='GenSwitchMin', args = {
IDU = 'mossebreed',
SEZIONE = 'Tramite Allevamento (Mosse Uovo)',
GEN1 = fillMovesTable(frame, data.breedMoves.firstGen, 2),
GEN2 = fillMovesTable(frame, data.breedMoves.secondGen, 2),
GEN3 = fillMovesTable(frame, data.breedMoves.thirdGen, 2),
GEN4 = fillMovesTable(frame, data.breedMoves.fourthGen, 2),
GEN5 = fillMovesTable(frame, data.breedMoves.fifthGen, 2),
GEN6 = fillMovesTable(frame, data.breedMoves.sixthGen, 2),
GEN7 = fillMovesTable(frame, data.breedMoves.seventhGen, 2),
GEN8 = fillMovesTable(frame, data.breedMoves.eighthGen, 2)
} }
end

function p.mosse_tutor(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
return frame:expandTemplate{ title='GenSwitchMin', args = {
IDU = 'mosseteach',
SEZIONE = 'Dall\'Insegnamosse',
GEN1 = fillMovesTable(frame, data.tutorMoves.firstGen, 2),
GEN2 = fillMovesTable(frame, data.tutorMoves.secondGen, 2),
GEN3 = fillMovesTable(frame, data.tutorMoves.thirdGen, 2),
GEN4 = fillMovesTable(frame, data.tutorMoves.fourthGen, 2),
GEN5 = fillMovesTable(frame, data.tutorMoves.fifthGen, 2),
GEN6 = fillMovesTable(frame, data.tutorMoves.sixthGen, 2),
GEN7 = fillMovesTable(frame, data.tutorMoves.seventhGen, 2),
GEN8 = fillMovesTable(frame, data.tutorMoves.eighthGen, 2)
} }
end

function p.go_intro(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
return frame:expandTemplate{ title = 'Pokemon_Evo1', args = {
EVO1_INFO = data.go.name,
EVO1_IMG = '[[File:PKMN_Go_'..string.format("%03d", data.go.id)..'.png]]',
EVO1_TIPI = buildEvoLineTypes(data.go.types.primary, data.go.types.secondary, frame),
} }
end

function buildGoEvoLine(entry, candy, frame)
if entry.stages == 2 then
local method1 = {name = entry.firstEvolutionMethod.candies .. ' caramelle', condition = nil, img = '[[File:PKMN_Go_Candy_'..candy..'.png|50px]]'}
return frame:expandTemplate{ title = 'Pokemon_Evo2', args = {
EVO1_INFO = entry.firstStageName,
EVO1_IMG = '[[File:PKMN_Go_'..entry.firstStageDexNumber..'.png]]',
EVO1_TIPI = buildEvoLineTypes(entry.firstStageTypes.primary, entry.firstStageTypes.secondary, frame),
STRUM_NOME = method1.name,
STRUM_IMG = method1.img,
STRUM_COND = method1.condition,
EVO2_INFO = entry.secondStageName,
EVO2_IMG = '[[File:PKMN_Go_'..entry.secondStageDexNumber..'.png]]',
EVO2_TIPI = buildEvoLineTypes(entry.secondStageTypes.primary, entry.secondStageTypes.secondary, frame),
} }
end
if entry.stages == 3 then
local method1 = {name = entry.firstEvolutionMethod.candies .. ' caramelle', condition = nil, img = '[[File:PKMN_Go_Candy_'..candy..'.png|50px]]'}
local method2 = {name = entry.secondEvolutionMethod.candies .. ' caramelle', condition = nil, img = '[[File:PKMN_Go_Candy_'..candy..'.png|50px]]'}
return frame:expandTemplate{ title = 'Pokemon_Evo3', args = {
EVO1_INFO = entry.firstStageName,
EVO1_IMG = '[[File:PKMN_Go_'..entry.firstStageDexNumber..'.png]]',
EVO1_TIPI = buildEvoLineTypes(entry.firstStageTypes.primary, entry.firstStageTypes.secondary, frame),
STRUM_NOME = method1.name,
STRUM_IMG = method1.img,
STRUM_COND = method1.condition,
EVO2_INFO = entry.secondStageName,
EVO2_IMG = '[[File:PKMN_Go_'..entry.secondStageDexNumber..'.png]]',
EVO2_TIPI = buildEvoLineTypes(entry.secondStageTypes.primary, entry.secondStageTypes.secondary, frame),
STRUM2_NOME = method2.name,
STRUM2_IMG = method2.img,
STRUM2_COND = method2.condition,
EVO3_INFO = entry.thirdStageName,
EVO3_IMG = '[[File:PKMN_Go_'..entry.thirdStageDexNumber..'.png]]',
EVO3_TIPI = buildEvoLineTypes(entry.thirdStageTypes.primary, entry.thirdStageTypes.secondary, frame),
} }
end
end

function p.go_evo(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
local t = {}
if data.go.evolutions ~= nil then
for index, entry in ipairs(data.go.evolutions) do
table.insert(t, buildGoEvoLine(entry, data.go.candyName, frame))
end
end
return table.concat(t,"\n")
end

function selectGoStatColor(stat, arr)
local minimum = math.min(arr.maxCP, arr.atk, arr.def, arr.sta)
local maximum = math.max(arr.maxCP, arr.atk, arr.def, arr.sta)
local statColor = 'verde'
if stat >= 150 then statColor = 'arancio' end
if stat == minimum then statColor = 'blu' end
if stat == maximum then statColor = 'rosso' end
return statColor
end

function p.go_stats(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
local plmaxp = data.go.maxCP * 100 / 5000
local attp = data.go.atk * 100 / 500
local difp = data.go.def * 100 / 500
local stap = data.go.sta * 100 / 500
local arr = {maxCP = data.go.maxCP, atk = data.go.atk, def = data.go.def, sta = data.go.sta}
return frame:expandTemplate{ title='Pokemon_Go_Stats', args = {
PLMax = data.go.maxCP,
PLMaxPerc = nil,
PLMaxColore = selectGoStatColor(arr.maxCP, arr),
Att = data.go.atk,
AttPerc = attp,
AttColore = selectGoStatColor(arr.atk, arr),
RankAtt = data.go.atkRank,
Dif = data.go.def,
DifPerc = difp,
DifColore = selectGoStatColor(arr.def, arr),
RankDif = data.go.defRank,
PS = data.go.sta,
PSPerc = stap,
PSColore = selectGoStatColor(arr.sta, arr),
RankPS = data.go.staRank,
RankTot = data.go.rankTot,
IconeCondizioni = nil,
} }
end

function p.go_info(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
return frame:expandTemplate{ title='Pokemon_Go_Info', args = {
Gen = data.go.generation,
Categoria = data.go.category,
CatturaBase = data.go.baseCatchRate,
FugaBase = data.go.baseFleeRate,
DistanzaCompagno = data.go.kmBuddyDistance,
Deposito = (data.go.isDeployable) and 'Sì' or 'No',
CostoPurificazionePolvere = data.go.purificationCost.stardust,
CostoPurificazioneCandy = data.go.purificationCost.candies,
BonusPolvere = data.go.stardustCaptureReward,
BonusCaramelle = data.go.candyCaptureReward,
Trasferibile = (data.go.isTransferable) and 'Sì' or 'No',
Descrizione = data.go.description,
NomeCandy = data.go.candyName,
PokeNome = data.go.name,
} }
end

function p.go_weakness(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
local deb4 = {}
local deb2 = {}
local res2 = {}
local res4 = {}
if data.go.weaknessTable.quadrupleDamage ~= nil then
for index, entry in ipairs(data.go.weaknessTable.quadrupleDamage) do
table.insert(deb4, frame:expandTemplate{ title='Template:Pokemon_TypeTableBubble', args = {tipo=string.lower(entry)}})
end
end
if data.go.weaknessTable.doubleDamage ~= nil then
for index, entry in ipairs(data.go.weaknessTable.doubleDamage) do
table.insert(deb2, frame:expandTemplate{ title='Template:Pokemon_TypeTableBubble', args = {tipo=string.lower(entry)}})
end
end
if data.go.weaknessTable.halfDamage ~= nil then
for index, entry in ipairs(data.go.weaknessTable.halfDamage) do
table.insert(res2, frame:expandTemplate{ title='Template:Pokemon_TypeTableBubble', args = {tipo=string.lower(entry)}})
end
end
if data.go.weaknessTable.quarterDamage ~= nil then
for index, entry in ipairs(data.go.weaknessTable.quarterDamage) do
table.insert(res4, frame:expandTemplate{ title='Template:Pokemon_TypeTableBubble', args = {tipo=string.lower(entry)}})
end
end
return frame:expandTemplate{ title='Pokemon_Go_Weak', args = {
Debolezze4 = (data.go.weaknessTable.quadrupleDamage ~= nil) and (table.concat(deb4, '')) or nil,
Debolezze2 = (data.go.weaknessTable.doubleDamage ~= nil) and (table.concat(deb2, '')) or nil,
Resistenze2 = (data.go.weaknessTable.halfDamage ~= nil) and (table.concat(res2, '')) or nil,
Resistenze4 = (data.go.weaknessTable.quarterDamage ~= nil) and (table.concat(res4, '')) or nil
} }
end

function fillGoQuickMovesTable(frame, obj)
local t = {}
if (obj ~= nil) then
for index, entry in ipairs(obj) do
table.insert(t, frame:expandTemplate{ title = 'Pokemon_Go_TabellaMosseQuickRiga', args = {
Mossa = entry.name,
Tipo = frame:expandTemplate{ title='Template:Pokemon_TypeTableBubbleEX', args = {tipo=string.lower(entry.type)}},
Potenza = entry.power,
Danno = nil,
DannoMeteo = nil,
FinestraDannoS = entry.damageWindow.start,
FinestraDannoF = entry.damageWindow.finish,
DPS = string.format("%.2f", entry.dps),
Energia = entry.energy,
EPS = string.format("%.2f", entry.eps),
Cooldown = string.format("%.2f", entry.cd/1000),
} } )
end
end
return frame:expandTemplate{ title='Template:Pokemon_Go_TabellaMosseQuick', args = {RIGHE=table.concat(t,"\n")} }
end

function fillGoChargedMovesTable(frame, obj)
local t = {}
if (obj ~= nil) then
for index, entry in ipairs(obj) do
local bars = {}
for cnt = 1, entry.chargeBars do
table.insert(bars, frame:expandTemplate{ title = 'Pokemon_Go_TabellaMosseChargedBars', args = { } } )
end
table.insert(t, frame:expandTemplate{ title = 'Pokemon_Go_TabellaMosseChargedRiga', args = {
Mossa = entry.name,
Tipo = frame:expandTemplate{ title='Template:Pokemon_TypeTableBubbleEX', args = {tipo=string.lower(entry.type)}},
BarreCaricamento = table.concat(bars,"\n"),
Potenza = entry.power,
Danno = nil,
DannoMeteo = nil,
FinestraDannoS = entry.damageWindow.start,
FinestraDannoF = entry.damageWindow.finish,
DPS = string.format("%.2f", entry.dps),
Energia = entry.energy,
EPS = string.format("%.2f", entry.eps),
DPEDPS = nil,
Cooldown = string.format("%.2f", entry.cd/1000),
} } )
end
end
return frame:expandTemplate{ title='Template:Pokemon_Go_TabellaMosseCharged', args = {RIGHE=table.concat(t,"\n")} }
end

function p.go_quickmoves(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
return fillGoQuickMovesTable(frame, data.go.quickMoves)
end

function p.go_quicklegacymoves(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
return fillGoQuickMovesTable(frame, data.go.quickLegacyMoves)
end

function p.go_chargedmoves(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
return fillGoChargedMovesTable(frame, data.go.chargedMoves)
end

function p.go_chargedlegacymoves(frame)
local modname = 'Module:PKMN_' .. frame.args['dex']
local data = mw.loadData(modname)
return fillGoChargedMovesTable(frame, data.go.chargedLegacyMoves)
end

return p

Menu di navigazione