File size: 5,209 Bytes
2113a6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
"""Trigger detection patterns.



Triggers determine WHEN an ability activates:

- ON_PLAY: When member enters the stage

- ON_LIVE_START: When a live begins

- ON_LIVE_SUCCESS: When a live succeeds

- ACTIVATED: Manual activation

- CONSTANT: Always active

- etc.



Patterns are organized in tiers:

- Tier 1 (priority 10-19): Icon filenames (most reliable)

- Tier 2 (priority 20-29): Specific phrases

- Tier 3 (priority 30-39): Generic kanji keywords

"""

from .base import Pattern, PatternPhase

TRIGGER_PATTERNS = [
    # ==========================================================================
    # TIER 1: Icon-based triggers (highest priority)
    # ==========================================================================
    Pattern(
        name="on_play_icon",
        phase=PatternPhase.TRIGGER,
        regex=r"toujyou",
        priority=10,
        output_type="TriggerType.ON_PLAY",
    ),
    Pattern(
        name="on_live_start_icon",
        phase=PatternPhase.TRIGGER,
        regex=r"live_start",
        priority=10,
        output_type="TriggerType.ON_LIVE_START",
    ),
    Pattern(
        name="on_live_success_icon",
        phase=PatternPhase.TRIGGER,
        regex=r"live_success",
        priority=10,
        # Skip if "この能力は...のみ発動する" (activation restriction, not trigger)
        excludes=["この能力は"],
        output_type="TriggerType.ON_LIVE_SUCCESS",
    ),
    Pattern(
        name="activated_icon",
        phase=PatternPhase.TRIGGER,
        regex=r"kidou",
        priority=10,
        output_type="TriggerType.ACTIVATED",
    ),
    Pattern(
        name="constant_icon",
        phase=PatternPhase.TRIGGER,
        regex=r"jyouji",
        priority=10,
        output_type="TriggerType.CONSTANT",
    ),
    Pattern(
        name="on_leaves_icon",
        phase=PatternPhase.TRIGGER,
        regex=r"jidou",
        priority=10,
        output_type="TriggerType.ON_LEAVES",
    ),
    Pattern(
        name="live_end_icon",
        phase=PatternPhase.TRIGGER,
        regex=r"live_end",
        priority=10,
        output_type="TriggerType.TURN_END",
    ),
    # ==========================================================================
    # TIER 2: Specific phrase triggers
    # ==========================================================================
    Pattern(
        name="on_reveal_cheer",
        phase=PatternPhase.TRIGGER,
        regex=r"エールにより公開|エールで公開",
        priority=20,
        output_type="TriggerType.ON_REVEAL",
    ),
    Pattern(
        name="constant_yell_reveal",
        phase=PatternPhase.TRIGGER,
        keywords=["エールで出た"],
        priority=20,
        output_type="TriggerType.CONSTANT",
    ),
    # ==========================================================================
    # TIER 3: Kanji keyword triggers
    # ==========================================================================
    Pattern(
        name="on_play_kanji",
        phase=PatternPhase.TRIGGER,
        regex=r"登場",
        priority=30,
        # Filter: Not when describing "has [Play] ability" etc
        look_ahead_excludes=["能力", "スキル", "を持つ", "を持たない", "がない"],
        output_type="TriggerType.ON_PLAY",
    ),
    Pattern(
        name="on_live_start_kanji",
        phase=PatternPhase.TRIGGER,
        regex=r"ライブ開始|ライブの開始",
        priority=30,
        look_ahead_excludes=["能力", "スキル", "を持つ"],
        output_type="TriggerType.ON_LIVE_START",
    ),
    Pattern(
        name="on_live_success_kanji",
        phase=PatternPhase.TRIGGER,
        regex=r"ライブ成功",
        priority=30,
        look_ahead_excludes=["能力", "スキル", "を持つ"],
        output_type="TriggerType.ON_LIVE_SUCCESS",
    ),
    Pattern(
        name="activated_kanji",
        phase=PatternPhase.TRIGGER,
        keywords=["起動"],
        priority=30,
        look_ahead_excludes=["能力", "スキル", "を持つ"],
        output_type="TriggerType.ACTIVATED",
    ),
    Pattern(
        name="constant_kanji",
        phase=PatternPhase.TRIGGER,
        keywords=["常時"],
        priority=30,
        look_ahead_excludes=["能力", "スキル", "を持つ"],
        output_type="TriggerType.CONSTANT",
    ),
    Pattern(
        name="on_leaves_kanji",
        phase=PatternPhase.TRIGGER,
        keywords=["自動"],
        priority=30,
        look_ahead_excludes=["能力", "スキル", "を持つ"],
        output_type="TriggerType.ON_LEAVES",
    ),
    Pattern(
        name="turn_start",
        phase=PatternPhase.TRIGGER,
        keywords=["ターン開始"],
        priority=30,
        output_type="TriggerType.TURN_START",
    ),
    Pattern(
        name="turn_end_kanji",
        phase=PatternPhase.TRIGGER,
        regex=r"ターン終了|ライブ終了",
        priority=30,
        look_ahead_excludes=["まで"],  # "Until end of turn" is duration, not trigger
        output_type="TriggerType.TURN_END",
    ),
]