Created
March 26, 2020 06:48
-
-
Save chrisledet/0e29fdf148a6bc222b656360b466bb7a to your computer and use it in GitHub Desktop.
script to calculate travel times for long distances in D&D 5e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
SPEED_PER_HOUR = { | |
'fast': 4, # miles | |
'normal': 3, | |
'slow': 2, | |
} | |
TRAVEL_TIME_PER_DAY = { | |
'fast': 7, # hours | |
'normal': 8, | |
'slow': 9, | |
} | |
def calc_travel_time(distance, pace='normal', mounted=False): | |
""" return number of days it will take to arrive """ | |
travelled = TRAVEL_TIME_PER_DAY[pace] * SPEED_PER_HOUR[pace] | |
if mounted: # mounted only gives an extra hour of speed | |
travelled += SPEED_PER_HOUR[pace] | |
return round(distance / travelled, 1) | |
if __name__ == '__main__': | |
if len(sys.argv) < 2: | |
print(f'usage: <distance in miles> [--mounted]') | |
exit(1) | |
distance = int(sys.argv[1]) | |
mounted = '--mounted' in sys.argv | |
for pace in ('fast', 'normal', 'slow'): | |
travel_time = calc_travel_time(distance, pace, mounted) | |
while_mounted = 'while mounted' if mounted else '' | |
print(f'[{pace}]: \t {travel_time} days {while_mounted}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment