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 (Pocket Camp)' 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( '' ) .. '.'	prose = prose .. ' It is a type of ' .. frame.args['type']:lower .. '.'	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 prose = prose .. frame:preprocess( '' ) if frame.args['availability-note'] then prose = prose .. ' (' .. frame.args['availability-note'] .. ')' end if frame.args['availability2'] then prose = prose .. ' or from ' .. frame:preprocess( '' ) if frame.args['availability2-note'] then prose = prose .. ' (' .. frame.args['availability2-note'] .. ')' end end prose = prose .. '.'

if frame.args['crafting-price'] then prose = prose .. ' Crafting takes ' .. frame.args['crafting-time'] .. ' seconds, costs ' .. frame:preprocess( 'Bells ' .. frame.args['crafting-bells'] .. '' ) .. ', and requires ' prose = prose .. frame:preprocess( '' ) 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-bells'] then prose = prose .. ' The item has also been reissued, taking ' .. frame.args['reissue-time'] .. ' seconds, costing ' .. frame:preprocess( 'Bells ' .. frame.args['reissue-bells'] .. '' ) .. ', and requiring ' prose = prose .. frame:preprocess( '' ) 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