# Path: athlib/utils.py
# def check_event_code(c: str) -> Optional[Match[str]]:
#     return PAT_EVENT_CODE.match(c)


from math import floor
from athlib.utils import check_event_code
"""IAAF Hungarian (non-combined-events) scoring system

IAAF has published a book of scoring factors, containing about 183,000
individual data points.  It is alleged that the formula herein gives the 
exact same answers.  We'll find out shortly ;-)

score = floor(b * (performance + a)**2  + c), 1)

See https://github.com/GlaivePro/IaafPoints

"""

def score(gender, inout, event_code, performance):
    "Return IAAF (Hungarian) points, or raise AssertionError"
    assert inout in ('IND', 'OUT'), "Must specify indoor (IN) or outdoor (OUT)"
    assert gender in 'MFX', "Gender must be M , F or X. X will be looked up in Male points tables!"

# Path: athlib/utils.py
# def check_event_code(c: str) -> Optional[Match[str]]:
#     return PAT_EVENT_CODE.match(c)


# Path: athlib/hungarian_score.py
from math import floor
from athlib.utils import check_event_code

"""IAAF Hungarian (non-combined-events) scoring system

IAAF has published a book of scoring factors, containing about 183,000
individual data points.  It is alleged that the formula herein gives the 
exact same answers.  We'll find out shortly ;-)

score = floor(b * (performance + a)**2  + c), 1)

See https://github.com/GlaivePro/IaafPoints

"""

def score(gender, inout, event_code, performance):
    "Return IAAF (Hungarian) points, or raise AssertionError"
    assert inout in ('IND', 'OUT'), "Must specify indoor (IN) or outdoor (OUT)"
    assert gender in 'MFX', "Gender must be M , F or X. X will be looked up in Male points tables!"

    ec = check_event_code(event_code)