File size: 2,890 Bytes
463f868
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import sys

sys.path.append(os.getcwd())

from engine.game.data_loader import CardDataLoader
from engine.game.enums import Phase
from engine.game.game_state import GameState


def reproduce_loop():
    print("Initializing GameState...")

    # Load data
    json_path = os.path.join(os.getcwd(), "data", "cards.json")
    loader = CardDataLoader(json_path)
    # Assuming loader defaults work, or we point to data/cards_compiled.json
    # We might need to handle paths if CWD is wrong, but we set CWD in run_command.
    members, lives, energy = loader.load()
    GameState.initialize_class_db(members, lives)

    gs = GameState()
    # gs.reset_game() # Does not exist

    p0 = gs.players[0]

    # Setup state matching the report
    # Player 0 Stage: Miyashita Ai (Nijigasaki)
    # ID: 3146176
    # Note: Using compiled IDs requires checking logic consistency
    # Assuming standard loading handles IDs correctly

    # Clear decks/hands for clarity
    p0.hand = []
    p0.stage = [-1] * 3
    p0.stage_energy = [[], [], []]
    p0.live_zone = []

    # Add Miyashita Ai to Stage 0
    p0.stage[0] = 3146176  # PL!N-sd1-017-SD (Nijigasaki)
    p0.tapped_members[0] = False

    # Add Love wing bell to Live Zone
    # ID: 1049587
    p0.live_zone.append(1049587)

    # Set Phase to PERFORMANCE_P1
    gs.phase = Phase.PERFORMANCE_P1
    gs.current_player = 0
    gs.first_player = 0

    # Ensure performance_abilities_processed is False
    p0.performance_abilities_processed = False

    print(f"Initial Phase: {gs.phase}")
    print(f"P0 Stage: {p0.stage}")
    print(f"P0 Live Zone: {p0.live_zone}")

    # Step 1: Should trigger ability and queue it
    print("\n--- Executing Step(0) #1 ---")
    gs = gs.step(0)
    print(f"Phase after #1: {gs.phase}")

    # Check if ability triggered
    # (can't check internal triggered_abilities easily from outside without inspection, but phase shouldn't change yet if it returned early)

    if gs.phase == Phase.PERFORMANCE_P1:
        print("Phase stayed P1 (Expected: Ability Triggered)")
    else:
        print(f"Phase changed unexpectedly! {gs.phase}")

    # Step 2: Should process ability and advance
    print("\n--- Executing Step(0) #2 ---")
    gs = gs.step(0)
    print(f"Phase after #2: {gs.phase}")

    if gs.phase != Phase.PERFORMANCE_P1:
        print("SUCCESS: Phase advanced!")
    else:
        print("FAILURE: Phase stuck in PERFORMANCE_P1 (Infinite Loop detected)")

        # Inspection
        print(f"Pending Choices: {gs.pending_choices}")
        print(f"Triggered Abilities: {gs.triggered_abilities}")
        print(f"Pending Effects: {gs.pending_effects}")
        print(f"Processed Flag: {getattr(p0, 'performance_abilities_processed', 'Missing')}")


if __name__ == "__main__":
    reproduce_loop()