import pytest from engine.game.enums import Phase from engine.game.game_state import initialize_game class TestVerificationBatch13: @pytest.fixture def game_state(self): gs = initialize_game(use_real_data=True) if not gs.member_db: pytest.skip("Card data not loaded") gs.active_player.tapped_energy.fill(False) return gs def get_card_id(self, gs, card_no): for cid, card in gs.member_db.items(): if card.card_no == card_no: return cid for cid, card in gs.live_db.items(): if card.card_no == card_no: return cid pytest.fail(f"Card {card_no} not found") def _test_look3_pick1(self, game_state, card_no): """ Generic test for "Look 3, Add 1, Discard Rest" with Hand Discard Cost. """ gs = game_state card_id = self.get_card_id(gs, card_no) p1 = gs.players[0] fodder_id = self.get_card_id(gs, "PL!-sd1-001-SD") p1.hand = [card_id, fodder_id] # Setup Deck - use real IDs from the DB to avoid missing card errors valid_ids = list(gs.member_db.keys())[:5] p1.main_deck = valid_ids + [fodder_id] * 5 gs.current_player = 0 gs.phase = Phase.MAIN gs.step(1, check_legality=False, in_place=True) # Play Card # Verify Cost: Discard from Hand if gs.pending_choices: choice_type, params = gs.pending_choices[0] if choice_type == "TARGET_HAND" and params.get("reason") == "cost": idx = p1.hand.index(fodder_id) gs.step(500 + idx, check_legality=False, in_place=True) # Verify Effect: Look 3, Pick 1 assert gs.pending_choices choice_type, params = gs.pending_choices[0] assert "SELECT" in choice_type assert len(params["cards"]) == 3 target_pick = params["cards"][1] gs.step(601, check_legality=False, in_place=True) # Index 1 assert target_pick in p1.hand assert len(p1.discard) >= 3 def _test_draw1_discard1(self, game_state, card_no): """ Generic test for "Draw 1, Discard 1". """ gs = game_state card_id = self.get_card_id(gs, card_no) p1 = gs.players[0] p1.hand = [card_id] fodder_id = self.get_card_id(gs, "PL!-sd1-001-SD") p1.main_deck = [fodder_id] * 5 gs.current_player = 0 gs.phase = Phase.MAIN initial_deck = len(p1.main_deck) gs.step(1, check_legality=False, in_place=True) # Play # Verify Draw happened assert len(p1.main_deck) == initial_deck - 1 assert len(p1.hand) == 1 # Verify Discard Choice assert gs.pending_choices, "Expected Discard Choice" gs.step(500, check_legality=False, in_place=True) # Discard first assert len(p1.hand) == 0 assert len(p1.discard) >= 1 def test_pln_pr_006_pr_look3_pick1(self, game_state): self._test_look3_pick1(game_state, "PL!N-PR-006-PR") def test_pln_pr_013_pr_look3_pick1(self, game_state): self._test_look3_pick1(game_state, "PL!N-PR-013-PR") def test_pln_bp1_007_p_look3_pick1(self, game_state): self._test_look3_pick1(game_state, "PL!N-bp1-007-P") def test_pln_bp1_007_r_look3_pick1(self, game_state): self._test_look3_pick1(game_state, "PL!N-bp1-007-R") def test_pln_bp1_010_p_look3_pick1(self, game_state): self._test_look3_pick1(game_state, "PL!N-bp1-010-P") def test_pln_bp1_010_r_look3_pick1(self, game_state): self._test_look3_pick1(game_state, "PL!N-bp1-010-R") def test_pln_sd1_002_sd_look3_pick1(self, game_state): self._test_look3_pick1(game_state, "PL!N-sd1-002-SD") def test_pln_sd1_003_sd_look3_pick1(self, game_state): self._test_look3_pick1(game_state, "PL!N-sd1-003-SD") def test_plhs_bp1_010_n_draw1_discard1(self, game_state): self._test_draw1_discard1(game_state, "PL!HS-bp1-010-N") def test_plhs_bp1_014_n_draw1_discard1(self, game_state): self._test_draw1_discard1(game_state, "PL!HS-bp1-014-N")