Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ UNO v1.01
- Pensez à mettre vous mettre en admin (voir ligne 8)
- Liste des commandes : !inv pseudo => Permet d'inviter un joueur à la prochaine partie
- !new => Permet de lancer une nouvelle partie
- !init => Permet de réinitialiser le module (à ne pas utiliser)
- ]]
- admin = "Pseudo" -- Remplacez Pseudo par votre pseudo (entre les "")
- --------------------------------------
- -- Évitez de toucher à ce qui suit --
- --------------------------------------
- color = { 'R', 'J', 'V', 'BL' }
- special = { "+2" , "↔", "Ø" }
- function initC ()
- for k, v in ipairs(color) do
- for n=1, 19 do
- table.insert(cartes, { ["color"]=v, ["value"]=n%10 })
- end
- for l, w in ipairs(special) do
- table.insert(cartes, { ["color"]=v, ["value"]=w })
- end
- end
- for k=1, 4 do
- table.insert(cartes, { ["color"]="ROSE", ["value"]="+4" })
- table.insert(cartes, { ["color"]="ROSE", ["value"]="C" })
- end
- end
- function initP ()
- paquet = {}
- local n = 0
- while #cartes ~= 0 do
- n = math.random(#cartes)
- table.insert(paquet, cartes[n])
- table.remove(cartes, n)
- end
- end
- function init ()
- initC()
- initP()
- for id in ipairs(playerL) do
- playerL[id]["cards"]={}
- giveCards(id, 7)
- ui.addTextArea (0, geneTJ (id), playerL[id]["name"], 5, 30, 790, 18, 1, 1, 0.75, true)
- end
- ui.addTextArea (-1, geneTA (), nil, 375, 150, 50, 30, 1, 1, 0.5, true)
- ui.addTextArea (-2, "C'est à "..playerL[playerA]["name"].." de jouer.", nil, 75, 60, 200, 20, 1, 1, 0.5, true)
- ui.addTextArea (-3, "<a href='event:pass 1'><b>passer</b></a>", nil, 5, 60, 60, 20, 1, 0, 0.75, true)
- ui.addTextArea (-4, geneTL(), nil, 5, 90, 110, 100, 1, 1, 0.5, true)
- end
- function eventTextAreaCallback (id, name, call)
- local idN = findId(name)
- if name == playerL[playerA]["name"] and ig then
- if string.sub(call, 0, 4) == "pass" then
- giveCards (idN, tonumber(string.sub(call, 6)))
- endT()
- else
- local c = playerL[idN]["cards"][tonumber(call)]
- if valide(c) then
- if c.value == "+2" then
- endT()
- giveCards ( playerA, 2)
- elseif c.value == "+4" then
- endT()
- giveCards (playerA, 4)
- elseif c.value == "Ø" then
- endT()
- elseif c.value == "↔" then
- sens = -sens
- end
- table.insert(paquet, c)
- table.remove(playerL[idN]["cards"], tostring(call))
- endT()
- end
- end
- for id, tab in ipairs(playerL) do
- ui.updateTextArea (0, geneTJ(id), tab.name)
- end
- end
- end
- function geneTJ (id)
- local s =""
- for k, v in ipairs(playerL[id]["cards"]) do
- s = s.." <"..v.color.."><a href='event:"..tostring(k).."'>"..v.value.."</a>"
- end
- return "<p align='center'><b>"..s.." </b></p>"
- end
- function geneTA ()
- local c = paquet[#paquet]
- return "<p align='center'><font size='20'><"..c.color.."><b>"..c.value.."</b></N></font></a>"
- end
- function geneTL ()
- local s =""
- for id, tab in ipairs(playerL) do
- s = s..tab.name.." : "..#tab.cards.."\n"
- end
- return s
- end
- function valide (tab)
- local c = paquet[#paquet]
- return (c.value == tab.value) or (c.color == tab.color) or (tab.color == "ROSE") or (c.color == "ROSE")
- end
- function endT ()
- ui.updateTextArea(-1, geneTA(), nil)
- if #playerL[playerA]["cards"] == 0 then
- ui.addPopup (1, 0, "<p align='center'>"..playerL[playerA]["name"].." vient de gagner !!\nFélicitations à lui</p>", nil, 300, 150, 200, true)
- ig = false
- end
- if sens == -1 then playerA = (playerA-2)%#playerL +1 else playerA = (playerA%#playerL)+1 end
- ui.updateTextArea(-2, "C'est à "..playerL[playerA]["name"].." de jouer", nil)
- ui.updateTextArea(-4, geneTL(), nil)
- end
- function giveCards (idP, nb)
- table.insert(playerL[idP]["cards"], paquet[1])
- table.remove(paquet, 1)
- if nb > 1 then giveCards(idP, nb-1) end
- end
- function findId (name)
- for id, tab in ipairs(playerL) do
- if tab["name"] == name then return id end
- end
- end
- function eventPopupAnswer (id, name, answer)
- if (answer == "yes") and (ig ~= true) then
- table.insert(playerL, {["name"]=name, ["cards"]={} })
- end
- end
- function eventChatCommand (name, command)
- if name == admin then
- if command == "new" then
- playerA = 1
- cartes = {}
- paquet = {}
- sens = 1
- init()
- ig = true
- elseif command == "init" then
- playerL = {}
- playerA = 1
- cartes = {}
- paquet = {}
- sens = 1
- ig = false
- elseif (string.sub(command, 1, 3) == "inv") and (ig ~= true) then
- ui.addPopup(1, 1, admin.." t'invite à faire une partie de UNO. Tu acceptes ?", string.sub(command, 5), 350, 180, 200, true)
- end
- end
- end
- eventChatCommand (admin, "init")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement