import openpyxl
from openpyxl.styles import Font, Alignment, PatternFill, Border, Side

wb = openpyxl.Workbook()
ws = wb.active
ws.title = "U23_L2_承"

ws.column_dimensions['A'].width = 12
ws.column_dimensions['B'].width = 45
ws.column_dimensions['C'].width = 12
ws.column_dimensions['D'].width = 42

header_font = Font(bold=True, size=11)
header_fill = PatternFill(start_color="D9D9D9", end_color="D9D9D9", fill_type="solid")
cell_align = Alignment(vertical="top", wrap_text=True)
header_align = Alignment(horizontal="center", vertical="center", wrap_text=True)
thin_border = Border(
    left=Side(style="thin"), right=Side(style="thin"),
    top=Side(style="thin"), bottom=Side(style="thin")
)

headers = ["类型", "剧情描述", "角色名", "编剧台词"]
for col, h in enumerate(headers, 1):
    cell = ws.cell(row=1, column=col, value=h)
    cell.font = header_font
    cell.fill = header_fill
    cell.alignment = header_align
    cell.border = thin_border

rows = [
    ["TL", '【场景】May农场 — 会场\n【角色】User、May、Sam、Jack', "", ""],
    ["", "Jack的话说完。Sam脸色刷白，额头冒汗", "", ""],
    ["", "", "Sam", "I... I need the toilet."],
    ["", "Sam转身就跑，差点撞倒展台上的Pineapple", "", ""],
    ["", "", "May", "Sam went to the toilet."],
    ["", "May朝User无奈地耸耸肩。两人跟去厕所门口", "", ""],
    ["TL", "【场景】厕所门口\n【角色】User、May、Sam", "", ""],
    ["", "厕所隔间门关着，Sam在里面深呼吸的声音传出来", "", ""],
    ["中互动", "", "User", "Sam is in the toilet."],
    ["", "隔间里传来冲水声。Sam推门出来，擦着汗", "", ""],
    ["", "", "Sam", "Okay. I am ready now."],
    ["", "May拍拍Sam肩膀", "", ""],
    ["", "", "May", "Good! Let's go back."],
    ["TL", "【场景】会场展台前\n【角色】User、May、Sam、Jack", "", ""],
    ["", "三人走回会场。展台前围了一群人，嘈杂声一片", "", ""],
    ["", 'May挤进去 —— 然后僵住了', "", ""],
    ["", "【镜头】展台上：巨大的Pineapple被啃得乱七八糟，只剩皮和残渣", "", ""],
    ["", "", "May", "The pineapple! Where is the pineapple?!"],
    ["", "Jack摸着下巴，若有所思", "", ""],
    ["", "", "Jack", "Tom loves pineapple..."],
    ["", "", "Jack", "Maybe he ate them?"],
    ["", "【emoji】May😱", "", ""],
    ["中互动", "【插入图】展台残局大图：pineapple被啃碎的残渣、皮、空盘，请用户找出被偷吃的是哪种fruit", "", ""],
    ["", "众人面面相觑。突然——【音效】远处传来一声响亮的驴叫", "", ""],
    ["", "", "May", "What was that?"],
    ["", "我们循声找去", "", ""],
    ["TL", "【场景】农场角落\n【角色】User、May、Sam、Jack、驴子", "", ""],
    ["", "农场角落的栅栏边。一头驴子正悠闲地嚼着东西，嘴边还挂着Pineapple皮", "", ""],
    ["", "", "May", "A donkey!"],
    ["", "【emoji】May😲 Sam😅", "", ""],
    ["", "May走近驴子，弯腰看着它", "", ""],
    ["", "", "May", "Hey, donkey!"],
    ["", "", "May", "What fruit do you like?"],
    ["", "驴子当然不理她，继续啃Pineapple。May转头对User眨眼", "", ""],
    ["", "", "May", "Okay. What fruit does it like?"],
    ["中互动", "", "User", "It likes pineapple!"],
    ["", "Sam终于笑了出来，擦擦汗", "", ""],
    ["", "", "Sam", "A donkey ate my pineapple."],
    ["", "", "Sam", "That is funny."],
    ["", "Jack挠头，有点尴尬", "", ""],
    ["", "", "Jack", "But Tom really likes pineapple too."],
    ["", "", "Jack", "I was sure he ate them."],
    ["TL", "【场景】厕所门口\n【角色】User、May、Sam", "", ""],
    ["", "三人准备回会场。Sam突然停下", "", ""],
    ["", "", "Sam", "Wait... I need the toilet... again!"],
    ["", "Sam捂着肚子又跑向厕所。May叹了一口长长的气", "", ""],
    ["", "", "May", "Come on, Sam!"],
    ["", "User和May靠在厕所门外。等了一会儿——没动静", "", ""],
    ["中互动", "", "User", "Sam went to the toilet."],
    ["", "May踮脚往门里张望", "", ""],
    ["", "", "May", "He is still in there."],
    ["", "又等了一会儿", "", ""],
    ["", "厕所门开了——出来的不是Sam。是Tom。", "", ""],
    ["", "【镜头】Tom满脸通红（过敏反应），揉着脸，完全没注意到我们", "", ""],
    ["TL", "【角色】Tom", "", ""],
    ["", "", "Tom", "I hate pineapple..."],
    ["", "", "Tom", "I hate kiwi..."],
    ["", "User和May愣在原地，交换了一个震惊的眼神", "", ""],
    ["", "May小声凑近User", "", ""],
    ["", "", "May", "Did you hear that?"],
    ["中互动", "", "User", "I heard that!"],
    ["中互动", "", "User", "Are you okay, Tom?"],
    ["", "Tom猛然抬头，看到我们。表情瞬间切换成笑脸（很不自然）", "", ""],
    ["", "", "Tom", "I am fine! I am okay!"],
    ["", "", "Tom", "I like pineapple and kiwi!"],
    ["", "", "Tom", "I love them!"],
    ["", "Tom边说边快步走开，几乎是小跑离开的", "", ""],
    ["", "【emoji】May😕 User🤨", "", ""],
    ["", "", "May", "That was strange."],
    ["", "", "May", "He said he hates them..."],
    ["", "", "May", "Then he said he loves them."],
    ["", "⚡钩子：Sam终于推门出来。会场方向传来掌声——Kalab的品鉴开始了。User回头看了一眼Tom消失的方向...", "", ""],
]

tl_fill = PatternFill(start_color="E8F0FE", end_color="E8F0FE", fill_type="solid")
interact_fill = PatternFill(start_color="FFF2CC", end_color="FFF2CC", fill_type="solid")

for i, row in enumerate(rows, 2):
    for col, val in enumerate(row, 1):
        cell = ws.cell(row=i, column=col, value=val)
        cell.alignment = cell_align
        cell.border = thin_border
        if row[0] == "TL":
            cell.fill = tl_fill
        elif row[0] == "中互动":
            cell.fill = interact_fill

ws.freeze_panes = "A2"

output_path = "/root/.openclaw/workspace-xiaobian/output/U23_L2_承_剧本V1.xlsx"
wb.save(output_path)
print(f"Saved: {output_path}")
