From 8e482087d1cadd0d3843c7227fa85cf52ad9e004 Mon Sep 17 00:00:00 2001 From: zyr17 Date: Thu, 31 Aug 2023 12:14:56 +0800 Subject: [PATCH] test: toss-up --- tests/server/cards/test_event_cards.py | 78 ++++++++++++++++++++++++-- tests/server/test_pipeline.py | 2 +- 2 files changed, 75 insertions(+), 5 deletions(-) diff --git a/tests/server/cards/test_event_cards.py b/tests/server/cards/test_event_cards.py index 24270bf7..010c0e9a 100644 --- a/tests/server/cards/test_event_cards.py +++ b/tests/server/cards/test_event_cards.py @@ -130,9 +130,6 @@ def test_changing_shifts(): Changing Shifts*30 ''' ) - for charactor in deck.charactors: - charactor.hp = 2 - charactor.max_hp = 2 match.set_deck([deck, deck]) match.config.max_same_card_number = 30 match.config.random_first_player = False @@ -164,6 +161,79 @@ def test_changing_shifts(): assert match.state != MatchState.ERROR +def test_toss_up(): + agent_0 = InteractionAgent( + player_idx = 0, + verbose_level = 0, + commands = [ + "sw_card", + "choose 0", + "card 0 0", + "TEST 2 reroll req 2 time", + "reroll 0 1 2 3 4 5 6 7", + "TEST 1 reroll req 1 time", + "reroll 0 1 2 3 4 5 6 7" + ], + only_use_command = True + ) + agent_1 = InteractionAgent( + player_idx = 1, + verbose_level = 0, + commands = [ + "sw_card", + "choose 0" + ], + only_use_command = True + ) + match = Match(random_state = get_random_state()) + deck = Deck.from_str( + ''' + charactor:Fischl + charactor:Mona + charactor:Nahida + # Gambler's Earrings*2 + # Wine-Stained Tricorne*2 + # Vanarana + # Timmie*2 + # Rana*2 + # Covenant of Rock + # Wind and Freedom + # The Bestest Travel Companion!*2 + # Changing Shifts*2 + # Toss-Up + # Strategize*2 + Toss-Up*30 + ''' + ) + match.set_deck([deck, deck]) + match.config.max_same_card_number = 30 + match.config.random_first_player = False + set_16_omni(match) + match.start() + match.step() + + while True: + if match.need_respond(0): + while True: + test_id = get_test_id_from_command(agent_0) + if test_id == 0: + break + assert len(match.requests) == 1 + req = match.requests[0] + assert req.name == 'RerollDiceRequest' + assert req.reroll_times == test_id + make_respond(agent_0, match) + elif match.need_respond(1): + make_respond(agent_1, match) + else: + raise AssertionError('No need respond.') + if len(agent_1.commands) == 0 and len(agent_0.commands) == 0: + break + + assert match.state != MatchState.ERROR + + if __name__ == '__main__': # test_bestest() - test_changing_shifts() + # test_changing_shifts() + test_toss_up() diff --git a/tests/server/test_pipeline.py b/tests/server/test_pipeline.py index f6ea87f3..9ece9ac5 100644 --- a/tests/server/test_pipeline.py +++ b/tests/server/test_pipeline.py @@ -149,7 +149,7 @@ def check_range(saves, agent_saves, start, end, def test_copy_speed(): - run_time = 100 + run_time = 50 match = Match() deck = TEST_DECK deck = Deck(**deck)