Module:PC Prose
From Nookipedia, the Animal Crossing wiki
Documentation for this module may be created at Module:PC Prose/doc
local p = {}
local cargo = mw.ext.cargo
local materialT = require("Module:Materials")
local currencyT = require("Module:Currency")
local time = require("Module:Time")
function split(str, pattern)
local out = {}
local i = 1
local split_start, split_end = string.find(str, pattern, i)
while split_start do
out[#out+1] = string.sub(str, i, split_start - 1)
i = split_end + 1
split_start, split_end = string.find(str, pattern, i)
end
out[#out+1] = string.sub(str, i)
return out
end
function isEmpty(s)
return s == nil or s == ''
end
function search(category, substrings)
for k,v in pairs(substrings) do
if string.find(category, v) then
return true
end
end
return false
end
function formatAvailability(availability)
if availability == 'Crafting' then
return 'crafting'
else
return availability
end
end
function formatClothingCategory(clothing)
if clothing == 'Tops' then
return '[[Clothing#Tops|top]]'
elseif clothing == 'Back Accessories' or clothing == 'Back accessories' then
return '[[Clothing#Accessories and headwear|back accessory]]'
elseif clothing == 'Face Accessories' then
return '[[Clothing#Accessories and headwear|face accessory]]'
elseif clothing == 'Handheld Accessories' then
return '[[Handheld item|handheld accessory]]'
elseif clothing == 'Bottoms' then
return '[[Clothing#Bottoms|bottom]]'
elseif clothing == 'Hats' then
return '[[Clothing#Accessories and headwear|headwear]]'
elseif clothing == 'Shoes' then
return '[[Clothing#Socks and shoes|shoe]]'
elseif clothing == 'Socks' then
return '[[Clothing#Socks and shoes|sock]]'
elseif clothing == 'Outfit' then
return '[[Clothing#Dress-up|outfit]]'
elseif clothing == 'Dress' then
return '[[Clothing#Dress-up|dress]]'
else
return clothing
end
end
function formatCatalogCategory(catalog, event)
if catalog == 'Knitted' and event == 'Fishing Tourney (Knitted)' then
return 'Knitted Set (Fishing Tourney)'
elseif catalog == 'Dreamy Pastels' and not event == "Isabelle's Pastel Party" then
return 'Dreamy Pastels Set (Fortune Cookie)'
else
return catalog .. ' Set'
end
end
function p.outputFurnitureProse (frame)
local prose = 'The ' .. frame:preprocess( "'''" .. frame.args['name'] .. "'''" )
if not isEmpty(frame.args['engb_name']) and not (frame.args['engb_name'] == frame.args['name']) then
prose = prose .. frame:preprocess(" (known as '''" .. frame.args['engb_name'] .. "''' in European English)")
end
prose = prose .. ' is a [[Theme (Pocket Camp)#' .. frame.args['theme'] .. '|' .. frame.args['theme']:lower() .. ']]-themed ' .. frame.args['type']:lower() .. ' item in ' .. frame:preprocess( '{{PC}}' )
if not isEmpty(frame.args['version-added']) then
prose = prose .. ' introduced in version ' .. frame.args['version-added'] .. '.'
else
prose = prose .. '.'
end
prose = prose .. ' It is '
if not isEmpty(frame.args['catalog-category']) then
local stringsToSearchFor = {'Bed', 'Rug', 'Seat', 'Chair', 'Walls/Floor', 'Outdoor', 'Lamp', 'Seasonal Event', 'Wallpaper', 'Flooring', 'Plant'}
if search(frame.args['catalog-category'], stringsToSearchFor) == true then
prose = prose .. '.'
else
prose = prose .. ' part of the ' .. frame:preprocess( '[[' .. formatCatalogCategory(frame.args['catalog-category'], frame.args['event']) .. ']].' )
end
else
prose = prose .. '.'
end
if not isEmpty(frame.args['unlock']) then
prose = prose .. ' The ' .. frame.args['name'] .. ' becomes available after '
local unlockStringTable = split( frame.args['unlock'] , ' ' )
if string.find(frame.args['unlock'], 'Unlocked at level ') then
prose = prose .. 'the player reaches level ' .. unlockStringTable[4] .. '.'
elseif string.find(frame.args['unlock'], 'Reach level ') then
prose = prose .. 'the player reaches level ' .. unlockStringTable[3] .. ' with ' .. frame:preprocess( '[[' .. unlockStringTable[5] .. ']]' ) .. '.'
end
end
prose = prose .. '\n\n'
if not isEmpty(frame.args['event']) then
prose = prose .. 'The ' .. frame.args['name'] .. ' was made available during ' .. frame:preprocess( '[[' .. frame.args['event'] .. ']]' )
if not isEmpty(frame.args['event2']) then
prose = prose .. ' and ' .. frame:preprocess( '[[' .. frame.args['event2'] .. ']]' )
end
prose = prose .. ', obtainable from '
else
prose = prose .. 'The ' .. frame.args['name'] .. ' can be obtained from '
end
if string.find(frame.args['availability'],'Cookie') then
prose = prose .. frame:preprocess( '[[File:' .. frame.args['availability'] .. ' PC Icon.png|20px|link=|alt=]] ' )
end
if frame.args['availability'] == 'Mailbox' then
prose = prose .. "the [[mailbox]]"
else
prose = prose .. '[[' .. frame.args['availability'] .. '|' .. formatAvailability(frame.args['availability']) .. ']]'
end
if frame.args['availability'] == 'Lloid' then
prose = prose .. ', which can be obtained by trading ' .. frame.args['trade-amount'] .. '[[File:' .. frame.args['trade-flower'] .. ' PC Icon.png|20px|link=|alt=]] ' .. frame.args['trade-flower']
end
if not isEmpty(frame.args['availability-note']) then
if string.find(frame.args['availability'],'Cookie') then
prose = prose .. ', with a ' .. frame.args['availability-note'] .. ' of appearing after eating the cookie'
elseif frame.args['availability-note'] == 'By completing tasks' then
prose = prose .. ''
elseif frame.args['availability'] == 'Lloid' then
prose = prose .. ''
elseif frame.args['availability-note'] == 'Randomly reaching a total size goal' then
prose = prose .. ''
elseif frame.args['availability-note'] == 'Completing an event challenge or randomly reaching a total size goal' then
prose = prose .. ''
elseif frame.args['availability-note'] == 'Completing an event challenge' then
prose = prose .. ''
else
prose = prose .. ' (' .. frame.args['availability-note'] .. ')'
end
end
if frame.args['availability'] == "Crafting" then
prose = prose .. ', which costs'
end
local crafting = ''
if not isEmpty(frame.args['crafting-price']) then
if frame.args['crafting-currency'] == "Leaf Tickets" then
crafting = crafting .. ' ' .. currencyT.outputCurrency("Leaf Tickets",frame.args['crafting-price'])
crafting = crafting .. ', and is crafted instantly after payment'
end
if frame.args['crafting-currency'] == "Bells" then
crafting = crafting .. ' ' .. currencyT.outputCurrency("Bells",frame.args['crafting-price'])
crafting = crafting .. ', takes around ' .. time.timeFormat(frame.args['crafting-time']) .. ' to make'
end
if not isEmpty(frame.args['crafting-mat1']) then
crafting = crafting .. ', and requires '
crafting = crafting .. materialT.outputMaterialPC(frame.args['crafting-mat1'],frame.args['crafting-mat1-num'],{nb="yes"})
end
if not isEmpty(frame.args['crafting-mat2']) then
crafting = crafting .. ', '
if isEmpty(frame.args['crafting-mat3']) then
crafting = crafting .. 'and '
end
crafting = crafting .. materialT.outputMaterialPC(frame.args['crafting-mat2'],frame.args['crafting-mat2-num'],{nb="yes"})
end
if not isEmpty(frame.args['crafting-mat3']) then
crafting = crafting .. ', '
if isEmpty(frame.args['crafting-mat4']) then
crafting = crafting .. 'and '
end
crafting = crafting .. materialT.outputMaterialPC(frame.args['crafting-mat3'],frame.args['crafting-mat3-num'],{nb="yes"})
end
if not isEmpty(frame.args['crafting-mat4']) then
crafting = crafting .. ', '
if isEmpty(frame.args['crafting-mat5']) then
crafting = crafting .. 'and '
end
crafting = crafting .. materialT.outputMaterialPC(frame.args['crafting-mat4'],frame.args['crafting-mat4-num'],{nb="yes"})
end
if not isEmpty(frame.args['crafting-mat5']) then
crafting = crafting .. ', '
if isEmpty(frame.args['crafting-mat6']) then
crafting = crafting .. 'and '
end
crafting = crafting .. materialT.outputMaterialPC(frame.args['crafting-mat5'],frame.args['crafting-mat5-num'],{nb="yes"})
end
if not isEmpty(frame.args['crafting-mat6']) then
crafting = crafting .. ', and ' .. materialT.outputMaterialPC(frame.args['crafting-mat6'],frame.args['crafting-mat6-num'],{nb="yes"})
end
if not isEmpty(frame.args['availability2']) then
prose = prose .. ''
else
prose = prose .. crafting
end
end
if not isEmpty(frame.args['availability2']) then
if frame.args['availability'] == "Crafting" then
prose = prose .. crafting .. ', '
end
prose = prose .. ' or from ' .. frame:preprocess( '[[' .. frame.args['availability2'] .. '|' .. formatAvailability(frame.args['availability2']) .. ']]' )
if frame.args['availability2'] == 'Lloid' then
prose = prose .. ', which can be obtained by trading ' .. frame.args['trade-amount'] .. frame:preprocess( '[[File:' .. frame.args['trade-flower'] .. ' PC Icon.png|20px|link=|alt=]] ' ) .. frame.args['trade-flower']
end
if not isEmpty(frame.args['availability2-note']) then
if frame.args['availability2-note'] == 'By ompleting tasks' then
prose = prose .. ''
elseif frame.args['availability2'] == 'Lloid' then
prose = prose .. ''
elseif frame.args['availability2-note'] == 'Randomly reaching a total size goal' then
prose = prose .. ''
elseif frame.args['availability2-note'] == 'Completing an event challenge or randomly reaching a total size goal' then
prose = prose .. ''
elseif frame.args['availability2-note'] == 'Completing an event challenge' then
prose = prose .. ''
else
prose = prose .. ' (' .. frame.args['availability2-note'] .. ')'
end
end
if frame.args['availability2'] == "Crafting" then
prose = prose .. ', which costs'
end
end
if frame.args['availability2'] == "Crafting" then
prose = prose .. ', which costs' .. crafting
else
prose = prose .. '.'
end
if not isEmpty(frame.args['reissue-crafting-price']) then
prose = prose .. ' The item has also been reissued, with the reissue costing '
if frame.args['reissue-crafting-currency'] == "Leaf Tickets" then
prose = prose .. currencyT.outputCurrency("Leaf Tickets",frame.args['reissue-crafting-price'])
end
if frame.args['reissue-crafting-currency'] == "Bells" then
prose = prose .. currencyT.outputCurrency("Bells",frame.args['reissue-crafting-price'])
prose = prose .. ', with ' .. time.timeFormat(frame.args['reissue-crafting-time']) .. ' to create'
end
if not isEmpty(frame.args['reissue-mat1']) then
prose = prose .. ', and requiring '
prose = prose .. materialT.outputMaterialPC(frame.args['reissue-mat1'],frame.args['reissue-mat1-num'],{nb="yes"})
end
if not isEmpty(frame.args['reissue-mat2']) then
prose = prose .. ', '
if isEmpty(frame.args['reissue-mat3']) then
prose = prose .. 'and '
end
prose = prose .. materialT.outputMaterialPC(frame.args['reissue-mat2'],frame.args['reissue-mat2-num'],{nb="yes"})
end
if not isEmpty(frame.args['reissue-mat3']) then
prose = prose .. ', '
if isEmpty(frame.args['reissue-mat4']) then
prose = prose .. 'and '
end
prose = prose .. materialT.outputMaterialPC(frame.args['reissue-mat3'],frame.args['reissue-mat3-num'],{nb="yes"})
end
if not isEmpty(frame.args['reissue-mat4']) then
prose = prose .. ', '
if isEmpty(frame.args['reissue-mat5']) then
prose = prose .. 'and '
end
prose = prose .. materialT.outputMaterialPC(frame.args['reissue-mat4'],frame.args['reissue-mat4-num'],{nb="yes"})
end
if not isEmpty(frame.args['reissue-mat5']) then
prose = prose .. ', '
if isEmpty(frame.args['reissue-mat6']) then
prose = prose .. 'and '
end
prose = prose .. materialT.outputMaterialPC(frame.args['reissue-mat5'],frame.args['reissue-mat5-num'],{nb="yes"})
end
if not isEmpty(frame.args['reissue-mat6']) then
prose = prose .. ', and ' .. materialT.outputMaterialPC(frame.args['reissue-mat6'],frame.args['reissue-mat6-num'],{nb="yes"})
end
prose = prose .. '.'
end
if frame.args['memory'] == "Yes" or frame.args['memory'] == "yes" then
-- Cargo query for pc_scrapbook_memory
local tables = 'pc_scrapbook_memory'
local fields = "pc_scrapbook_memory.en_name=name"
local args = {
where = "pc_scrapbook_memory.item = \"" .. frame.args['name']:gsub("'","\'") .. "\"",
limit = 300,
default = ''
}
local result = cargo.query( tables, fields, args )
prose = prose .. " When obtained, the " .. frame.args['name'] .. " unlocks the [[Scrapbook Memory|memory]] \"[[" .. result[1].name .. "]]\"."
end
return prose
end
--[[
Start clothing prose
]]--
function p.outputClothingProse (frame)
local prose = 'The ' .. frame:preprocess( "'''" .. frame.args['name'] .. "'''" )
if not isEmpty(frame.args['engb_name']) and not (frame.args['engb_name'] == frame.args['name']) then
prose = prose .. frame:preprocess(" (known as '''" .. frame.args['engb_name'] .. "''' in European English)")
end
prose = prose .. ' is a [[Theme (Pocket Camp)#' .. frame.args['theme'] .. '|' .. frame.args['theme']:lower() .. ']]-themed ' .. formatClothingCategory(frame.args['type']) .. ' item in ' .. frame:preprocess( '{{PC}}' )
if not isEmpty(frame.args['version-added']) then
prose = prose .. ' introduced in version ' .. frame.args['version-added'] .. '.'
else
prose = prose .. '.'
end
if not isEmpty(frame.args['catalog-category']) then
local stringsToSearchFor = {'Pants', 'Tops', 'Shoes', 'Accessories', 'Boots', 'Caps', 'Coats', 'Dresses', 'Glasses', 'Hats', 'Helmets', 'Pants', 'Shoes', 'Skirts', 'Sneakers', 'Socks', 'Tops', 'Wigs'}
if search(frame.args['catalog-category'], stringsToSearchFor) == true then
prose = prose .. ''
else
prose = prose .. 'It is part of the ' .. frame:preprocess( '[[' .. formatCatalogCategory(frame.args['catalog-category'], frame.args['event']) .. ']].' )
end
end
if not isEmpty(frame.args['unlock']) then
prose = prose .. 'The ' .. frame.args['name'] .. ' becomes available after '
local unlockStringTable = split( frame.args['unlock'] , ' ' )
if string.find(frame.args['unlock'], 'Unlocked at level ') then
prose = prose .. 'the player reaches level ' .. unlockStringTable[4] .. '.'
elseif string.find(frame.args['unlock'], 'Reach level ') then
prose = prose .. 'the player reaches level ' .. unlockStringTable[3] .. ' with ' .. frame:preprocess( '[[' .. unlockStringTable[5] .. ']]' ) .. '.'
end
end
prose = prose .. '\n\n'
if not isEmpty(frame.args['event']) then
prose = prose .. 'The ' .. frame.args['name'] .. ' was made available during ' .. frame:preprocess( '[[' .. frame.args['event'] .. ']]' )
if not isEmpty(frame.args['event2']) then
prose = prose .. ' and ' .. frame:preprocess( '[[' .. frame.args['event2'] .. ']]' )
end
prose = prose .. ', obtainable from '
else
prose = prose .. 'The ' .. frame.args['name'] .. ' can be obtained from '
end
if string.find(frame.args['availability'],'Cookie') then
prose = prose .. frame:preprocess( '[[File:' .. frame.args['availability'] .. ' PC Icon.png|20px|link=|alt=]] ' )
end
if frame.args['availability'] == 'Mailbox' then
prose = prose .. "the [[mailbox]]"
else
prose = prose .. '[[' .. frame.args['availability'] .. '|' .. formatAvailability(frame.args['availability']) .. ']]'
end
if frame.args['availability'] == 'Lloid' then
prose = prose .. ', which can be obtained by trading ' .. frame.args['trade-amount'] .. '[[File:' .. frame.args['trade-flower'] .. ' PC Icon.png|20px|link=|alt=]] ' .. frame.args['trade-flower']
end
if not isEmpty(frame.args['availability-note']) then
if string.find(frame.args['availability'],'Cookie') then
prose = prose .. ', with a ' .. frame.args['availability-note'] .. ' of appearing after eating the cookie'
elseif frame.args['availability-note'] == 'By completing tasks' then
prose = prose .. ''
elseif frame.args['availability'] == 'Lloid' then
prose = prose .. ''
elseif frame.args['availability-note'] == 'Randomly reaching a total size goal' then
prose = prose .. ''
elseif frame.args['availability-note'] == 'Completing an event challenge or randomly reaching a total size goal' then
prose = prose .. ''
elseif frame.args['availability-note'] == 'Completing an event challenge' then
prose = prose .. ''
else
prose = prose .. ' (' .. frame.args['availability-note'] .. ')'
end
end
if frame.args['availability'] == "Crafting" then
prose = prose .. ', which costs'
end
local crafting = ''
if not isEmpty(frame.args['crafting-price']) then
if frame.args['crafting-currency'] == "Leaf Tickets" then
crafting = crafting .. ' ' .. currencyT.outputCurrency("Leaf Tickets",frame.args['crafting-price'])
crafting = crafting .. ', and is crafted instantly after payment'
end
if frame.args['crafting-currency'] == "Bells" then
crafting = crafting .. ' ' .. currencyT.outputCurrency("Bells",frame.args['crafting-price'])
crafting = crafting .. ', takes around ' .. time.timeFormat(frame.args['crafting-time']) .. ' to make'
end
if not isEmpty(frame.args['crafting-mat1']) then
crafting = crafting .. ', and requires '
crafting = crafting .. materialT.outputMaterialPC(frame.args['crafting-mat1'],frame.args['crafting-mat1-num'],{nb="yes"})
end
if not isEmpty(frame.args['crafting-mat2']) then
crafting = crafting .. ', '
if isEmpty(frame.args['crafting-mat3']) then
crafting = crafting .. 'and '
end
crafting = crafting .. materialT.outputMaterialPC(frame.args['crafting-mat2'],frame.args['crafting-mat2-num'],{nb="yes"})
end
if not isEmpty(frame.args['crafting-mat3']) then
crafting = crafting .. ', '
if isEmpty(frame.args['crafting-mat4']) then
crafting = crafting .. 'and '
end
crafting = crafting .. materialT.outputMaterialPC(frame.args['crafting-mat3'],frame.args['crafting-mat3-num'],{nb="yes"})
end
if not isEmpty(frame.args['crafting-mat4']) then
crafting = crafting .. ', '
if isEmpty(frame.args['crafting-mat5']) then
crafting = crafting .. 'and '
end
crafting = crafting .. materialT.outputMaterialPC(frame.args['crafting-mat4'],frame.args['crafting-mat4-num'],{nb="yes"})
end
if not isEmpty(frame.args['crafting-mat5']) then
crafting = crafting .. ', '
if isEmpty(frame.args['crafting-mat6']) then
crafting = crafting .. 'and '
end
crafting = crafting .. materialT.outputMaterialPC(frame.args['crafting-mat5'],frame.args['crafting-mat5-num'],{nb="yes"})
end
if not isEmpty(frame.args['crafting-mat6']) then
crafting = crafting .. ', and ' .. materialT.outputMaterialPC(frame.args['crafting-mat6'],frame.args['crafting-mat6-num'],{nb="yes"})
end
if not isEmpty(frame.args['availability2']) then
prose = prose .. ''
else
prose = prose .. crafting
end
end
if not isEmpty(frame.args['availability2']) then
if frame.args['availability'] == "Crafting" then
prose = prose .. crafting .. ', '
end
prose = prose .. ' or from ' .. frame:preprocess( '[[' .. frame.args['availability2'] .. '|' .. formatAvailability(frame.args['availability2']) .. ']]' )
if frame.args['availability2'] == 'Lloid' then
prose = prose .. ', which can be obtained by trading ' .. frame.args['trade-amount'] .. frame:preprocess( '[[File:' .. frame.args['trade-flower'] .. ' PC Icon.png|20px|link=|alt=]] ' ) .. frame.args['trade-flower']
end
if not isEmpty(frame.args['availability2-note']) then
if frame.args['availability2-note'] == 'By completing tasks' then
prose = prose .. ''
elseif frame.args['availability2'] == 'Lloid' then
prose = prose .. ''
elseif frame.args['availability2-note'] == 'Randomly reaching a total size goal' then
prose = prose .. ''
elseif frame.args['availability2-note'] == 'Completing an event challenge or randomly reaching a total size goal' then
prose = prose .. ''
elseif frame.args['availability2-note'] == 'Completing an event challenge' then
prose = prose .. ''
else
prose = prose .. ' (' .. frame.args['availability2-note'] .. ')'
end
end
if frame.args['availability2'] == "Crafting" then
prose = prose .. ', which costs'
end
end
if frame.args['availability2'] == "Crafting" then
prose = prose .. ', which costs' .. crafting
else
prose = prose .. '.'
end
if not isEmpty(frame.args['reissue-crafting-price']) then
prose = prose .. ' The item has also been reissued, with the reissue costing '
if frame.args['reissue-crafting-currency'] == "Leaf Tickets" then
prose = prose .. currencyT.outputCurrency("Leaf Tickets",frame.args['reissue-crafting-price'])
end
if frame.args['reissue-crafting-currency'] == "Bells" then
prose = prose .. currencyT.outputCurrency("Bells",frame.args['reissue-crafting-price'])
prose = prose .. ', with ' .. time.timeFormat(frame.args['reissue-crafting-time']) .. ' to create'
end
if not isEmpty(frame.args['reissue-mat1']) then
prose = prose .. ', and requiring '
prose = prose .. materialT.outputMaterialPC(frame.args['reissue-mat1'],frame.args['reissue-mat1-num'],{nb="yes"})
end
if not isEmpty(frame.args['reissue-mat2']) then
prose = prose .. ', '
if isEmpty(frame.args['reissue-mat3']) then
prose = prose .. 'and '
end
prose = prose .. materialT.outputMaterialPC(frame.args['reissue-mat2'],frame.args['reissue-mat2-num'],{nb="yes"})
end
if not isEmpty(frame.args['reissue-mat3']) then
prose = prose .. ', '
if isEmpty(frame.args['reissue-mat4']) then
prose = prose .. 'and '
end
prose = prose .. materialT.outputMaterialPC(frame.args['reissue-mat3'],frame.args['reissue-mat3-num'],{nb="yes"})
end
if not isEmpty(frame.args['reissue-mat4']) then
prose = prose .. ', '
if isEmpty(frame.args['reissue-mat5']) then
prose = prose .. 'and '
end
prose = prose .. materialT.outputMaterialPC(frame.args['reissue-mat4'],frame.args['reissue-mat4-num'],{nb="yes"})
end
if not isEmpty(frame.args['reissue-mat5']) then
prose = prose .. ', '
if isEmpty(frame.args['reissue-mat6']) then
prose = prose .. 'and '
end
prose = prose .. materialT.outputMaterialPC(frame.args['reissue-mat5'],frame.args['reissue-mat5-num'],{nb="yes"})
end
if not isEmpty(frame.args['reissue-mat6']) then
prose = prose .. ', and ' .. materialT.outputMaterialPC(frame.args['reissue-mat6'],frame.args['reissue-mat6-num'],{nb="yes"})
end
prose = prose .. '.'
end
return prose
end
return p