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 formatAvailability(availability) if availability == 'Crafting' then return 'crafting' else return availability end end

function p.outputFurnitureProse (frame) local prose = 'The ' .. frame:preprocess( "" .. frame.args['name'] .. "" ) .. ' is a ' .. frame.args['theme']:lower .. '-themed furniture item in ' .. frame:preprocess( '' ) if 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 frame.args['catalog-category'] then if string.find(frame.args['catalog-category'],'Series') then prose = prose .. ' part of the ' .. frame:preprocess( '' .. frame.args['catalog-category'] .. '.' ) elseif string.find(frame.args['catalog-category'],'Walls/Floor') or string.find(frame.args['catalog-category'],'Wallpaper') or string.find(frame.args['catalog-category'],'Rug') or string.find(frame.args['catalog-category'],'Seasonal Event') or string.find(frame.args['catalog-category'],'Seat') or string.find(frame.args['catalog-category'],'Lamp') or string.find(frame.args['catalog-category'],'Bed') or string.find(frame.args['catalog-category'],'Flooring') or string.find(frame.args['catalog-category'],'Plant') or string.find(frame.args['catalog-category'],'Outdoor') then prose = prose .. '.'		else prose = prose .. ' part of the ' .. frame:preprocess( '' .. frame.args['catalog-category'] .. ' Set.' ) end else prose = prose .. '.'	end if 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 frame.args['event'] then prose = prose .. 'It was made available during ' .. frame:preprocess(  .. frame.args['event'] ..  ) if 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-note'] then if string.find(frame.args['availability'],'Cookie') then prose = prose .. ', with a ' .. frame.args['availability-note'] .. ' of appearing after eating the cookie' else prose = prose .. ' (' .. frame.args['availability-note'] .. ')' end end if frame.args['availability'] == "Crafting" then prose = prose .. ', which costs' end if frame.args['availability2'] then prose = prose .. ' or from' frame:preprocess(  .. formatAvailability(frame.args['availability2']) ..  ) if frame.args['availability2-note'] then prose = prose .. ' (' .. frame.args['availability2-note'] .. ')' end end if frame.args['availability'] == "Crafting" then prose = prose .. ' '	else prose = prose .. '.'	end

if frame.args['crafting-price'] then if frame.args['crafting-currency'] == "Leaf Tickets" then prose = prose .. frame:preprocess( 'Leaf Tickets ' .. frame.args['crafting-price'] .. ', and is crafted instantly after payment' ) end if frame.args['crafting-currency'] == "Bells" then prose = prose .. frame:preprocess( 'Bells ' .. frame.args['crafting-price'] .. ', takes around ' .. frame.args['crafting-time'] .. ' seconds to create' ) end if frame.args['crafting-mat1'] then prose = prose .. ', and requires ' .. frame:preprocess( '' ) end if frame.args['crafting-mat2'] then prose = prose .. ', '			if not frame.args['crafting-mat3'] then prose = prose .. 'and ' end prose = prose .. frame:preprocess( '' ) end if frame.args['crafting-mat3'] then prose = prose .. ', '			if not frame.args['crafting-mat4'] then prose = prose .. 'and ' end prose = prose .. frame:preprocess( '' ) end if frame.args['crafting-mat4'] then prose = prose .. ', '			if not frame.args['crafting-mat5'] then prose = prose .. 'and ' end prose = prose .. frame:preprocess( '' ) end if frame.args['crafting-mat5'] then prose = prose .. ', '			if not frame.args['crafting-mat6'] then prose = prose .. 'and ' end prose = prose .. frame:preprocess( '' ) end if frame.args['crafting-mat6'] then prose = prose .. ', and ' frame:preprocess( '' ) end prose = prose .. '.'	end if 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'] .. ', taking ' .. frame.args['reissue-time'] .. ' seconds to create' ) end if frame.args['reissue-mat1'] then prose = prose .. ', and requiring ' .. frame:preprocess( '' ) end if frame.args['reissue-mat2'] then prose = prose .. ', '			if not frame.args['reissue-mat3'] then prose = prose .. 'and ' end prose = prose .. frame:preprocess( '' ) end if frame.args['reissue-mat3'] then prose = prose .. ', '			if not frame.args['reissue-mat4'] then prose = prose .. 'and ' end prose = prose .. frame:preprocess( '' ) end if frame.args['reissue-mat4'] then prose = prose .. ', '			if not frame.args['reissue-mat5'] then prose = prose .. 'and ' end prose = prose .. frame:preprocess( '' ) end if frame.args['reissue-mat5'] then prose = prose .. ', '			if not frame.args['reissue-mat6'] then prose = prose .. 'and ' end prose = prose .. frame:preprocess( '' ) end if frame.args['reissue-mat6'] then prose = prose .. ', and ' frame:preprocess( '' ) end prose = prose .. '.'	end if frame.args['task-event'] then local words = {} words[1], words[2] = frame.args['task']:match("(%w+)(.+)") if words[1] == 'Obtain' then words[1] = '' elseif words[1] == 'Collect' then words[1] = 'by collecting ' elseif words[1] == 'Catch' then words[1] = 'by catching ' words[2] = words[2]:gsub( "catch ", "catching ") words[2] = words[2]:gsub( "obtain ", "obtained ") elseif words[1] == 'Task' then words[1] = 'by completing the following tasks:\n* ' .. words[1] end words[2] = words[2]:gsub( "\n", "\n* ") prose = prose .. '\n\nDuring ' .. frame.args['task-event'] .. ', the ' .. frame.args['name'] .. ' can be acquired ' .. words[1] .. words[2] if words[1] == 'by collecting ' then prose = prose .. '.'		end end

return prose end

return p