def test_crash_when_tyring_to_discard_with_open_hand(): """ Bot crashed when tried to discard tile from hand 266m4444z + 1z [111z, 789m] This test is checking that there are no crashes in such situations anymore """ table = Table() player = table.player tiles = string_to_136_array(man="266789", honors="1114444") player.init_hand(tiles) # we manually reveal one tile to emulate the fact that we saw it when it was discarded table._add_revealed_tile(string_to_136_tile(honors="1")) table.add_called_meld(player.seat, make_meld(MeldPrint.PON, honors="111")) table.add_called_meld(player.seat, make_meld(MeldPrint.CHI, man="789")) # it is important for crash to take fourth 4z tile = string_to_136_array(honors="1111")[3] player.draw_tile(tile) discard = player.discard_tile() assert discard is not None
def test_threatening_riichi_player_with_dora_kan(): table = Table() enemy_seat = 2 enemy_called_riichi_helper(table, enemy_seat) table.add_dora_indicator(string_to_136_tile(man="2")) table.add_called_meld(enemy_seat, make_meld(MeldPrint.KAN, is_open=False, man="3333")) # we have to do it manually in test # normally tenhou client would do that table._add_revealed_tile(string_to_136_tile(man="3")) # non dealer threatening_player = table.player.ai.defence.get_threatening_players()[0] assert threatening_player.enemy.seat == enemy_seat assert threatening_player.get_assumed_hand_cost( string_to_136_tile(man="2")) == 12000 # dealer threatening_player.enemy.dealer_seat = enemy_seat assert threatening_player.get_assumed_hand_cost( string_to_136_tile(man="2")) == 18000