Advertisement
Guest User

Uno by ninguem

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