# Path: project/utils/test_helpers.py
# def make_meld(meld_type, is_open=True, man="", pin="", sou="", honors="", tiles=None):
#     if not tiles:
#         tiles = string_to_136_array(man=man, pin=pin, sou=sou, honors=honors)
#     meld = MeldPrint(
#         meld_type=meld_type,
#         tiles=tiles,
#         opened=is_open,
#         called_tile=tiles[0],
#         who=0,
#     )
#     return meld


from game.table import Table
from mahjong.constants import FIVE_RED_MAN
from utils.decisions_logger import MeldPrint
from utils.test_helpers import find_discard_option, string_to_136_array, string_to_136_tile
from project.utils.test_helpers import make_meld
def test_calculate_our_hand_cost():
    table = Table()
    player = table.player
    enemy_seat = 2
    table.add_called_riichi_step_one(enemy_seat)
    table.add_discarded_tile(enemy_seat, string_to_136_tile(pin="9"), True)

    tiles = string_to_136_array(sou="234678", pin="23478", man="22")
    tile = string_to_136_tile(honors="1")
    player.init_hand(tiles)
    player.draw_tile(tile)

    discard_option = find_discard_option(player, honors="1")
    assert discard_option.danger.weighted_cost == 6128


def test_calculate_our_hand_cost_1_shanten():
    table = Table()
    player = table.player
    enemy_seat = 2

    table.has_open_tanyao = True
    table.has_aka_dora = False

    table.add_called_riichi_step_one(enemy_seat)

    tiles = string_to_136_array(sou="22245677", pin="145", man="67")

    tile = string_to_136_tile(honors="1")
    player.init_hand(tiles)

# Path: project/utils/test_helpers.py
# def make_meld(meld_type, is_open=True, man="", pin="", sou="", honors="", tiles=None):
#     if not tiles:
#         tiles = string_to_136_array(man=man, pin=pin, sou=sou, honors=honors)
#     meld = MeldPrint(
#         meld_type=meld_type,
#         tiles=tiles,
#         opened=is_open,
#         called_tile=tiles[0],
#         who=0,
#     )
#     return meld


# Path: project/game/ai/defence/tests/test_threat_and_push_fold_decisions.py
from game.table import Table
from mahjong.constants import FIVE_RED_MAN
from utils.decisions_logger import MeldPrint
from utils.test_helpers import find_discard_option, string_to_136_array, string_to_136_tile
from project.utils.test_helpers import make_meld

def test_calculate_our_hand_cost():
    table = Table()
    player = table.player
    enemy_seat = 2
    table.add_called_riichi_step_one(enemy_seat)
    table.add_discarded_tile(enemy_seat, string_to_136_tile(pin="9"), True)

    tiles = string_to_136_array(sou="234678", pin="23478", man="22")
    tile = string_to_136_tile(honors="1")
    player.init_hand(tiles)
    player.draw_tile(tile)

    discard_option = find_discard_option(player, honors="1")
    assert discard_option.danger.weighted_cost == 6128


def test_calculate_our_hand_cost_1_shanten():
    table = Table()
    player = table.player
    enemy_seat = 2

    table.has_open_tanyao = True
    table.has_aka_dora = False

    table.add_called_riichi_step_one(enemy_seat)

    tiles = string_to_136_array(sou="22245677", pin="145", man="67")

    tile = string_to_136_tile(honors="1")
    player.init_hand(tiles)

    player.add_called_meld(make_meld(MeldPrint.PON, sou="222"))