#![allow(dead_code)]
#![allow(long_running_const_eval)]
#![allow(unused_imports)]

use crate::character::Character::{self, *};
use crate::condition::Condition::{self, *};
use crate::entity::Entity;
use crate::item::Item::{self, *};
use crate::location::Location::{self, *};
use crate::save_point::SavePoint::{self, *};
use crate::script::Token::{self, *};
use crate::script::script;
use crate::snippet::Snippet::{self, *};
use crate::sound::Sound::{self, *};
use crate::style::Style::{self, *};

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[repr(u32)]
pub enum Label {
    Label088034,
    Label08803B,
    Label088044,
    Label08804B,
    Label08804F,
    Label088055,
    Label08805B,
    Label088060,
    Label0880A7,
    Label0880C4,
    Label0880E1,
    Label088104,
    Label088122,
    Label08812F,
    Label088146,
    Label08815A,
    Label088172,
    Label088179,
    Label088180,
    Label088188,
    Label088190,
    Label088199,
    Label0881A2,
    Label0881AB,
    Label0881B4,
    Label0881BD,
    Label0881C7,
    Label0881D1,
    Label0881DB,
    Label0881E6,
    Label08822B,
}

use self::Label::*;

const fn find_label(script: &'static [Token<Label>], label: Label) -> usize {
    let mut i = 0;
    while i < script.len() {
        match script[i] {
            Token::Label(l) if l as u8 == label as u8 => return i,
            _ => i += 1,
        };
    }
    unreachable!();
}

pub fn dialog_for_label(index: usize) -> &'static [Token<'static, Label>] {
    &SCRIPTS[INDEXED[index]..]
}

pub fn dialog(index: usize) -> &'static [Token<'static, Label>] {
    &SCRIPTS[INDEXED[index]..]
}

const SCRIPTS: &[Token<Label>] = script![

Label(Label088034)
    "ランプの�" End

Label(Label08803B)
    ToggleCanSpeedUp Style(WhiteOnTransparent) SetOutline(true) End

Label(Label088044)
    "黒ヒョウ" End

Label(Label08804B)
    "女神" End

Label(Label08804F)
    "�ガメ" End

Label(Label088055)
    "ミミズク" End

Label(Label08805B)
    "ツバメ" End

Label(Label088060)
    PauseSound "�の��をとなえよ" NewLine
    Style(RedOnBlack) IncantSpell("🌝🪿🪲🪿") "てを" Style(WhiteOnBlack) SetOutline(false) NewLine
    "�るがよい" Wait(30) ResumeSound End

Label(Label0880A7)
    PauseSound "�の��をとなえよ" NewLine
    Style(BlueOnBlack) IncantSpell("🪿🌝🌝🪲") End

Label(Label0880C4)
    PauseSound "白の��をとなえよ" NewLine
    IncantSpell("🪲🌝🪲🪲🪲🌝") End

Label(Label0880E1)
    PauseSound "黒の��をとなえよ" NewLine
    SetOutline(true) Style(BlackOnBlack) IncantSpell("🌝🪲🌝🌝🌝🪲") End

Label(Label088104)
    "むずかしそうな�が" NewLine
    "ならんでいる。" More Clear
    "よみますか？" End

Label(Label088122)
    "ぱんぱかぱーん！" NewLine
    End

Label(Label08812F)
    Wait(15) "ぱっ" Wait(15) "ぱっ" Wait(15) "ぱっ" Wait(15) NewLine
    End

Label(Label088146)
    "ぱんぱからん" Wait(15) "ぱぱぱ！" NewLine
    End

Label(Label08815A)
    "ぱぱぱぱぱぱぱぱぱぱっ！" NewLine
    End

Label(Label088172)
    "攻�力\u{3000}〸１" End

Label(Label088179)
    "攻�力\u{3000}〸２" End

Label(Label088180)
    "攻�力\u{3000}〸４" End

Label(Label088188)
    "攻�力\u{3000}〸８" End

Label(Label088190)
    "��力\u{3000}〸０" End

Label(Label088199)
    "��力\u{3000}〸１" End

Label(Label0881A2)
    "��力\u{3000}〸２" End

Label(Label0881AB)
    "��力\u{3000}〸３" End

Label(Label0881B4)
    "��力\u{3000}〸３" End

Label(Label0881BD)
    "��力\u{3000}〸５" End

Label(Label0881C7)
    "��力\u{3000}〸７" End

Label(Label0881D1)
    "��力\u{3000}〸１０" End

Label(Label0881DB)
    "��力\u{3000}〸１５" End

Label(Label0881E6)
    NewLine
    "ところで‥‥" Wait(30) NewLine
    "あなた\u{3000}『�ののべ�』\u{3000}を" NewLine
    "もってるザマスね。" More NewLine
    "ワタクシが�ってあげても" NewLine
    "よろしいザマスよ。" More NewLine
    End

Label(Label08822B)
    NewLine
    "マジカルヒット" End
    ];

pub const INDEXED: &[usize] = &[
    find_label(SCRIPTS, Label088034),
    find_label(SCRIPTS, Label08803B),
    find_label(SCRIPTS, Label088044),
    find_label(SCRIPTS, Label08804B),
    find_label(SCRIPTS, Label08804F),
    find_label(SCRIPTS, Label088055),
    find_label(SCRIPTS, Label08805B),
    find_label(SCRIPTS, Label088060),
    find_label(SCRIPTS, Label0880A7),
    find_label(SCRIPTS, Label0880C4),
    find_label(SCRIPTS, Label0880E1),
    find_label(SCRIPTS, Label088104),
    find_label(SCRIPTS, Label088122),
    find_label(SCRIPTS, Label08812F),
    find_label(SCRIPTS, Label088146),
    find_label(SCRIPTS, Label08815A),
    find_label(SCRIPTS, Label088172),
    find_label(SCRIPTS, Label088179),
    find_label(SCRIPTS, Label088180),
    find_label(SCRIPTS, Label088188),
    find_label(SCRIPTS, Label088190),
    find_label(SCRIPTS, Label088199),
    find_label(SCRIPTS, Label0881A2),
    find_label(SCRIPTS, Label0881AB),
    find_label(SCRIPTS, Label0881B4),
    find_label(SCRIPTS, Label0881BD),
    find_label(SCRIPTS, Label0881C7),
    find_label(SCRIPTS, Label0881D1),
    find_label(SCRIPTS, Label0881DB),
    find_label(SCRIPTS, Label0881E6),
    find_label(SCRIPTS, Label08822B),
];
