Module:Sandbox/nataliemeoww

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

p = {}

local function get_phrase(bottles, caps)
	local number, word
	
	if bottles == 0 then number = caps and 'No more' or 'no more'
	else number = bottles end
	if bottles == 1 then word = 'bottle'
	else word = 'bottles' end
	
	return ('%s %s'):format(number, word)
end
function p.ninety_nine_bottles()
	local lyrics = ''
	for bottles = 99, 0, -1 do
		lyrics = lyrics .. ('%s of beer on the wall, %s of beer.<br>'):format(
			get_phrase(bottles, true), get_phrase(bottles, false)
		)
		
		if bottles == 0 then
			lyrics = lyrics .. 'Go to the store and buy some more, 99 bottles of beer on the wall.\n\n'
		else
			lyrics = lyrics .. ('Take one down and pass it around, %s of beer on the wall.\n\n'):format(
				get_phrase(bottles - 1, false)
			)
		end
	end
	return lyrics
end
return p