From f2c7dbddb602db06ec8e8a8c9a4134451acd52e9 Mon Sep 17 00:00:00 2001 From: Supremist Date: Tue, 28 Oct 2025 23:47:23 +0200 Subject: Move common data structs to game.py --- main.py | 45 +-------------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index 7d55e96..138da27 100644 --- a/main.py +++ b/main.py @@ -1,53 +1,10 @@ import math -from sys import base_exec_prefix -from distribution import Distribution from character import CharacterPlan +from game import Roll, d import pb2e -def d(edge_count): - res = Distribution() - if edge_count == 0: - res.insert(0, 1) - return res - prob = 1/edge_count - for val in range(1, edge_count+1): - res.insert(val, prob) - return res - - -class Roll: - Fumble = -1 - Fail = 0 - Success = 1 - Crit = 2 - - @staticmethod - def get_natural_success_mod(value): - if value <= 1: - return -1 - if value >= 20: - return 1 - return 0 - - @staticmethod - def check(value, dc, bonus=0): - res = 0 - rolled = value + bonus - if rolled >= dc + 10: - res = Roll.Crit - elif rolled >= dc: - res = Roll.Success - elif rolled <= dc - 10: - res = Roll.Fumble - res += Roll.get_natural_success_mod(value) - return Roll.clamp(res) - - @staticmethod - def clamp(value): - return max(Roll.Fumble, min(Roll.Crit, value)) - class Weapon: def __init__(self, crit_effect, main_die, potency, striking=1, fatal=0, -- cgit v1.2.3