Created
April 26, 2018 09:10
-
-
Save madclaws/93874d0e48037031db4a36acae854340 to your computer and use it in GitHub Desktop.
error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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