File size: 4,300 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
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")