misc/mythic.py
2025-09-04 13:59:01 -04:00

75 lines
1.9 KiB
Python

#!/usr/bin/env python3
# Code mostly written using llms no copyright is claimed
# but in case there is copyrightable matter here
# To the extent possible under law, Matt Arnold
# has waived all copyright and related or neighboring rights
# to Mythic Pie. This work is published from: United States.
import random
# Define the Fate table from Mythic Game Master Emulator
fate_table = [
"Exceptional Yes",
"Yes",
"Yes, but...",
"No, but...",
"No",
"Exceptional No"
]
# Define the Chaos Factor table from Mythic Game Master Emulator
chaos_factor_table = {
1: "Stable",
2: "Low",
3: "Moderate",
4: "Elevated",
5: "High",
6: "Very High",
7: "Extreme",
8: "Absolute Chaos",
9: "Total Chaos",
10: "Impossible Chaos"
}
# Define the Chaos Factor adjustments table from Mythic Game Master Emulator
chaos_factor_adjustments_table = {
"Stable": 0,
"Low": 1,
"Moderate": 2,
"Elevated": 3,
"High": 4,
"Very High": 5,
"Extreme": 6,
"Absolute Chaos": 7,
"Total Chaos": 8,
"Impossible Chaos": 9
}
# Function to roll Fate
def roll_fate(chaos_factor):
# Roll 2d10, one die for the Fate chart, one die for the Fate Modifier
fate_roll = random.randint(1, 10)
modifier_roll = random.randint(1, 10)
# Calculate the final Fate roll
final_roll = fate_roll + modifier_roll + chaos_factor_adjustments_table[chaos_factor] - 6
# If the final roll is less than 1, set it to 1
if final_roll < 1:
final_roll = 1
# If the final roll is greater than 6, set it to 6
if final_roll > 6:
final_roll = 6
# Return the result
return fate_table[final_roll - 1]
# Test the function with a Chaos Factor of "Moderate"
chaos_factor = "Moderate"
new_chaos_factor = random.randint(1, 10) + chaos_factor_adjustments_table[chaos_factor]
print("Chaos Factor:", chaos_factor_table[new_chaos_factor])
print("Fate Roll:", roll_fate(chaos_factor))