Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tPlayers = {[1] = 'board'}
- -- tPlayers[playerID] = string
- tCards = {}
- -- tCards[playerID][cardID] = (2/3/4/5/6/7/8/9/T/J/Q/K + d/s/h/c)
- -- example: tCards[4][2] = 'Jc'
- tStatus = {}
- -- tStatus[playerID][cardID] = boolean
- -- example: tCards[4][2] = 0
- tMoney = {}
- -- tMoney[playerID] = number
- local tH = {
- '2d', '3d', '4d', '5d', '6d', '7d', '8d', '9d', 'Td', 'Jd', 'Qd', 'Kd', 'Ad', -- diamonds
- '2s', '3s', '4s', '5s', '6s', '7s', '8s', '9s', 'Ts', 'Js', 'Qs', 'Ks', 'As', -- spades
- '2h', '3h', '4h', '5h', '6h', '7h', '8h', '9h', 'Th', 'Jh', 'Qh', 'Kh', 'Ah', -- hearts
- '2c', '3c', '4c', '5c', '6c', '7c', '8c', '9c', 'Tc', 'Jc', 'Qc', 'Kc', 'Ac'} -- clubs
- for i = 0, 13 do
- tCards[i] = {0, 0, 0, 0, 0}
- tStatus[i] = {0, 0, 0, 0, 0}
- tMoney[i]=0
- end
- function shuffle()
- trs = math.random(1, 13)
- for i = 0, trs do
- i = 53
- while i > 1 do
- i = i - 1
- j = math.random(1, i)
- tH[j], tH[i] = tH[i], tH[j]
- end
- end
- return tH
- end
- local function addPlayer() -- dealer
- id, msg = rednet.receive()
- msg = textutils.unserialize(msg)
- if msg[1] == 'add' then
- tPlayers[#tPlayers+1] = msg[2]
- end
- end
- local function resetCards() -- dealer
- for i = 0, 13 do
- tCards[i] = {0, 0, 0, 0, 0}
- tStatus[i] = {0, 0, 0, 0, 0}
- end
- end
- local function addMoney(plid, amount) -- dealer
- tMoney[plid] = amount
- end
- local function ShowHideC(plid, crdid, st) -- playerID, cardID, status \\ dealer, player
- tStatus[plid][crdid] = st
- end
- local function cardTransfer(plid, tgid, crdid) -- dealer, player
- tgCid = #tCards[tgid]+1
- tCards[tgid][tgCid] = tCards[plid][crdid]
- ShowHideC(tgid, tgCid, tStatus[plid][crdid])
- end
- local function moneyTransfer(plid, tgid, amount) -- dealer, player
- tMoney[tgid] = tMoney[tgid]+amount
- tMoney[plid] = tMoney[plid]-amount
- end
- local function executeCMD(command, v1, v2, v3)
- if command == 'shuffle' then shuffle()
- elseif command == 'addPlayer' then addPlayer()
- elseif command == 'addMoney' then addMoney(v1, v2)
- elseif command == 'cardTransfer' then cardTransfer(v1, v2, v3)
- elseif command == 'showCards' then ShowHideC(v1, v2, v3)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement