import { ExtrapolationMode } from "cc";

export let GAME_STATE = {
    IDLE: 0,
    ROTATE: 1,
    WINNING: 2,
    FREE_SPIN: 3,
}

export let ICON_WIDTH = 165;
export let ICON_HEIGHT = 174;

export let ICON_MAP = {
    0: "WILD",
    1: "SCATTER",
    2: "倍数",
    3: "马",
    4: "牛",
    5: "盾",
    6: "M",
    7: "三叉戟",
    8: "宝马",
    9: "凯迪拉克",
    10: "丰田",
    11: "别克",
    12: "大众",
}

// 图标赔率
export let ICON_RATE = {
    0: [0, 0, 0, 0],     // Wild
    1: [0, 0, 0, 0],     // Scatter
    2: [0, 0, 0, 0],       // 倍数
    3: [50, 40, 25, 20],       // 马
    4: [40, 30, 20, 10],       // 牛
    5: [30, 20, 15, 8],       // 盾
    6: [15, 12, 10, 6],       // M
    7: [15, 12, 10, 6],       // 三叉戟
    8: [10, 8, 6, 4],       // 宝马
    9: [10, 8, 6, 4],       // 凯迪拉克
    10: [4, 3, 2, 1],       // 丰田
    11: [4, 3, 2, 1],       // 别克
    12: [4, 3, 2, 1],       // 大众
}

export let ROLLER_RULE = [
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
]

export let FREE_SPIN_ROLLER_RULE = [
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
]


export enum ICON_STATE {
    ACTIVATE,           // 激活
    IDLE,               // 在转盘不动的状态
    ROTATE,             // 旋转中
    FAST,               // 快速旋转
    WIN,                // 图标中奖
    HIDE,               // 对象池回收
}

// 单个滚轮事件
export enum ROLLER_EVENT {
    ON_R_ICON_CREATE = 'ON_R_ICON_CREATE',              // 当滚轮上随机Icon创建的时候回调
    ROLLER_UNIFORM = "ROLLER_UNIFORM",                  // 滚轮开始匀速
    ROLLER_DECELERATE = "ROLLER_DECELERATE",            // 滚轮开始减速
    LAST_PAGE_CREATE = 'LAST_PAGE_CREATE',              // 最后一页创建
    ROLLER_BOUNCE = 'ROLLER_BOUNCE',                    // 滚轮开始回弹
    ROLLER_STOP = 'ROLLER_STOP',                        // 滚轮停止

    // 消除相关
    ICON_DELETED = 'ICON_DELETED',                      // 图标删除
    ICON_CREATE = 'ICON_CREATE',                        // 图标创建
    ICON_FALLEN = 'ICON_FALLEN',                        // 图标落下
}

// 滚轮组合事件
export enum ROLLER_COMBINE_EVENT {
    ONE_ROLLER_STOP = 'ONE_ROLLER_STOP',                // 一个滚轮停止的事件
    ALL_ROLLER_STOP = 'ALL_ROLLER_STOP',                // 所有滚轮停止的事件
    ROLLER_BOUNCE = 'ROLLER_BOUNCE',                    // 滚轮开始回弹
    ROLLER_DECELERATE = 'ROLLER_DECELERATE',            // 滚轮开始减速

    // 消除相关
    ALL_ROLLER_ICONS_DELETED = 'ALL_ROLLER_ICONS_DELETED', // 所有滚轮图标删除
    ALL_ROLLER_ICONS_CREATED = 'ALL_ROLLER_ICONS_CREATED', // 所有滚轮图标创建
    ALL_ROLLER_ICONS_FALLEN = 'ALL_ROLLER_ICONS_FALLEN', // 所有滚轮图标落下
}

export enum SLOT_BAR_EVENT {
    BET_CHANGE = 'BET_CHANGE',                  //  下注金额改变
    ON_TEST_SPIN_CLICK = 'ON_TEST_SPIN_CLICK',    // 测试旋转
    ON_SPIN_CLICK = 'ON_SPIN_CLICK',
    ON_MANUAL_STOP = 'ON_MANUAL_STOP',
    FAST_SPIN = 'FAST_SPIN',                    // 快速旋转
    ON_AUTO_SPIN_CLICK = 'ON_AUTO_SPIN_CLICK',  // 自动旋转点击
    ON_EXIT_CLICK = 'ON_EXIT_CLICK',            // 退出游戏
}

export enum SYS_GIFT {
    CLICK_CONTINUE = 'CLICK_CONTINUE',
    SETTLE_CONTINUE = 'SETTLE_CONTINUE',
}

export enum SLOT_GAME_EVENT {
    ALL_ROLLER_STOP = 'ALL_ROLLER_STOP',       // 事件传递
    ALL_ROLLER_ICONS_DELETED = 'ALL_ROLLER_ICONS_DELETED', // 所有滚轮图标删除
    ALL_ROLLER_ICONS_CREATED = 'ALL_ROLLER_ICONS_CREATED', // 所有滚轮图标创建
    ALL_ROLLER_ICONS_FALLEN = 'ALL_ROLLER_ICONS_FALLEN', // 所有滚轮图标落下
}

