File size: 2,559 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
88
89
90
91
92
import os
import sys

# Ensure we can import engine
sys.path.append(os.getcwd())

import engine_rust


def setup_game():
    # Load DB
    db_path = "engine/data/cards_compiled.json"
    with open(db_path, "r", encoding="utf-8") as f:
        cards_data_raw = f.read()

    db = engine_rust.PyCardDatabase(cards_data_raw)
    state = engine_rust.PyGameState(db)
    return state, db


def test_live_start_interactivity():
    state, db = setup_game()

    # Init game
    members = [249] * 48
    lives = [10001] * 12
    energy = [20001] * 12

    state.initialize_game(members, members, energy, energy, lives, lives)

    # Setup state via new methods
    KOTORI_ID = 249
    state.set_stage_card(0, 0, KOTORI_ID)
    state.set_hand_cards(0, [KOTORI_ID])
    state.set_live_card(0, 0, 10001, True)  # Reveal it to trigger 11.4

    state.current_player = 0
    state.phase = 6  # PERFORMANCE_P1

    print("Starting Performance Phase (Triggering OnLiveStart)...")
    # Rule: step(0) progresses
    state.step(0)

    print(f"Phase after step: {state.phase}")

    # Dump ALL logs
    print("\n--- FULL ENGINE LOG ---")
    for line in state.rule_log:
        print(line)
    print("--- END LOG ---\n")

    if state.phase == 10:  # RESPONSE
        print(f"Pending Card ID: {state.pending_card_id}")
        print(f"Pending Ab Idx: {state.pending_ab_idx}")

        # Take action 560 (Pink)
        print("Selecting Pink color (Action 560)...")
        state.step(560)

        if state.phase == 10:
            print("Paused for second choice (SELECT_MODE).")
            state.step(560)  # Pick first heart mode
            print(f"Phase after second choice: {state.phase}")

    # Verify log
    log = state.rule_log
    print("\n--- TEST LOG SUMMARY ---")
    for line in log:
        if "(On Live Start)" in line or "Pausing" in line:
            print(line)

    trigger_count = sum(1 for line in log if "(On Live Start)" in line)
    print(f"On Live Start trigger count in log: {trigger_count}")

    p0_final = state.get_player(0)
    print(f"Hand size after discard: {len(p0_final.hand)}")

    # Assertions
    assert trigger_count == 1, f"Expected 1 trigger, found {trigger_count}."
    print("\nREPRODUCTION TEST PASSED")


if __name__ == "__main__":
    try:
        test_live_start_interactivity()
    except Exception as e:
        print(f"\nREPRODUCTION TEST FAILED: {e}")
        import traceback

        traceback.print_exc()
        sys.exit(1)