diff --git a/server/card/equipment/artifact/old_version.py b/server/card/equipment/artifact/old_version.py index c2967811..36fc85e6 100644 --- a/server/card/equipment/artifact/old_version.py +++ b/server/card/equipment/artifact/old_version.py @@ -1,7 +1,10 @@ -from typing import Literal +from typing import Any, List, Literal + +from ....action import Actions from ....struct import Cost from .element_artifacts import SmallElementalArtifact as SEA_4_0 +from .others import GamblersEarrings as GE_3_8 class SmallElementalArtifact(SEA_4_0): @@ -9,4 +12,16 @@ class SmallElementalArtifact(SEA_4_0): cost: Cost = Cost(same_dice_number = 2) -OldVersionArtifacts = SmallElementalArtifact | SmallElementalArtifact +class GamblersEarrings(GE_3_8): + version: Literal['3.3'] + usage: int = 999 + + def equip(self, match: Any) -> List[Actions]: + """ + Equip this artifact. Reset usage. + """ + self.usage = 999 + return [] + + +OldVersionArtifacts = SmallElementalArtifact | GamblersEarrings diff --git a/tests/server/cards/test_artifacts.py b/tests/server/cards/test_artifacts.py index 4b273d11..b8c7029d 100644 --- a/tests/server/cards/test_artifacts.py +++ b/tests/server/cards/test_artifacts.py @@ -188,7 +188,7 @@ def test_create_small_element_artifacts(): assert match.state != MatchState.ERROR -def test_old_version_artifacts(): +def test_old_version_elemental_artifacts(): agent_0 = NothingAgent(player_idx = 0) agent_1 = InteractionAgent( player_idx = 1, @@ -398,8 +398,117 @@ def test_gambler(): assert match.state != MatchState.ERROR +def test_old_gambler(): + agent_0 = InteractionAgent( + player_idx = 0, + verbose_level = 0, + commands = [ + "sw_card", + "choose 0", + "end", + "choose 1", + "choose 2", + "choose 3", + "choose 4", + "choose 5", + "choose 6", + ], + only_use_command = True + ) + agent_1 = InteractionAgent( + player_idx = 1, + verbose_level = 0, + commands = [ + "sw_card", + "choose 0", + "card 0 1 1", + "skill 0 0 1 2", + "TEST 1 16 12", + "card 0 0 1", + "skill 0 0 1 2", + "TEST 1 16 10", + "skill 0 0 1 2", + "skill 0 0 1 2", + "TEST 1 16 8", + "skill 0 0 1 2", + "TEST 1 16 7", + "skill 0 0 1 2", + "TEST 1 16 6", + "end", + ], + only_use_command = True + ) + deck = Deck.from_str( + ''' + # charactor:Fischl + # charactor:Mona + # charactor:Nahida + charactor:Nahida*10 + # Gambler's Earrings*2 + # Wine-Stained Tricorne*2 + # Timmie*2 + # Rana*2 + # Strategize*2 + # The Bestest Travel Companion!*2 + # Covenant of Rock + # Gambler's Earrings*30 + ''' + ) + old_gambler = {'name': "Gambler's Earrings", 'version': '3.3'} + deck_dict = deck.dict() + deck_dict['cards'] += [old_gambler] * 30 + deck = Deck(**deck_dict) + for charactor in deck.charactors: + charactor.hp = 1 + charactor.max_hp = 1 + match = Match(random_state = get_random_state()) + match.config.max_same_card_number = 30 + match.config.charactor_number = 10 + match.config.random_first_player = False + match.set_deck([deck, deck]) + set_16_omni(match) + match.start() + match.step() + while True: + if match.need_respond(0): + while True: + cmd = agent_0.commands[0] + test_id = get_test_id_from_command(agent_0) + if test_id == 1: + number = [int(x) for x in cmd.strip().split(' ')[-2:]] + assert number[0] == len(match.player_tables[0].dice.colors) + assert number[1] == len(match.player_tables[1].dice.colors) + elif test_id == 2: + charactor = match.player_tables[0].charactors[7] + assert charactor.artifact is not None + assert charactor.artifact.name == "Gambler's Earrings" + else: + break + make_respond(agent_0, match) + elif match.need_respond(1): + while True: + cmd = agent_1.commands[0] + test_id = get_test_id_from_command(agent_1) + if test_id == 1: + number = [int(x) for x in cmd.strip().split(' ')[-2:]] + assert number[0] == len(match.player_tables[0].dice.colors) + assert number[1] == len(match.player_tables[1].dice.colors) + else: + break + 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 len(agent_1.commands) == 0 and len(agent_0.commands) == 0 + + assert match.state != MatchState.ERROR + + if __name__ == '__main__': # test_small_elemental_artifacts() # test_create_small_element_artifacts() # test_old_version_artifacts() - test_gambler() + # test_gambler() + test_old_gambler()