+def conddecode(cond):
+ # If M=0 it's unconditional.
+ # If 0<M<100 it is done with M% probability.
+ # If M=100 unconditional, but forbidden to dwarves.
+ # If 100<M<=200 he must be carrying object M-100.
+ # If 200<M<=300 must be carrying or in same room as M-200.
+ # If 300<M<=400 game.prop(M % 100) must *not* be 0.
+ # If 400<M<=500 game.prop(M % 100) must *not* be 1.
+ # If 500<M<=600 game.prop(M % 100) must *not* be 2, etc.
+ if cond == 0:
+ return ""
+ elif cond < 100:
+ return "cond: [pct %d], " % cond
+ elif cond <= 200:
+ return "cond: [carry %s], " % objnames[cond-100]
+ elif cond <= 300:
+ return "cond: [with %s], " % objnames[cond-200]
+ else:
+ return "cond: [not %s %d], " % (objnames[cond % 100], (cond - 300) // 100)
+