GogoTfm

UNO FLUCH

May 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.92 KB | None | 0 0
  1. -- UNO
  2. -- Escrito por Ninguem - Data 04/09/2015
  3.  
  4. -- Instruções
  5. -- -- Digite Ctrl+A e copie isso tudo
  6. -- -- Vá no cafofo e digite /lua
  7. -- -- Cole o código na janela que abriu e depois clique em enviar.
  8. -- -- A janela vai ficar transparente e o jogo vai iniciar, pode fechá-la.
  9. -- -- IMPORTANTE: se sua conta foi banida por hack alguma vez, não poderá colocar
  10.  
  11. -- Comandos (funciona apenas para o adm, edite o código logo abaixo para se tornar o adm)
  12. -- !start - inicia a partida
  13. -- !new - começa uma nova partida
  14. -- !skip - pula a vez do jogador atual
  15. -- !ban nome - tira um jogador da partida
  16. -- !draw nome quantidade -- faz o jogador comprar cartas, se não for informado a quantidade comprará 1 carta só
  17.  
  18. -- VARIÁVEIS EDITÁVEIS
  19.  
  20. adm = "Henki" -- ponha seu nick
  21. gameName = "UNO | flushmice" -- nome do mapa
  22. numeroCartas = 5 -- numero de cartas ao inicio do jogo
  23. limiteCartas = 30 -- máximo de cartas que pode ter em mãos
  24. configTempo = 8000 -- tempo limite de uma jogada em milissegundos
  25. autoStart = true -- se for true inicia e encerra a partida sozinho sem precisar dar !start e !new, caso queira manual ponha false
  26. tempoStart = 20000 -- tempo até dar !start automático
  27. tempoNew = 20000 -- tempo até dar !new automático
  28.  
  29. mapa = [[<C><P /><Z><S><S P="0,0,0.3,0.2,0,0,0,0" L="800" o="32335b" X="400" c="3" Y="135" T="12" H="40" /><S P="0,0,0.3,0.2,0,0,0,0" L="800" o="32335b" H="60" N="" Y="370" T="12" X="400" /><S P="0,0,0,0.2,0,0,0,0" L="200" o="6a7495" X="900" c="3" N="" Y="200" T="12" H="3000" /><S H="3000" L="200" o="6a7495" X="-100" c="3" N="" Y="200" T="12" P="0,0,0,0.2,0,0,0,0" /><S H="100" L="800" o="6a7495" X="400" c="4" N="" Y="-41" T="12" P="0,0,0,0.2,0,0,0,0" /></S><D><P C="ffa930" Y="60" T="90" X="606" P="0,0" /><P C="ffa930" Y="60" T="90" P="0,0" X="812" /><P C="ffa930" Y="60" T="90" X="194" P="0,0" /><P C="ffa930" Y="60" T="90" P="0,0" X="-12" /><P C="ffa930" Y="60" T="90" P="0,0" X="400" /><P C="46478c" Y="125" T="34" X="0" P="0,0" /><DS Y="100" X="400" /><P P="0,0" Y="134" T="16" X="430" /><P X="370" Y="134" T="16" P="0,0" /><P X="490" Y="134" T="16" P="0,0" /><P P="0,0" Y="134" T="16" X="550" /><P X="610" Y="134" T="16" P="0,0" /><P P="0,0" Y="134" T="16" X="670" /><P X="730" Y="134" T="16" P="0,0" /><P P="0,0" Y="134" T="16" X="70" /><P X="130" Y="134" T="16" P="0,0" /><P P="0,0" Y="134" T="16" X="190" /><P X="250" Y="134" T="16" P="0,0" /><P P="0,0" Y="134" T="16" X="310" /></D><O /></Z></C>]]
  30.  
  31. -- cores das cartas
  32. -- vermelho, azul, amarelo, verde, preto
  33. corInt = {0xFF3232, 0x5365CC, 0xFFD800, 0x73D33B, 1} -- usado para colorir fundos
  34. corStr = {"FF3232", "5365CC", "FFD800", "73D33B", "000000"} -- usado para colorir textos
  35.  
  36. -- cores de outros elementos
  37. corUno = {corInt[5], 0xffffff, corInt[1], corStr[3]} -- cor do baralho: fundo, borda, tarja, texto
  38. corCarta = {0xffffff, "FFFFFF"} -- detalhes das cartas: borda, símbolo
  39. corVez = {-1, 0xffffff} -- ponteiro da vez: fundo, borda
  40. corFluxo = "32335B" -- cor das setas da mesa
  41. corTimer = corStr[3] -- cor do timer
  42.  
  43. -- símnolos das cartas
  44. n0 = "0"
  45. n1 = "1"
  46. n2 = "2"
  47. n3 = "3"
  48. n4 = "4"
  49. n5 = "5"
  50. n6 = "6"
  51. n7 = "7"
  52. n8 = "8"
  53. n9 = "9"
  54. rev=">" -- reverter
  55. skip="X" -- pular vez
  56. d2="+2" -- comprar 2
  57. d4="+4" -- comprar 4
  58. wild="*" -- coringa
  59.  
  60. -- baralho com 108 cartas
  61. cartas = { -- {cor,valor}
  62. {1,n0},{1,n1},{1,n1},{1,n2},{1,n2},{1,n3},{1,n3},{1,n4},{1,n4},{1,n5},{1,n5},{1,n6},{1,n6},{1,n7},{1,n7},{1,n8},{1,n8},{1,n9},{1,n9},{1,rev},{1,rev},{1,skip},{1,skip},{1,d2},{1,d2},
  63. {2,n0},{2,n1},{2,n1},{2,n2},{2,n2},{2,n3},{2,n3},{2,n4},{2,n4},{2,n5},{2,n5},{2,n6},{2,n6},{2,n7},{2,n7},{2,n8},{2,n8},{2,n9},{2,n9},{2,rev},{2,rev},{2,skip},{2,skip},{2,d2},{2,d2},
  64. {3,n0},{3,n1},{3,n1},{3,n2},{3,n2},{3,n3},{3,n3},{3,n4},{3,n4},{3,n5},{3,n5},{3,n6},{3,n6},{3,n7},{3,n7},{3,n8},{3,n8},{3,n9},{3,n9},{3,rev},{3,rev},{3,skip},{3,skip},{3,d2},{3,d2},
  65. {4,n0},{4,n1},{4,n1},{4,n2},{4,n2},{4,n3},{4,n3},{4,n4},{4,n4},{4,n5},{4,n5},{4,n6},{4,n6},{4,n7},{4,n7},{4,n8},{4,n8},{4,n9},{4,n9},{4,rev},{4,rev},{4,skip},{4,skip},{4,d2},{4,d2},
  66. {5,wild},{5,wild},{5,wild},{5,wild},{5,d4},{5,d4},{5,d4},{5,d4},
  67. }
  68.  
  69. -- TEXTOS
  70.  
  71. txtDraw = "Jogue um %s ou compre %d cartas."
  72. txtSit = "Vá até uma cadeira e aperte espaço para pegar seu lugar!"
  73. txtGameOver = "%s venceu o jogo!"
  74. txtPass = "Passar a vez"
  75. txtWarn = "Volte para sua cadeira!"
  76. txtChoose = "Escolha uma cor"
  77. txtRed = "VERMELHO"
  78. txtBlue = "AZUL"
  79. txtYellow = "AMARELO"
  80. txtGreen = "VERDE"
  81. txtUno = "UNO!"
  82. txtFlawless = "Flawless victory. Terminou sem comprar nenhuma carta."
  83. txtVirada = "De virada. Foi de %d a 0 cartas."
  84. txtDefesa2 = "Bloqueando +2"
  85. txtDefesa4 = "Bloqueando +4"
  86. txtDemorado = "Uma partida que levou %d minutos."
  87. txtCoringa = "Com coringa."
  88. txtConsecutivo = "%s vitórias consecutivas."
  89. txtMencao = "Menção honrosa"
  90. txtNaoJogou = "%s, que não teve chances de jogar."
  91. txtAcumulador = "%s, que ficou com %d cartas na mão."
  92. txt16 = "%s, que comprou 16 cartas de uma vez."
  93.  
  94. -- VARIÁVEIS DE JOGO
  95.  
  96. comandos = {"ban", "kick", "new", "start"}
  97. baralho = {}
  98. pilha = {}
  99. jogador = {}
  100. nome = {}
  101. timerTxt = {}
  102. modo = "inicio"
  103. duelo = false
  104. atual = nil
  105. vez = false
  106. sel = true
  107. draw = false
  108. acumulo = 0
  109. acumulo4 = 0
  110. fluxo = 1
  111. tempoJogada = os.time() + tempoStart
  112. tempoInicio = os.time()
  113. consecutivas = {nome="", qtd=0}
  114.  
  115. tempo = os.time()+1000
  116.  
  117. -- FUNÇÕES AUXILIARES -- podem funcionar em outros scripts
  118.  
  119. function split(t,s) -- retorna uma table com a string dividida
  120. local a={}
  121. for i,v in string.gmatch(t,string.format("[^%s]+",s or "%s")) do
  122. table.insert(a,i)
  123. end
  124. return a
  125. end
  126.  
  127. function arrumaNick(p) -- retorna o nick com o formato padrão (inicial maiúscula e restante minúsculo)
  128. local n = p:sub(1,1) == "+" and 2 or 1
  129. return p:sub(1,1) == "*" and p or p:sub(1,n):upper() .. p:sub(n+1):lower()
  130. end
  131.  
  132. function embaralhar(b) -- embaralha uma table recebida
  133. local novo = {}
  134. local rand = {}
  135. for i=1, #b do
  136. rand[i] = i
  137. end
  138. for i=1, #b do
  139. local r = math.random(#rand)
  140. table.insert(novo, b[rand[r]])
  141. table.remove(rand, r)
  142. end
  143. return novo
  144. end
  145.  
  146. function efeitoExplosao(id, x, y, vezes, vel) -- faz uma mini explosão de partículas
  147. for i=1, vezes do
  148. tfm.exec.displayParticle(id, x, y, math.random(-vel,vel)/10, math.random(-vel,vel)/10, 0, 0)
  149. end
  150. end
  151.  
  152. function apagaText() -- procura textos pra apagar, requer uma table global timerTxt, preenchida com {id=idDaTextArea, p=JogadorAlvo, time=TempoDeDuracao}
  153. local apagar={}
  154. for i,v in pairs(timerTxt) do
  155. if v.time<os.time() then
  156. table.insert(apagar,i)
  157. ui.removeTextArea(v.id, v.p)
  158. end
  159. end
  160. for i=1,#apagar do
  161. timerTxt[apagar[i]]=nil
  162. end
  163. end
  164.  
  165. function timerText(i, t, pp) -- auxilia no preenchimento da tabela timerTxt
  166. table.insert(timerTxt, {id=i, time=os.time()+t, p=pp})
  167. end
  168.  
  169. -- FUNÇÕES DO SCRIPT
  170.  
  171. function novoJogo()
  172. for i=1, 50 do
  173. ui.removeTextArea(i)
  174. end
  175. for i=1, 12 do
  176. if jogador[i] then
  177. nome[jogador[i].nome] = nil
  178. jogador[i] = nil
  179. end
  180. end
  181. ui.removeTextArea(100)
  182. ui.removeTextArea(2000)
  183. modo = "inicio"
  184. tfm.exec.newGame(mapa)
  185. end
  186.  
  187. function desenhaCarta(i, c, p, x, y)
  188. ui.addTextArea(i, string.format("\n<p align='center'><font size='23px' color='#%s'>%s", corCarta[2],c[2]), p, x, y, 40, 60, corInt[c[1]], corCarta[1], 1,false)
  189. end
  190.  
  191. function desenhaBaralho(p)
  192. ui.addTextArea(401, "", p, 330, 200, 40, 60, corUno[1], corUno[2], 1,false)
  193. ui.addTextArea(402, "<p align='center'><font size='12px' color='#"..corUno[4].."'>UNO", p, 333, 223, 34, 16, corUno[3], corUno[3], 1,false)
  194. end
  195.  
  196. function atualizaScore(n, p)
  197. ui.addTextArea(n, "<p align='center'><font size='8px'>"..jogador[n].nome.."\n<font size='20px'><j>"..(#jogador[n].mao~=1 and #jogador[n].mao or txtUno), p, (n-1)*60+40-20, 115, 100, 60, 0, 0, 0, false)
  198. end
  199.  
  200. function atualizaMao(p)
  201. for i=20, 50 do
  202. ui.removeTextArea(i, p)
  203. end
  204. for i, v in pairs(jogador[nome[p]].mao) do
  205. desenhaCarta(i+20, v, p, 400-(#jogador[nome[p]].mao*25)+50*(i-1), 330)
  206. end
  207. end
  208.  
  209. function atualizaFluxo(p)
  210. defFluxo = {
  211. "&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;",
  212. "&lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt;"
  213. }
  214. ui.addTextArea(14, string.format("<p align='center'><font size='20px' color='#"..corFluxo.."'><b>%s", defFluxo[fluxo]), p, 0, 160, 800, 120, 0, 0, 0, false)
  215. end
  216.  
  217. function atualizaPonteiro(p)
  218. ui.addTextArea(13, "", p, (vez-1)*60+40, 30, 60, 120, corVez[1], corVez[2], 1, false)
  219. end
  220.  
  221. function atualizaTimer()
  222. tempoJogada = os.time() + configTempo
  223. end
  224.  
  225. function criaJogador(p, n)
  226. jogador[n] = {nome=p, mao={}, jogadas=0, maiorCompra=0, maximoCartas=numeroCartas,timer=os.time()+2000}
  227. atualizaScore(n)
  228. ui.removeTextArea(0, p)
  229. nome[p] = n
  230. end
  231.  
  232. function removeJogadorUI(p, n)
  233. ui.removeTextArea(n)
  234. jogador[n] = nil
  235. nome[p] = nil
  236. end
  237.  
  238. function removeJogador(p, n)
  239. if n == vez then
  240. autoPlay()
  241. end
  242. for i=1, #jogador[n].mao do
  243. ui.removeTextArea(i+20, p)
  244. table.insert(pilha, table.remove(jogador[n].mao))
  245. end
  246. removeJogadorUI(p, n)
  247. end
  248.  
  249. function ordenar(b)
  250. table.sort(b, function(a, b)
  251. p = {[n0]=0,[n1]=1,[n2]=2,[n3]=3,[n4]=4,[n5]=5,[n6]=6,[n7]=7,[n8]=8,[n9]=9,[rev]=10,[skip]=11,[d2]=12,[wild]=13,[d4]=14,}
  252. if a[1] ~= b[1] then
  253. return a[1] < b[1]
  254. else
  255. return p[a[2]] < p[b[2]]
  256. end
  257. end)
  258. end
  259.  
  260. function comprarCartas(p, qtd)
  261. ui.addTextArea(70+nome[p], "<p align='center'><font size='20px'><bv><b>+"..qtd, nil, (nome[p]-1)*60+40, 145, 60, 60, 0, 0, 0, false)
  262. timerText(70+nome[p], 2000)
  263. draw = true
  264. for i=1, qtd do
  265. if #baralho == 0 then
  266. baralho = embaralhar(pilha)
  267. pilha = {}
  268. end
  269. if #jogador[nome[p]].mao < limiteCartas then
  270. table.insert(jogador[nome[p]].mao, table.remove(baralho))
  271. end
  272. end
  273. ordenar(jogador[nome[p]].mao)
  274. atualizaMao(p)
  275. atualizaScore(nome[p])
  276. if qtd > jogador[nome[p]].maiorCompra and qtd ~= numeroCartas then
  277. jogador[nome[p]].maiorCompra = qtd
  278. end
  279. if #jogador[nome[p]].mao > jogador[nome[p]].maximoCartas then
  280. jogador[nome[p]].maximoCartas = #jogador[nome[p]].mao
  281. end
  282. end
  283.  
  284. function pegaAnterior()
  285. local n = vez
  286. repeat
  287. n = fluxo == 1 and (n == 1 and 12 or n - 1) or (n == 12 and 1 or n + 1)
  288. until jogador[n]
  289. return n
  290. end
  291.  
  292. function pegaProximo()
  293. local n = vez
  294. repeat
  295. n = fluxo == 1 and (n == 12 and 1 or n + 1) or (n == 1 and 12 or n - 1)
  296. until jogador[n]
  297. return n
  298. end
  299.  
  300. function passarVez()
  301. vez = pegaProximo()
  302. draw = false
  303. atualizaPonteiro()
  304. atualizaTimer()
  305. ui.removeTextArea(15)
  306. ui.removeTextArea(16)
  307. ui.removeTextArea(17)
  308. end
  309.  
  310. function estaNoLugar(p)
  311. local x = tfm.get.room.playerList[p].x
  312. return nome[p] and x > (nome[p]-1)*60+40 and x < (nome[p]-1)*60+100
  313. end
  314.  
  315. function usaDraw4()
  316. acumulo4 = acumulo4 + 4
  317. ui.addTextArea(16, string.format("<p align='center'>"..txtDraw, d4, acumulo4), jogador[vez].nome, 250, 290, 300, 20, 1, 1, 0.4, true)
  318. end
  319.  
  320. function autoPlay()
  321. local p = jogador[vez].nome
  322. n = acumulo > 0 and acumulo or acumulo4 > 0 and acumulo4 or 1
  323. acumulo = 0
  324. acumulo4 = 0
  325. if not draw then
  326. comprarCartas(p, n)
  327. end
  328. passarVez()
  329. if atual[1] == 5 then
  330. mudaCor()
  331. sel = true
  332. if atual[2] == d4 then
  333. usaDraw4()
  334. end
  335. end
  336. end
  337.  
  338. function mudaCor(n)
  339. atual[1] = n or math.random(1,4)
  340. desenhaCarta(10, atual, nil, 420, 200)
  341. local b = {21, 23, 24, 22}
  342. efeitoExplosao(b[atual[1]], 445, 230, 30, 20)
  343. end
  344.  
  345. function usaSkip()
  346. efeitoExplosao(35, pegaProximo()*60-50+70, 100, 50, 10)
  347. passarVez()
  348. passarVez()
  349. end
  350.  
  351. function usaReverse()
  352. fluxo = fluxo == 1 and 2 or 1
  353. atualizaFluxo()
  354. for i=20, 780, 10 do
  355. tfm.exec.displayParticle(3, i, 177, 0, 0, 0, 0)
  356. end
  357. end
  358.  
  359. function motivoVitoria(p)
  360. if consecutivas.nome == p then
  361. consecutivas.qtd = consecutivas.qtd + 1
  362. else
  363. consecutivas.qtd = 1
  364. consecutivas.nome = p
  365. end
  366. local maior = 0
  367. local nomeMaior = ""
  368. for i, v in pairs(jogador) do
  369. if v.maximoCartas > 0 then
  370. maior = v.maximoCartas
  371. nomeMaior = v.nome
  372. end
  373. end
  374. if jogador[nome[p]].maiorCompra == 0 then
  375. return txtFlawless
  376. elseif acumulo > 0 and atual[2] == d2 then
  377. return txtDefesa2
  378. elseif acumulo4 > 0 and atual[2] == d4 then
  379. return txtDefesa4
  380. elseif atual[1] == 5 then
  381. return txtCoringa
  382. elseif consecutivas.qtd > 1 then
  383. return string.format(txtConsecutivo, consecutivas.qtd)
  384. elseif os.time() - tempoInicio > 600000 then
  385. return string.format(txtDemorado, math.floor((os.time() - tempoInicio)/60000))
  386. elseif nomeMaior == p and maior > numeroCartas then
  387. return string.format(txtVirada, maior)
  388. else
  389. return ""
  390. end
  391. end
  392.  
  393. function mencaoHonrosa(p)
  394. local mencao = {}
  395. local maior = 0
  396. local nomeMaior = ""
  397. for i, v in pairs(jogador) do
  398. if v.maximoCartas > 0 then
  399. maior = v.maximoCartas
  400. nomeMaior = v.nome
  401. end
  402. if v.jogadas == 0 then
  403. table.insert(mencao, string.format(txtNaoJogou, v.nome))
  404. end
  405. if v.maiorCompra == 16 then
  406. table.insert(mencao, string.format(txt16, v.nome))
  407. end
  408. end
  409. if nomeMaior ~= p and maior >= 20 then
  410. print(nomeMaior)
  411. table.insert(mencao, string.format(txtAcumulador, nomeMaior, maior))
  412. end
  413. if #mencao > 0 then
  414. return string.format("<vp>%s\n<n>%s", txtMencao, table.concat(mencao, "\n"))
  415. else
  416. return ""
  417. end
  418. end
  419.  
  420. -- EVENTOS
  421.  
  422. function eventNewGame()
  423. tempo = os.time()+1000
  424. tfm.exec.setUIMapName(gameName)
  425. ui.addTextArea(0, "<font size='25px'><p align='center'>"..txtSit, nil, 0, 180, 800, 200, 0, 0, 0, false)
  426. for i, v in pairs(tfm.get.room.playerList) do
  427. tfm.exec.bindKeyboard(i, 32, true, true)
  428. system.bindMouse(i, true)
  429. end
  430. end
  431.  
  432. function eventTextAreaCallback(id, p, cmd)
  433. if id == 15 and nome[p] == vez then
  434. mudaCor(tonumber(cmd))
  435. passarVez()
  436. sel = true
  437. if atual[2] == d4 then
  438. acumulo4 = acumulo4 + 4
  439. ui.addTextArea(16, string.format("<p align='center'>"..txtDraw, d4, acumulo4), jogador[vez].nome, 250, 290, 300, 20, 1, 1, 0.4, true)
  440. end
  441. jogador[nome[p]].jogadas = jogador[nome[p]].jogadas + 1
  442. elseif cmd == "skip" and nome[p] == vez then
  443. passarVez()
  444. jogador[nome[p]].jogadas = jogador[nome[p]].jogadas + 1
  445. end
  446. end
  447.  
  448. function eventMouse(p, x, y)
  449. if modo == "start" then
  450. local xx = tfm.get.room.playerList[p].x
  451. if jogador[nome[p]] and y > 325 and y < 400 and estaNoLugar(p) then
  452. local carta = math.ceil((x+5 - (400 - (#jogador[nome[p]].mao*25)))/50)
  453. local mao = jogador[nome[p]].mao
  454. if vez == nome[p] and sel then
  455. if mao[carta] and (acumulo == 0 or mao[carta][2] == d2) and (acumulo4 == 0 or mao[carta][2] == d4) and (mao[carta][1] == atual[1] or mao[carta][2] == atual[2] or mao[carta][2] == wild or mao[carta][2] == d4) then
  456. if atual[2] == d4 or atual[2] == wild then
  457. atual[1] = 5
  458. else
  459. jogador[nome[p]].jogadas = jogador[nome[p]].jogadas + 1
  460. end
  461. table.insert(pilha, atual)
  462. atual = table.remove(mao, carta)
  463. atualizaMao(p)
  464. desenhaCarta(10000, atual, nil, 420, 200)
  465. atualizaScore(nome[p])
  466. if #jogador[nome[p]].mao == 0 then
  467. local txt = motivoVitoria(p)
  468. txt = txt .. "\n\n" .. mencaoHonrosa(p)
  469. ui.addTextArea(13, "", nil, 5, 5, 790, 400, 1, 1, 0.5, false)
  470. ui.addTextArea(14, string.format("<p align='center'><font size='40px' color='#ffffff'>"..txtGameOver, p).."<font size='20px' color='#FFD800'>\n<b>"..txt, nil, 0, 170, 800, 400, 0, 0, 0, false)
  471. tfm.exec.setPlayerScore(p, 1, true)
  472. tempoJogada = os.time() + tempoNew
  473. modo = "fim"
  474. else
  475. if atual[2] == wild or atual[2] == d4 then
  476. sel = false
  477. draw = true
  478. ui.addTextArea(15, string.format("<p align='center'>%s\n<a href='event:1'><font color='#FF3232'>%s</font></a> - <a href='event:2'><font color='#5365CC'>%s</font></a> - <a href='event:3'><font color='#FFD800'>%s</font></a> - <a href='event:4'><font color='#73D33B'>%s</font></a>", txtChoose, txtRed, txtBlue, txtYellow, txtGreen), p, 250, 285, 300, 35, 1, 1, 0.7, true)
  479. else
  480. if atual[2] == skip then
  481. usaSkip()
  482. elseif atual[2] == rev then
  483. if duelo then
  484. usaSkip()
  485. else
  486. usaReverse()
  487. passarVez()
  488. end
  489. elseif atual[2] == d2 then
  490. acumulo = acumulo + 2
  491. passarVez()
  492. ui.addTextArea(16, string.format("<p align='center'>"..txtDraw, d2, acumulo), jogador[vez].nome, 250, 290, 300, 20, 1, 1, 0.4, true)
  493. else
  494. passarVez()
  495. end
  496. end
  497. end
  498. for i=1, 10 do
  499. tfm.exec.displayParticle(3, 445, 230, math.random(-20,20)/10, math.random(-20,20)/10, 0, 0)
  500. end
  501. end
  502. elseif os.time() > jogador[nome[p]].timer and mao[carta] then
  503. desenhaCarta(nome[p]+20000, mao[carta], nil, (nome[p]-1)*60+45, 30)
  504. timerText(nome[p]+20000, 1000)
  505. jogador[nome[p]].timer = os.time()+2000
  506. end
  507. elseif x > 325 and x < 375 and y > 195 and y < 245 and not draw and vez == nome[p] and sel then
  508. if acumulo > 0 or acumulo4 > 0 then
  509. comprarCartas(p, acumulo > 0 and acumulo or acumulo4)
  510. acumulo = 0
  511. acumulo4 = 0
  512. passarVez()
  513. else
  514. comprarCartas(p, 1)
  515. ui.addTextArea(16, "<p align='center'><a href='event:skip'>"..txtPass, p, 250, 290, 300, 20, 1, 1, 0.7, true)
  516. draw = true
  517. end
  518. end
  519. end
  520. end
  521.  
  522. function eventChatCommand(p, cmd)
  523. local arg = split(cmd, " ")
  524. if p == adm then
  525. if arg[1] == "start" and modo == "inicio" then
  526. atualizaTimer()
  527. local r = {}
  528. local numJogadores = 0
  529. modo = "start"
  530. tempoInicio = os.time()
  531. sel = true
  532. fluxo = 1
  533. draw = false
  534. atual = nil
  535. baralho = embaralhar(cartas)
  536. pilha = {}
  537. ui.removeTextArea(0)
  538. for i, v in pairs(jogador) do
  539. comprarCartas(v.nome, numeroCartas)
  540. table.insert(r, i)
  541. numJogadores = numJogadores + 1
  542. end
  543. if numJogadores == 0 then
  544. eventChatCommand(adm, "new")
  545. return false
  546. end
  547. duelo = #r == 2
  548. repeat
  549. table.insert(pilha, atual)
  550. atual = table.remove(baralho)
  551. until atual[2] ~= d4 and atual[2] ~= wild and atual[2] ~= d2 and atual[2] ~= skip and atual[2] ~= rev
  552. desenhaCarta(10000, atual, nil, 420, 200)
  553. desenhaBaralho()
  554. vez = r[math.random(#r)]
  555. atualizaPonteiro()
  556. atualizaFluxo()
  557. elseif arg[1] == "new" then
  558. novoJogo()
  559. elseif arg[1] == "skip" and modo == "start" then
  560. autoPlay()
  561. elseif arg[1] == "ban" and arg[2] and nome[arrumaNick(arg[2])] then
  562. eventPlayerLeft(arrumaNick(arg[2]))
  563. end
  564. end
  565. end
  566.  
  567. function eventKeyboard(p, t, d, x, y)
  568. if modo == "inicio" and os.time() > tempo and not nome[p] then
  569. if x > 55 and x < 85 and not jogador[1] then
  570. criaJogador(p, 1)
  571. elseif x > 115 and x < 145 and not jogador[2] then
  572. criaJogador(p, 2)
  573. elseif x > 175 and x < 205 and not jogador[3] then
  574. criaJogador(p, 3)
  575. elseif x > 235 and x < 265 and not jogador[4] then
  576. criaJogador(p, 4)
  577. elseif x > 295 and x < 325 and not jogador[5] then
  578. criaJogador(p, 5)
  579. elseif x > 355 and x < 385 and not jogador[6] then
  580. criaJogador(p, 6)
  581. elseif x > 415 and x < 445 and not jogador[7] then
  582. criaJogador(p, 7)
  583. elseif x > 475 and x < 505 and not jogador[8] then
  584. criaJogador(p, 8)
  585. elseif x > 535 and x < 565 and not jogador[9] then
  586. criaJogador(p, 9)
  587. elseif x > 595 and x < 625 and not jogador[10] then
  588. criaJogador(p, 10)
  589. elseif x > 655 and x < 685 and not jogador[11] then
  590. criaJogador(p, 11)
  591. elseif x > 715 and x < 745 and not jogador[12] then
  592. criaJogador(p, 12)
  593. end
  594. end
  595. end
  596.  
  597. function eventLoop()
  598. math.randomseed(os.time())
  599. for i, v in pairs(jogador) do
  600. if not estaNoLugar(v.nome) then
  601. ui.addTextArea(100, "<font size='50px' color='#ffffff'><p align='center'>"..txtWarn, v.nome, 5, 325, 790, 80, 0xff0000, 0xff0000, 1, true)
  602. else
  603. ui.removeTextArea(100, v.nome)
  604. end
  605. end
  606. if modo == "fim" then
  607. local b = {0, 1, 2, 4, 9, 11, 13}
  608. local x, y, id = math.random(800), math.random(400), b[math.random(#b)]
  609. for i=1, 40 do
  610. tfm.exec.displayParticle(id, x, y, math.random(-20,20)/10, math.random(-20,20)/10, 0, 0)
  611. end
  612. if os.time() > tempoJogada and autoStart then
  613. tempoJogada = os.time() + tempoStart
  614. eventChatCommand(adm, "new")
  615. end
  616. end
  617. if modo == "start" then
  618. if os.time() > tempoJogada then
  619. jogador[vez].jogadas = jogador[vez].jogadas + 1
  620. autoPlay()
  621. elseif tempoJogada - os.time() < 10000 then
  622. ui.addTextArea(17, "<p align='center'><font size='25px' color='#"..corTimer.."'>"..math.ceil((tempoJogada - os.time())/1000), nil, 350, 210, 90, 100, 0, 0, 0, false)
  623. else
  624. ui.removeTextArea(17)
  625. end
  626. elseif modo == "inicio" then
  627. if os.time() > tempoJogada and autoStart then
  628. atualizaTimer()
  629. eventChatCommand(adm, "start")
  630. end
  631. end
  632. apagaText()
  633. end
  634.  
  635. function eventNewPlayer(p)
  636. if modo == "inicio" then
  637. ui.addTextArea(0, "<font size='25px'><p align='center'>"..txtSit, p, 0, 180, 800, 200, 0, 0, 0, false)
  638. tfm.exec.bindKeyboard(p, 32, true, true)
  639. system.bindMouse(p, true)
  640. elseif modo == "start" then
  641. desenhaCarta(10, atual, p, 420, 200)
  642. desenhaBaralho(p)
  643. atualizaPonteiro(p)
  644. atualizaFluxo(p)
  645. end
  646. for i, v in pairs(jogador) do
  647. atualizaScore(i, p)
  648. end
  649. tfm.exec.respawnPlayer(p)
  650. tfm.exec.setUIMapName(gameName)
  651. end
  652.  
  653. function eventPlayerLeft(p)
  654. if modo == "inicio" then
  655. if nome[p] then
  656. removeJogadorUI(p, nome[p])
  657. end
  658. elseif modo == "start" then
  659. if nome[p] and jogador[nome[p]] then
  660. removeJogador(p, nome[p])
  661. end
  662. end
  663. end
  664.  
  665. function eventPlayerDied(p)
  666. tfm.exec.respawnPlayer(p)
  667. end
  668.  
  669. -- INICIO
  670.  
  671. tfm.exec.disableAutoScore(true)
  672. tfm.exec.disableAutoShaman(true)
  673. tfm.exec.disableAutoNewGame(true)
  674. tfm.exec.disableAfkDeath(true)
  675. for i, v in pairs(comandos) do
  676. system.disableChatCommandDisplay(v, true)
  677. end
  678. for i, v in pairs(tfm.get.room.playerList) do
  679. tfm.exec.setPlayerScore(i, 0, false)
  680. end
  681. tfm.exec.newGame(mapa)
  682.  
  683. --system.newTimer(function()
  684. -- tfm.exec.chatMessage("<j>Quer jogar uno no seu cafofo? Pegue o código dele em http://pastebin.com/raw.php?i=Cqbd3MeN")
  685. --end, 300000, true)
Advertisement
Add Comment
Please, Sign In to add comment