Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- FUNEMPLOYED
- -- Перевел на русский язык Zigwin / RU translate by Zigwin
- 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={
- "Пират",
- "Дегустатор вина",
- "Разработчик игр",
- "Надуватель шаров",
- "Артист",
- "Король",
- "Певец",
- "Художник",
- "Шаман",
- "Шеф-повар",
- "Джедай",
- "Вышибала",
- "Куриный sexer",
- "Адвокат",
- "Телемаркетер",
- "Телезвезда",
- "Почтальон",
- "Бог",
- "Демон",
- "Повелитель мира",
- "Водитель танка",
- "Учитель",
- "Сиделка",
- "Механик",
- "Архитектор",
- "Рукопожиматель",
- "Ветеринар",
- "Заключенный",
- "Тюремный офицер",
- "Комьюнити менеджер",
- "Пилот",
- "Переводчик",
- "Модератоор",
- "Экзорцист",
- "Укротител ",
- "Парикмахер",
- "Фотограф",
- "Офцер полиции",
- "Продавец чёрного рынка",
- "Учёный",
- "Изобретатель",
- "Раб",
- "Частный детектив",
- "Убийца",
- "Диктатор",
- "Волшебник",
- "Ведьма",
- "Служанка",
- "Чирлидер",
- "Участник реалити шоу",
- "Сумоист",
- "Терапевт",
- "Таксидермист",
- "Охранник",
- "Ведущий игрового шоу",
- "Секретный агент",
- "Доктор",
- "Разработчик",
- "Создатель мемов",
- },
- used={}
- },
- traits={
- unused={
- "Вонючий",
- "Козел",
- "Панда",
- "Волосатый",
- "Брюнет",
- "Рыжий",
- "Блондин",
- "Один глаз",
- "Ужасный метеоризм",
- "Сыр",
- "Магический",
- "Злой",
- "Французский акцент",
- "Багет",
- "Германкий",
- "Пчелы",
- "Апельсиновый сок",
- "Зубная паста",
- "Дерево",
- "Гнилой бублик",
- "Катер",
- "Суперкар",
- "Телефон",
- "Дислексик",
- "Мокрый",
- "Памперс",
- "Шоколадный фетиш",
- "Сын",
- "Дочь",
- "Меч",
- "Корона принцессы",
- "Балет",
- "Бормотать",
- "Не уметь свистеть",
- "12 Лет",
- "Целовать всех",
- "Быстрый бег",
- "Ежедневный душ",
- "Уверенный",
- "Общительный",
- "Смешной",
- "Дружелюбный",
- "Рыбный",
- "Без рубашки",
- "Съесть все",
- "Праздничный колпак",
- "Дух",
- "Нечего терять",
- "Дешифратор",
- "Машина времени",
- "Читать мысли",
- "1 Процент",
- "Пыльца феи",
- "Противоядие",
- "Хлыст",
- "Без верхней одежды",
- "Полюс",
- "Клеймо",
- "Эмоционально подавлен",
- "Проигрывать",
- "Неуправляемый газ",
- "Грязный",
- "Наркоман",
- "Галлюцинации",
- "Целевой фонд",
- "Волшебная палочка",
- "Шляпа волшебника",
- "Онлайн курсы",
- "Высокие плечи",
- "Развартный",
- "Качок",
- "Шесть пакетов",
- "Пакет",
- "Агрессивный",
- "Холодное сердце",
- "Спандекс",
- "Классные штуки",
- "Печальная история",
- "Проблема для всех",
- "Импотент",
- "ЛГБТ",
- "Эль дьябло",
- "Дворовой рестлер",
- "Остроумный стеб",
- "Стероиды",
- "Больной",
- "Двухполярный",
- "Мертвый",
- "Яростный алкоголик",
- "Отмазки",
- "Патологический лжец",
- "Диплом",
- "Пояс",
- "Суперсила",
- "Наручники",
- "Огненный меч",
- "Говорящая панда",
- "Дефект речи",
- "Обезвредить бомбу",
- "Дракон",
- "Алкоголик",
- "Улыбка на миллион",
- "Презервативы",
- "Суки",
- "Эмоционально неустойчивый",
- "Ром",
- "Кокс",
- "Подземелье",
- "Мягкие ручки",
- "Британский акцент",
- "Зеленая карта",
- "Рак",
- "Мертвые родители",
- "Онии Тян",
- "Пафосный",
- "Каннибализм",
- "Разыскиваемый",
- "Зек",
- "Трофеи",
- "Кровавый",
- "Комиксы",
- "Мемы"
- },
- used={}
- }
- }
- players={}
- function eventNewPlayer(name)
- tfm.exec.chatMessage('Эта комната - ремейк карточной игры "Funemployed". Этот тестовый модуль в разработке, очень много вещей склонно к багам.', 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,"Ты на интервью и пытаешься устроится на работу.\n\nКогда ваша очередь, вам нужно поговорить с работодателем, чтобы убедить его нанять вас, упомянув "..cardsPerRound.." черты характера на картах у тебя внизу.",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("Работодатель: <N>"..employer.."<J>\n")
- for name,player in pairs(players) do
- player.justJoined = false
- player.chat="<font color='#000000'>"
- player.traitsString="<b>Кандидат:</b>\n"..player.name.."\n\n"
- if tfm.get.room.playerList[player.name].registrationDate then
- player.traitsString=player.traitsString.."<b>Дата рождения:</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>Племя:</b>\n"..tfm.get.room.playerList[player.name].tribeName.."\n\n"
- end
- player.traitsString=player.traitsString.."<b>Черты характера:</b>\n"
- player.traitsUsed=0
- setupPlayer(player)
- ui.addTextArea(210,"<p align='center'><font size='24'>Работодатель решает, кого он хочет нанять</font></p>",player.name,200,130,400,nil,0x000000,0x000000,0,true)
- end
- ui.addTextArea(50,"Ты работодатель который берет интервью у кандидатов на работу. Вы можете выбрать кандидата из списка справа.\n\nПосле кандидаты расскажут вам о "..cardsPerRound.." своих чертах характера, вы можете решить, стоит ли их нанимать.",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\nВы работодатель, вы не можете использовать свои карты в этом раунде.</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'>Я собираюсь нанять одного ...</font></p>",employer,200,34,400,nil,0x000000,0x000000,0,true)
- ui.addPopup(1,2,"<p align='center'>Введите свое название работы</p>",employer,300,85,200,true)
- ui.addTextArea(212,"<p align='center'>Или выберите винзу</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'>Введите свое название работы</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.." Решил нанять "..p.name.." на должность "..job)
- currentPlayer=nil
- employer=p.name
- tfm.exec.newGame(xml)
- else
- tfm.exec.chatMessage(p.name.." должен рассказать вам немного больше о себе...",employer)
- end
- end
- end
- function selectedJob()
- ui.removeTextArea(51)
- tfm.exec.setUIMapName("Работодатель: <N>"..employer.." <BL>| <J>Работа: <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=="Zigwin" and command=="skip" then
- tfm.exec.chatMessage(name.." пропустил текущий раунд")
- 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>Выбери кандидата:</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 canLimstEloyer 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("Это ваша очередь, чтобы пройти собеседование!",player.name)
- end
- currentPlayer=player.name
- employersTools()
- ui.addTextArea(95,"<p align='center'><font size='18'><J>"..tostring(employer).." нанимает одного <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.."'>Нанять\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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement