Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def d20_with_adv(adv):
"""Returns Xd20 for the correct advantage type."""
if adv == d20.AdvType.NONE:
return "1d20"
elif adv == d20.AdvType.ADV:
return "2d20kh1"
elif adv == d20.AdvType.DIS:
return "2d20kl1"
elif adv == 2:
return "3d20kh1"
return "1d20"
def _string_search_adv(rollstr):
adv = d20.AdvType.NONE
if re.search('(^|\s+)(adv|dis)(\s+|$)', rollstr) is not None:
adv = d20.AdvType.ADV if re.search('(^|\s+)adv(\s+|$)', rollstr) is not None else d20.AdvType.DIS
rollstr = re.sub('(adv|dis)(\s+|$)', '', rollstr)
return rollstr, adv