File size: 4,101 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
import pytest

from engine.game.enums import Phase
from engine.game.game_state import initialize_game
from engine.models.ability import EffectType


class TestSD1Batch4:
    @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.verbose = True
        return gs

    def get_card_id_by_no(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
        raise ValueError(f"Card {card_no} not found")

    def test_pl_sd1_016_nozomi(self, game_state):
        gs = game_state
        gs.current_player = 0
        p = gs.players[0]
        card_id = self.get_card_id_by_no(gs, "PL!-sd1-016-SD")
        fodder_id = self.get_card_id_by_no(gs, "PL!-sd1-001-SD")

        deck_cards = [
            self.get_card_id_by_no(gs, "PL!-sd1-002-SD"),
            self.get_card_id_by_no(gs, "PL!-sd1-003-SD"),
            self.get_card_id_by_no(gs, "PL!-sd1-004-SD"),
        ]

        p.main_deck = deck_cards + [self.get_card_id_by_no(gs, "PL!-sd1-005-SD")] * 10
        p.hand = [card_id, fodder_id]
        p.energy_zone = [200] * 10
        p.tapped_energy.fill(False)

        gs.phase = Phase.MAIN

        gs = gs.step(1)

        assert gs.pending_choices
        assert gs.pending_choices[0][0] == "TARGET_HAND"
        assert gs.pending_choices[0][1]["effect"] == "discard"

        gs = gs.step(500)

        assert gs.pending_choices
        assert gs.pending_choices[0][0] == "SELECT_FROM_LIST"
        params = gs.pending_choices[0][1]
        assert len(params["cards"]) == 3

        target_card = deck_cards[1]
        gs = gs.step(601)

        p = gs.players[0]
        assert target_card in p.hand
        assert fodder_id in p.discard
        assert len(p.discard) == 3

    def test_pl_sd1_019_start_dash(self, game_state):
        # PL!-sd1-019-SD (START:DASH!!)
        gs = game_state
        gs.current_player = 0
        p = gs.players[0]
        live_id = self.get_card_id_by_no(gs, "PL!-sd1-019-SD")

        card = gs.live_db[live_id]
        ability = next(
            ab for ab in card.abilities if "ライブ成功時" in ab.raw_text or "On Live Success" in ab.reconstruct_text()
        )

        deck_cards = [101, 102, 103, 104, 105]
        p.main_deck = list(deck_cards)
        context = {"card_id": live_id, "player_id": 0}

        gs._play_automatic_ability(0, ability, context)

        assert gs.pending_choices
        choice_type, params = gs.pending_choices[0]

        if choice_type == "SELECT_FROM_LIST":
            gs = gs.step(600)
            if gs.pending_choices and gs.pending_choices[0][0] == "SELECT_FROM_LIST":
                gs = gs.step(601)

    def test_pl_sd1_022_bokura(self, game_state):
        gs = game_state
        gs.current_player = 0
        p = gs.players[0]
        live_id = self.get_card_id_by_no(gs, "PL!-sd1-022-SD")
        dummy_live_id = self.get_card_id_by_no(gs, "PL!-sd1-019-SD")

        p.success_lives = [dummy_live_id, dummy_live_id]
        p.live_zone = [live_id]
        p.main_deck = [888] * 10
        p.discard = []

        gs.phase = Phase.PERFORMANCE_P1
        gs.current_player = 0
        p.performance_abilities_processed = False

        gs = gs.step(0)
        p = gs.players[0]  # REFRESH PLAYER

        # Ensure triggers process
        limit = 10
        while (gs.triggered_abilities or gs.pending_effects) and limit > 0:
            gs = gs.step(0)
            p = gs.players[0]  # REFRESH PLAYER
            limit -= 1

        effects = [
            ce["effect"] for ce in p.continuous_effects if ce["effect"].effect_type == EffectType.REDUCE_HEART_REQ
        ]
        print(f"Continuous Effects found: {len(effects)}")

        assert len(effects) > 0