diff options
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 45 |
1 files changed, 1 insertions, 44 deletions
@@ -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, |
