File size: 7,620 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import numpy as np
import pytest

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


class TestVerificationBatch16:
    @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 = np.zeros(20, dtype=bool)
        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_energy_deck_rest(self, game_state, card_no):
        """

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

        Text: 自分のエネルギーデッキから、エネルギーカードを1枚ウェイト状態で置く

        Cost: Discard 1 Hand (Type 3)

        """
        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._execute_action(1)  # Play

        assert gs.pending_choices, "Expected pending choice (Cost)"
        choice_type, params = gs.pending_choices[0]

        if choice_type == "TARGET_HAND" and params.get("reason") == "cost":
            gs._handle_choice(500)
        else:
            pytest.fail(f"Expected Discard Cost, got {choice_type}")

        while gs.pending_effects:
            gs._resolve_pending_effect(0)

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

    def _test_conditional_draw(self, game_state, card_no):
        """

        Generic test for "On Play: If 7+ Energy, Draw 1".

        Text: 自分のエネルギーが7枚以上ある場合、カードを1枚引く

        """
        gs = game_state
        card_id = self.get_card_id(gs, card_no)
        p1 = gs.players[0]

        p1.hand = [card_id]
        p1.main_deck = [888] * 5

        # Setup Energy = 7
        p1.energy_zone = [888] * 7
        p1.tapped_energy = np.zeros(20, dtype=bool)

        initial_hand = 1

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

        gs._execute_action(1)  # Play

        if gs.triggered_abilities:
            pid, ab, ctx = gs.triggered_abilities.pop(0)
            gs._play_automatic_ability(pid, ab, ctx)

        # Hand: 1 (start) - 1 (play) + 1 (draw) = 1
        assert len(p1.hand) == 1, "Should have drawn 1 card"

        # Negative Test: 6 Energy
        gs._reset()
        p1 = gs.players[0]
        p1.hand = [card_id]
        p1.energy_zone = [888] * 6
        p1.main_deck = [888] * 5

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

        gs._execute_action(1)  # Play

        if gs.triggered_abilities:
            # Should check condition and fail effect or not trigger?
            # Logic usually puts it in triggers, then check_condition runs.
            pid, ab, ctx = gs.triggered_abilities.pop(0)
            gs._play_automatic_ability(pid, ab, ctx)

        # Hand: 1 (start) - 1 (play) = 0
        assert len(p1.hand) == 0, "Should NOT have drawn"

    def _test_active_all(self, game_state, card_no):
        """

        Generic test for "On Play: Active all members".

        """
        gs = game_state
        card_id = self.get_card_id(gs, card_no)
        p1 = gs.players[0]

        p1.hand = [card_id]

        # Setup tapped members
        dummy_id = card_id
        p1.stage[1] = dummy_id
        p1.stage[2] = dummy_id
        p1.tapped_members[1] = True
        p1.tapped_members[2] = True

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

        gs._execute_action(1)  # Play

        if gs.triggered_abilities:
            pid, ab, ctx = gs.triggered_abilities.pop(0)
            gs._play_automatic_ability(pid, ab, ctx)

        while gs.pending_effects:
            gs._resolve_pending_effect(0)

        assert not p1.tapped_members[1]
        assert not p1.tapped_members[2]

    def test_plsp_sd1_014_sd_liella_energy(self, game_state):
        self._test_energy_deck_rest(game_state, "PL!SP-sd1-014-SD")

    def test_plsp_sd1_016_sd_liella_energy(self, game_state):
        self._test_energy_deck_rest(game_state, "PL!SP-sd1-016-SD")

    def test_plsp_pr_003_pr_liella_draw(self, game_state):
        self._test_conditional_draw(game_state, "PL!SP-PR-003-PR")

    def test_plsp_pr_007_pr_liella_draw(self, game_state):
        self._test_conditional_draw(game_state, "PL!SP-PR-007-PR")

    def test_plsp_pr_010_pr_liella_draw(self, game_state):
        self._test_conditional_draw(game_state, "PL!SP-PR-010-PR")

    def test_pl_bp3_005_p_active_all(self, game_state):
        self._test_active_all(game_state, "PL!-bp3-005-P")

    def test_pl_bp3_005_r_active_all(self, game_state):
        self._test_active_all(game_state, "PL!-bp3-005-R")

    def test_pl_sd1_019_sd_start_dash(self, game_state):
        """

        Card: PL!-sd1-019-SD (Start Dash!!)

        Text: [Live Success] Look 3 from deck top. Place any number on top in any order, rest to WR.

        """
        gs = game_state
        card_id = self.get_card_id(gs, "PL!-sd1-019-SD")
        p1 = gs.players[0]

        # Setup Live Success
        # Need to simulate Live Success Trigger
        # This is complex. We can inject the trigger manually.

        # Mock Deck
        p1.main_deck = [901, 902, 903, 904, 905]

        # Inject Trigger
        # TriggerType.ON_LIVE_SUCCESS (3)
        # We need the ability object
        card = gs.live_db[card_id]
        ability = card.abilities[0]  # Assuming first ability

        gs.triggered_abilities.append((0, ability, {}))

        # Execute
        pid, ab, ctx = gs.triggered_abilities.pop(0)
        gs._play_automatic_ability(pid, ab, ctx)

        # Effect: Look 3
        assert gs.pending_choices, "Expected Look 3 Choice"
        choice_type, params = gs.pending_choices[0]

        # Verify params
        # Should involve reordering/placing on top?
        # Text: "好きな枚数を好きな順番でデッキの上に置き" (Place any number in any order on top)
        # Implementation might be ORDER_DECK or similar?
        # Or Look -> Select to Top -> Discard Rest.

        # Based on logs/bytecode: EffectType 4 (LOOK_DECK) -> EffectType 27 (LOOK_AND_CHOOSE) -> EffectType 18 (MOVE_TO_DECK)?
        # Implementation details vary.
        # If it's a standard choice:
        # Assuming we can choose cards to keep on top.

        # Just verifying we got the choice is a good smoke test for now.
        assert choice_type in ["SELECT_FROM_LIST", "ORDER_DECK", "Look"]

    def test_pl_bp3_015_n_vanilla(self, game_state):
        gs = game_state
        card_id = self.get_card_id(gs, "PL!-bp3-015-N")
        card = gs.member_db.get(card_id)
        assert not card.abilities

    def test_pl_bp3_016_n_vanilla(self, game_state):
        gs = game_state
        card_id = self.get_card_id(gs, "PL!-bp3-016-N")
        card = gs.member_db.get(card_id)
        assert not card.abilities