LovecaSim / engine /tests /cards /batches /test_verification_batch_11.py
trioskosmos's picture
Upload folder using huggingface_hub
bb3fbf9 verified
import numpy as np
import pytest
from engine.game.enums import Phase
from engine.game.game_state import initialize_game
class TestVerificationBatch11:
@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_live_retrieve(self, game_state, card_no):
"""
Generic test for "Retire self -> Retrieve Live from Discard"
Text: 自分の控え室からライブカードを1枚手札に加える (Add 1 Live from WR to Hand)
Cost: Type 5 (Sacrifice Self)
"""
gs = game_state
card_id = self.get_card_id(gs, card_no)
p1 = gs.players[0]
p1.stage[0] = card_id
# Setup discard with a valid Live card
live_id = 999
if live_id not in gs.live_db:
from engine.models.card import LiveCard
gs.live_db[live_id] = LiveCard(live_id, "D", "Dummy", 0, np.zeros(7, dtype=np.int32))
p1.discard = [live_id]
gs.current_player = 0
gs.phase = Phase.MAIN
# Activate (Action 200 for slot 0)
gs._execute_action(200)
# Cost: Retire
assert p1.stage[0] == -1, f"Card {card_no} should be retired (Cost)"
# Effect: Select Live from Discard
assert gs.pending_choices, "Should have pending choice"
choice_type, params = gs.pending_choices[0]
assert choice_type == "SELECT_FROM_DISCARD"
assert live_id in params["cards"]
gs._handle_choice(660) # Select index 0
assert live_id in p1.hand, "Live card should be in hand"
def test_pl_bp4_003_p_live_retrieve(self, game_state):
self._test_live_retrieve(game_state, "PL!-bp4-003-P")
def test_pl_bp4_003_r_live_retrieve(self, game_state):
self._test_live_retrieve(game_state, "PL!-bp4-003-R")
def test_pl_pb1_024_n_live_retrieve(self, game_state):
self._test_live_retrieve(game_state, "PL!-pb1-024-N")
def test_plhs_bp2_004_p_live_retrieve(self, game_state):
self._test_live_retrieve(game_state, "PL!HS-bp2-004-P")
def test_plhs_bp2_004_r_live_retrieve(self, game_state):
self._test_live_retrieve(game_state, "PL!HS-bp2-004-R")
def test_pln_pr_009_pr_live_retrieve(self, game_state):
self._test_live_retrieve(game_state, "PL!N-PR-009-PR")
def test_pln_pr_012_pr_live_retrieve(self, game_state):
self._test_live_retrieve(game_state, "PL!N-PR-012-PR")
def test_pln_pr_014_pr_live_retrieve(self, game_state):
self._test_live_retrieve(game_state, "PL!N-PR-014-PR")
def test_pln_sd1_011_sd_live_retrieve(self, game_state):
self._test_live_retrieve(game_state, "PL!N-sd1-011-SD")
def test_pls_pr_026_pr_live_retrieve(self, game_state):
self._test_live_retrieve(game_state, "PL!S-PR-026-PR")