LovecaSim / engine /tests /cards /batches /test_sd1_batch4.py
trioskosmos's picture
Upload folder using huggingface_hub
bb3fbf9 verified
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