Spaces:
Running
Running
| import pytest | |
| from engine.game.enums import Phase | |
| from engine.game.game_state import initialize_game | |
| from engine.models.ability import TriggerType | |
| class TestStarterDeck: | |
| 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}" | |
| 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}") | |