I don't know if anybody plays them, or if any roller code has already been posted, but I thought I'd share. For those who don't know, the mechanic for those games is to roll a pool of 2 to 10 d10's, and then count matches. If you get a match (two dice coming up the same number), you have a set. Set have "width" - in other words, how many dice matched; and "height", or what number was matched.
So if you rolled and had two dice come up 10, you would have a set that was 2 wide and 10 high, or a "2x10" set.
Anyway, so I wrote a macro that rolls some number of d10s and figures out how many sets.
Code: Select all
[h:resList=""]
[h:outputList=""]
[h,count(dicepool),CODE:
{
[h:resList=setStrProp(resList,"roll"+roll.count,1d10)]
}]
[h:sets1=0]
[h:sets2=0]
[h:sets3=0]
[h:sets4=0]
[h:sets5=0]
[h:sets6=0]
[h:sets7=0]
[h:sets8=0]
[h:sets9=0]
[h:sets10=0]
[h,count(10),code:
{
[h:sets1=sets1+if(getStrProp(resList,"roll"+roll.count)=="1",1,0)]
[h:sets2=sets2+if(getStrProp(resList,"roll"+roll.count)=="2",1,0)]
[h:sets3=sets3+if(getStrProp(resList,"roll"+roll.count)=="3",1,0)]
[h:sets4=sets4+if(getStrProp(resList,"roll"+roll.count)=="4",1,0)]
[h:sets5=sets5+if(getStrProp(resList,"roll"+roll.count)=="5",1,0)]
[h:sets6=sets6+if(getStrProp(resList,"roll"+roll.count)=="6",1,0)]
[h:sets7=sets7+if(getStrProp(resList,"roll"+roll.count)=="7",1,0)]
[h:sets8=sets8+if(getStrProp(resList,"roll"+roll.count)=="8",1,0)]
[h:sets9=sets9+if(getStrProp(resList,"roll"+roll.count)=="9",1,0)]
[h:sets10=sets10+if(getStrProp(resList,"roll"+roll.count)=="10",1,0)]
}]
[h,for(x,0,9),CODE:
{
[h:setSlot=x+1]
[h:sets=eval("sets"+setSlot)]
[h:setString=if(sets>=2, sets+"x"+setSlot, "")]
[h:outputList=if(setString!="", listAppend(outputList, setString), outPutList)]
}]
[IF(outputList!=""),CODE:
{
Rolling [r:dicepool+"d"]: [r:outputList]
};
{
Rolling [r:dicepool+"d"]: No sets.
};]