exten => s,1,set(__ROOMMATE[1]=Brad)
exten => s,2,set(__MATEWEIGHT[1]=75)
exten => s,3,set(__WINNERS=0) ;at first we have no winners
exten => s,4,set(__CLEANER[1]=NoOne) ;and we'll use a new counter
exten => s,5,while($[${WINNERS} < 2]) ;while we dont have two winners...
exten => s,6,goto(Brad,1) ;go to an extension based on roommate name below
exten => s,7,endwhile
;;;;;;;;Go to exten brad, and use his weight to "draw" for a "win";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
exten => Brad,1,random(${MATEWEIGHT[1]}:Brad,3) ;jump to three if we have a winner
exten => Brad,2,goto(s,5) ;or else draw again.
exten => Brad,3,gotoif($["${CLEANER[1]}" = "Brad"]?4:4) ;did we just pick him?
exten => Brad,4,set(__WINNERS=$[${WINNERS}+1]) ;if not we have a winner
exten => Brad,5,set(__CLEANER[${WINNERS}]=${ROOMMATE[1]}) ;and we set the CLEANER variable
exten => Brad,6,goto(s,5) ;and draw again
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
exten => s,7,noop(${CLEANER[1]} "and" ${CLEANER[2]})
exten => s,8,hangup
-- Executing Goto("SIP/Brian-bcdc", "gototest|s|1") in new stack
-- Goto (gototest,s,1)
-- Executing Set("SIP/Brian-bcdc", "__ROOMMATE[1]=Brad") in new stack
-- Executing Set("SIP/Brian-bcdc", "__MATEWEIGHT[1]=75") in new stack
-- Executing Set("SIP/Brian-bcdc", "__WINNERS=0") in new stack
-- Executing Set("SIP/Brian-bcdc", "__CLEANER[1]=NoOne") in new stack
-- Executing While("SIP/Brian-bcdc", "1") in new stack
-- Executing Goto("SIP/Brian-bcdc", "Brad|1") in new stack
-- Goto (gototest,Brad,1)
-- Executing Random("SIP/Brian-bcdc", "75:Brad|3") in new stack
-- Random branches to (gototest,Brad,3)
-- Executing GotoIf("SIP/Brian-bcdc", "0?4:4") in new stack
-- Goto (gototest,Brad,4)
-- Executing Set("SIP/Brian-bcdc", "__WINNERS=1") in new stack
-- Executing Set("SIP/Brian-bcdc", "__CLEANER[1]=Brad") in new stack
-- Executing Goto("SIP/Brian-bcdc", "s|5") in new stack
-- Goto (gototest,s,5)
-- Executing While("SIP/Brian-bcdc", "1") in new stack
-- Executing Goto("SIP/Brian-bcdc", "Brad|1") in new stack
-- Goto (gototest,Brad,1)
-- Executing Random("SIP/Brian-bcdc", "75:Brad|3") in new stack
-- Random branches to (gototest,Brad,3)
-- Executing GotoIf("SIP/Brian-bcdc", "1?4:4") in new stack
-- Goto (gototest,Brad,4)
-- Executing Set("SIP/Brian-bcdc", "__WINNERS=2") in new stack
-- Executing Set("SIP/Brian-bcdc", "__CLEANER[2]=Brad") in new stack
-- Executing Goto("SIP/Brian-bcdc", "s|5") in new stack
-- Goto (gototest,s,5)
-- Executing While("SIP/Brian-bcdc", "0") in new stack
-- Jumping to priority 7
-- Executing Hangup("SIP/Brian-bcdc", "") in new stack
== Spawn extension (gototest, s, 8) exited non-zero on 'SIP/Brian-bcdc'