def calculate_hand_point(agari_hand: AgariHand, hand_info: HandInfo, rule: Rule = None): if rule is None: rule = RuleLoader.load_rule() divisions = divide_hand(agari_hand) base_points = [] for division in divisions: fu, fu_info = calculate_fu(division, hand_info, rule) han, han_info, is_yakuman = calculate_han(division, hand_info, rule) base_point = calculate_base_point(fu, han, is_yakuman) base_points.append((base_point, han, fu, han_info, fu_info)) max_base_points = max(base_points) if hand_info.player_wind == Tile.EAST: if hand_info.is_tsumo_agari: point = (max_base_points[0] * 2 + 99) // 100 * 100 point_string = str(point) + ' all' else: point = (max_base_points[0] * 6 + 99) // 100 * 100 point_string = str(point) else: if hand_info.is_tsumo_agari: point1 = (max_base_points[0] + 99) // 100 * 100 point2 = (max_base_points[0] * 2 + 99) // 100 * 100 point_string = str(point1) + ', ' + str(point2) else: point = (max_base_points[0] * 4 + 99) // 100 * 100 point_string = str(point) return point_string, *max_base_points[1:]
def test_sanankou_ron(test_input, agari_tile, expected): result = False for division in divide_hand(AgariHand(test_input, agari_tile), is_tsumo_agari=False): result |= Sanankou().is_satisfied(division, HandInfo(is_tsumo_agari=False)) assert result == expected
def test_sanshoku(test_input, agari_tile, expected): result = False for division in divide_hand(AgariHand(test_input, agari_tile)): result |= Sanshoku().is_satisfied(division, HandInfo()) assert result == expected