Shadowrun dice roller with exploding sixes (edge) and glitch/critical detection
from random import randint _s = chr(144) def _re(dice, edge=False): ro = _r(dice) _dp(ro["d"]) if edge: rs = ro["s"] while rs: rr = _r(rs) for k in ro: ro[k] += rr[k] rs = rr["s"] _dp(rr["d"]) if ro["o"] >= len(ro["d"])/2: if ro["h"]: print(_s+" glitch!") else: print(_s+" CRITICAL GLITCH!") if ro["h"]: print(_s+_s+" "+str(ro["h"])+" ") print() def _dp(d): print((chr(149) if len(d) <= 15 else "").join(map(str,sorted(d)[::-1]))) def _r(di): out = dict(d=[], h=0, s=0, o=0) for i in range(di): r = randint(1,6) out["d"].append(r) if r == 6: out["s"] += 1 if r >= 5: out["h"] += 1 if r == 1: out["o"] += 1 return out def roll(): _di = True for i in range(12): print() while _di: ed = False _di = input("Roll (d,e) "+_s+" ") if _di == "" or _di == "0": break _di = _di.split(",",2) if len(_di) > 1: ed = int(_di[1]) _di = int(_di[0]) _re(_di, ed)