Skip to content

Instantly share code, notes, and snippets.

@madclaws
Created April 26, 2018 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madclaws/93874d0e48037031db4a36acae854340 to your computer and use it in GitHub Desktop.
Save madclaws/93874d0e48037031db4a36acae854340 to your computer and use it in GitHub Desktop.
error
local function onRequestDice(context,payload)
local id,jsonData,isAllowed,diceVal
jsonData=RecordsInst.nk.json_decode(payload)
id=jsonData.id
-- if not checkTurn(id) then
-- return RecordsInst.nk.json_encode({["dice"]=0})
-- else
diceVal=math.random(6)
-- return RecordsInst.nk.json_encode({["dice"]=diceVal})
return manageNextTurn(_diceval)
-- end
end
local function manageNextTurn(_diceval)
local t_count
updateDiceValue(_diceval,_currentPlayer.current)
if _diceval ~= 6 then
updateActivestate(false,_currentPlayer.current)
t_count=_currentPlayer.current+1
t_count=t_count%_currentPlayer.total
RecordsInst.updateCount(_currentPlayer.current)
updateActivestate(true,t_count)
end
return RecordsInst.nk.json_encode({["dice"]=_diceval,["id"]=_currentPlayer.current})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment