File size: 3,810 Bytes
bb3fbf9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import pytest

from engine.game.enums import Phase
from engine.game.game_state import initialize_game


class TestVerificationBatch15:
    @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_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_energy_deck_rest(self, game_state, card_no):
        """

        Generic test for "On Play: Place 1 Energy from Energy Deck (Rest)".

        """
        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]
        p1.energy_deck = [888, 888]
        p1.energy_zone = []

        gs.current_player = 0
        gs.phase = Phase.MAIN

        gs.step(1, check_legality=False, in_place=True)  # Play

        # Cost: Discard 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)

        assert len(p1.energy_zone) == 1
        assert p1.tapped_energy[0] == True, "Placed energy should be rested (Tapped)"

    def test_plhs_bp1_020_l_niji_all_blade_heart(self, game_state):
        self._test_all_blade_heart(game_state, "PL!HS-bp1-020-L")

    def test_pln_bp1_025_l_niji_all_blade_heart(self, game_state):
        self._test_all_blade_heart(game_state, "PL!N-bp1-025-L")

    def test_pln_sd1_026_sd_niji_all_blade_heart(self, game_state):
        self._test_all_blade_heart(game_state, "PL!N-sd1-026-SD")

    def test_plsp_bp1_025_l_niji_all_blade_heart(

        self,

        game_state,

    ):
        self._test_all_blade_heart(game_state, "PL!SP-bp1-025-L")

    def test_plsp_sd1_024_sd_niji_all_blade_heart(self, game_state):
        self._test_all_blade_heart(game_state, "PL!SP-sd1-024-SD")

    def test_plsp_sd1_025_sd_niji_all_blade_heart(self, game_state):
        self._test_all_blade_heart(game_state, "PL!SP-sd1-025-SD")

    def test_plsp_pr_004_pr_liella_energy(self, game_state):
        self._test_energy_deck_rest(game_state, "PL!SP-PR-004-PR")

    def test_plsp_pr_006_pr_liella_energy(self, game_state):
        self._test_energy_deck_rest(game_state, "PL!SP-PR-006-PR")

    def test_plsp_pr_013_pr_liella_energy(self, game_state):
        self._test_energy_deck_rest(game_state, "PL!SP-PR-013-PR")

    def test_plsp_bp1_021_n_liella_energy(self, game_state):
        self._test_energy_deck_rest(game_state, "PL!SP-bp1-021-N")