diff --git a/mahjong_utils/point_by_han_hu.py b/mahjong_utils/point_by_han_hu.py index 01df1bc..c6c8fd9 100644 --- a/mahjong_utils/point_by_han_hu.py +++ b/mahjong_utils/point_by_han_hu.py @@ -15,8 +15,8 @@ def _ceil100(x): } no_tsumo = { + (1, 20), (1, 25), (1, 110), (2, 25), - (1, 110) } @@ -44,7 +44,10 @@ def build_han_hu_to_parent_point(mapping): """ for han in range(1, 5): for hu in range(20, 120, 10): - mapping[han, hu] = _calc_parent_point(han, hu) + if (han, hu) not in no_ron and (han, hu) not in no_tsumo: + mapping[han, hu] = _calc_parent_point(han, hu) + + for han in range(2, 4): mapping[han, 25] = _calc_parent_point(han, 25) mapping[5, 20] = 12000, 4000 @@ -84,7 +87,8 @@ def build_han_hu_to_child_point(mapping): """ for han in range(1, 5): for hu in range(20, 120, 10): - mapping[han, hu] = _calc_child_point(han, hu) + if (han, hu) not in no_ron and (han, hu) not in no_tsumo: + mapping[han, hu] = _calc_child_point(han, hu) for han in range(2, 4): mapping[han, 25] = _calc_child_point(han, 25) diff --git a/test/test_han_hu.py b/test/test_han_hu.py index 3103b0a..d5ac0e7 100644 --- a/test/test_han_hu.py +++ b/test/test_han_hu.py @@ -1,3 +1,5 @@ +import pytest + from mahjong_utils.point_by_han_hu import get_parent_point_by_han_hu, get_child_point_by_han_hu @@ -7,9 +9,25 @@ def test_get_parent_point_by_han_hu(): assert get_parent_point_by_han_hu(5, 40) == (12000, 4000) assert get_parent_point_by_han_hu(16, 40) == (48000, 16000) + assert get_parent_point_by_han_hu(2, 25) == (2400, 0) + + with pytest.raises(ValueError): + get_parent_point_by_han_hu(1, 20) + + with pytest.raises(ValueError): + get_parent_point_by_han_hu(1, 25) + def test_get_child_point_by_han_hu(): assert get_child_point_by_han_hu(2, 30) == (2000, 1000, 500) assert get_child_point_by_han_hu(4, 40) == (8000, 4000, 2000) assert get_child_point_by_han_hu(5, 40) == (8000, 4000, 2000) assert get_child_point_by_han_hu(16, 40) == (32000, 16000, 8000) + + assert get_child_point_by_han_hu(2, 25) == (1600, 0, 0) + + with pytest.raises(ValueError): + get_child_point_by_han_hu(1, 20) + + with pytest.raises(ValueError): + get_child_point_by_han_hu(1, 25)