Module:Sandbox/User:I Am Me

From WIDEVERSE Wiki
Revision as of 10:28, 24 January 2020 by en>I Am Me
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Sandbox/User:I Am Me/doc

yesno = require("Module:Yesno")

local p = {}

local all_statements = {
	"I'm not keeping any at all. You will get all five types.",
	"¤#, but you get all of the ¤¤ ones. Aww, I already have loads of gold ones!",
	"¤#, but you get all the ¤¤ ones. It's not my favourite colour, but a charm's a charm!",
	"¤#, and you get all the elder, blue and crimson ones. You've a discerning eye alright.",
	"¤#, but you get all of the ¤¤ ones. Crimson is my favourite colour!",
	"¤#, and you get all the ¤¤ ones. Do you like the sea?",
	"¤#, and you get all the ¤¤ ones. A nice split!",
	"¤#, and you only get the ¤¤ ones. I see you are only after the rarest charms!",
	"¤#, but you get all ¤¤ ones. I might get fewer charms, but I'm happy that they're rare ones!",
	"¤#, and you get all the ¤¤ ones. A nice split!",
	"¤#, and you get all the ¤¤ ones. They're not my favourite ones, but I do get the rarest type!",
	"¤#, and you only get the ¤¤ ones. Don't blame you - they're my favourite too!",
	"¤#, and you get all the ¤¤ ones. Seems like a good deal to me!",
	"¤#, and you only get the ¤¤ ones. To be honest, I'm not so fond of the green ones, so that's great!",
	"¤#, and you only get the ¤¤ ones. Guess it's good to stock up, eh?",
	"¤#, and you only get the ¤¤ ones. Those are quite unique!",
	"¤#, and you get the ¤¤ ones. I really wanted some of these!",
	"¤#, and you get the ¤¤ ones. I can definitely work with this!",
	"¤#, and you get the ¤¤ ones. I think these will go well together in my collection.",
	"¤#, and you get the ¤¤ charms. That's fair, I've got enough blue and crimson ones anyway.",
	"¤#, and you get the ¤¤ ones. Are you sure you want the blue ones?",
	"¤#, and you get the ¤¤ ones. That's not a bad split I think.",
	"¤#, and you get the ¤¤ ones. I like it!",
	"¤#, and you get the ¤¤ charms. Blue is a good colour, it makes sense.",
	"¤#, and you get the ¤¤ charms. Giving me the rares, eh? I can work with this.",
	"¤#, and you get the ¤¤ charms. You're quite generous you are.",
	"¤#, and you get the ¤¤ charms. I feel like I'm taking a little bit of an advantage here, but if you're sure.",
	"¤#, and you get the ¤¤ charms. Red really suits you!",
	"¤#, and you get the ¤¤ charms. Thank you so much, I really wanted these!",
	"¤#, and you get the ¤¤ charms. Those charms really bring out the colour in your eyes.",
	"¤#, and you get the ¤¤ charms. Stocking up are we?",
	"I'll take ALL the charms in exchange for summoning experience. I've seen some generous people in my time, but you...oh I'm tearing up!"
}

function p.imp(frame)
	local args = frame:getParent().args
	return _imp(   yesno(args.takes_gold)
	             , yesno(args.takes_green)
	             , yesno(args.takes_crimson)
	             , yesno(args.takes_blue)
	             , yesno(args.takes_elder)
	             , yesno(args.takes_talon)
	             , yesno(args.takes_abyssal)
	             , yesno(args.takes_obsidian)
	             , yesno(args.takes_spirit_dragon)
	           )
end

function _imp(takes_gold, takes_green, takes_crimson, takes_blue, takes_elder, takes_talon, takes_abyssal, takes_obsidian, takes_spirit_dragon)
	local normals_bitmask = 0
	local charms_taken = {}
	local charms_left = {}
	if takes_elder then
		normals_bitmask = normals_bitmask + 16
		table.insert(charms_taken, "elder")
	else
		table.insert(charms_left, "elder")
	end
	if takes_blue then
		normals_bitmask = normals_bitmask + 8
		table.insert(charms_taken, "blue")
	else
		table.insert(charms_left, "blue")
	end
	if takes_crimson then
		normals_bitmask = normals_bitmask + 4
		table.insert(charms_taken, "crimson")
	else
		table.insert(charms_left, "crimson")
	end
	if takes_green then
		normals_bitmask = normals_bitmask + 2
		table.insert(charms_taken, "green")
	else
		table.insert(charms_left, "green")
	end
	if takes_gold then
		normals_bitmask = normals_bitmask + 1
		table.insert(charms_taken, "gold")
	else
		table.insert(charms_left, "gold")
	end
	
	local prettified_charms_taken = mw.text.listToText(charms_taken) or "THIS SHOULD NOT SHOW UP"
	local prettified_charms_left = mw.text.listToText(charms_left) or "THIS SHOULD NOT SHOW UP"
	
	local intro = "I'll take the " .. prettified_charms_taken .. " charms in exchange for summoning experience"
	
	local result = all_statements[1 + normals_bitmask]:gsub("¤#", intro):gsub("¤¤", prettified_charms_left)
	
	-- Next, special charms
	result = result .. " With special charms, "
	local specials_taken = {}
	local specials_left = {}
	
	table.insert(takes_talon and specials_taken or specials_left, "talon")
	table.insert(takes_abyssal and specials_taken or specials_left, "abyssal")
	table.insert(takes_obsidian and specials_taken or specials_left, "obsidian")
	table.insert(takes_spirit_dragon and specials_taken or specials_left, "spirit dragon")
	
	mw.logObject(specials_taken)
	mw.logObject(specials_left)
	
	if #specials_taken == 0 then
		return result .. "I'm not taking any."
	elseif #specials_left == 0 then
		return result .. "I'm taking them all."
	else
		return    result
		       .. "I'm taking "
		       .. mw.text.listToText(specials_taken)
		       .. " charms, you get "
		       .. mw.text.listToText(specials_left)
		       .. "."
	end
end

return p