Spaces:
Running
Running
| import pytest | |
| from engine.game.enums import Phase | |
| from engine.game.game_state import initialize_game | |
| class TestVerificationBatch14: | |
| 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_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 | |
| 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) | |
| assert len(p1.hand) == 0 | |
| assert len(p1.discard) >= 1 | |
| def _test_all_blade_heart(self, game_state, card_no): | |
| """ | |
| Generic test for "All Blade Heart" ability. | |
| """ | |
| gs = game_state | |
| card_id = self.get_card_id(gs, card_no) | |
| card = gs.member_db.get(card_id) or gs.live_db.get(card_id) | |
| assert card is not None | |
| assert len(card.abilities) > 0 | |
| has_meta = False | |
| for ab in card.abilities: | |
| for eff in ab.effects: | |
| if eff.effect_type.name == "META_RULE" and eff.params.get("source") == "all_blade": | |
| has_meta = True | |
| break | |
| assert has_meta, f"Card {card_no} missing ALL_BLADE meta rule" | |
| def test_pln_bp1_014_n_draw1_discard1(self, game_state): | |
| self._test_draw1_discard1(game_state, "PL!N-bp1-014-N") | |
| def test_pln_bp1_015_n_draw1_discard1(self, game_state): | |
| self._test_draw1_discard1(game_state, "PL!N-bp1-015-N") | |
| def test_pln_bp1_019_n_draw1_discard1(self, game_state): | |
| self._test_draw1_discard1(game_state, "PL!N-bp1-019-N") | |
| def test_pln_bp1_019_pr_draw1_discard1(self, game_state): | |
| self._test_draw1_discard1(game_state, "PL!N-bp1-019-PR") | |
| def test_pln_sd1_013_sd_draw1_discard1(self, game_state): | |
| self._test_draw1_discard1(game_state, "PL!N-sd1-013-SD") | |
| def test_pln_sd1_021_sd_draw1_discard1(self, game_state): | |
| self._test_draw1_discard1(game_state, "PL!N-sd1-021-SD") | |
| def test_pln_sd1_022_sd_draw1_discard1(self, game_state): | |
| self._test_draw1_discard1(game_state, "PL!N-sd1-022-SD") | |
| def test_plhs_pr_010_pr_niji_all_blade_heart(self, game_state): | |
| self._test_all_blade_heart(game_state, "PL!HS-PR-010-PR") | |
| def test_plhs_pr_011_pr_niji_all_blade_heart(self, game_state): | |
| self._test_all_blade_heart(game_state, "PL!HS-PR-011-PR") | |
| def test_plhs_pr_012_pr_niji_all_blade_heart(self, game_state): | |
| self._test_all_blade_heart(game_state, "PL!HS-PR-012-PR") | |