dice.py: renamed program, cleaned up both input and output formats
This commit is contained in:
parent
34c82f0e52
commit
eb1c897b96
|
@ -62,7 +62,6 @@ class Dice():
|
||||||
# Get the results
|
# Get the results
|
||||||
total = sum(results) + self.mod
|
total = sum(results) + self.mod
|
||||||
|
|
||||||
# fixme - verbose mode could use slightly better formatting re: drop_info and reroll_info...
|
|
||||||
if verbose:
|
if verbose:
|
||||||
drop_info = ''
|
drop_info = ''
|
||||||
reroll_info = ''
|
reroll_info = ''
|
||||||
|
@ -86,15 +85,15 @@ class Dice():
|
||||||
mod_info = ''
|
mod_info = ''
|
||||||
|
|
||||||
if self.reroll:
|
if self.reroll:
|
||||||
reroll_info = ', reroll <= {}'.format(self.reroll)
|
reroll_info = ' [reroll {}'.format(self.reroll)
|
||||||
|
|
||||||
if self.reroll_times:
|
if self.reroll_times:
|
||||||
reroll_info = reroll_info + ' up to {} times'.format(self.reroll_times)
|
reroll_info = reroll_info + 'x{}'.format(self.reroll_times)
|
||||||
|
reroll_info = reroll_info + ']'
|
||||||
|
|
||||||
if self.drop_low:
|
if self.drop_low:
|
||||||
drop_info = drop_info + ', drop low {}'.format(self.drop_low)
|
drop_info = drop_info + ' [drop low {}]'.format(self.drop_low)
|
||||||
if self.drop_high:
|
if self.drop_high:
|
||||||
drop_info = drop_info + ', drop high {}'.format(self.drop_high)
|
drop_info = drop_info + ' [drop high {}]'.format(self.drop_high)
|
||||||
|
|
||||||
if self.mod > 0:
|
if self.mod > 0:
|
||||||
mod_info = '+{}'.format(self.mod)
|
mod_info = '+{}'.format(self.mod)
|
||||||
|
@ -123,14 +122,14 @@ def parse_input(args):
|
||||||
reroll = 0
|
reroll = 0
|
||||||
reroll_times = 0
|
reroll_times = 0
|
||||||
|
|
||||||
for m in re.findall(r'[hl+-]\d+', arg):
|
for m in re.findall(r'[dD+-]\d+', arg):
|
||||||
if m[0] == '-':
|
if m[0] == '-':
|
||||||
mod += int(m)
|
mod += int(m)
|
||||||
elif m[0] == '+':
|
elif m[0] == '+':
|
||||||
mod += int(m[1:])
|
mod += int(m[1:])
|
||||||
elif m[0] == 'h':
|
elif m[0] == 'D':
|
||||||
dhigh = int(m[1:])
|
dhigh = int(m[1:])
|
||||||
elif m[0] == 'l':
|
elif m[0] == 'd':
|
||||||
dlow = int(m[1:])
|
dlow = int(m[1:])
|
||||||
|
|
||||||
m = re.search(r'r(\d+)(x\d+)?', arg)
|
m = re.search(r'r(\d+)(x\d+)?', arg)
|
||||||
|
@ -159,8 +158,8 @@ This will roll X Y-sided dice and apply the specified modifiers.
|
||||||
Modifiers can be any of the following (where N and M are integers):
|
Modifiers can be any of the following (where N and M are integers):
|
||||||
|
|
||||||
(+|-)N Add or subtract N from the total
|
(+|-)N Add or subtract N from the total
|
||||||
lN Drop the lowest-rolling N dice from the total
|
dN Drop the lowest-rolling N dice from the total
|
||||||
hN Drop the highest-rolling N dice from the total
|
DN Drop the highest-rolling N dice from the total
|
||||||
rN[xM] Any dice that roll <= N will be rerolled.
|
rN[xM] Any dice that roll <= N will be rerolled.
|
||||||
If the optional 'xM' option is specified, dice will be rerolled a maximum of M times.
|
If the optional 'xM' option is specified, dice will be rerolled a maximum of M times.
|
||||||
Otherwise each die will be rerolled until the result is > N
|
Otherwise each die will be rerolled until the result is > N
|
Loading…
Reference in New Issue
Block a user