Skip to content

Commit

Permalink
修复1番20符
Browse files Browse the repository at this point in the history
  • Loading branch information
ssttkkl committed Oct 31, 2022
1 parent a7f98d8 commit 0357a07
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
10 changes: 7 additions & 3 deletions mahjong_utils/point_by_han_hu.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def _ceil100(x):
}

no_tsumo = {
(1, 20), (1, 25), (1, 110),
(2, 25),
(1, 110)
}


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions test/test_han_hu.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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)

0 comments on commit 0357a07

Please sign in to comment.