Skip to content

Instantly share code, notes, and snippets.

@ManDeJan
Created October 3, 2020 18:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ManDeJan/0d6865416cae1974b0620b2a0547446a to your computer and use it in GitHub Desktop.
Save ManDeJan/0d6865416cae1974b0620b2a0547446a to your computer and use it in GitHub Desktop.
Random Pact of Punishment generator for the Hades game
# Hi! This script is a slow way to generate a random pact of punishment
# for the Hades game, if you want a more complete version, check out my
# friends work at https://github.com/Druyv/hades_randomizer
from random import choice
from itertools import product
pop = {
'Hard Labor' : [1, 2, 3, 4],
'Lasting Consequences' : [1, 2, 3],
'Convenience Fee' : [1, 2],
'Jury Summons' : [1, 2, 3],
'Extreme Measures' : [1, 3, 6, 10],
'Calisthenics Program' : [1, 2],
'Benefits Package' : [2, 5],
'Middle Management' : [1, 2],
'Underworld Customs' : [1, 2],
'Forced Overtime' : [2, 4, 6],
'Heightened Security' : [1],
'Routine Inspection' : [2, 4, 6, 8],
'Damage Control' : [1, 2],
'Approval Process' : [2, 5],
'Tight Deadline' : [2, 5],
}
heat = int(input('--- How much heat do you want (0-60)?\n>>> '))
all_combs = product(*[[(pact[0], heat) for heat in pact[1]] # for every pact option
for pact in [(name, [0] + heat) # prepend 0 heat as option
for name, heat in pop.items()]])
# this is a custom sum that can quit early for performance reasons
def sum_eq_or_max(max):
def inner(comb):
total = 0
for pun in comb:
total += pun[1]
if total > max:
return False
return total == max
return inner
print(f'--- Starting generation process (might take a while)')
filtered = list(filter(sum_eq_or_max(heat), all_combs))
print(f'--- Generated {len(filtered)} options for {heat} heat')
pact = choice(filtered)
print(f'--- Here is your random Pact of Punishment with {heat} heat')
print(f'{"Pact Option:":23}{"Level:"}')
print(*[f'{pun[0]:.<20}: {pun[1]:2}' for pun in pact], sep='\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment