Module:PC Prose

local p = {}

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 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 'top' elseif clothing == 'Back Accessories' or clothing == 'Back accessories' then return 'back accessory' elseif clothing == 'Face Accessories' then return 'face accessory' elseif clothing == 'Handheld Accessories' then return 'handheld accessory' elseif clothing == 'Bottoms' then return 'bottom' elseif clothing == 'Hats' then return 'headwear' elseif clothing == 'Shoes' then return 'shoe' elseif clothing == 'Socks' then return 'sock' elseif clothing == 'Outfit' then return 'outfit' elseif clothing == 'Dress' then return '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)' elseif string.find(catalog,'Series') then return catalog .. ' Series' else return catalog .. ' Set' end end

function p.outputFurnitureProse (frame) local function isEmpty(s) return s == nil or s == '' end local prose = 'The ' .. frame:preprocess( "" .. frame.args['name'] .. "" ) if not isEmpty(frame.args['engb_name']) then prose = prose .. frame:preprocess(" (known as '''" .. frame.args['engb_name'] .. "''' in European English)") end prose = prose .. ' is a ' .. frame.args['theme']:lower .. '-themed furniture item in ' .. frame:preprocess( '' ) 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 a type of ' .. frame.args['type']:lower 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 .. 'It 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 .. 'It can be obtained from ' end if string.find(frame.args['availability'],'Cookie') then prose = prose .. frame:preprocess( ' ' ) end prose = prose .. frame:preprocess(  .. formatAvailability(frame.args['availability']) ..  ) if frame.args['availability'] == 'Lloid' then prose = prose .. ', which can be obtained by trading ' .. frame.args['trade-amount'] .. frame:preprocess( ' ' ) .. 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'] == 'Completing tasks' then prose = prose .. ''		elseif frame.args['availability'] == 'Lloid' then prose = prose .. ''		elseif frame.args['availability'] == 'Randomly reaching a total size goal' 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 .. frame:preprocess( ' Leaf Tickets ' .. frame.args['crafting-price'] .. '') crafting = crafting .. ', and is crafted instantly after payment' end if frame.args['crafting-currency'] == "Bells" then crafting = crafting .. frame:preprocess( ' Bells ' .. frame.args['crafting-price'] .. '') crafting = crafting .. ', takes around ' .. frame:preprocess( 'HMS ' .. frame.args['crafting-time'] .. ' to make') end if not isEmpty(frame.args['crafting-mat1']) then crafting = crafting .. ', and requires ' crafting = crafting .. frame:preprocess( '' ) end if not isEmpty(frame.args['crafting-mat2']) then crafting = crafting .. ', '			if isEmpty(frame.args['crafting-mat3']) then crafting = crafting .. 'and ' end crafting = crafting .. frame:preprocess( '' ) end if not isEmpty(frame.args['crafting-mat3']) then crafting = crafting .. ', '			if isEmpty(frame.args['crafting-mat4']) then crafting = crafting .. 'and ' end crafting = crafting .. frame:preprocess( '' ) end if not isEmpty(frame.args['crafting-mat4']) then crafting = crafting .. ', '			if isEmpty(frame.args['crafting-mat5']) then crafting = crafting .. 'and ' end crafting = crafting .. frame:preprocess( '' ) end if not isEmpty(frame.args['crafting-mat5']) then crafting = crafting .. ', '			if isEmpty(frame.args['crafting-mat6']) then crafting = crafting .. 'and ' end crafting = crafting .. frame:preprocess( '' ) end if not isEmpty(frame.args['crafting-mat6']) then crafting = crafting .. ', and ' frame:preprocess( '' ) 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(  .. formatAvailability(frame.args['availability2']) ..  ) if frame.args['availability2'] == 'Lloid' then prose = prose .. ', which can be obtained by trading ' .. frame.args['trade-amount'] .. frame:preprocess( ' ' ) .. frame.args['trade-flower'] end if not isEmpty(frame.args['availability2-note']) then if frame.args['availability2-note'] == '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 .. ''			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 .. frame:preprocess( 'Leaf Tickets ' .. frame.args['reissue-crafting-price'] .. '' ) end if frame.args['reissue-crafting-currency'] == "Bells" then prose = prose .. frame:preprocess( 'Bells ' .. frame.args['reissue-crafting-price'] .. '') prose = prose .. ', with ' prose = prose .. frame:preprocess( 'HMS ' .. frame.args['reissue-time'] .. '') prose = prose .. ' to create' end if not isEmpty(frame.args['reissue-mat1']) then prose = prose .. ', and requiring ' prose = prose .. frame:preprocess( '' ) end if not isEmpty(frame.args['reissue-mat2']) then prose = prose .. ', '			if isEmpty(frame.args['reissue-mat3']) then prose = prose .. 'and ' end prose = prose .. frame:preprocess( '' ) end if not isEmpty(frame.args['reissue-mat3']) then prose = prose .. ', '			if isEmpty(frame.args['reissue-mat4']) then prose = prose .. 'and ' end prose = prose .. frame:preprocess( '' ) end if not isEmpty(frame.args['reissue-mat4']) then prose = prose .. ', '			if isEmpty(frame.args['reissue-mat5']) then prose = prose .. 'and ' end prose = prose .. frame:preprocess( '' ) end if not isEmpty(frame.args['reissue-mat5']) then prose = prose .. ', '			if isEmpty(frame.args['reissue-mat6']) then prose = prose .. 'and ' end prose = prose .. frame:preprocess( '' ) end if not isEmpty(frame.args['reissue-mat6']) then prose = prose .. ', and ' frame:preprocess( '' ) end prose = prose .. '.'	end if frame.args['memory'] == "Yes" or frame.args['memory'] == "yes" then prose = prose .. " " .. frame:preprocess( '') end return prose end

function p.outputClothingProse (frame) local function isEmpty(s) return s == nil or s == '' end local prose = 'The ' .. frame:preprocess( "" .. frame.args['name'] .. "" ) if not isEmpty(frame.args['engb_name']) then prose = ' (known as ' .. frame.args['engb_name'] .. ' in European English)' end prose = 'is a ' .. frame.args['theme']:lower .. '-themed ' .. formatClothingCategory(frame.args['type']) .. ' item in ' .. frame:preprocess( '' ) 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 .. 'It 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 .. 'It can be obtained from ' end if string.find(frame.args['availability'],'Cookie') then prose = prose .. frame:preprocess( ' ' ) end prose = prose .. frame:preprocess(  .. formatAvailability(frame.args['availability']) ..  ) if frame.args['availability'] == 'Lloid' then prose = prose .. ', which can be obtained by trading ' .. frame.args['trade-amount'] .. frame:preprocess( ' ' ) .. 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'] == 'Completing tasks' then prose = prose .. ' from completing tasks' elseif frame.args['availability'] == 'Lloid' then prose = prose .. ''		elseif frame.args['availability-note'] == 'By completing tasks' 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 .. frame:preprocess( 'Leaf Tickets ' .. frame.args['crafting-price'] .. '') crafting = crafting .. ', and is crafted instantly after payment' end if frame.args['crafting-currency'] == "Bells" then crafting = crafting .. frame:preprocess( 'Bells ' .. frame.args['crafting-price'] .. '') crafting = crafting .. ', takes around ' .. frame:preprocess( 'HMS ' .. frame.args['crafting-time'] .. ' to make') end if not isEmpty(frame.args['crafting-mat1']) then crafting = crafting .. ', and requires ' crafting = crafting .. frame:preprocess( '' ) end if not isEmpty(frame.args['crafting-mat2']) then crafting = crafting .. ', '			if isEmpty(frame.args['crafting-mat3']) then crafting = crafting .. 'and ' end crafting = crafting .. frame:preprocess( '' ) end if not isEmpty(frame.args['crafting-mat3']) then crafting = crafting .. ', '			if isEmpty(frame.args['crafting-mat4']) then crafting = crafting .. 'and ' end crafting = crafting .. frame:preprocess( '' ) end if not isEmpty(frame.args['crafting-mat4']) then crafting = crafting .. ', '			if isEmpty(frame.args['crafting-mat5']) then crafting = crafting .. 'and ' end crafting = crafting .. frame:preprocess( '' ) end if not isEmpty(frame.args['crafting-mat5']) then crafting = crafting .. ', '			if isEmpty(frame.args['crafting-mat6']) then crafting = crafting .. 'and ' end crafting = crafting .. frame:preprocess( '' ) end if not isEmpty(frame.args['crafting-mat6']) then crafting = crafting .. ', and ' frame:preprocess( '' ) 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(  .. formatAvailability(frame.args['availability2']) ..  ) if frame.args['availability2'] == 'Lloid' then prose = prose .. ', which can be obtained by trading ' .. frame.args['trade-amount'] .. frame:preprocess( ' ' ) .. frame.args['trade-flower'] end if not isEmpty(frame.args['availability2-note']) then if frame.args['availability2-note'] == '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 .. ''			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 .. frame:preprocess( 'Leaf Tickets ' .. frame.args['reissue-crafting-price'] .. '' ) end if frame.args['reissue-crafting-currency'] == "Bells" then prose = prose .. frame:preprocess( 'Bells ' .. frame.args['reissue-crafting-price'] .. '') prose = prose .. ', with ' prose = prose .. frame:preprocess( 'HMS ' .. frame.args['reissue-time'] .. '') prose = prose .. ' to create' end if not isEmpty(frame.args['reissue-mat1']) then prose = prose .. ', and requiring ' prose = prose .. frame:preprocess( '' ) end if not isEmpty(frame.args['reissue-mat2']) then prose = prose .. ', '			if isEmpty(frame.args['reissue-mat3']) then prose = prose .. 'and ' end prose = prose .. frame:preprocess( '' ) end if not isEmpty(frame.args['reissue-mat3']) then prose = prose .. ', '			if isEmpty(frame.args['reissue-mat4']) then prose = prose .. 'and ' end prose = prose .. frame:preprocess( '' ) end if not isEmpty(frame.args['reissue-mat4']) then prose = prose .. ', '			if isEmpty(frame.args['reissue-mat5']) then prose = prose .. 'and ' end prose = prose .. frame:preprocess( '' ) end if not isEmpty(frame.args['reissue-mat5']) then prose = prose .. ', '			if isEmpty(frame.args['reissue-mat6']) then prose = prose .. 'and ' end prose = prose .. frame:preprocess( '' ) end if not isEmpty(frame.args['reissue-mat6']) then prose = prose .. ', and ' frame:preprocess( '' ) end prose = prose .. '.'	end end

return p