Module:PokemonForms: Difference between revisions

From Pokemon Revolution Online Wiki
Jump to navigation Jump to search
Cae (talk | contribs)
No edit summary
Cae (talk | contribs)
No edit summary
 
Line 83: Line 83:
     ['Terapagos-Terastal'] = 'Terapagos-Terestal',
     ['Terapagos-Terastal'] = 'Terapagos-Terestal',
}
}
-- Shared by Module:Pokemon and Module:Learnsets so both resolve a form's raw-list
-- (PokemonRawList) name identically -- previously each kept its own copy of this
-- logic, which is exactly the kind of duplication that quietly drifts out of sync.
function p.formStem(name)
    for _, form in ipairs(p.FORM_SUFFIXES) do
        local head = form.label .. ' '
        if mw.ustring.sub(name, 1, mw.ustring.len(head)) == head then
            return mw.ustring.sub(name, mw.ustring.len(head) + 1)
        end
    end
    for _, suffix in ipairs(p.STRIP_SUFFIXES) do
        for _, sep in ipairs({ '-', ' ' }) do
            local tail = sep .. suffix
            if mw.ustring.sub(name, -mw.ustring.len(tail)) == tail then
                return mw.ustring.sub(name, 1, -mw.ustring.len(tail) - 1)
            end
        end
    end
    return name
end
function p.rawListFormName(form, stem)
    if form.rawList == 'suffix' then
        return stem .. '-' .. form.suffix
    elseif form.rawList == 'prefix-hyphen' then
        return form.label .. '-' .. stem
    elseif form.rawList == 'suffix-label' then
        return stem .. '-' .. form.label
    elseif form.rawList == 'suffix-space' then
        return stem .. ' ' .. form.label
    end
    return form.label .. ' ' .. stem
end


p.MOB_PREFIXES = { 'Baby', 'Crystal', 'Shadow' }
p.MOB_PREFIXES = { 'Baby', 'Crystal', 'Shadow' }

Latest revision as of 12:36, 9 August 2026

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

local p = {}

p.FORM_SUFFIXES = {
    { suffix = 'Alolan', label = 'Alolan', rawList = 'prefix' },
    { suffix = 'Galar', label = 'Galarian', rawList = 'prefix' },
    { suffix = 'Hisui', label = 'Hisuian', rawList = 'prefix' },
    { suffix = 'Paldea', label = 'Paldean', rawList = 'prefix' },
    { suffix = 'Sandy', label = 'Sandy', rawList = 'suffix' },
    { suffix = 'Trash', label = 'Trash', rawList = 'suffix' },
    { suffix = 'Sky', label = 'Sky', rawList = 'suffix' },
    { suffix = 'Fan', label = 'Fan', rawList = 'suffix' },
    { suffix = 'Frost', label = 'Frost', rawList = 'suffix' },
    { suffix = 'Heat', label = 'Heat', rawList = 'suffix' },
    { suffix = 'Mow', label = 'Mow', rawList = 'suffix' },
    { suffix = 'Wash', label = 'Wash', rawList = 'suffix' },
    { suffix = 'Ash', label = 'Ash', learnsetStyle = 'prefix-space', rawList = 'prefix-hyphen' },
    { suffix = 'Bloodmoon', label = 'Bloodmoon', rawList = 'suffix' },
    { suffix = 'Low-Key', label = 'Low Key', rawList = 'suffix-label' },
    { suffix = 'F', label = 'Female', rawList = 'suffix-space', baseLabel = 'Male' },
    { suffix = 'Blue-Striped', label = 'Blue-Striped', rawList = 'suffix-label' },
    { suffix = 'White-Striped', label = 'White-Striped', rawList = 'suffix-label' },
    { suffix = 'Rainy', label = 'Rainy', rawList = 'suffix-label' },
    { suffix = 'Snowy', label = 'Snowy', rawList = 'suffix-label' },
    { suffix = 'Sunny', label = 'Sunny', rawList = 'suffix-label' },
    { suffix = 'Sunshine', label = 'Sunshine', rawList = 'suffix-label' },
    { suffix = 'Attack', label = 'Attack', rawList = 'suffix-label' },
    { suffix = 'Defense', label = 'Defense', rawList = 'suffix-label' },
    { suffix = 'Speed', label = 'Speed', rawList = 'suffix-label' },
    { suffix = 'Unbound', label = 'Unbound', rawList = 'suffix-label' },
    { suffix = 'Black', label = 'Black', rawList = 'suffix-label' },
    { suffix = 'White', label = 'White', rawList = 'suffix-label' },
    { suffix = 'Dusk', label = 'Dusk', rawList = 'suffix-label' },
    { suffix = 'Midnight', label = 'Midnight', rawList = 'suffix-label' },
    { suffix = 'Pirouette', label = 'Pirouette', rawList = 'suffix-label' },
    { suffix = 'Yellow', label = 'Yellow', rawList = 'suffix-label' },
    { suffix = 'School', label = 'School', rawList = 'suffix-label' },
    { suffix = 'Crowned', label = 'Crowned', rawList = 'suffix-label' },
    { suffix = 'Noice-Face', label = 'Noice Face', rawList = 'suffix-label' },
    { suffix = 'Dusk-Mane', label = 'Dusk Mane', rawList = 'prefix' },
    { suffix = 'Dawn-Wings', label = 'Dawn Wings', rawList = 'prefix' },
}

