SHOW:
|
|
- or go back to the newest paste.
| 1 | -- UNO | |
| 2 | -- Escrito por Ninguem - Data 04/09/2015 | |
| 3 | ||
| 4 | -- Comandos | |
| 5 | -- !start - inicia a partida | |
| 6 | -- !new - começa uma nova partida | |
| 7 | -- !skip - pula a vez do jogador atual | |
| 8 | -- !ban nome - tira um jogador da partida | |
| 9 | ||
| 10 | -- VARIÁVEIS EDITÁVEIS | |
| 11 | ||
| 12 | adm = "Ninguem" -- seu nick | |
| 13 | gameName = "UNO!" -- nome do mapa | |
| 14 | configTempo = 15000 -- tempo limite entre cada jogada | |
| 15 | autoStart = false -- inicia e encerra a partida sozinho sem precisar dar !start e !new | |
| 16 | ||
| 17 | mapa = [[<C><P /><Z><S><S P="0,0,0.3,0.2,0,0,0,0" L="800" o="214a25" 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="214a25" X="400" N="" Y="370" T="12" H="60" /><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="ffd800" Y="60" T="90" P="0,0" X="400" /><P C="ffd800" Y="60" T="90" X="606" P="0,0" /><P C="ffd800" Y="60" T="90" P="0,0" X="812" /><P C="ffd800" Y="60" T="90" X="194" P="0,0" /><P C="ffd800" Y="60" T="90" P="0,0" X="-12" /><P C="317c39" Y="125" T="34" X="0" P="0,0" /><P C="8a311b" Y="135" T="19" X="150" P="0,0" /><P C="8a311b" Y="135" T="19" P="0,0" X="250" /><P C="8a311b" Y="134" T="19" X="350" P="0,0" /><P C="8a311b" Y="134" T="19" P="0,0" X="450" /><P C="8a311b" Y="134" T="19" X="550" P="0,0" /><P C="8a311b" Y="134" T="19" P="0,0" X="650" /><P C="8a311b" Y="135" T="19" P="0,0" X="50" /><P C="8a311b" Y="134" T="19" X="750" P="0,0" /><DS Y="100" X="400" /></D><O /></Z></C>]] | |
| 18 | ||
| 19 | -- cores das cartas | |
| 20 | -- vermelho, azul, amarelo, verde, preto | |
| 21 | corInt = {0xFF3232, 0x5365CC, 0xFFD800, 0x73D33B, 1}
| |
| 22 | corStr = {"FF3232", "5365CC", "FFD800", "73D33B", "000000"}
| |
| 23 | ||
| 24 | -- ícones das cartas especiais | |
| 25 | rev="§" | |
| 26 | skip="Ø" | |
| 27 | d2="+2" | |
| 28 | d4="+4" | |
| 29 | wild="*" | |
| 30 | ||
| 31 | -- baralho com 108 cartas | |
| 32 | cartas = { -- {cor,valor}
| |
| 33 | {1,"0"},{1,"1"},{1,"1"},{1,"2"},{1,"2"},{1,"3"},{1,"3"},{1,"4"},{1,"4"},{1,"5"},{1,"5"},{1,"6"},{1,"6"},{1,"7"},{1,"7"},{1,"8"},{1,"8"},{1,"9"},{1,"9"},{1,rev},{1,rev},{1,skip},{1,skip},{1,d2},{1,d2},
| |
| 34 | {2,"0"},{2,"1"},{2,"1"},{2,"2"},{2,"2"},{2,"3"},{2,"3"},{2,"4"},{2,"4"},{2,"5"},{2,"5"},{2,"6"},{2,"6"},{2,"7"},{2,"7"},{2,"8"},{2,"8"},{2,"9"},{2,"9"},{2,rev},{2,rev},{2,skip},{2,skip},{2,d2},{2,d2},
| |
| 35 | {3,"0"},{3,"1"},{3,"1"},{3,"2"},{3,"2"},{3,"3"},{3,"3"},{3,"4"},{3,"4"},{3,"5"},{3,"5"},{3,"6"},{3,"6"},{3,"7"},{3,"7"},{3,"8"},{3,"8"},{3,"9"},{3,"9"},{3,rev},{3,rev},{3,skip},{3,skip},{3,d2},{3,d2},
| |
| 36 | {4,"0"},{4,"1"},{4,"1"},{4,"2"},{4,"2"},{4,"3"},{4,"3"},{4,"4"},{4,"4"},{4,"5"},{4,"5"},{4,"6"},{4,"6"},{4,"7"},{4,"7"},{4,"8"},{4,"8"},{4,"9"},{4,"9"},{4,rev},{4,rev},{4,skip},{4,skip},{4,d2},{4,d2},
| |
| 37 | {5,wild},{5,wild},{5,wild},{5,wild},{5,d4},{5,d4},{5,d4},{5,d4},
| |
| 38 | } | |
| 39 | ||
| 40 | -- TEXTOS | |
| 41 | ||
| 42 | txtDraw = "Jogue um %s ou compre %d cartas." | |
| 43 | txtSit = "Vá até uma cadeira e aperte espaço para pegar seu lugar!" | |
| 44 | txtGameOver = "%s venceu o jogo!" | |
| 45 | txtPass = "Passar a vez" | |
| 46 | txtWarn = "Volte para sua cadeira!" | |
| 47 | txtChoose = "Escolha uma cor" | |
| 48 | txtRed = "VERMELHO" | |
| 49 | txtBlue = "AZUL" | |
| 50 | txtYellow = "AMARELO" | |
| 51 | txtGreen = "VERDE" | |
| 52 | ||
| 53 | -- VARIÁVEIS DE JOGO | |
| 54 | ||
| 55 | comandos = {"ban", "kick", "new", "start"}
| |
| 56 | baralho = {}
| |
| 57 | pilha = {}
| |
| 58 | jogador = {}
| |
| 59 | nome = {}
| |
| 60 | timerTxt = {}
| |
| 61 | modo = "inicio" | |
| 62 | duelo = false | |
| 63 | atual = nil | |
| 64 | vez = false | |
| 65 | sel = true | |
| 66 | draw = false | |
| 67 | acumulo = 0 | |
| 68 | acumulo4 = 0 | |
| 69 | fluxo = 1 | |
| 70 | tempoJogada = os.time() + 15000 | |
| 71 | tempo = os.time()+1000 | |
| 72 | ||
| 73 | -- FUNÇÕES AUXILIARES -- podem funcionar em outros scripts | |
| 74 | ||
| 75 | function split(t,s) -- retorna uma table com a string dividida | |
| 76 | local a={}
| |
| 77 | for i,v in string.gmatch(t,string.format("[^%s]+",s or "%s")) do
| |
| 78 | table.insert(a,i) | |
| 79 | end | |
| 80 | return a | |
| 81 | end | |
| 82 | ||
| 83 | function arrumaNick(p) -- retorna o nick com o formato padrão (inicial maiúscula e restante minúsculo) | |
| 84 | return p:sub(1,1):upper() .. p:sub(2):lower() | |
| 85 | end | |
| 86 | ||
| 87 | function embaralhar(b) -- embaralha uma table recebida | |
| 88 | local novo = {}
| |
| 89 | local rand = {}
| |
| 90 | for i=1, #b do | |
| 91 | rand[i] = i | |
| 92 | end | |
| 93 | for i=1, #b do | |
| 94 | local r = math.random(#rand) | |
| 95 | table.insert(novo, b[rand[r]]) | |
| 96 | table.remove(rand, r) | |
| 97 | end | |
| 98 | return novo | |
| 99 | end | |
| 100 | ||
| 101 | function efeitoExplosao(id, x, y, vezes, vel) -- faz uma mini explosão de partículas | |
| 102 | for i=1, vezes do | |
| 103 | tfm.exec.displayParticle(id, x, y, math.random(-vel,vel)/10, math.random(-vel,vel)/10, 0, 0) | |
| 104 | end | |
| 105 | end | |
| 106 | ||
| 107 | function apagaText() -- procura textos pra apagar, requer uma table global timerTxt, preenchida com {id=idDaTextArea, p=JogadorAlvo, time=TempoDeDuracao}
| |
| 108 | local apagar={}
| |
| 109 | for i,v in pairs(timerTxt) do | |
| 110 | if v.time<os.time() then | |
| 111 | table.insert(apagar,i) | |
| 112 | ui.removeTextArea(v.id, v.p) | |
| 113 | end | |
| 114 | end | |
| 115 | for i=1,#apagar do | |
| 116 | timerTxt[apagar[i]]=nil | |
| 117 | end | |
| 118 | end | |
| 119 | ||
| 120 | function timerText(i, t, pp) -- auxilia no preenchimento da tabela timerTxt | |
| 121 | table.insert(timerTxt, {id=i, time=os.time()+t, p=pp})
| |
| 122 | end | |
| 123 | ||
| 124 | -- FUNÇÕES DO SCRIPT | |
| 125 | ||
| 126 | function novoJogo() | |
| 127 | for i=1, 50 do | |
| 128 | ui.removeTextArea(i) | |
| 129 | end | |
| 130 | for i=1, 8 do | |
| 131 | if jogador[i] then | |
| 132 | nome[jogador[i].nome] = nil | |
| 133 | jogador[i] = nil | |
| 134 | end | |
| 135 | end | |
| 136 | ui.removeTextArea(100) | |
| 137 | modo = "inicio" | |
| 138 | tfm.exec.newGame(mapa) | |
| 139 | end | |
| 140 | ||
| 141 | function desenhaCarta(i, c, p, x, y) | |
| 142 | ui.addTextArea(i, "\n<p align='center'><font size='23px' color='#ffffff'>"..c[2], p, x, y, 40, 60, corInt[c[1]], 0xffffff, 1,false) | |
| 143 | end | |
| 144 | ||
| 145 | function desenhaBaralho(p) | |
| 146 | ui.addTextArea(11, "", p, 330, 200, 40, 60, 1, 0xffffff, 1,false) | |
| 147 | ui.addTextArea(12, "<p align='center'><font size='12px' color='#FFD800'>UNO", p, 333, 223, 34, 16, 0xFF3232, 0xFF3232, 1,false) | |
| 148 | end | |
| 149 | ||
| 150 | function atualizaScore(n, p) | |
| 151 | ui.addTextArea(n, "<p align='center'>"..jogador[n].nome.."<b>\n<font size='18px'><j>"..(#jogador[n].mao~=1 and #jogador[n].mao or "UNO!"), p, (n-1)*100-50, 115, 200, 60, 0, 0, 0, false) | |
| 152 | end | |
| 153 | ||
| 154 | function atualizaMao(p) | |
| 155 | for i=20, 50 do | |
| 156 | ui.removeTextArea(i, p) | |
| 157 | end | |
| 158 | for i, v in pairs(jogador[nome[p]].mao) do | |
| 159 | desenhaCarta(i+20, v, p, 400-(#jogador[nome[p]].mao*25)+50*(i-1), 330) | |
| 160 | end | |
| 161 | end | |
| 162 | ||
| 163 | function atualizaFluxo(p) | |
| 164 | defFluxo = {
| |
| 165 | "> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >", | |
| 166 | "< < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < <" | |
| 167 | } | |
| 168 | ui.addTextArea(14, string.format("<p align='center'><font size='20px' color='#214A25'><b>%s", defFluxo[fluxo]), p, 0, 160, 800, 120, 0, 0, 0, false)
| |
| 169 | end | |
| 170 | ||
| 171 | function atualizaPonteiro(p) | |
| 172 | ui.addTextArea(13, "", p, 100*(vez-1), 30, 100, 120, -1, 0xffffff, 1, false) | |
| 173 | end | |
| 174 | ||
| 175 | function atualizaTimer() | |
| 176 | tempoJogada = os.time() + configTempo | |
| 177 | end | |
| 178 | ||
| 179 | function criaJogador(p, n) | |
| 180 | jogador[n] = {nome=p, mao={}, timer=os.time()+2000}
| |
| 181 | atualizaScore(n) | |
| 182 | ui.removeTextArea(0, p) | |
| 183 | nome[p] = n | |
| 184 | end | |
| 185 | ||
| 186 | function removeJogadorUI(p, n) | |
| 187 | ui.removeTextArea(n) | |
| 188 | jogador[n] = nil | |
| 189 | nome[p] = nil | |
| 190 | end | |
| 191 | ||
| 192 | function removeJogador(p, n) | |
| 193 | if n == vez then | |
| 194 | autoPlay() | |
| 195 | end | |
| 196 | for i=1, #jogador[n].mao do | |
| 197 | table.insert(pilha, table.remove(jogador[n].mao)) | |
| 198 | end | |
| 199 | removeJogadorUI(p, n) | |
| 200 | end | |
| 201 | ||
| 202 | function ordenar(b) | |
| 203 | table.sort(b, function(a, b) | |
| 204 | p = {["0"]=0,["1"]=1,["2"]=2,["3"]=3,["4"]=4,["5"]=5,["6"]=6,["7"]=7,["8"]=8,["9"]=9,[rev]=10,[skip]=11,[d2]=12,[wild]=13,[d4]=14,}
| |
| 205 | if a[1] ~= b[1] then | |
| 206 | return a[1] < b[1] | |
| 207 | else | |
| 208 | return p[a[2]] < p[b[2]] | |
| 209 | end | |
| 210 | end) | |
| 211 | end | |
| 212 | ||
| 213 | function comprarCartas(p, qtd) | |
| 214 | ui.addTextArea(70+nome[p], "<p align='center'><font size='20px'><bv><b>+"..qtd, nil, (nome[p]-1)*100, 145, 100, 60, 0, 0, 0, false) | |
| 215 | timerText(70+nome[p], 2000) | |
| 216 | for i=1, qtd do | |
| 217 | if #baralho == 0 then | |
| 218 | baralho = embaralhar(pilha) | |
| 219 | pilha = {}
| |
| 220 | end | |
| 221 | table.insert(jogador[nome[p]].mao, table.remove(baralho)) | |
| 222 | end | |
| 223 | ordenar(jogador[nome[p]].mao) | |
| 224 | atualizaMao(p) | |
| 225 | atualizaScore(nome[p]) | |
| 226 | end | |
| 227 | ||
| 228 | function pegaAnterior() | |
| 229 | local n = vez | |
| 230 | repeat | |
| 231 | n = fluxo == 1 and (n == 1 and 8 or n - 1) or (n == 8 and 1 or n + 1) | |
| 232 | until jogador[n] | |
| 233 | return n | |
| 234 | end | |
| 235 | ||
| 236 | function pegaProximo() | |
| 237 | local n = vez | |
| 238 | repeat | |
| 239 | n = fluxo == 1 and (n == 8 and 1 or n + 1) or (n == 1 and 8 or n - 1) | |
| 240 | until jogador[n] | |
| 241 | return n | |
| 242 | end | |
| 243 | ||
| 244 | function passarVez() | |
| 245 | vez = pegaProximo() | |
| 246 | draw = false | |
| 247 | atualizaPonteiro() | |
| 248 | atualizaTimer() | |
| 249 | ui.removeTextArea(15) | |
| 250 | ui.removeTextArea(16) | |
| 251 | ui.removeTextArea(17) | |
| 252 | end | |
| 253 | ||
| 254 | function estaNoLugar(p) | |
| 255 | local x = tfm.get.room.playerList[p].x | |
| 256 | return nome[p] and x > (nome[p]-1)*100+20 and x < (nome[p]-1)*100+80 | |
| 257 | end | |
| 258 | ||
| 259 | function usaDraw4() | |
| 260 | acumulo4 = acumulo4 + 4 | |
| 261 | ui.addTextArea(16, string.format("<p align='center'>"..txtDraw, d4, acumulo4), jogador[vez].nome, 250, 290, 300, 20, 1, 1, 0.4, true)
| |
| 262 | end | |
| 263 | ||
| 264 | function autoPlay() | |
| 265 | local p = jogador[vez].nome | |
| 266 | n = acumulo > 0 and acumulo or acumulo4 > 0 and acumulo4 or 1 | |
| 267 | acumulo = 0 | |
| 268 | acumulo4 = 0 | |
| 269 | if not draw then | |
| 270 | comprarCartas(p, n) | |
| 271 | end | |
| 272 | passarVez() | |
| 273 | if atual[1] == 5 then | |
| 274 | mudaCor() | |
| 275 | sel = true | |
| 276 | if atual[2] == d4 then | |
| 277 | usaDraw4() | |
| 278 | end | |
| 279 | end | |
| 280 | end | |
| 281 | ||
| 282 | function mudaCor(n) | |
| 283 | atual[1] = n or math.random(1,4) | |
| 284 | desenhaCarta(10, atual, nil, 420, 200) | |
| 285 | local b = {21, 23, 24, 22}
| |
| 286 | efeitoExplosao(b[atual[1]], 445, 230, 30, 20) | |
| 287 | end | |
| 288 | ||
| 289 | function usaSkip() | |
| 290 | efeitoExplosao(35, pegaProximo()*100-50, 100, 50, 10) | |
| 291 | passarVez() | |
| 292 | end | |
| 293 | ||
| 294 | function usaReverse() | |
| 295 | fluxo = fluxo == 1 and 2 or 1 | |
| 296 | atualizaFluxo() | |
| 297 | for i=20, 780, 10 do | |
| 298 | tfm.exec.displayParticle(3, i, 177, 0, 0, 0, 0) | |
| 299 | end | |
| 300 | end | |
| 301 | ||
| 302 | -- EVENTOS | |
| 303 | ||
| 304 | function eventNewGame() | |
| 305 | tempo = os.time()+1000 | |
| 306 | tfm.exec.setUIMapName(gameName) | |
| 307 | ui.addTextArea(0, "<font size='25px'><p align='center'>"..txtSit, nil, 0, 180, 800, 200, 0, 0, 0, false) | |
| 308 | for i, v in pairs(tfm.get.room.playerList) do | |
| 309 | tfm.exec.bindKeyboard(i, 32, true, true) | |
| 310 | system.bindMouse(i, true) | |
| 311 | end | |
| 312 | end | |
| 313 | ||
| 314 | function eventTextAreaCallback(id, p, cmd) | |
| 315 | if id == 15 and nome[p] == vez then | |
| 316 | mudaCor(tonumber(cmd)) | |
| 317 | passarVez() | |
| 318 | sel = true | |
| 319 | if atual[2] == d4 then | |
| 320 | acumulo4 = acumulo4 + 4 | |
| 321 | ui.addTextArea(16, string.format("<p align='center'>"..txtDraw, d4, acumulo4), jogador[vez].nome, 250, 290, 300, 20, 1, 1, 0.4, true)
| |
| 322 | end | |
| 323 | - | elseif cmd = "skip" then |
| 323 | + | elseif cmd == "skip" then |
| 324 | passarVez() | |
| 325 | end | |
| 326 | end | |
| 327 | ||
| 328 | function eventMouse(p, x, y) | |
| 329 | if modo == "start" then | |
| 330 | local xx = tfm.get.room.playerList[p].x | |
| 331 | if jogador[nome[p]] and y > 325 and y < 400 and estaNoLugar(p) then | |
| 332 | local carta = math.ceil((x+5 - (400 - (#jogador[nome[p]].mao*25)))/50) | |
| 333 | local mao = jogador[nome[p]].mao | |
| 334 | if vez == nome[p] and sel then | |
| 335 | 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 | |
| 336 | if atual[2] == d4 or atual[2] == wild then | |
| 337 | atual[1] = 5 | |
| 338 | end | |
| 339 | table.insert(pilha, atual) | |
| 340 | atual = table.remove(mao, carta) | |
| 341 | atualizaMao(p) | |
| 342 | desenhaCarta(10, atual, nil, 420, 200) | |
| 343 | atualizaScore(nome[p]) | |
| 344 | if #jogador[nome[p]].mao == 0 then | |
| 345 | ui.addTextArea(13, "", nil, 5, 5, 790, 400, 1, 1, 0.5, false) | |
| 346 | ui.addTextArea(14, string.format("<p align='center'><font size='60px' color='#ffffff'>"..txtGameOver, p), nil, 0, 170, 800, 400, 0, 0, 0, false)
| |
| 347 | tfm.exec.setPlayerScore(p, 1, true) | |
| 348 | modo = "fim" | |
| 349 | else | |
| 350 | if atual[2] == wild or atual[2] == d4 then | |
| 351 | sel = false | |
| 352 | draw = true | |
| 353 | 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, 290, 300, 30, 1, 1, 0.7, true)
| |
| 354 | else | |
| 355 | if atual[2] == skip then | |
| 356 | usaSkip() | |
| 357 | elseif atual[2] == rev then | |
| 358 | if duelo then | |
| 359 | usaSkip() | |
| 360 | else | |
| 361 | usaReverse() | |
| 362 | end | |
| 363 | elseif atual[2] == d2 then | |
| 364 | acumulo = acumulo + 2 | |
| 365 | ui.addTextArea(16, string.format("<p align='center'>"..txtDraw, d2, acumulo), jogador[pegaProximo()].nome, 250, 290, 300, 20, 1, 1, 0.4, true)
| |
| 366 | end | |
| 367 | passarVez() | |
| 368 | end | |
| 369 | end | |
| 370 | for i=1, 10 do | |
| 371 | tfm.exec.displayParticle(3, 445, 230, math.random(-20,20)/10, math.random(-20,20)/10, 0, 0) | |
| 372 | end | |
| 373 | end | |
| 374 | elseif os.time() > jogador[nome[p]].timer and mao[carta] then | |
| 375 | desenhaCarta(nome[p]+200, mao[carta], nil, (nome[p]-1)*100+30, 30) | |
| 376 | timerText(200+nome[p], 1000) | |
| 377 | jogador[nome[p]].timer = os.time()+2000 | |
| 378 | end | |
| 379 | elseif x > 325 and x < 375 and y > 195 and y < 245 and not draw and vez == nome[p] and sel then | |
| 380 | if acumulo > 0 or acumulo4 > 0 then | |
| 381 | comprarCartas(p, acumulo > 0 and acumulo or acumulo4) | |
| 382 | acumulo = 0 | |
| 383 | acumulo4 = 0 | |
| 384 | passarVez() | |
| 385 | else | |
| 386 | comprarCartas(p, 1) | |
| 387 | ui.addTextArea(16, "<p align='center'><a href='event:skip'>"..txtPass, p, 250, 290, 300, 20, 1, 1, 0.7, true) | |
| 388 | draw = true | |
| 389 | end | |
| 390 | end | |
| 391 | end | |
| 392 | end | |
| 393 | ||
| 394 | function eventChatCommand(p, cmd) | |
| 395 | local arg = split(cmd, " ") | |
| 396 | if p == adm then | |
| 397 | if arg[1] == "start" and modo == "inicio" then | |
| 398 | local r = {}
| |
| 399 | modo = "start" | |
| 400 | sel = true | |
| 401 | fluxo = 1 | |
| 402 | draw = false | |
| 403 | atual = nil | |
| 404 | atualizaTimer() | |
| 405 | baralho = embaralhar(cartas) | |
| 406 | pilha = {}
| |
| 407 | ui.removeTextArea(0) | |
| 408 | for i, v in pairs(jogador) do | |
| 409 | comprarCartas(v.nome, 7) | |
| 410 | table.insert(r, i) | |
| 411 | end | |
| 412 | duelo = #r == 2 | |
| 413 | repeat | |
| 414 | table.insert(pilha, atual) | |
| 415 | atual = table.remove(baralho) | |
| 416 | until atual[2] ~= d4 and atual[2] ~= wild and atual[2] ~= d2 and atual[2] ~= skip and atual[2] ~= rev | |
| 417 | desenhaCarta(10, atual, nil, 420, 200) | |
| 418 | desenhaBaralho() | |
| 419 | vez = r[math.random(#r)] | |
| 420 | atualizaPonteiro() | |
| 421 | atualizaFluxo() | |
| 422 | elseif arg[1] == "new" then | |
| 423 | novoJogo() | |
| 424 | elseif arg[1] == "skip" then | |
| 425 | autoPlay() | |
| 426 | elseif arg[1] == "ban" and arg[2] and nome[arrumaNick(arg[2])] then | |
| 427 | eventPlayerLeft(arrumaNick(arg[2])) | |
| 428 | end | |
| 429 | end | |
| 430 | end | |
| 431 | ||
| 432 | function eventKeyboard(p, t, d, x, y) | |
| 433 | if modo == "inicio" and os.time() > tempo and not nome[p] then | |
| 434 | if x > 20 and x < 80 and not jogador[1] then | |
| 435 | criaJogador(p, 1) | |
| 436 | elseif x > 120 and x < 180 and not jogador[2] then | |
| 437 | criaJogador(p, 2) | |
| 438 | elseif x > 220 and x < 280 and not jogador[3] then | |
| 439 | criaJogador(p, 3) | |
| 440 | elseif x > 320 and x < 380 and not jogador[4] then | |
| 441 | criaJogador(p, 4) | |
| 442 | elseif x > 420 and x < 480 and not jogador[5] then | |
| 443 | criaJogador(p, 5) | |
| 444 | elseif x > 520 and x < 580 and not jogador[6] then | |
| 445 | criaJogador(p, 6) | |
| 446 | elseif x > 620 and x < 680 and not jogador[7] then | |
| 447 | criaJogador(p, 7) | |
| 448 | elseif x > 720 and x < 780 and not jogador[8] then | |
| 449 | criaJogador(p, 8) | |
| 450 | end | |
| 451 | end | |
| 452 | end | |
| 453 | ||
| 454 | function eventLoop() | |
| 455 | for i, v in pairs(jogador) do | |
| 456 | if not estaNoLugar(v.nome) then | |
| 457 | ui.addTextArea(100, "<font size='50px' color='#ffffff'><p align='center'>"..txtWarn, v.nome, 5, 325, 790, 80, 0xff0000, 0xff0000, 1, true) | |
| 458 | else | |
| 459 | ui.removeTextArea(100, v.nome) | |
| 460 | end | |
| 461 | end | |
| 462 | if modo == "fim" then | |
| 463 | local b = {0, 1, 2, 4, 9, 11, 13}
| |
| 464 | local x, y, id = math.random(800), math.random(400), b[math.random(#b)] | |
| 465 | for i=1, 40 do | |
| 466 | tfm.exec.displayParticle(id, x, y, math.random(-20,20)/10, math.random(-20,20)/10, 0, 0) | |
| 467 | end | |
| 468 | if os.time() > tempoJogada and autoStart then | |
| 469 | atualizaTimer() | |
| 470 | eventChatCommand(adm, "new") | |
| 471 | end | |
| 472 | end | |
| 473 | if modo == "start" then | |
| 474 | if os.time() > tempoJogada then | |
| 475 | autoPlay() | |
| 476 | elseif tempoJogada - os.time() < 10000 then | |
| 477 | ui.addTextArea(17, "<p align='center'><font size='25px' color='#214A25'>"..math.ceil((tempoJogada - os.time())/1000), nil, 350, 210, 90, 100, 0, 0, 0, false) | |
| 478 | else | |
| 479 | ui.removeTextArea(17) | |
| 480 | end | |
| 481 | elseif modo == "inicio" then | |
| 482 | if os.time() > tempoJogada and autoStart then | |
| 483 | atualizaTimer() | |
| 484 | eventChatCommand(adm, "start") | |
| 485 | end | |
| 486 | end | |
| 487 | apagaText() | |
| 488 | end | |
| 489 | ||
| 490 | function eventNewPlayer(p) | |
| 491 | if modo == "inicio" then | |
| 492 | ui.addTextArea(0, "<font size='25px'><p align='center'>"..txtSit, p, 0, 180, 800, 200, 0, 0, 0, false) | |
| 493 | tfm.exec.bindKeyboard(p, 32, true, true) | |
| 494 | system.bindMouse(p, true) | |
| 495 | elseif modo == "start" then | |
| 496 | desenhaCarta(10, atual, p, 420, 200) | |
| 497 | desenhaBaralho(p) | |
| 498 | atualizaPonteiro(p) | |
| 499 | atualizaFluxo(p) | |
| 500 | end | |
| 501 | for i, v in pairs(jogador) do | |
| 502 | atualizaScore(i, p) | |
| 503 | end | |
| 504 | tfm.exec.respawnPlayer(p) | |
| 505 | tfm.exec.setUIMapName(gameName) | |
| 506 | end | |
| 507 | ||
| 508 | function eventPlayerLeft(p) | |
| 509 | if modo == "inicio" then | |
| 510 | if nome[p] then | |
| 511 | removeJogadorUI(p, nome[p]) | |
| 512 | end | |
| 513 | elseif modo == "start" then | |
| 514 | if nome[p] and jogador[nome[p]] then | |
| 515 | removeJogador(p, nome[p]) | |
| 516 | end | |
| 517 | end | |
| 518 | end | |
| 519 | ||
| 520 | function eventPlayerDied(p) | |
| 521 | tfm.exec.respawnPlayer(p) | |
| 522 | end | |
| 523 | ||
| 524 | -- INICIO | |
| 525 | ||
| 526 | tfm.exec.disableAutoScore(true) | |
| 527 | tfm.exec.disableAutoShaman(true) | |
| 528 | tfm.exec.disableAutoNewGame(true) | |
| 529 | tfm.exec.disableAfkDeath(true) | |
| 530 | for i, v in pairs(comandos) do | |
| 531 | system.disableChatCommandDisplay(v, true) | |
| 532 | end | |
| 533 | for i, v in pairs(tfm.get.room.playerList) do | |
| 534 | tfm.exec.setPlayerScore(i, 0, false) | |
| 535 | end | |
| 536 | tfm.exec.newGame(mapa) |