diff options
| author | Supremist <sergkarv@gmail.com> | 2025-10-28 23:47:23 +0200 |
|---|---|---|
| committer | Supremist <sergkarv@gmail.com> | 2025-10-28 23:47:23 +0200 |
| commit | f2c7dbddb602db06ec8e8a8c9a4134451acd52e9 (patch) | |
| tree | e3d2e0e7900baf8057efc4e0813065ff16990b34 /main.py | |
| parent | e0911bc676e92ce15b7096b2e85f8b3965a48823 (diff) | |
| download | pf2e_calc-f2c7dbddb602db06ec8e8a8c9a4134451acd52e9.tar.xz pf2e_calc-f2c7dbddb602db06ec8e8a8c9a4134451acd52e9.zip | |
Move common data structs to game.py
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, |
