Advertisement
Math_TM

Loups-Garous V1.3

Oct 9th, 2016
4,389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 24.46 KB | None | 0 0
  1. --[         Loups-Garous         ]--
  2. --[  Module crée par Athesdrake  ]--
  3. --[ lien: https://goo.gl/QoTSmW  ]--
  4.  
  5. transparence = 0.75 --[[transparence des zones de textes]] --À Changer par un chiffre entre 0 et 1 (0 = transparent, 1 = opaque)
  6.  
  7. changeLesNoms = {
  8.     voyante =    {"Voyante", "La"},
  9.     loup_garou = {"Loup$ Garou$", "Le"}, -- mettez "$" aux endroits où il faut un "s" au pluriel. (ne fonctionne que pour ce rôle)
  10.     villageois = {"Villageois", "Le"},
  11.     sorciere =   {"Sorcière", "La"},
  12.     cupidon =    {"Cupidon", "Le"},
  13.     chasseur =   {"Chasseur", "Le"},
  14.     salvateur =  {"Salvateur", "Le"},
  15.     voleur =     {"Voleur", "Le"},
  16.     costaud =    {"Costaud", "Le"}
  17. }
  18.  
  19. function main()
  20. --vars:
  21.     play = true
  22.     speak = false
  23.     TIME = 0
  24.     mapName = "<VP>Loups-Garous<BL> | <N>Temps: <V>%ds</V><BL> | <N>Souris: <V>%d<N>/<V>%d<N> (<PT>%d<N>, <R>%d<N>)<BL> | <N>Créateur: <BV>Athesdrake\n"
  25. --ids:
  26.     idHaut = 1
  27.     idRole = 2
  28.     idChoser = 3
  29.     idTimer = 4
  30.     idPlay = 5
  31.     idLovers = 6
  32.     idChat = 7
  33. --tables:
  34.     task = {}
  35.     players = {}
  36.     plNbr = {}
  37.     want2Play = {}
  38.     jeu = {}
  39.     roles = {"Voyante", "Loup$ Garou$", "Simple Villageois", "Sorcière", "Cupidon", "Chasseur", "Salvateur", "Voleur", "Costaud"}
  40.     game = {}
  41.         game[6] = {1,2,2,1}
  42.         game[7] = {1,2,2,1,1}
  43.         game[8] = {1,2,2,1,1,1}
  44.         game[9] = {1,2,2,1,1,1,1}
  45.     T = {
  46.         events = {
  47.             night = "La nuit tombe, tout le village s'endort.",
  48.             thief = "%s %s se réveille, vole quelqu'un et se rendort.\nVérifiez votre carte après son tour !!!",
  49.             cupid = "%s %s se réveille, choisis deux amoureux et se rendort.",
  50.             lovers = "Les amoureux se réveillent, se reconnaisent, se font des bisous et se rendorment.",
  51.             seer = "%s %s se réveille, regarde la face cachée de quelqu'un et se rendort.",
  52.             saving = "%s %s se réveille, protège quelqu'un et se rendort.",
  53.             werewolf = "Les %s se réveillent, choisissent leur victime et se rendorment, le ventre plein.",
  54.             witch = "%s %s se réveille, choisis de réssuciter le mort, ou de tuer quelqu'un et se rendort.",
  55.             vote = "Choissisez la personne à mettre au bûcher !",
  56.             hunter = "%s %s choisis sa cible !",
  57.         },
  58.         win = "Les %s ont gagnés !"
  59.     }
  60. --sytème:
  61.     for pl in pairs(tfm.get.room.playerList) do
  62.         eventNewPlayer(pl)
  63.     end
  64.     for k, v in pairs({"start", "t"}) do
  65.         system.disableChatCommandDisplay(v, true)
  66.     end
  67. end
  68.  
  69. function eventNewPlayer(name)
  70.     ui.addPopup(idPlay, 1, "<p align='center'>Veux-tu jouer au Loup-Garou ?", name, 350, 175, nil, true)
  71.     players[name] = {isPlaying = false, play = false}
  72.     tfm.lg.map()
  73. end
  74.  
  75. function eventPlayerLeft(name)
  76.     if players[name].isPlaying then
  77.         for k, v in pairs(plNbr) do
  78.             if v==name then
  79.                 table.remove(plNbr, k)
  80.                 break
  81.             end
  82.         end
  83.         players[name].isPlaying = false
  84.         local txt = tfm.lg.dead(name, "<ROSE>"..name.."</ROSE> a quitté le salon. C'était un "..roles[players[name].jeu.role].." !")
  85.         ui.msg(txt)
  86.         if tfm.lg.win() then
  87.             for k, v in ipairs(task) do
  88.                 task[k].finish = true
  89.             end
  90.             tfm.lg.task(3, "win")
  91.         end
  92.     end
  93.     tfm.lg.map()
  94. end
  95.  
  96. function eventNewGame() tfm.lg.map() end
  97.  
  98. function eventChatCommand(name, cmd)
  99.     if cmd=="start" and play then
  100.         if (not pcall(setRolesNames)) then
  101.             error("<R>La table \'changeLesNoms\' est obselète!</R>")
  102.         end
  103.         if #want2Play>5 then
  104.             task = {}
  105.             play = false
  106.             jeu = {roles={0,0,0,0,0,0,0,0,0}}
  107.             local r = {}
  108.             if game[#want2Play]~=nil then
  109.                 for k, v in pairs(game[#want2Play]) do
  110.                     r[k] = v
  111.                 end
  112.             else
  113.                 r = {1,3,2,1,1,1,1,1,1}
  114.                 r[2] = #want2Play/4
  115.                 r[3] = #want2Play-(r[2]+7)
  116.             end
  117.             math.randomseed(os.time())
  118.             for i=1, #want2Play do
  119.                 local pl = nil
  120.                 repeat
  121.                     pl = want2Play[math.random(#want2Play)]
  122.                 until players[pl].isPlaying==false
  123.                 local ran = 0
  124.                 local objectif = "Tues tous les Loups-Garous !"
  125.                 repeat
  126.                     ran = math.random(#r)
  127.                 until r[ran]~=0
  128.                 if ran==2 then
  129.                     objectif = "Tues tous les Villageois !"
  130.                 end
  131.                 r[ran] = r[ran] - 1
  132.                 table.insert(plNbr, pl)
  133.                 jeu.roles[ran] = jeu.roles[ran] + 1
  134.                 players[pl].jeu = {}
  135.                 players[pl].jeu.role = ran
  136.                 players[pl].isPlaying = true
  137.                 ui.role(pl, roles[ran], objectif)
  138.             end
  139.             tfm.lg.tour("ini")
  140.         else
  141.             ui.msg("Il n'y a pas assez de joueurs!\nIl faut minimum <J>6</J> joueurs!")
  142.         end
  143.     end
  144.     if string.lower(cmd:sub(0,1))=="t" and speak and players[name].jeu.role~=nil and players[name].jeu.role==2 and players[name].mort then
  145.         jeu.chat = "["..name.."] "..((cmd:sub(3)):gsub("&lt;"..".-".."&gt;", "")):gsub("%c", "").."\n"..jeu.chat
  146.         for k, v in pairs(plNbr) do
  147.             if players[v].jeu.role==2 then
  148.                 ui.chat(v)
  149.             end
  150.         end
  151.     end
  152. end
  153.  
  154. function eventTextAreaCallback(id, name, call)
  155.     if call:sub(1,5)=="steal" then
  156.         players[name].choose = true
  157.         players[name].jeu.role = players[call:sub(6)].jeu.role
  158.         players[call:sub(6)].jeu.role = 1
  159.         ui.role(name, roles[players[name].jeu.role], players[name].jeu.role==2 and "Tues tous les Villageois !" or "Tues tous les Loups-Garous !")
  160.         ui.role(call:sub(6), "Simple Villageois", "Tues tous les Loups-Garous !")
  161.     end
  162.     if call:sub(1,6)=="lovers" then
  163.         name2 = call:sub(7)
  164.         local nbr = (players[name].amour[1]==nil and 1) or (players[name].amour[2]==nil and 2) or nil
  165.         if nbr~=nil and players[name].amour[1]~=name2 then
  166.             players[name].amour[nbr] = name2
  167.             players[name].jeu.texte = string.gsub(players[name].jeu.texte, "%s"..name2, " "..name2.."("..nbr..")")
  168.             ui.choser(players[name].jeu.texte, name)
  169.         end
  170.     end
  171.     if call:sub(1,4)=="seer" then
  172.         ui.choser(call:sub(5).." est un(e) "..roles[players[call:sub(5)].jeu.role], name)
  173.     end
  174.     if call:sub(1,6)=="saving" then
  175.         players[name].lastProtect = call:sub(7)
  176.         players[call:sub(7)].isProtect = true
  177.         ui.choser("Tu protèges "..call:sub(7).." pour la nuit !", name)
  178.     end
  179.     if call:sub(1,8)=="werewolf" then
  180.         local name2 = call:sub(9)
  181.         if jeu.vote[name2]==nil then
  182.             jeu.vote[name2] = 1
  183.         else
  184.             jeu.vote[name2] = jeu.vote[name2] + 1
  185.         end
  186.         jeu.txt = jeu.txt:gsub(name2.."%(".."%d".."%)", name2.."("..tostring(jeu.vote[name2])..")")
  187.         if players[name].vote~=nil then
  188.             jeu.vote[players[name].vote] = jeu.vote[players[name].vote] - 1
  189.             jeu.txt = jeu.txt:gsub(players[name].vote.."%(".."%d".."%)", players[name].vote.."("..jeu.vote[players[name].vote]..")")
  190.         end
  191.         players[name].vote = name2
  192.         for k, v in pairs(plNbr) do
  193.             if players[v].jeu.role==2 and players[v].mort then
  194.                 ui.choser(jeu.txt, v)
  195.             end
  196.         end
  197.     end
  198.     if call:sub(1,4)=="vote" then
  199.         local name2 = call:sub(5)
  200.         if jeu.vote[name2]==nil then
  201.             jeu.vote[name2] = 1
  202.         else
  203.             jeu.vote[name2] = jeu.vote[name2] + 1
  204.         end
  205.         --jeu.txt = jeu.txt:gsub(name.."%(%d%)%→%S+", name.."("..(jeu.vote[name] and jeu.vote[name] or "0")..")→"..name2 )
  206.         --jeu.txt = jeu.txt:gsub(name2.."%(%d%)", name2.."("..tostring(jeu.vote[name2])..")")
  207.         if players[name].vote and jeu.vote[players[name].vote]  then
  208.             jeu.vote[players[name].vote] = jeu.vote[players[name].vote] - 1
  209.         end
  210.         players[name].vote = name2
  211.         for k,v in pairs(plNbr) do
  212.             if players[v].mort then
  213.                 jeu.txtVote[v] = string.format("<a href='event:vote%s'>%s</a>(%d)→%s\n", v, v, jeu.vote[v] and jeu.vote[v] or 0, players[v].vote and players[v].vote or "personne")
  214.             end
  215.         end
  216.         local txt = ""
  217.         for k,v in pairs(jeu.txtVote) do txt = txt..v end
  218.         for k, v in pairs(plNbr) do
  219.             if players[v].mort then
  220.                 ui.choser(txt, v, false, true)
  221.             else
  222.                 ui.choser(txt, v, true, true)
  223.             end
  224.         end
  225.     end
  226.     if call:sub(1,4)=="kill" then
  227.         players[name].kill = call:sub(5)
  228.         table.insert(jeu.mort, call:sub(5))
  229.         ui.choser(call:sub(5).." bois ta potion et meurt dans d'atroces souffrances !", name)
  230.     end
  231.     if call:sub(1,4)=="hunt" then
  232.         jeu.mort[1] = call:sub(5)
  233.         ui.choser("Tu tires sur "..call:sub(5).." en pleine tête", name)
  234.     end
  235. end
  236.  
  237. function eventPopupAnswer(id, name, ans)
  238.     if id==idPlay and ans=="yes" then
  239.         if (not play) then
  240.             ui.addPopup(idPlay, 0, "Tu dois attendre la prochaine partie pour jouer", name, 350, 175, nil, true)
  241.         end
  242.         players[name].play = true
  243.         players[name].mort = true
  244.         table.insert(want2Play, name)
  245.         tfm.lg.map()
  246.     end
  247.     if id==idChoser then
  248.         if ans=="yes" then
  249.             ressu = true
  250.             players[name].rez = ""
  251.         else
  252.             ui.addPopup(idTimer, 1, "Veux-tu tuer quelqu'un ?", name, 350, 175, nil, true)
  253.         end
  254.     end
  255.     if id==idTimer then
  256.         local txt = ""
  257.         for k, v in pairs(plNbr) do
  258.             if players[v].mort then
  259.                 txt = txt.."<a href='event:kill"..v.."'>"..v.."</a>\n"
  260.             end
  261.         end
  262.         players[name].txt = txt
  263.         ui.addTextArea(idChoser, txt, name, 620, 110, 180, nil, 0x8C3232, 0x131A2A, transparence, true)
  264.     end
  265. end
  266.  
  267. function eventLoop(t1, t2)
  268.     for k, v in ipairs(task) do
  269.         local tbl = task[k]
  270.         TIME = math.ceil(os.difftime(tbl.time,os.time())/1000)
  271.         tfm.lg.map()
  272.         if tbl.timer then
  273.             ui.addTextArea(idTimer, TIME, all, 740, 45, nil, nil, 0, 0, 0, true)
  274.         end
  275.         if tbl.time<=os.time() or tbl.finish then
  276.             ui.removeTextArea(idTimer)
  277.             if tbl.txtArea then
  278.                 ui.removeTextArea(tbl.id, tbl.name)
  279.             end
  280.             if (not tbl.finish) then
  281.                 tfm.lg.tour(tbl.tour, tbl.last, tbl.name)
  282.             end
  283.             table.remove(task, k)
  284.         end
  285.     end
  286. end
  287.  
  288. function setRolesNames()
  289.     if changeLesNoms~=nil and type(changeLesNoms)=="table" then
  290.         local tbl = changeLesNoms
  291.         T.events.seer = string.format(T.events.seer, tbl.voyante~=nil and (tbl.voyante~=nil and (tbl.voyante[2]~=nil and tbl.voyante[2] or "La")) or "La", tbl.voyante[1]~=nil and tbl.voyante[1] or "Voyante" or "Voyante")
  292.         T.events.werewolf = string.format(T.events.werewolf, tbl.loup_garou~=nil and (tbl.loup_garou[1]~=nil and tbl.loup_garou[1]:gsub("%$", "s") or "Loups Garous") or "Loups Garous")
  293.         T.events.witch = string.format(T.events.witch, tbl.sorciere~=nil and (tbl.sorciere~=nil and (tbl.sorciere[2]~=nil and tbl.sorciere[2] or "La")) or "La", tbl.sorciere[1]~=nil and tbl.sorciere[1] or "Sorcière" or "Sorcière")
  294.         T.events.cupid = string.format(T.events.cupid, tbl.cupidon~=nil and (tbl.cupidon~=nil and (tbl.cupidon[2]~=nil and tbl.cupidon[2] or "Le")) or "Le", tbl.cupidon[1]~=nil and tbl.cupidon[1] or "Cupidon" or "Cupidon")
  295.         T.events.hunter = string.format(T.events.hunter, tbl.chasseur~=nil and (tbl.chasseur~=nil and (tbl.chasseur[2]~=nil and tbl.chasseur[2] or "Le")) or "Le", tbl.chasseur[1]~=nil and tbl.chasseur[1] or "Chasseur" or "Chasseur")
  296.         T.events.saving = string.format(T.events.saving, tbl.salvateur~=nil and (tbl.salvateur~=nil and (tbl.salvateur[2]~=nil and tbl.salvateur[2] or "Le")) or "Le", tbl.salvateur[1]~=nil and tbl.salvateur[1] or "Salvateur" or "Salvateur")
  297.         T.events.thief = string.format(T.events.thief, tbl.voleur~=nil and (tbl.voleur~=nil and (tbl.voleur[2]~=nil and tbl.voleur[2] or "Le")) or "Le", tbl.voleur[1]~=nil and tbl.voleur[1] or "Voleur" or "Voleur")
  298.        
  299.         roles[1] = tbl.voyante~=nil and (tbl.voyante[1]~=nil and tbl.voyante[1] or roles[1]) or roles[1]
  300.         roles[2] = tbl.loup_garou~=nil and (tbl.loup_garou[1]~=nil and tbl.loup_garou[1]:gsub("%$", "") or roles[2]) or roles[2]
  301.         roles[3] = tbl.villageois~=nil and (tbl.villageois[1]~=nil and tbl.villageois[1] or roles[3]) or roles[3]
  302.         roles[4] = tbl.sorciere~=nil and (tbl.sorciere[1]~=nil and tbl.sorciere[1] or roles[4]) or roles[4]
  303.         roles[5] = tbl.cupidon~=nil and (tbl.cupidon[1]~=nil and tbl.cupidon[1] or roles[5]) or roles[5]
  304.         roles[6] = tbl.chasseur~=nil and (tbl.chasseur[1]~=nil and tbl.chasseur[1] or roles[6]) or roles[6]
  305.         roles[7] = tbl.salvateur~=nil and (tbl.salvateur[1]~=nil and tbl.salvateur[1] or roles[7]) or roles[7]
  306.         roles[8] = tbl.voleur~=nil and (tbl.voleur[1]~=nil and tbl.voleur[1] or roles[8]) or roles[8]
  307.         roles[9] = tbl.costaud~=nil and (tbl.costaud[1]~=nil and tbl.costaud[1] or roles[9]) or roles[9]
  308.     end
  309. end
  310.  
  311. function findKey(value, tbl)
  312.     for k,v in next, tbl do
  313.         if value==v then
  314.             return k
  315.         end
  316.     end
  317.     return false
  318. end
  319.  
  320. function nbrSouris()
  321.     local nbr = 0
  322.     for k,v in pairs(tfm.get.room.playerList) do
  323.         nbr = nbr +1
  324.     end
  325.     return nbr
  326. end
  327.  
  328. ui.msg = function(txt)
  329.     ui.addTextArea(idHaut, "<p align='center'>"..txt.."</p>", name, 15, 28, 770, 50, 0x8C3232, 0x131A2A, transparence, true)
  330. end
  331.  
  332. ui.role = function(name, role, obj)
  333.     ui.addTextArea(idRole, "<font size='16' color='#131a2a'>Tu es: </font><font size='16'>"..role.."</font>\n<p align='center'><font size='8'><b>"..(obj==name and ("Tu étais: "..roles[players[name].jeu.role]) or "Objectif: "..obj), name, 15, 350, 220, 50, 0x8C3232, 0x131A2A, transparence, true)
  334. end
  335.  
  336. ui.choser = function(txt, name, bool, display)
  337.     ui.addTextArea(idChoser, (bool and txt:gsub("href", "color") or txt), name, (display and 560 or 670), 86, (display and 225 or 115), nil, 0x8C3232, 0x131A2A, transparence, true)
  338. end
  339.  
  340. ui.chat = function(name)
  341.     ui.addTextArea(idChat, "<J>!t message</J><BL> pour parler avec les loups-garous</BL>\n"..jeu.chat, name, 15, 86, 200, 228, 0x8c3232, 0x131a2a, tonumber(transparence)/1.5, true)
  342. end
  343.  
  344. tfm.lg = {
  345.     dead = function(name, mort)
  346.         local role, txt, hunter, cos = players[name].jeu.role, mort, players[name].jeu.role==6, players[name].jeu.role==9
  347.         if cos and players[name].life==nil then
  348.             players[name].life = 1
  349.             return  txt, false;
  350.         end
  351.         players[name].mort = false
  352.         jeu.roles[role] = jeu.roles[role] - 1
  353.         ui.role(name, "mort", name)
  354.         if jeu.amour~=nil and jeu.amour[1]~=nil then
  355.             local tbl = jeu.amour
  356.             if (name==tbl[1] and players[tbl[2]].mort) or (name==tbl[2] and players[tbl[1]].mort) then
  357.                 local name2 = name==tbl[1] and tbl[2] or tbl[1]
  358.                 tfm.lg.dead(name2)
  359.                 txt = txt.."\n"..name2.." meurt de chagrin après avoir perdu son aimé(e). "..name2.." était "..roles[players[name2].jeu.role].." !"
  360.             end
  361.         end
  362.         return txt, hunter
  363.     end,
  364.  
  365.     plDead = function()
  366.         local nbr = 0
  367.         for k,v in pairs(plNbr) do
  368.             if (not players[v].mort) then
  369.                 nbr = nbr +1
  370.             end
  371.         end
  372.         return nbr
  373.     end,
  374.  
  375.     tour = function(tour, lastTour, name)
  376.         if lastTour~=nil then
  377.             if lastTour=="thief" then
  378.                 if players[name] and players[name].choose==nil then
  379.                     jeu.roles[8] = 0
  380.                     jeu.roles[3] = jeu.roles[3] + 1
  381.                 end
  382.             end
  383.             if lastTour=="cupid" then
  384.                 if players[name].amour[2]==nil then
  385.                     tour = "daily"
  386.                 else
  387.                     jeu.amour = {}
  388.                     jeu.amour[1] = players[name].amour[1]
  389.                     jeu.amour[2] = players[name].amour[2]
  390.                     jeu.roles[5] = 0
  391.                     jeu.roles[3] = jeu.roles[3] + 1
  392.                     ui.role(name, "Simple Villageois", "Tues tous les Loups-Garous !")
  393.                 end
  394.             end
  395.             if lastTour=="witch" then
  396.                 ui.addPopup(idTimer,2,"",name,1e7,1e7)
  397.                 ui.addPopup(idChoser,2,"",name,1e7,1e7)
  398.             end
  399.             if lastTour=="werewolf" then
  400.                 speak = true
  401.                 local last = 0
  402.                 local mort = ""
  403.                 for k, v in pairs(jeu.vote) do
  404.                     if v~=nil and v~="" and v>last then
  405.                         last = v
  406.                         mort = k
  407.                     end
  408.                 end
  409.                 if mort=="" then
  410.                     jeu.mort = {}
  411.                 else
  412.                     jeu.mort = {mort}
  413.                 end
  414.                 jeu.vote = {}
  415.             end
  416.             if lastTour=="vote" then
  417.                 local last = 0
  418.                 local mort = ""
  419.                 local tbl = {}
  420.                 local nbr = 0
  421.                 for k, v in pairs(plNbr) do
  422.                     if players[v].mort then
  423.                         nbr = nbr + 1
  424.                     end
  425.                 end
  426.                 for k,v in pairs(jeu.vote) do
  427.                     if v~=nil and v~="" and v>last then
  428.                         last = v
  429.                         mort = k
  430.                         tbl = {k}
  431.                     elseif v==last then
  432.                         table.insert(tbl, k)
  433.                     end
  434.                 end
  435.                 if mort=="" then
  436.                     jeu.mort = {}
  437.                 elseif #tbl>1 and (#plNbr%2)~=0 then
  438.                     if nbr==2 then
  439.                         jeu.mort = {mort}
  440.                     else
  441.                         tour = "vote"
  442.                     end
  443.                 else
  444.                     jeu.mort = {mort}
  445.                 end
  446.                 jeu.vote = {}
  447.             end
  448.         end
  449.         if tour~=nil then
  450.             if tour=="ini" then
  451.                 jeu.mort = {""}
  452.                 jeu.amour = {""}
  453.                 jeu.vote = {""}
  454.                 jeu.chat = ""
  455.                 for k, v in pairs(plNbr) do
  456.                     players[v].mort = true
  457.                 end
  458.                 tfm.lg.task(2, "night")
  459.             end
  460.             if tour=="night" then
  461.                 for _, pl in pairs(plNbr) do
  462.                     players[pl].isProtect = false
  463.                 end
  464.                 ui.msg(T.events[tour])
  465.                 tfm.lg.task(2, "thief", tour)
  466.             end
  467.             if tour=="thief" then
  468.                 if jeu.roles[8]==1 then
  469.                     local txt = "Prends la carte de:"
  470.                     local pl = ""
  471.                     for k, v in pairs(plNbr) do
  472.                         if players[v].jeu.role==8 and players[v].mort then
  473.                             pl = v
  474.                         elseif players[v].mort then
  475.                             txt = txt.."\n<a href='event:steal"..v.."'>"..v.."</a>"
  476.                         end
  477.                     end
  478.                     ui.choser(txt, pl)
  479.                     ui.msg(T.events[tour])
  480.                     tfm.lg.task(10, "cupid", tour, true, true, idChoser, pl)
  481.                 else
  482.                     tour = "cupid"
  483.                 end
  484.             end
  485.             if tour=="cupid" then
  486.                 if jeu.roles[5]==1 then
  487.                     local txt = "Choisis les deux amoureux:"
  488.                     local pl = ""
  489.                     for k, v in pairs(plNbr) do
  490.                         if players[v].mort then
  491.                             txt = txt.."\n<a href='event:lovers"..v.."'> "..v.."</a>"
  492.                             if players[v].jeu.role==5 then
  493.                                 pl = v
  494.                                 players[v].amour = {}
  495.                             end
  496.                         end
  497.                     end
  498.                     players[pl].jeu.texte = txt
  499.                     ui.choser(txt, pl)
  500.                     ui.msg(T.events[tour])
  501.                     tfm.lg.task(20, "lovers", tour, true, true, idChoser, pl)
  502.                 else
  503.                     tour = "daily"
  504.                 end
  505.             end
  506.             if tour=="lovers" then
  507.                 for i=1, 2 do
  508.                     ui.addTextArea(idLovers, "<font size='12' color='#131a2a'>Ton ame-soeur: "..jeu.amour[i], jeu.amour[i==1 and 2 or 1], 6, 322, nil, 20, 0x8C3232, 0x131A2A, transparence, true)
  509.                 end
  510.                 ui.msg(T.events[tour])
  511.                 tfm.lg.task(10, "daily", tour, true)
  512.             end
  513.             if tour=="daily" then
  514.                 if jeu.roles[1]==1 or jeu.roles[7]==1 then
  515.                     local txt2 = "Personne à protéger:"
  516.                     local txt = "Personne à dévoiler:"
  517.                     local pl, pl2, msg
  518.                     for k, v in pairs(plNbr) do
  519.                         if players[v].mort then
  520.                             if players[v].jeu.role==1 then
  521.                                 pl = v
  522.                             else
  523.                                 txt = txt.."\n<a href='event:seer"..v.."'>"..v.."</a>"
  524.                             end
  525.                             txt2 = txt2.."\n<a href='event:saving"..v.."'>"..v.."</a>"
  526.                             if players[v].jeu.role==7 then
  527.                                 pl2 = v
  528.                             end
  529.                         end
  530.                     end
  531.                     if pl and pl2 then
  532.                         msg = T.events.seer.."\n"..T.events.saving
  533.                         ui.choser(txt, pl)
  534.                         ui.choser(txt2, pl2)
  535.                     elseif pl then
  536.                         msg = T.events.seer
  537.                         ui.choser(txt, pl)
  538.                     else
  539.                         msg = T.events.saving
  540.                         ui.choser(txt2, pl2)
  541.                     end
  542.                     ui.msg(msg)
  543.                     tfm.lg.task(20, "werewolf", tour, true, true, idChoser)
  544.                 else
  545.                     tour = "werewolf"
  546.                 end
  547.             end
  548.             if tour=="werewolf" then
  549.                 jeu.mort = {}
  550.                 speak = true
  551.                 for k, v in pairs(plNbr) do
  552.                     players[v].vote = nil
  553.                 end
  554.                 local werewolf, txt = {}, "Personne à manger:"
  555.                 for k, v in pairs(plNbr) do
  556.                     if players[v].jeu.role==2 and players[v].mort then
  557.                         table.insert(werewolf, v)
  558.                     elseif players[v].mort then
  559.                         txt = txt.."\n<a href='event:werewolf"..v.."'>"..v.."(0)</a>"
  560.                     end
  561.                 end
  562.                 jeu.txt = txt
  563.                 for k, v in pairs(plNbr) do
  564.                     if players[v].jeu.role==2 and players[v].mort then
  565.                         ui.choser(txt, v)
  566.                         ui.chat(v)
  567.                     end
  568.                 end
  569.                 ui.msg(T.events[tour])
  570.                 tfm.lg.task(45, "witch", tour, true, true, idChoser)
  571.             end
  572.             if tour=="witch" then
  573.                 if jeu.roles[4]==1 then
  574.                     for k, v in pairs(plNbr) do
  575.                         if players[v].jeu.role==4 then
  576.                             if jeu.mort[1]~=nil and players[v].rez==nil then
  577.                                 ui.addPopup(idChoser, 1, "Veux-tu réssuciter <VI>"..jeu.mort[1].."</VI>?", v, 350, 175, nil, true)
  578.                             elseif players[v].kill==nil then
  579.                                 ui.addPopup(idTimer, 1, "Veux-tu tuer quelqu'un ?", v, 350, 175, nil, true)
  580.                             else
  581.                                 tour = "dead"
  582.                                 break;
  583.                             end
  584.                             ui.msg(T.events[tour])
  585.                             tfm.lg.task(15, "dead", tour, true, true, idChoser, v) 
  586.                         end
  587.                     end
  588.                 else
  589.                     tour = "dead"
  590.                 end
  591.             end
  592.             if tour=="vote" then
  593.                 jeu.txtVote, jeu.mort = {}, {}
  594.                 for k, v in pairs(plNbr) do
  595.                     players[v].vote = nil
  596.                 end
  597.                 local txt = ""
  598.                 for k, v in pairs(plNbr) do
  599.                     if players[v].mort then
  600.                         jeu.txtVote[v] = string.format("<a href='event:vote%s'>%s</a>(%d)→%s\n", v, v, jeu.vote[v] and jeu.vote[v] or 0, "personne")
  601.                     end
  602.                 end
  603.                 for k,v in pairs(jeu.txtVote) do txt = txt..v end
  604.                 for k, v in pairs(plNbr) do
  605.                     if players[v].mort then
  606.                         ui.choser(txt, v, false, true)
  607.                     else
  608.                         ui.choser(txt, v, true, true)
  609.                     end
  610.                 end
  611.                 ui.msg(T.events[tour])
  612.                 tfm.lg.task(10*(#plNbr-tfm.lg.plDead()), "bucher", tour, true, true, idChoser)
  613.             end
  614.             if tour=="dead" then
  615.                 local txt, hunter = "Le village se réveille, "
  616.                 if jeu.mort==nil or ressu or jeu.mort[1]==nil or jeu.mort=={} then
  617.                     txt = txt.."sans victimes !"
  618.                     ressu = false
  619.                     ui.msg(txt)
  620.                     tfm.lg.task(15, tfm.lg.win() and "win" or "vote", tour)
  621.                 else
  622.                     for k, v in pairs(jeu.mort) do
  623.                         if (not players[v].isProtect) then
  624.                             txt, hunter = tfm.lg.dead(v, txt.."sans <ROSE>"..v.."</ROSE> qui était "..roles[players[v].jeu.role].." !!\n")
  625.                         end
  626.                     end
  627.                     jeu.mort = {}
  628.                     ui.msg(txt)
  629.                     if hunter then
  630.                         tfm.lg.task(15, tfm.lg.win() and "win" or "hunter", "mort")
  631.                     else
  632.                         tfm.lg.task(15, tfm.lg.win() and "win" or "vote", tour)
  633.                     end
  634.                 end
  635.             end
  636.             if tour=="bucher" then
  637.                 local txt, hunter = "Le village fait brûler "
  638.                 if jeu.mort[1]==nil then
  639.                     txt = "Personne ne vas au bûcher !"
  640.                 else
  641.                     for k, v in pairs(jeu.mort) do
  642.                         txt, hunter = tfm.lg.dead(v, tostring(txt).."<ROSE>"..v.."</ROSE> qui était "..tostring(roles[players[v].jeu.role]).." !!\n")
  643.                     end
  644.                     jeu.mort = {}
  645.                     ui.msg(txt)
  646.                     if hunter then
  647.                         tfm.lg.task(15, tfm.lg.win() and "win" or "hunter", "feu")
  648.                     else
  649.                         tfm.lg.task(15, tfm.lg.win() and "win" or "night", tour)
  650.                     end
  651.                 end
  652.             end
  653.             if tour=="win" then
  654.                 local txt = "ERROR"
  655.                 if tfm.lg.win()=="no" then
  656.                     txt = "Personne n'a survécu !"
  657.                 else
  658.                     local tbl = {}
  659.                     txt = T.win:format(tfm.lg.win()).."\n Bravo à <ROSE>"
  660.                     for k, v in pairs(plNbr) do
  661.                         if players[v].mort then
  662.                             table.insert(tbl, v)
  663.                         end
  664.                     end
  665.                     for k, v in pairs(tbl) do
  666.                         if k==#tbl then
  667.                             txt = txt..v.."</ROSE>!"
  668.                         elseif k==#tbl-1 then
  669.                             txt = txt..v.."</ROSE> et <ROSE>"
  670.                         else
  671.                             txt = txt..v.."</ROSE>, <ROSE>"
  672.                         end
  673.                     end
  674.                 end
  675.                 ui.msg(txt)
  676.             end
  677.             if tour=="hunter" then
  678.                 local txt, pl = "Choisis la personne que tu veux tuer:"
  679.                 for k, v in pairs(plNbr) do
  680.                     if players[v].jeu.role==6 then
  681.                         pl = v
  682.                     elseif players[v].mort then
  683.                         txt = txt.."\n<a href='event:hunt"..v.."'>"..v.."</a>"
  684.                     end
  685.                 end
  686.                 ui.choser(txt, pl)
  687.                 ui.msg("Le chasseur, dans ses derniers soupir, tire sur la personne de son choix !")
  688.                 tfm.lg.task(15, "deadHunt", lastTour, true, true, idChoser, pl)
  689.             end
  690.             if tour=="deadHunt" then
  691.                 if jeu.mort[1]==nil then
  692.                     ui.msg(name.." n'a tiré sur personne")
  693.                 else
  694.                     ui.msg(tfm.lg.dead(jeu.mort[1], name.." a tiré sur "..jeu.mort[1].." qui était "..roles[players[jeu.mort[1]].jeu.role]))
  695.                 end
  696.                 tfm.lg.task(15, tfm.lg.win() and "win" or (lastTour=="feu" and "night" or "vote"))
  697.             end
  698.         end
  699.     end,
  700.  
  701.     task = function(time, tour, lastTour, timer, txtArea, id, name)
  702.         table.insert(task, {time = os.time()+time*1000, tour = tour, timer = timer==nil and false or timer, txtArea = txtArea==nil and false or txtArea, id = id, name = name, last = lastTour})
  703.     end,
  704.  
  705.     map = function()
  706.         local nbr = #plNbr
  707.         if play then nbr=#want2Play end
  708.         ui.setMapName(string.format(mapName, TIME, nbr, nbrSouris(), nbr-tfm.lg.plDead(), tfm.lg.plDead()))
  709.     end,
  710.  
  711.     win = function()
  712.         tfm.lg.map()
  713.         if jeu.roles[2]==#plNbr-tfm.lg.plDead() then
  714.             return "Loups-Garous";
  715.         elseif jeu.roles[2]==0 then
  716.             return "Villageois";
  717.         elseif #plNbr-tfm.lg.plDead()==2 then
  718.             for k, v in pairs(plNbr) do
  719.                 if jeu.amour[1]==v and players[v].mort then
  720.                     return "Amoureux";
  721.                 end
  722.             end
  723.         elseif #plNbr-tfm.lg.plDead()==0 then
  724.             return "no";
  725.         else
  726.             return false;
  727.         end
  728.     end
  729. }
  730.  
  731. badPrint = print
  732. print=function( ... )
  733.     local tbl, self, i = {}, {}, 1
  734.     self.wType=function(var)
  735.         return (type(var)=="number" and "J" or (type(var)=="string" and "VP" or (type(var)=="boolean" and "BV" or (type(var)=="table" and "VI" or "R"))))
  736.     end
  737.     self.pTable=function(tbl1)
  738.         local txt = ""
  739.         for k,v in next, tbl1 do
  740.             txt = txt..("<%s>"..(type(v)=="table" and tostring(k) or tostring(v)).."</%s>"):format(self.wType(v), self.wType(v))
  741.             if type(v)=="table" then
  742.                 txt = txt..self.pTable(v)
  743.             end
  744.             txt = txt.."<R>, </R>"
  745.         end
  746.         txt = txt:sub(0, #txt-9)
  747.         return "={"..txt.."}"
  748.     end
  749.  
  750.     for k,v in next, {...} do
  751.         tbl[i] = ("<%s>"..tostring(v).."</%s>"):format(self.wType(v), self.wType(v))
  752.         if type(v)=="table" then
  753.             tbl[i] = tbl[i]..self.pTable(v)
  754.         end
  755.         i = i+1
  756.     end
  757.     badPrint(table.concat(tbl, "<R>, </R>"))
  758. end
  759.  
  760. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement