Code: Select all
[h: card_list="C2,C3,C4,C5,C6,C7,C8,C9,C10,CJ,CQ,CK,CA,JK"]
[h: init=getInitiativeList()]
[h: initiativeList=json.get(init,"tokens")]
[h, if(json.isEmpty(initiativeList)==1), CODE:{
[h: token_List=getSelected()]
[foreach(token,token_List,""), CODE:{
[h, token(token) : addToInitiative()]
}]
[h: init=getInitiativeList()]
[h: initiativeList=json.get(init,"tokens")]
}]
[h: currentPhase=json.get(init,"current")]
[h: tokenList=""]
[foreach(init,initiativeList,""), CODE:{
[h: tokenID=json.get(init,"tokenId")]
[h: tokenList=json.append(tokenList,tokenID)]
}]
[h: tokenList=json.unique(tokenList)]
[r, if(currentPhase=="-1"), CODE:{
[h: setInitiativeRound(1)]
[foreach(tokenID,tokenList,""), CODE:{
[h, token(tokenID) : type=getPropertyType()]
[h: jokerRoll=1d52]
[h: roll=1d13]
[h: jokerCheck=if(jokerRoll>50,14,roll)]
[h: rawk=input(
"junk|<html><b>Numbers Range 1 - 14</b></html>|-|LABEL|SPAN=TRUE",
"setROLL|" +jokerCheck +"|Manually Input Initiative for " +getName(tokenID) +"|TEXT|WIDTH=3")]
[h: abort(rawk)]
[h: total=setRoll]
[h: chosen_card=listGet(card_list,total-1)]
[h, token(tokenID) : setState(chosen_card,1)]
[h, token(tokenID) : setInitiative(total)]
}]
[h: sortInitiative()]
[h: setCurrentInitiative(0)]
[h: curToken=getInitiativeToken()]
[h, token(curToken) : type=getPropertyType()]
[h, token(curToken) : setState("Current",1)]
[h, if(type=="PC"), CODE:{
[h: broadcast(macroLink(getName(curToken),"charCheck@Lib:Forms","","",curToken) +" has received Initiative.")]
};{
[h: broadcast(macroLink(getName(curToken),"charCheck@Lib:Forms","","",curToken) +" has received Initiative.","gm")]
}]
[h, MACRO("charCheck@Lib:Forms") : ""]
};{}]
[h: initSize=initiativeSize()]
[r, if(currentPhase==initSize-1),CODE:{
[h: curToken=getInitiativeToken()]
[h, token(curToken) : setState("Current",0)]
[h, token(curToken) : initNumber=getInitiative()]
[h: initCheck=initNumber-1]
[h: chosen_card=listGet(card_list,initCheck)]
[h, token(curToken) : setState(chosen_card,0)]
[h: init=getInitiativeList()]
[h: initiativeList=json.get(init,"tokens")]
[h: tokenList=""]
[h: initList=""]
[foreach(init,initiativeList,""), CODE:{
[h: tokenID=json.get(init,"tokenId")]
[h: tokenList=listAppend(tokenList,tokenID)]
[h: tokenInitiative=json.get(init,"initiative")]
[h: initList=listAppend(initList,tokenInitiative)]
}]
[h: dis=getInitiativeRound()]
[h: setInitiativeRound(sum(dis+1))]
[h: removeAllFromInitiative()]
[h: currentRound=dis]
[h: setInitiativeRound(currentRound +1)]
[foreach(tokenID,tokenList,""), CODE:{
[h, token(tokenID) : addToInitiative()]
[h: jokerRoll=1d52]
[h: roll=1d13]
[h: jokerCheck=if(jokerRoll>50,14,roll)]
[h: rawk=input(
"junk|<html><b>Numbers Range 1 - 14</b></html>|-|LABEL|SPAN=TRUE",
"setROLL|" +jokerCheck +"|Manually Input Initiative for " +getName(tokenID) +"|TEXT|WIDTH=3")]
[h: abort(rawk)]
[h: total=setRoll]
[h: chosen_card=listGet(card_list,total-1)]
[h, token(tokenID) : setState(chosen_card,1)]
[h, token(tokenID) : setInitiative(total)]
}]
[h: sortInitiative()]
[h: setCurrentInitiative(0)]
[h: curToken=getInitiativeToken()]
[h, token(curToken) : type=getPropertyType()]
[h, token(curToken) : setState("Current",1)]
[h, if(type=="PC"), CODE:{
[h: broadcast(macroLink(getName(curToken),"charCheck@Lib:Forms","","",curToken) +" has received Initiative.")]
};{
[h: broadcast(macroLink(getName(curToken),"charCheck@Lib:Forms","","",curToken) +" hase received Initiative.","gm")]
}]
};{}]
[r, if(currentPhase>-1 && currentPhase<initSize-1), CODE:{
[h: curToken=getInitiativeToken()]
[h, token(curToken) : setState("Current",0)]
[h, token(curToken) : initNumber=getInitiative()]
[h: initCheck=initNumber-1]
[h: chosen_card=listGet(card_list,initCheck)]
[h, token(curToken) : setState(chosen_card,0)]
[h: nextInitiative()]
[h: curToken=getInitiativeToken()]
[h, token(curToken) : type=getPropertyType()]
[h, token(curToken) : setState("Current",1)]
[h, if(type=="PC"), CODE:{
[h: broadcast(macroLink(getName(curToken),"charCheck@Lib:Forms","","",curToken) +" has received Initiative.")]
};{
[h: broadcast(macroLink(getName(curToken),"charCheck@Lib:Forms","","",curToken) +" has received Initiative.","gm")]
}]
[h, MACRO("charCheck@Lib:Forms") : ""]
};{}]
[h: curToken=getInitiativeToken()]
[h: selectTokens(curToken)]
[h, MACRO("charCheck@Lib:Forms") : ""]