Skip to content

Commit

Permalink
test: toss-up
Browse files Browse the repository at this point in the history
  • Loading branch information
zyr17 committed Aug 31, 2023
1 parent 745d83d commit 8e48208
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 5 deletions.
78 changes: 74 additions & 4 deletions tests/server/cards/test_event_cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
2 changes: 1 addition & 1 deletion tests/server/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8e48208

Please sign in to comment.