Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function start()
- -- Jeu complet (modérateur, joueurs au hasard, etc.) --
- modo = "Pseudo"
- texteg = "Tu es le joueur qui jouera avec les"
- wintxt = "Le gagnant de cette partie est"
- t = -0.5 -- Ne touchez pas !
- tfm.exec.setGameTime (900, init)
- version = "v. 1.3"
- joueur_tourX = true
- joueur_tourO = false
- joueurs = {}
- for name, pseudo in pairs(tfm.get.room.playerList) do
- table.insert(joueurs, name)
- end
- if joueurs[2] == nil then
- print("<R>Vous êtes seul, vous ne pouvez pas jouer, désolé.")
- else
- joueur_hasardX = joueurs[math.random(#joueurs)]
- joueur_hasardO = joueurs[math.random(#joueurs)]
- game = {}
- ui.addTextArea (0, "<p align='center'>"..texteg.." X </p", ""..joueur_hasardX.."", 13, 21, 776, 17, 0x000001, 0xffffff, 1.0, true)
- ui.addTextArea (0, "<p align='center'>"..texteg.." O </p", ""..joueur_hasardO.."", 13, 21, 776, 17, 0x000001, 0xffffff, 1.0, true)
- ui.addTextArea (1, "O", nil, 268, 103, 146, 146, 0xffffff, 0xffffff, 1.0, true)
- ui.addTextArea (2, "<P align='center'>-- Tic Tac Mousse by Izzeberg --<br>-- "..version.." --<br> C'est le joueur avec les X qui commence !<br>"..joueur_hasardO.."(O) vs "..joueur_hasardX.."(X) <P>", nil, 514, 70, 197, 70, 0x000001, 0xffffff, 1.0, true)
- ui.addTextArea(3, "<P align='center'><a href ='event:osco'>Nouvelle partie </a>", nil, 15, 375, 100, 19, 0x000001, 0xffffff, 1.0, true)
- ui.addTextArea(110, "<br><a href='event:1c'> . </a>", nil, 268, 103, 42, 42, 0x000001, 0xffffff, 1.0, true)
- ui.addTextArea(120, "<br><a href='event:2c'> . </a>", nil, 320, 103, 42, 42, 0x000001, 0xffffff, 1.0, true)
- ui.addTextArea(130, "<br><a href='event:3c'> . </a>", nil, 372, 103, 42, 42, 0x000001, 0xffffff, 1.0, true)
- ui.addTextArea(140, "<br><a href='event:4c'> . </a>", nil, 268, 155, 42, 42, 0x000001, 0xffffff, 1.0, true)
- ui.addTextArea(150, "<br><a href='event:5c'> . </a>", nil, 320, 155, 42, 42, 0x000001, 0xffffff, 1.0, true)
- ui.addTextArea(160, "<br><a href='event:6c'> . </a>", nil, 372, 155, 42, 42, 0x000001, 0xffffff, 1.0, true)
- ui.addTextArea(170, "<br><a href='event:7c'> . </a>", nil, 268, 207, 42, 42, 0x000001, 0xffffff, 1.0, true)
- ui.addTextArea(180, "<br><a href='event:8c'> . </a>", nil, 320, 207, 42, 42, 0x000001, 0xffffff, 1.0, true)
- ui.addTextArea(190, "<br><a href='event:9c'> . </a>", nil, 372, 207, 42, 42, 0x000001, 0xffffff, 1.0, true)
- samePlayerVerify()
- end
- end
- function click(textAreaId, name, x, y, other)
- if name == joueur_hasardX then
- if joueur_tourX == true then
- game[other] = "X"
- ui.addTextArea(textAreaId, "<br> X ", nil, x, y, 42, 42, 0x000001, 0xffffff, 1.0, true)
- joueur_tourX = false
- joueur_tourO = true
- gameVerify()
- end
- elseif name == joueur_hasardO then
- if joueur_tourO == true then
- game[other] = "O"
- ui.addTextArea(textAreaId, "<br> O ", nil, x, y, 42, 42, 0x000001, 0xffffff, 1.0, true)
- joueur_tourO = false
- joueur_tourX = true
- gameVerify()
- end
- end
- end
- function samePlayerVerify()
- if joueur_hasardO == joueur_hasardX then
- start()
- end
- end
- function eventTextAreaCallback(textAreaId, name, callback)
- if callback == "1c" then
- click(110,name,268,103,1)
- elseif callback == "2c" then
- click(120,name,320,103,2)
- elseif callback == "3c" then
- click(130,name,372,103,3)
- elseif callback == "4c" then
- click(140,name,268,155,4)
- elseif callback == "5c" then
- click(150,name,320,155,5)
- elseif callback == "6c" then
- click(160,name,372,155,6)
- elseif callback == "7c" then
- click(170,name,268,207,7)
- elseif callback == "8c" then
- click(180,name,320,207,8)
- elseif callback == "9c" then
- click(190,name,372,207,9)
- elseif callback == "osco" then
- if name == ""..modo.."" then
- start()
- end
- end
- end
- function gameVerify()
- for other,nb in pairs({1,2,3,4,5,6,7,8,9}) do
- if game[other] == nil then
- else
- gameVerify2("X")
- gameVerify2("O")
- end
- end
- end
- function gameVerify2(value)
- if game[1] == value and game[2] == value and game[3] == value then
- win(value)
- elseif game[4] == value and game[5] == value and game[6] == value then
- win(value)
- elseif game[7] == value and game[8] == value and game[9] == value then
- win(value)
- elseif game[1] == value and game[4] == value and game[7] == value then
- win(value)
- elseif game[2] == value and game[5] == value and game[8] == value then
- win(value)
- elseif game[3] == value and game[6] == value and game[9] == value then
- win(value)
- elseif game[1] == value and game[5] == value and game[9] == value then
- win(value)
- elseif game[3] == value and game[5] == value and game[7] == value then
- win(value)
- else
- if win == false then
- win("nul")
- end
- end
- end
- function win(value)
- if value == "X" then
- win = true
- ui.addTextArea (0, "<font color='#000000'><p align='center'>"..wintxt.." "..joueur_hasardX.."</p>", nil, 13, 21, 776, 17, 0xffff00, 0x000001, 1.0, true)
- t = 10.5
- elseif value == "O" then
- win = true
- ui.addTextArea (0, "<font color='#000000'><p align='center'>"..wintxt.." "..joueur_hasardO.."</p>", nil, 13, 21, 776, 17, 0xffff00, 0x000001, 1.0, true)
- t = 10.5
- elseif value == "nul" then
- ui.addTextArea (0, "<font color='#000000'><p align='center'>Partie nul</p>", nil, 13, 21, 776, 17, 0xffff00, 0x000001, 1.0, true)
- t = 10.5
- end
- end
- function eventLoop()
- t = t - 0.5
- if t == 0.5 then
- start()
- end
- end
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement