Created
May 26, 2017 00:08
-
-
Save imliam/3e93c217aa8201d2781ef4af44209e7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- FUNEMPLOYED | |
xml=[[<C><P /><Z><S><S L="800" X="400" H="50" Y="380" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S L="500" H="44" X="400" Y="338" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="500" X="400" Y="150" T="12" H="250" /></S><D /><O /></Z></C>]] | |
hand=5 | |
cardsPerRound=3 | |
cards={ | |
jobs={ | |
unused={ | |
"Pirate", | |
"Wine taster", | |
"Game show host", | |
"Game developer", | |
"Artist", | |
"King", | |
"Singer", | |
"Painter", | |
"Shaman", | |
"Chef", | |
"Jedi", | |
"Bouncer", | |
"Chicken sexer", | |
"Balloon artist", | |
"Counsellor", | |
"Telemarketer", | |
"Movie star", | |
"Mailman", | |
"A god", | |
"Demon", | |
"World overlord", | |
"Tank driver", | |
"Teacher", | |
"Care assistant", | |
"Mechanic", | |
"Architect", | |
"Professional handshaker", | |
"Cat behaviour consultant", | |
"Prisoner", | |
"Prison officer", | |
"Community manager", | |
"Pilot", | |
"Underwear specialist", | |
"Translator", | |
"Moderator", | |
"Exorcist", | |
"Dinosaur supervisor", | |
"Beard specialist", | |
"Photographer", | |
"Police officer", | |
"Black market salesperson", | |
"Scientist", | |
"Inventor", | |
"Slave", | |
"Private detective", | |
"Assassin", | |
"Dictator", | |
"Magician", | |
"Witch", | |
"Altar boy", | |
"Cheerleader", | |
"Reality show contestant", | |
"Sumo wrestler", | |
"Therapist", | |
"Taxidermist", | |
"Security guard", | |
"Diplomatic translator", | |
"Game show host", | |
"Secret agent", | |
"Doctor", | |
"Software developer", | |
"Meme artist", | |
"Sandwich artist" | |
}, | |
used={} | |
}, | |
traits={ | |
unused={ | |
"Smelly", | |
"Goat", | |
"Panda", | |
"Hairy", | |
"Brunette", | |
"Ginger", | |
"Blonde", | |
"One eye", | |
"Terrible flatulence", | |
"Cheese", | |
"Magical", | |
"Evil", | |
"French accent", | |
"Baguette", | |
"German", | |
"Bees", | |
"Orange juice", | |
"Toothpaste", | |
"Wood", | |
"Rotten bagel", | |
"Speedboat", | |
"Supercar", | |
"Phone", | |
"Dyslexic", | |
"Wet", | |
"Diaper", | |
"Chocolate fetish", | |
"Son", | |
"Daughter", | |
"Sword", | |
"Princess tiara", | |
"Ballet", | |
"Mumble", | |
"Can't whistle", | |
"12 years old", | |
"Kiss everything", | |
"Fast runner", | |
"Daily shower", | |
"Confident", | |
"Social", | |
"Funny", | |
"Friendly", | |
"Fishy", | |
"Shirtless", | |
"Eat anything", | |
"Party hat", | |
"Spirit", | |
"Nothing left to lose", | |
"Decoder ring", | |
"Time machine", | |
"Mind reader", | |
"1%", | |
"Fairy dust", | |
"The antidote", | |
"Whip", | |
"Topless", | |
"Pole", | |
"Tramp stamp", | |
"Emotionally hollow", | |
"Loose", | |
"Uncontrollable gas", | |
"Dirty", | |
"Drug habit", | |
"Hallucinates", | |
"Trust fund", | |
"Magic wand", | |
"Wizard hat", | |
"Online degree", | |
"Jacked forearms", | |
"Slutty", | |
"Beefcake", | |
"Six-pack", | |
"Package", | |
"Passive aggressive", | |
"Cold black heart", | |
"Spandex", | |
"Nice things", | |
"Sob story", | |
"Every problem ever", | |
"Erectile dysfunction", | |
"STD", | |
"El diablo", | |
"Backyard wrestler", | |
"Witty banter", | |
"Steroids", | |
"Patient", | |
"Bipolar", | |
"Dead", | |
"Raging alcoholic", | |
"Excuses", | |
"Pathological liar", | |
"Associate's degree", | |
"Utility belt", | |
"Superpower", | |
"Handcuffs", | |
"Flaming sword", | |
"Speaks panda", | |
"Speech impediment", | |
"Can defuse bombs", | |
"Dragon", | |
"Alcoholic", | |
"Million dollar smile", | |
"Condoms", | |
"Bitches", | |
"Emotionally unstable", | |
"Rum", | |
"Coke", | |
"Dungeon", | |
"Soft hands", | |
"British accent", | |
"Green card", | |
"Cancer", | |
"Dead parents", | |
"Onii-chan", | |
"Pretencious", | |
"Cannibalism", | |
"Arrested", | |
"Convict", | |
"Trophies", | |
"Bleed", | |
"Ragecomics", | |
"Memes" | |
}, | |
used={} | |
} | |
} | |
players={} | |
function eventNewPlayer(name) | |
tfm.exec.chatMessage('This room is a remake of the card game "Funemployed". It is a test module and in development, so may be prone to bugs.', name) | |
players[name]={ | |
name=name, | |
hand={}, | |
chat="", | |
justJoined = true | |
} | |
if not job then | |
ui.addTextArea(51,"",name,154,26,492,238,0x324650,0x212F36,1,true) | |
end | |
local player=players[name] | |
setupPlayer(player) | |
if currentPlayer and job then | |
playersTurn(currentPlayer) | |
end | |
end | |
function eventPlayerLeft(name) | |
players[name]=nil | |
if name==employer then | |
local tbl={} | |
for name in pairs(players) do | |
table.insert(tbl,name) | |
end | |
playersTurn(tbl[math.random(#tbl)]) | |
employersTools() | |
end | |
end | |
function setupPlayer(player) | |
if #player.hand<hand then | |
for i=1,hand-#player.hand do | |
local card=randomItem(cards.traits.unused,cards.traits.used) | |
table.insert(player.hand,{ | |
text=card, | |
displayed=false, | |
used=false | |
}) | |
table.insert(cards.traits.used,card) | |
end | |
end | |
for _,card in pairs(player.hand) do | |
card.x=nil | |
card.id=nil | |
card.displayed=false | |
end | |
for _,card in pairs(player.hand) do | |
displayCard(card,player) | |
end | |
ui.addTextArea(50,"You are at a job interview trying to get hired.\n\nWhen it's your turn, you have to chat to the employer to convince them to hire you, mentioning "..cardsPerRound.." of the traits you have in the cards at the bottom.",name,8,26,132,nil,0x324650,0x212F36,1,true) | |
end | |
function eventNewGame() | |
ui.removeTextArea(94) | |
ui.removeTextArea(95) | |
ui.removeTextArea(97) | |
ui.removeTextArea(98) | |
ui.removeTextArea(99) | |
ui.removeTextArea(100) | |
ui.removeTextArea(200) | |
ui.removeTextArea(210) | |
ui.removeTextArea(211) | |
ui.removeTextArea(212) | |
ui.addTextArea(51,"",nil,154,26,492,238,0x324650,0x212F36,1,true) | |
if not employer then | |
local tbl={} | |
for name in pairs(tfm.get.room.playerList) do | |
table.insert(tbl,name) | |
end | |
employer=tbl[math.random(#tbl)] | |
end | |
tfm.exec.setUIMapName("Employer: <N>"..employer.."<J>\n") | |
for name,player in pairs(players) do | |
player.justJoined = false | |
player.chat="<font color='#000000'>" | |
player.traitsString="<b>Applicant:</b>\n"..player.name.."\n\n" | |
if tfm.get.room.playerList[player.name].registrationDate then | |
player.traitsString=player.traitsString.."<b>Date of Birth:</b>\n"..os.date('%d/%m/%Y',tfm.get.room.playerList[player.name].registrationDate).."\n\n" | |
end | |
if tfm.get.room.playerList[player.name].tribeName then | |
player.traitsString=player.traitsString.."<b>Tribe:</b>\n"..tfm.get.room.playerList[player.name].tribeName.."\n\n" | |
end | |
player.traitsString=player.traitsString.."<b>Traits:</b>\n" | |
player.traitsUsed=0 | |
setupPlayer(player) | |
ui.addTextArea(210,"<p align='center'><font size='24'>The employer is deciding what they want to hire</font></p>",player.name,200,130,400,nil,0x000000,0x000000,0,true) | |
end | |
ui.addTextArea(50,"You are an employer interviewing applicants for a job. You can select the applicant to talk to from the list at the right.\n\nOnce the applicants have told you "..cardsPerRound.." traits about themselves, you can decide whether or not to hire them.",employer,8,26,132,nil,0x324650,0x212F36,1,true) | |
randomJobs={ | |
randomItem(cards.jobs.unused,cards.jobs.used), | |
randomItem(cards.jobs.unused,cards.jobs.used), | |
randomItem(cards.jobs.unused,cards.jobs.used) | |
} | |
if table.count(tfm.get.room.playerList)>1 then | |
ui.addTextArea(94,"<p align='center'>\n\nYou are the employer, you cannot use your own cards this round.</p>",employer,154,320,492,100,0x324650,0x212F36,0.8,true) | |
end | |
ui.addTextArea(51,"",employer,154,26,492,280,0x324650,0x212F36,1,true) | |
ui.addTextArea(210,"<p align='center'><font size='24'>I'm going to hire one ...</font></p>",employer,200,34,400,nil,0x000000,0x000000,0,true) | |
ui.addPopup(1,2,"<p align='center'>Enter your own job title</p>",employer,300,85,200,true) | |
ui.addTextArea(212,"<p align='center'>or select from the options below</p>",employer,300,170,200,nil,0x000000,0x000000,0,true) | |
for i,card in pairs(randomJobs) do | |
table.insert(cards.jobs.used,v) | |
ui.addTextArea(200+i,"<N><a href='event:job "..i.."'>"..card.."</a>",employer,136+(i*110),200,90,100,0x000001,0x000001,1,true) | |
end | |
end | |
function eventPopupAnswer(id,name,answer) | |
if id==1 then | |
answer=encodeAngleBrackets(answer) | |
if #trimSpaces(answer)>0 then | |
job=answer | |
selectedJob() | |
else | |
ui.addPopup(1,2,"<p align='center'>Enter your own job title</p>",employer,300,85,200,true) | |
end | |
end | |
end | |
function eventTextAreaCallback(id,name,callback) | |
local args = string.split(callback, "%s") | |
if args[1]=="job" and tonumber(args[2]) then | |
job=randomJobs[tonumber(args[2])] | |
table.insert(cards.jobs.used,job) | |
selectedJob() | |
elseif args[1]=="switchplayer" and args[2] and players[args[2]] and (currentPlayer~=args[2]) then | |
playersTurn(args[2]) | |
elseif args[1]=="hire" and args[2] and players[args[2]] then | |
local p=players[args[2]] | |
if p.traitsUsed==cardsPerRound then | |
tfm.exec.setPlayerScore(p.name,1,true) | |
tfm.exec.chatMessage(employer.." has decided to hire "..p.name.." for the position of "..job) | |
currentPlayer=nil | |
employer=p.name | |
tfm.exec.newGame(xml) | |
else | |
tfm.exec.chatMessage(p.name.." needs to tell you a bit more about themself...",employer) | |
end | |
end | |
end | |
function selectedJob() | |
ui.removeTextArea(51) | |
tfm.exec.setUIMapName("Employer: <N>"..employer.." <BL>| <J>Job title: <N>"..job.."\n") | |
for i=1,#randomJobs do | |
if randomJobs[i]~=job then | |
table.insert(cards.jobs.unused,randomJobs[i]) | |
end | |
ui.removeTextArea(200+i) | |
end | |
ui.addPopup(1,0,"",nil,450,450,100,true) | |
ui.removeTextArea(210) | |
ui.removeTextArea(212) | |
randomJobs=nil | |
local tbl={} | |
local playerCount=table.count(tfm.get.room.playerList) | |
for name in pairs(players) do | |
if playerCount>1 then | |
if name~=employer then | |
table.insert(tbl,name) | |
end | |
else | |
table.insert(tbl,name) | |
end | |
end | |
playersTurn(tbl[math.random(#tbl)]) | |
employersTools() | |
ui.removeTextArea(51) | |
end | |
function eventChatMessage(name,message) | |
local player=players[name] | |
if currentPlayer and currentPlayer==player.name then | |
displayChat(message,player) | |
end | |
end | |
function eventChatCommand(name, command) | |
if name=="Shamousey" and command=="skip" then | |
tfm.exec.chatMessage(name.." has skipped the current round.") | |
local tbl={} | |
for name in pairs(tfm.get.room.playerList) do | |
table.insert(tbl,name) | |
end | |
employer=tbl[math.random(#tbl)] | |
currentPlayer=nil | |
tfm.exec.newGame(xml) | |
end | |
end | |
function employersTools() | |
local str="<b>View Applicants:</b>\n" | |
local playerCount=table.count(tfm.get.room.playerList) | |
for name,player in pairs(players) do | |
if not player.justJoined then | |
local canListEmployer=true | |
if playerCount>1 then | |
canListEmployer=false | |
end | |
if (canListEmployer) or (not canListEmployer and name~=employer) then | |
if currentPlayer and currentPlayer==name then | |
str=str.."<J><a href='event:switchplayer "..name.."'>• "..name.."</a><N> ("..player.traitsUsed..")\n" | |
else | |
str=str.."<a href='event:switchplayer "..name.."'>• "..name.."</a> ("..player.traitsUsed..")\n" | |
end | |
end | |
end | |
end | |
ui.addTextArea(200,str,employer,659,26,130,nil,0x324650,0x212F36,1,true) | |
end | |
function playersTurn(name) | |
local player=players[name] | |
if player and not player.justJoined then | |
if currentPlayer~=player.name then | |
tfm.exec.chatMessage("It's your turn to be interviewed!",player.name) | |
end | |
currentPlayer=player.name | |
employersTools() | |
ui.addTextArea(95,"<p align='center'><font size='18'><J>"..tostring(employer).." is hiring one <b>"..tostring(job).."</b></p>",nil,154,26,492,26,0x324650,0x212F36,1,true) | |
ui.addTextArea(98,"",nil,154,65,342,200,0xFFFFFF,0x212F36,1,true) | |
ui.addTextArea(99,"<p align='center'><font color='#cccccc'>"..string.rep("_",1000).."</font></p>",nil,150,65,350,200,0x324650,0x212F36,0,true) | |
ui.addTextArea(100,player.chat,nil,154,65,346,200,0xFFFFFF,0x212F36,0,true) | |
ui.addTextArea(97,player.traitsString,nil,500,65,146,200,0x324650,0x212F36,1,true) | |
ui.addTextArea(211,"<p align='center'><a href='event:hire "..player.name.."'>Hire\n</a></p>",employer,500,245,146,20,0x324650,0x212F36,1,true) | |
end | |
end | |
function randomItem(tbl,tbl2) | |
if #tbl==0 then | |
for k,v in pairs(tbl2) do | |
tbl[k]=v | |
end | |
for i=1,#tbl2 do | |
tbl2[i]=nil | |
end | |
end | |
local i=math.random(#tbl) | |
local item=tbl[i] | |
table.remove(tbl,i) | |
return item | |
end | |
function string.split(str,s) | |
if not str then | |
return nil | |
end | |
local res = {} | |
for part in string.gmatch(str, "[^" .. s .. "]+") do | |
table.insert(res, part) | |
end | |
return res | |
end | |
function displayCard(card,player) | |
local i=1 | |
for _,c in pairs(player.hand) do | |
if c.displayed then | |
i=i+1 | |
end | |
end | |
local x=card.x and card.x or 54+(i*100) | |
local y=card.used and 300 or 320 | |
ui.addTextArea(card.id and card.id or 100+i,card.used and "<VP>"..card.text or card.text,player.name,x,y,90,100,0x324650,0x212F36,1,true) | |
card.displayed=true | |
card.id=100+i | |
card.x=x | |
end | |
function displayChat(text,player) | |
local used={} | |
for i,card in pairs(player.hand) do | |
local found = string.find(text:lower(),card.text:lower()) | |
if player.traitsUsed<cardsPerRound and found and not card.used then | |
local str="" | |
str=str..text:sub(1,found-1) | |
str=str.."<font color='#324650'><b>"..text:sub(found,found+#card.text-1).."</font></b><font color='#000000'>" | |
str=str..text:sub(found+#card.text) | |
text=str | |
card.used=true | |
displayCard(card,player) | |
player.traitsString=player.traitsString.." • "..card.text.."\n" | |
ui.updateTextArea(97,player.traitsString) | |
player.traitsUsed=player.traitsUsed+1 | |
playersTurn(player.name) | |
employersTools() | |
end | |
end | |
local t={} | |
for i,card in pairs(player.hand) do | |
if card.used then | |
table.insert(t,1,i) | |
end | |
end | |
if #t==cardsPerRound then | |
for k,v in pairs(t) do | |
table.remove(player.hand,v) | |
end | |
end | |
player.chat=player.chat..text.."\n" | |
ui.updateTextArea(100,player.chat) | |
end | |
function table.count(tbl) | |
local i=0 | |
for k,v in pairs(tbl) do | |
i=i+1 | |
end | |
return i | |
end | |
function sortScores() | |
local tbl={} | |
for k,v in pairs(tfm.get.room.playerList) do | |
table.insert(tbl,{name=v.playerName,score=v.score}) | |
end | |
table.sort(tbl,function(i,v) return i.score>v.score end) | |
return tbl | |
end | |
function trimSpaces(str) | |
return str:gsub(" ","") | |
end | |
function encodeAngleBrackets(str) | |
return str:gsub("<","<"):gsub(">",">") | |
end | |
for name,player in pairs(tfm.get.room.playerList) do | |
eventNewPlayer(name) | |
end | |
tfm.exec.disableAutoTimeLeft(true) | |
tfm.exec.disableAutoNewGame(true) | |
tfm.exec.disableAutoScore(true) | |
tfm.exec.disableAfkDeath(true) | |
tfm.exec.disableAutoShaman(true) | |
tfm.exec.newGame(xml) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment