Advertisement
Guest User

Перевод v 0.31

a guest
Aug 19th, 2017
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.79 KB | None | 0 0
  1. -- FUNEMPLOYED
  2. -- Перевел на русский язык Zigwin / RU translate by Zigwin
  3.  
  4. 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>]]
  5. hand=5
  6. cardsPerRound=3
  7.  
  8. cards={
  9.     jobs={
  10.         unused={
  11.             "Пират",
  12.             "Дегустатор вина",
  13.             "Разработчик игр",           
  14.             "Надуватель шаров",
  15.             "Артист",
  16.             "Король",
  17.             "Певец",
  18.             "Художник",
  19.             "Шаман",
  20.             "Шеф-повар",
  21.             "Джедай",
  22.             "Вышибала",
  23.             "Куриный sexer",
  24.             "Адвокат",
  25.             "Телемаркетер",
  26.             "Телезвезда",
  27.             "Почтальон",
  28.             "Бог",
  29.             "Демон",
  30.             "Повелитель мира",
  31.             "Водитель танка",
  32.             "Учитель",
  33.             "Сиделка",
  34.             "Механик",
  35.             "Архитектор",
  36.             "Рукопожиматель",
  37.             "Ветеринар",
  38.             "Заключенный",
  39.             "Тюремный офицер",
  40.             "Комьюнити менеджер",
  41.             "Пилот",
  42.             "Переводчик",
  43.             "Модератоор",
  44.             "Экзорцист",
  45.             "Укротител ",
  46.             "Парикмахер",
  47.             "Фотограф",
  48.             "Офцер полиции",
  49.             "Продавец чёрного рынка",
  50.             "Учёный",
  51.             "Изобретатель",
  52.             "Раб",
  53.             "Частный детектив",
  54.             "Убийца",
  55.             "Диктатор",
  56.             "Волшебник",
  57.             "Ведьма",
  58.             "Служанка",
  59.             "Чирлидер",
  60.             "Участник реалити шоу",
  61.             "Сумоист",
  62.             "Терапевт",
  63.             "Таксидермист",
  64.             "Охранник",
  65.             "Ведущий игрового шоу",
  66.             "Секретный агент",
  67.             "Доктор",
  68.             "Разработчик",
  69.             "Создатель мемов",
  70.         },
  71.         used={}
  72.     },
  73.     traits={
  74.         unused={
  75.             "Вонючий",
  76.             "Козел",
  77.             "Панда",
  78.             "Волосатый",
  79.             "Брюнет",
  80.             "Рыжий",
  81.             "Блондин",
  82.             "Один глаз",
  83.             "Ужасный метеоризм",
  84.             "Сыр",
  85.             "Магический",
  86.             "Злой",
  87.             "Французский акцент",
  88.             "Багет",
  89.             "Германкий",
  90.             "Пчелы",
  91.             "Апельсиновый сок",
  92.             "Зубная паста",
  93.             "Дерево",
  94.             "Гнилой бублик",
  95.             "Катер",
  96.             "Суперкар",
  97.             "Телефон",
  98.             "Дислексик",
  99.             "Мокрый",
  100.             "Памперс",
  101.             "Шоколадный фетиш",
  102.             "Сын",
  103.             "Дочь",
  104.             "Меч",
  105.             "Корона принцессы",
  106.             "Балет",
  107.             "Бормотать",
  108.             "Не уметь свистеть",
  109.             "12 Лет",
  110.             "Целовать всех",
  111.             "Быстрый бег",
  112.             "Ежедневный душ",
  113.             "Уверенный",
  114.             "Общительный",
  115.             "Смешной",
  116.             "Дружелюбный",
  117.             "Рыбный",
  118.             "Без рубашки",
  119.             "Съесть все",
  120.             "Праздничный колпак",
  121.             "Дух",
  122.             "Нечего терять",
  123.             "Дешифратор",
  124.             "Машина времени",
  125.             "Читать мысли",
  126.             "1 Процент",
  127.             "Пыльца феи",
  128.             "Противоядие",
  129.             "Хлыст",
  130.             "Без верхней одежды",
  131.             "Полюс",
  132.             "Клеймо",
  133.             "Эмоционально подавлен",
  134.             "Проигрывать",
  135.             "Неуправляемый газ",
  136.             "Грязный",
  137.             "Наркоман",
  138.             "Галлюцинации",
  139.             "Целевой фонд",
  140.             "Волшебная палочка",
  141.             "Шляпа волшебника",
  142.             "Онлайн курсы",
  143.             "Высокие плечи",
  144.             "Развартный",
  145.             "Качок",
  146.             "Шесть пакетов",
  147.             "Пакет",
  148.             "Агрессивный",
  149.             "Холодное сердце",
  150.             "Спандекс",
  151.             "Классные штуки",
  152.             "Печальная история",
  153.             "Проблема для всех",
  154.             "Импотент",
  155.             "ЛГБТ",
  156.             "Эль дьябло",
  157.             "Дворовой рестлер",
  158.             "Остроумный стеб",
  159.             "Стероиды",
  160.             "Больной",
  161.             "Двухполярный",
  162.             "Мертвый",
  163.             "Яростный алкоголик",
  164.             "Отмазки",
  165.             "Патологический лжец",
  166.             "Диплом",
  167.             "Пояс",
  168.             "Суперсила",
  169.             "Наручники",
  170.             "Огненный меч",
  171.             "Говорящая панда",
  172.             "Дефект речи",
  173.             "Обезвредить бомбу",
  174.             "Дракон",
  175.             "Алкоголик",
  176.             "Улыбка на миллион",
  177.             "Презервативы",
  178.             "Суки",
  179.             "Эмоционально неустойчивый",
  180.             "Ром",
  181.             "Кокс",
  182.             "Подземелье",
  183.             "Мягкие ручки",
  184.             "Британский акцент",
  185.             "Зеленая карта",
  186.             "Рак",
  187.             "Мертвые родители",
  188.             "Онии Тян",
  189.             "Пафосный",
  190.             "Каннибализм",
  191.             "Разыскиваемый",
  192.             "Зек",
  193.             "Трофеи",
  194.             "Кровавый",
  195.             "Комиксы",
  196.             "Мемы"
  197.         },
  198.         used={}
  199.     }
  200. }
  201.  
  202. players={}
  203.  
  204. function eventNewPlayer(name)
  205.     tfm.exec.chatMessage('Эта комната - ремейк карточной игры "Funemployed". Этот тестовый модуль в разработке, очень много вещей склонно к багам.', name)
  206.     players[name]={
  207.         name=name,
  208.         hand={},
  209.         chat="",
  210.         justJoined = true
  211.     }
  212.     if not job then
  213.         ui.addTextArea(51,"",name,154,26,492,238,0x324650,0x212F36,1,true)
  214.     end
  215.     local player=players[name]
  216.     setupPlayer(player)
  217.     if currentPlayer and job then
  218.         playersTurn(currentPlayer)
  219.     end
  220. end
  221.  
  222. function eventPlayerLeft(name)
  223.     players[name]=nil
  224.     if name==employer then
  225.         local tbl={}
  226.         for name in pairs(players) do
  227.             table.insert(tbl,name)
  228.         end
  229.         playersTurn(tbl[math.random(#tbl)])
  230.         employersTools()
  231.     end
  232. end
  233.  
  234. function setupPlayer(player)
  235.     if #player.hand<hand then
  236.         for i=1,hand-#player.hand do
  237.             local card=randomItem(cards.traits.unused,cards.traits.used)
  238.             table.insert(player.hand,{
  239.                 text=card,
  240.                 displayed=false,
  241.                 used=false
  242.             })
  243.             table.insert(cards.traits.used,card)
  244.         end
  245.     end
  246.     for _,card in pairs(player.hand) do
  247.         card.x=nil
  248.         card.id=nil
  249.         card.displayed=false
  250.     end
  251.     for _,card in pairs(player.hand) do
  252.         displayCard(card,player)
  253.     end
  254.     ui.addTextArea(50,"Ты на интервью и пытаешься устроится на работу.\n\nКогда ваша очередь, вам нужно поговорить с работодателем, чтобы убедить его нанять вас, упомянув "..cardsPerRound.." черты характера на картах у тебя внизу.",name,8,26,132,nil,0x324650,0x212F36,1,true)
  255. end
  256.  
  257. function eventNewGame()
  258.     ui.removeTextArea(94)
  259.     ui.removeTextArea(95)
  260.     ui.removeTextArea(97)
  261.     ui.removeTextArea(98)
  262.     ui.removeTextArea(99)
  263.     ui.removeTextArea(100)
  264.     ui.removeTextArea(200)
  265.     ui.removeTextArea(210)
  266.     ui.removeTextArea(211)
  267.     ui.removeTextArea(212)
  268.     ui.addTextArea(51,"",nil,154,26,492,238,0x324650,0x212F36,1,true)
  269.     if not employer then
  270.         local tbl={}
  271.         for name in pairs(tfm.get.room.playerList) do
  272.             table.insert(tbl,name)
  273.         end
  274.         employer=tbl[math.random(#tbl)]
  275.     end
  276.     tfm.exec.setUIMapName("Работодатель: <N>"..employer.."<J>\n")
  277.  
  278.     for name,player in pairs(players) do
  279.         player.justJoined = false
  280.         player.chat="<font color='#000000'>"
  281.         player.traitsString="<b>Кандидат:</b>\n"..player.name.."\n\n"
  282.         if tfm.get.room.playerList[player.name].registrationDate then
  283.             player.traitsString=player.traitsString.."<b>Дата рождения:</b>\n"..os.date('%d/%m/%Y',tfm.get.room.playerList[player.name].registrationDate).."\n\n"
  284.         end
  285.         if tfm.get.room.playerList[player.name].tribeName then
  286.             player.traitsString=player.traitsString.."<b>Племя:</b>\n"..tfm.get.room.playerList[player.name].tribeName.."\n\n"
  287.         end
  288.         player.traitsString=player.traitsString.."<b>Черты характера:</b>\n"
  289.         player.traitsUsed=0
  290.         setupPlayer(player)
  291.         ui.addTextArea(210,"<p align='center'><font size='24'>Работодатель решает, кого он хочет нанять</font></p>",player.name,200,130,400,nil,0x000000,0x000000,0,true)
  292.     end
  293.     ui.addTextArea(50,"Ты работодатель который берет интервью у кандидатов на работу. Вы можете выбрать кандидата из списка справа.\n\nПосле кандидаты расскажут вам о  "..cardsPerRound.." своих чертах характера, вы можете решить, стоит ли их нанимать.",employer,8,26,132,nil,0x324650,0x212F36,1,true)
  294.  
  295.     randomJobs={
  296.         randomItem(cards.jobs.unused,cards.jobs.used),
  297.         randomItem(cards.jobs.unused,cards.jobs.used),
  298.         randomItem(cards.jobs.unused,cards.jobs.used)
  299.     }
  300.     if table.count(tfm.get.room.playerList)>1 then
  301.         ui.addTextArea(94,"<p align='center'>\n\nВы работодатель, вы не можете использовать свои карты в этом раунде.</p>",employer,154,320,492,100,0x324650,0x212F36,0.8,true)
  302.     end
  303.     ui.addTextArea(51,"",employer,154,26,492,280,0x324650,0x212F36,1,true)
  304.     ui.addTextArea(210,"<p align='center'><font size='24'>Я собираюсь нанять одного ...</font></p>",employer,200,34,400,nil,0x000000,0x000000,0,true)
  305.     ui.addPopup(1,2,"<p align='center'>Введите свое название работы</p>",employer,300,85,200,true)
  306.     ui.addTextArea(212,"<p align='center'>Или выберите винзу</p>",employer,300,170,200,nil,0x000000,0x000000,0,true)
  307.     for i,card in pairs(randomJobs) do
  308.         table.insert(cards.jobs.used,v)
  309.         ui.addTextArea(200+i,"<N><a href='event:job "..i.."'>"..card.."</a>",employer,136+(i*110),200,90,100,0x000001,0x000001,1,true)
  310.     end
  311. end
  312.  
  313. function eventPopupAnswer(id,name,answer)
  314.     if id==1 then
  315.         answer=encodeAngleBrackets(answer)
  316.         if #trimSpaces(answer)>0 then
  317.             job=answer
  318.             selectedJob()
  319.         else
  320.             ui.addPopup(1,2,"<p align='center'>Введите свое название работы</p>",employer,300,85,200,true)
  321.         end
  322.     end
  323. end
  324.  
  325. function eventTextAreaCallback(id,name,callback)
  326.     local args = string.split(callback, "%s")
  327.     if args[1]=="job" and tonumber(args[2]) then
  328.         job=randomJobs[tonumber(args[2])]
  329.         table.insert(cards.jobs.used,job)
  330.         selectedJob()
  331.     elseif args[1]=="switchplayer" and args[2] and players[args[2]] and (currentPlayer~=args[2]) then
  332.         playersTurn(args[2])
  333.     elseif args[1]=="hire" and args[2] and players[args[2]] then
  334.         local p=players[args[2]]
  335.         if p.traitsUsed==cardsPerRound then
  336.             tfm.exec.setPlayerScore(p.name,1,true)
  337.             tfm.exec.chatMessage(employer.." Решил нанять "..p.name.." на должность "..job)
  338.             currentPlayer=nil
  339.             employer=p.name
  340.             tfm.exec.newGame(xml)
  341.         else
  342.             tfm.exec.chatMessage(p.name.." должен рассказать вам немного больше о себе...",employer)
  343.         end
  344.     end
  345. end
  346.  
  347. function selectedJob()
  348.     ui.removeTextArea(51)
  349.     tfm.exec.setUIMapName("Работодатель: <N>"..employer.."   <BL>|   <J>Работа: <N>"..job.."\n")
  350.     for i=1,#randomJobs do
  351.         if randomJobs[i]~=job then
  352.             table.insert(cards.jobs.unused,randomJobs[i])
  353.         end
  354.         ui.removeTextArea(200+i)
  355.     end
  356.     ui.addPopup(1,0,"",nil,450,450,100,true)
  357.     ui.removeTextArea(210)
  358.     ui.removeTextArea(212)
  359.     randomJobs=nil
  360.     local tbl={}
  361.     local playerCount=table.count(tfm.get.room.playerList)
  362.     for name in pairs(players) do
  363.         if playerCount>1 then
  364.             if name~=employer then
  365.                 table.insert(tbl,name)
  366.             end
  367.         else
  368.             table.insert(tbl,name)
  369.         end
  370.     end
  371.     playersTurn(tbl[math.random(#tbl)])
  372.     employersTools()
  373.     ui.removeTextArea(51)
  374. end
  375.  
  376. function eventChatMessage(name,message)
  377.     local player=players[name]
  378.     if currentPlayer and currentPlayer==player.name then
  379.         displayChat(message,player)
  380.     end
  381. end
  382.  
  383. function eventChatCommand(name, command)
  384.     if name=="Zigwin" and command=="skip" then
  385.         tfm.exec.chatMessage(name.." пропустил текущий раунд")
  386.  
  387.         local tbl={}
  388.         for name in pairs(tfm.get.room.playerList) do
  389.             table.insert(tbl,name)
  390.         end
  391.         employer=tbl[math.random(#tbl)]
  392.  
  393.         currentPlayer=nil
  394.         tfm.exec.newGame(xml)
  395.     end
  396. end
  397.  
  398. function employersTools()
  399.     local str="<b>Выбери кандидата:</b>\n"
  400.     local playerCount=table.count(tfm.get.room.playerList)
  401.     for name,player in pairs(players) do
  402.         if not player.justJoined then
  403.             local canListEmployer=true
  404.             if playerCount>1 then
  405.                 canListEmployer=false
  406.             end
  407.             if (canListEmployer) or (not canLimstEloyer and name~=employer) then
  408.                 if currentPlayer and currentPlayer==name then
  409.                     str=str.."<J><a href='event:switchplayer "..name.."'>• "..name.."</a><N> ("..player.traitsUsed..")\n"
  410.                 else
  411.                     str=str.."<a href='event:switchplayer "..name.."'>• "..name.."</a> ("..player.traitsUsed..")\n"
  412.                 end
  413.             end
  414.         end
  415.     end
  416.     ui.addTextArea(200,str,employer,659,26,130,nil,0x324650,0x212F36,1,true)
  417. end
  418.  
  419. function playersTurn(name)
  420.     local player=players[name]
  421.     if player and not player.justJoined then
  422.         if currentPlayer~=player.name then
  423.             tfm.exec.chatMessage("Это ваша очередь, чтобы пройти собеседование!",player.name)
  424.         end
  425.         currentPlayer=player.name
  426.         employersTools()
  427.         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)
  428.         ui.addTextArea(98,"",nil,154,65,342,200,0xFFFFFF,0x212F36,1,true)
  429.         ui.addTextArea(99,"<p align='center'><font color='#cccccc'>"..string.rep("_",1000).."</font></p>",nil,150,65,350,200,0x324650,0x212F36,0,true)
  430.         ui.addTextArea(100,player.chat,nil,154,65,346,200,0xFFFFFF,0x212F36,0,true)
  431.         ui.addTextArea(97,player.traitsString,nil,500,65,146,200,0x324650,0x212F36,1,true)
  432.         ui.addTextArea(211,"<p align='center'><a href='event:hire "..player.name.."'>Нанять\n</a></p>",employer,500,245,146,20,0x324650,0x212F36,1,true)
  433.     end
  434. end
  435.  
  436. function randomItem(tbl,tbl2)
  437.     if #tbl==0 then
  438.         for k,v in pairs(tbl2) do
  439.             tbl[k]=v
  440.         end
  441.         for i=1,#tbl2 do
  442.             tbl2[i]=nil
  443.         end
  444.     end
  445.     local i=math.random(#tbl)
  446.     local item=tbl[i]
  447.     table.remove(tbl,i)
  448.     return item
  449. end
  450.  
  451. function string.split(str,s)
  452.     if not str then
  453.         return nil
  454.     end
  455.     local res = {}
  456.     for part in string.gmatch(str, "[^" .. s .. "]+") do
  457.         table.insert(res, part)
  458.     end
  459.     return res
  460. end
  461.  
  462. function displayCard(card,player)
  463.     local i=1
  464.     for _,c in pairs(player.hand) do
  465.         if c.displayed then
  466.             i=i+1
  467.         end
  468.     end
  469.     local x=card.x and card.x or 54+(i*100)
  470.     local y=card.used and 300 or 320
  471.     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)
  472.     card.displayed=true
  473.     card.id=100+i
  474.     card.x=x
  475. end
  476.  
  477. function displayChat(text,player)
  478.     local used={}
  479.     for i,card in pairs(player.hand) do
  480.         local found = string.find(text:lower(),card.text:lower())
  481.         if player.traitsUsed<cardsPerRound and found and not card.used then
  482.             local str=""
  483.             str=str..text:sub(1,found-1)
  484.             str=str.."<font color='#324650'><b>"..text:sub(found,found+#card.text-1).."</font></b><font color='#000000'>"
  485.             str=str..text:sub(found+#card.text)
  486.             text=str
  487.             card.used=true
  488.             displayCard(card,player)
  489.             player.traitsString=player.traitsString.." • "..card.text.."\n"
  490.             ui.updateTextArea(97,player.traitsString)
  491.             player.traitsUsed=player.traitsUsed+1
  492.             playersTurn(player.name)
  493.             employersTools()
  494.         end
  495.     end
  496.  
  497.     local t={}
  498.     for i,card in pairs(player.hand) do
  499.         if card.used then
  500.             table.insert(t,1,i)
  501.         end
  502.     end
  503.     if #t==cardsPerRound then
  504.         for k,v in pairs(t) do
  505.             table.remove(player.hand,v)
  506.         end
  507.     end
  508.  
  509.     player.chat=player.chat..text.."\n"
  510.     ui.updateTextArea(100,player.chat)
  511. end
  512.  
  513. function table.count(tbl)
  514.     local i=0
  515.     for k,v in pairs(tbl) do
  516.         i=i+1
  517.     end
  518.     return i
  519. end
  520.  
  521. function sortScores()
  522.     local tbl={}
  523.     for k,v in pairs(tfm.get.room.playerList) do
  524.         table.insert(tbl,{name=v.playerName,score=v.score})
  525.     end
  526.     table.sort(tbl,function(i,v) return i.score>v.score end)
  527.     return tbl
  528. end
  529.  
  530. function trimSpaces(str)
  531.   return str:gsub(" ","")
  532. end
  533.  
  534. function encodeAngleBrackets(str)
  535.     return str:gsub("<","&lt;"):gsub(">","&gt;")
  536. end
  537.  
  538. for name,player in pairs(tfm.get.room.playerList) do
  539.     eventNewPlayer(name)
  540. end
  541. tfm.exec.disableAutoTimeLeft(true)
  542. tfm.exec.disableAutoNewGame(true)
  543. tfm.exec.disableAutoScore(true)
  544. tfm.exec.disableAfkDeath(true)
  545. tfm.exec.disableAutoShaman(true)
  546. tfm.exec.newGame(xml)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement