File size: 3,159 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
import pytest

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


class TestStarterDeck:
    @pytest.fixture
    def game_state(self):
        gs = initialize_game(use_real_data=True)
        if not gs.member_db:
            pytest.skip("Card data not loaded")
        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
        return None

    def test_sd1_cards_exist(self, game_state):
        """Verify all SD1 cards are loaded in the DB."""
        missing = []
        # Check Members 001-024
        for i in range(1, 25):
            card_no = f"PL!N-sd1-{i:03d}-SD"
            if self.get_card_id_by_no(game_state, card_no) is None:
                missing.append(card_no)

        # Check Lives 025-028
        for i in range(25, 29):
            card_no = f"PL!N-sd1-{i:03d}-SD"
            if self.get_card_id_by_no(game_state, card_no) is None:
                missing.append(card_no)

        assert not missing, f"Missing cards: {missing}"

    @pytest.mark.parametrize("card_idx", range(1, 25))
    def test_member_abilities_runnable(self, game_state, card_idx):
        """

        Generic stability test for all member cards.

        Places card on stage, attempts to trigger abilities if possible.

        """
        gs = game_state
        p1 = gs.players[0]
        card_no = f"PL!N-sd1-{card_idx:03d}-SD"
        card_id = self.get_card_id_by_no(gs, card_no)
        if card_id is None:
            pytest.skip(f"Card {card_no} not found")

        # Setup: Place card on stage
        p1.stage[0] = card_id

        # Give tons of resources to pay for any potential cost
        p1.energy_zone = [200] * 10
        p1.hand = [888] * 5  # Dummy cards for discard costs

        # Check triggers
        member = gs.member_db[card_id]

        # 1. On Play (Main Phase) trigger check
        # We manually trigger to see if it crashes
        if any(ab.trigger == TriggerType.ON_PLAY for ab in member.abilities):
            # Simulate play
            pass

        # 2. Activated Ability check
        # If it has activated ability, try to activate it
        activated_abs = [ab for ab in member.abilities if ab.trigger == TriggerType.ACTIVATED]
        if activated_abs:
            gs.phase = Phase.MAIN
            gs.current_player = 0

            # Mock the activation flow
            # (We don't need full correctness, just crash proofness for now)
            try:
                # We need to find the action ID for stage slot 0 -> 200
                # But legal actions are calculated dynamically.
                # Let's just FORCE the ability via internal method to test crash worthiness
                pass
            except Exception as e:
                pytest.fail(f"Crash testing ability for {card_no}: {e}")