export enum WIN_TYPE {
    NONE,
    NORAML_WIN,
    MIDDLE_WIN,
    BIG_WIN,
    MEGA_WIN,
    SUPER_MEGA_WIN,
}


export interface FreeSpin {
    LeftCount: number,  // 剩余次数
    MaxCount: number,   // 总共次数
}

export interface CrossSymbol {
    FrameType: number;  // 框类型
    PosFirst: number;   // 起始位置
    PosLast: number;    // 结束位置
    Color: number;      // iconIndex
}

export interface GameInfo {
    // 当前余额
    Balance: number;
    // 是否关闭购买
    CloseBuyGame: boolean;
    // 下注区间
    BetGrade: number[];
    // 游戏数据
    Data: GameData
    // 购买倍率
    BuyMul: number;
    // 最大购买倍数
    MaxBuyBet: number
}

export interface GameData {
    // 总计得分
    AllScore: number;
    // 当前得分
    Score: number;
    // 单次旋转得分
    SpinScore: number;
    // 盘面数据
    Data: number[];
    // 消除数据
    Remove: number[];
    // 游戏模式 0:普通模式 1:免费游戏模式
    Mode: number;
    // 免费游戏信息
    FreeSpin: FreeSpin | null;
    // 当前下注
    Bet: number;
    // 不规则图标信息
    CrossSymbols: {
        [key: string]: {
            FrameType: number;
            PosFirst: number;
            PosLast: number;
            Color: number;
        }
    };
    // 连线数
    WaysNum: number;
    // 每列图标数量
    SymbolNumOfReels: number[];
    // 是否结束
    IsEnd: boolean;
    // 图标中奖信息
    SymbolWinInfos: any;
    // 中奖位置
    WinPosition: any;
    // 盘面信息
    PanColor: {
        Top: number[];
        Bottom: number[];
    };
    // 盘面变化
    PanChanges: any;
    // 局信息
    RoundInfo: any;
    // scatter数量
    ScNum: number;
    // 获得游戏次数
    GetGamesTimes: number;
    // 盈利分数
    ProfitScore: number;
    // 得分列表
    Scores: any;
    //倍率信息
    XnInfo: any;
}

export interface SpinData {

}


// 
export let testData: any = {
    "Balance": 51602584500,  //余额
    "Data": {
        "Rid": "686389cd1bf37e54226ad747_1_1",
        "AllScore": 0,
        "Score": 0,
        "SpinScore": 0,
        "Data": null,
        "Remove": null,
        "HitLine": null,
        "HitBlock": null,
        "DataType": null,
        "Mode": 0,
        "FreeSpin": null,
        "Bet": 10000,
        "Balance": 99880882500,
        "IsFree": false,
        "WinMultiPlier": 0,
        "CrossSymbols": {
            "1": {
                "FrameType": 0,
                "PosFirst": 5,
                "PosLast": 6,
                "Color": 12
            },
            "2": {
                "FrameType": 0,
                "PosFirst": 8,
                "PosLast": 9,
                "Color": 9
            },
            "3": {
                "FrameType": 0,
                "PosFirst": 10,
                "PosLast": 12,
                "Color": 7
            },
            "4": {
                "FrameType": 0,
                "PosFirst": 13,
                "PosLast": 14,
                "Color": 7
            },
            "5": {
                "FrameType": 0,
                "PosFirst": 15,
                "PosLast": 17,
                "Color": 8
            },
            "6": {
                "FrameType": 0,
                "PosFirst": 21,
                "PosLast": 22,
                "Color": 7
            }
        },
        "WaysNum": 6000,
        "SymbolNumOfReels": [
            5,
            4,
            3,
            4,
            5,
            5
        ],
        "IsEnd": true,
        "SymbolWinInfos": {},
        "WinPosition": null,
        "PanColor": {
            "Top": [
                4,
                2,
                2,
                11
            ],
            "Bottom": [
                12,
                12,
                9,
                9,
                9,
                12,
                12,
                8,
                9,
                9,
                7,
                7,
                7,
                7,
                7,
                8,
                8,
                8,
                3,
                3,
                11,
                7,
                7,
                3,
                3,
                11,
                6,
                12,
                10,
                8
            ]
        },
        "PanChanges": null,
        "RoundInfo": null,
        "ScNum": 0,
        "GetGamesTimes": 0,
        "ProfitScore": -10000,
        "ScoreInfos": null,
        "AllBet": 10000,
        "GmNum": 0,
        "MultiPlierSymbolNum": 0,
        "Nst": 0,
        "TopTNum": null,
        "AnimationCtrl": {
            "Axis13EqualPlayAnim": false,
            "AxisTitleInfo": [
                0,
                0,
                0
            ]
        },
        "HistoryDetail": null,
        "XnInfo": {
            "Top": [
                {
                    "StartIndex": 1,
                    "N": 5
                },
                {
                    "StartIndex": 2,
                    "N": 8
                }
            ],
            "Bottom": null,
            "AddN": 6,
            "NowN": 6,
            "Win": "",
            "WinDetail": ""
        }
    },
    "Frb": {
        "Finished": null,
        "Ongoing": null
    }
}