p.STRIP_SUFFIXES = {
    'Alolan', 'Galar', 'Hisui', 'Paldea', 'Sandy', 'Trash', 'Plant', 'Amped', 'Male',
    'Ice Face', 'Noice Face', 'Midday', 'Solo',
}

p.RAW_LIST_ALIASES = {
    ['Nidoran M'] = 'Nidoran Male',
    ['Nidoran F'] = 'Nidoran Female',
    ['Farfetchd'] = "Farfetch'd",
    ['Sirfetchd'] = "Sirfetch'd",
    ['Ho-oh'] = 'Ho-Oh',
    ['Porygon-z'] = 'Porygon-Z',
    ['Eiscue'] = 'Eiscue-Ice Face',
    ['Indeedee'] = 'Indeedee Male',
    ['Meowstic'] = 'Meowstic Male',
    ['Basculegion'] = 'Basculegion-Male',
    ['Oinkologne'] = 'Oinkologne-Male',
    ['Calyrex-Ice-Rider'] = 'Calyrex-Ice Rider',
    ['Calyrex-Shadow-Rider'] = 'Calyrex-Shadow Rider',
    ['Necrozma-Dusk-Mane'] = 'Dusk Mane Necrozma',
    ['Necrozma-Dawn-Wings'] = 'Dawn Wings Necrozma',
    ['Ogerpon'] = 'Ogerpon-Teal Mask',
    ['Ogerpon-Wellspring'] = 'Ogerpon-Wellspring Mask',
    ['Ogerpon-Hearthflame'] = 'Ogerpon-Hearthflame Mask',
    ['Ogerpon-Cornerstone'] = 'Ogerpon-Cornerstone Mask',
    ['Ogerpon-Wellspring-Tera'] = 'Ogerpon-Wellspring Mask',
    ['Ogerpon-Hearthflame-Tera'] = 'Ogerpon-Hearthflame Mask',
    ['Ogerpon-Cornerstone-Tera'] = 'Ogerpon-Cornerstone Mask',
    ['Oricorio'] = 'Oricorio Baile',
    ['Oricorio-Pom-Pom'] = 'Oricorio Pom-Pom',
    ['Oricorio-Pau'] = "Oricorio Pa'u",
    ['Tauros-Paldea-Combat'] = 'Paldean Tauros-Combat',
    ['Tauros-Paldea-Blaze'] = 'Paldean Tauros-Blaze',
    ['Tauros-Paldea-Aqua'] = 'Paldean Tauros-Aqua',
    ['Toxtricity'] = 'Toxtricity-Amped',
    ['Urshifu'] = 'Urshifu-Single Strike',
    ['Urshifu-Rapid-Strike'] = 'Urshifu-Rapid Strike',
    ['Wishiwashi'] = 'Wishiwashi Solo',
    ['Wormadam'] = 'Wormadam-Plant',
    ['Lycanroc'] = 'Lycanroc-Midday',
    ['Terapagos-Terastal'] = 'Terapagos-Terestal',
}

-- Shared by Module:Pokemon and Module:Learnsets so both resolve a form's raw-list
-- (PokemonRawList) name identically -- previously each kept its own copy of this
-- logic, which is exactly the kind of duplication that quietly drifts out of sync.
function p.formStem(name)
    for _, form in ipairs(p.FORM_SUFFIXES) do
        local head = form.label .. ' '
        if mw.ustring.sub(name, 1, mw.ustring.len(head)) == head then
            return mw.ustring.sub(name, mw.ustring.len(head) + 1)
        end
    end
    for _, suffix in ipairs(p.STRIP_SUFFIXES) do
        for _, sep in ipairs({ '-', ' ' }) do
            local tail = sep .. suffix
            if mw.ustring.sub(name, -mw.ustring.len(tail)) == tail then
                return mw.ustring.sub(name, 1, -mw.ustring.len(tail) - 1)
            end
        end
    end
    return name
end

function p.rawListFormName(form, stem)
    if form.rawList == 'suffix' then
        return stem .. '-' .. form.suffix
    elseif form.rawList == 'prefix-hyphen' then
        return form.label .. '-' .. stem
    elseif form.rawList == 'suffix-label' then
        return stem .. '-' .. form.label
    elseif form.rawList == 'suffix-space' then
        return stem .. ' ' .. form.label
    end
    return form.label .. ' ' .. stem
end

p.MOB_PREFIXES = { 'Baby', 'Crystal', 'Shadow' }

p.MEGA_VARIANTS = { '', ' X', ' Y' }

p.LEARNSET_ALIASES = {}
for learnsetName, rawListName in pairs(p.RAW_LIST_ALIASES) do
    p.LEARNSET_ALIASES[rawListName] = learnsetName
end

return p