import { ExtrapolationMode } from "cc";

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


export let ROWS = [3, 4, 3];
export let COL = 4;

export let ICON_WIDTH = 165;
export let ICON_HEIGHT = 145;

export let ICON_MAP = {
    0: "WILD",
    1: "SCATTER",
    2: "黄色云朵",
    3: "紫色星球",
    4: "红色星球",
    5: "蓝色火山",
    6: "紫色水母",
    7: "绿色章鱼",
    8: "A",
    9: "K",
    10: "Q",
    11: "J",
    12: "10",
}

// 图标赔率
export let ICON_RATE = {
    0: [0, 0, 0, 0],     // Wild
    1: [0, 0, 0, 0],     // Scatter
    2: [80, 60, 40, 30],       // 黄色云朵
    3: [70, 50, 25, 20],       // 紫色星球
    4: [60, 40, 25, 10],       // 红色星球
    5: [30, 20, 15, 8],       // 蓝色火山
    6: [15, 12, 10, 6],       // 紫色水母
    7: [15, 12, 10, 6],       // 绿色章鱼
    8: [10, 8, 6, 4],       // A
    9: [10, 8, 6, 4],       // K
    10: [4, 3, 2, 1],       // Q
    11: [4, 3, 2, 1],       // J
    12: [4, 3, 2, 1],       // 10
}

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;
    // 不规则图标信息
    CroSymbols: {
        [key: string]: {
            Type: number;
            PosFirst: number;
            PosLast: number;
            Symbol: number;
        }
    };
    // 连线数
    WaysNum: number;
    // 每列图标数量
    SymbolNumOfReels: number[];
    // 是否结束
    IsEnd: boolean;
    // 图标中奖信息
    WinInfo: {
        Score: number;
        Multi: number;
        MultiValue: any;
        Desc: any;
    };
    // 中奖位置
    WinPosition: any;
    // 盘面信息
    Symbol: {
        ScNum: number;
        winMulti: number;
        WaysNum: number;
        ReelNum: number[];
        MultiValue: number[];
        Middle: number[];
    };
    // 盘面变化
    PanChanges: any;
    // 局信息
    RoundInfo: any;
    // scatter数量
    ScNum: number;
    // 获得游戏次数
    GetGamesTimes: number;
    // 盈利分数
    ProfitScore: number;
    // 得分列表
    Scores: any;
}

export interface SpinData {

}

export let gameInfo: any = {
    "Balance": 512887215700,
    "BetGrade": [
        10000,
        20000,
        30000,
        40000,
        50000,
        60000,
        70000,
        80000,
        90000,
        100000,
        200000,
        300000,
        400000,
        500000,
        600000,
        700000,
        800000,
        900000,
        1000000,
        2000000,
        3000000,
        4000000,
        5000000,
        6000000,
        7000000,
        8000000,
        9000000,
        10000000,
        15000000,
        20000000,
        25000000,
        30000000,
        35000000,
        40000000,
        45000000,
        50000000
    ],
    "Data": {
        "AllScore": 0,
        "Score": 0,
        "SpinScore": 0,
        "Data": null,
        "Remove": null,
        "HitLine": null,
        "HitBlock": null,
        "DataType": null,
        "Mode": 0,
        "FreeSpin": null,
        "Bet": 10000,
        "Balance": 0,
        "WinMultiPlier": 1,
        "CroSymbols": {
            "1": {
                "FrameType": 1,
                "PosFirst": 5,
                "PosLast": 6,
                "Color": 4
            },
            "2": {
                "FrameType": 0,
                "PosFirst": 8,
                "PosLast": 9,
                "Color": 3
            },
            "3": {
                "FrameType": 0,
                "PosFirst": 11,
                "PosLast": 12,
                "Color": 7
            },
            "4": {
                "FrameType": 0,
                "PosFirst": 13,
                "PosLast": 14,
                "Color": 9
            },
            "5": {
                "FrameType": 0,
                "PosFirst": 15,
                "PosLast": 16,
                "Color": 1
            },
            "6": {
                "FrameType": 1,
                "PosFirst": 17,
                "PosLast": 18,
                "Color": 10
            },
            "7": {
                "FrameType": 1,
                "PosFirst": 20,
                "PosLast": 21,
                "Color": 3
            },
            "8": {
                "FrameType": 0,
                "PosFirst": 22,
                "PosLast": 23,
                "Color": 9
            }
        },
        "WaysNum": 6400,
        "SymbolNumOfReels": [
            5,
            4,
            4,
            4,
            4,
            5
        ],
        "IsEnd": true,
        "SymbolWinInfos": null,
        "WinPosition": null,
        "PanColor": {
            "Top": [
                3,
                6,
                8,
                2
            ],
            "Bottom": [
                5,
                12,
                4,
                9,
                11,
                4,
                4,
                12,
                3,
                3,
                5,
                7,
                7,
                9,
                9,
                1,
                1,
                10,
                10,
                12,
                3,
                3,
                9,
                9,
                11,
                8,
                6,
                10,
                6,
                12
            ]
        },
        "PanChanges": null,
        "RoundInfo": null,
        "ScNum": 0,
        "GetGamesTimes": 0,
        "ProfitScore": 0,
        "Scores": null
    }
}


// 
export let winData: any = {
    "Balance": 51602584500,  //余额
    "Data": {
        "AllScore": 76000, //累积赢分
        "Score": 24000,//本盘赢分
        "SpinScore": 0, //忽略
        "Data": null,//忽略
        "Remove": null,//忽略
        "HitLine": null,//忽略
        "HitBlock": null,//忽略
        "DataType": null,//忽略
        "Mode": 1,  //0普通模式 1购买模式
        "FreeSpin": {
            "MaxCount": 10, //小游戏总次数
            "LeftCount": 7 //小游戏剩余次数
        },
        "Bet": 10000,  //下注
        "Balance": 51602584500, //余额
        "WinMultiPlier": 6,   //当前算分的倍率 界面显示的X6倍
        "CroSymbols": {//跨行的符号集
            "1": {
                "FrameType": 0,  //0:普通框 1:银框 2:金框 3:百搭框
                "PosFirst": 6,
                "PosLast": 7,
                "Color": 12
            },
            "2": {
                "FrameType": 1,
                "PosFirst": 8,
                "PosLast": 9,
                "Color": 6
            },
            "3": {
                "FrameType": 1,
                "PosFirst": 11,
                "PosLast": 12,
                "Color": 6
            },
            "4": {
                "FrameType": 1,
                "PosFirst": 13,
                "PosLast": 14,
                "Color": 9
            },
            "5": {
                "FrameType": 0,
                "PosFirst": 18,
                "PosLast": 19,
                "Color": 6
            },
            "6": {
                "FrameType": 1,
                "PosFirst": 22,
                "PosLast": 23,
                "Color": 6
            }
        },
        "WaysNum": 10000,
        "SymbolNumOfReels": [ //每一根轴上有几个符号,跨行的符号算一个
            5,
            4,
            4,
            5,
            5,
            5
        ],
        "IsEnd": false, //是否为最后一盘
        "SymbolWinInfos": {//赢分信息
            "9": {//9作为key代表symbol的color
                "Score": 4000, //中奖分数
                "Ways": 1,  //中奖路数
                "SymbolPayoutValue": 8,//赢分对应的符号值，3个多少分，4个多少分，5个多少分
                "BottomSymbols": [ //2维数组,代表赢分的块
                    [
                        0
                    ],
                    [
                        5
                    ],
                    [
                        13,
                        14
                    ]
                ],
                "BottomPos": [//1维数组,底部代表赢分的块的占领的块索引值
                    0,
                    5,
                    13,
                    14
                ],
                "TopPos": [//1维数组,顶部代表赢分的块的占领的块索引值
                    2,
                    3
                ],
                "Formula": "0.07 x 6",//下注历史使用
                "FormulaDetail": "1.00 / 20 x 8 x 1 x 6",//下注历史使用
                "WinAxisNum": 5//下注历史使用
            }
        },
        "WinPosition": {//赢分位置
            "BottomNormal": [//没有变百搭的赢分符号的位置
                0,
                5
            ],
            "BottomSilver": [//变为百搭的赢分符号的位置
                13,
                14
            ],
        },
        "PanColor": {//盘面
            "Top": [//盘面顶部
                2,
                11,
                9,
                9
            ],
            "Bottom": [//盘面底部
                9,
                8,
                3,
                3,
                3,
                9,
                12,
                12,
                6,
                6,
                11,
                6,
                6,
                9,
                9,
                2,
                10,
                10,
                6,
                6,
                1,
                5,
                6,
                6,
                5,
                11,
                8,
                3,
                3,
                3
            ]
        },
        "PanChanges": {//当前盘面相对于上一把盘面的变化
            "CrossSymbolFrameTypeChange": {//crossSymbol符号 银框金框等之间的变化
                "FrameType": 2,//变成金框了
                "PosFirst": 0,//crossSymbol的起始位置
                "PosLast": 3,
            },//crossSymbol的结束位置
            "CrossSymbolPosChange": {//crossSymbol符号的位置发生了变化
                "1": {  //1的key对应于CroSymbols字段中的key
                    "OldPos": [//CroSymbols的变化之前的位置
                        5,
                        6
                    ],
                    "NewPos": [//CroSymbols的变化之后的位置
                        6,
                        7
                    ]
                },
                "2": {
                    "OldPos": [
                        7,
                        8
                    ],
                    "NewPos": [
                        8,
                        9
                    ]
                }
            },
            "CrossSymbolColorChange": {},//crossSymbol符号的color发生了变化
            "BottomNewSymbols": [//此盘每一列新增加的symbol 数据中的值代表color
                [
                    9
                ],
                [
                    9
                ],
                [
                    11
                ],
                [],
                [],
                []
            ],
            "TopNewSymbols": []//此局头部新增加的symbol 数据中的值代表color
        },
        "RoundInfo": {//回合信息 //下注历史用
            "Current": 2,
            "Total": 3
        },
        "ScNum": 1,//下注历史用
        "GetGamesTimes": 0,//下注历史用
        "ProfitScore": 24000,//下注历史用
        "Scores": null//下注历史用
    }
}

export let winTestData = {
    "Balance": 512890548700,
    "Data": {
        "Rid": "67da7b0e3fb9bd4878ff44d2_7_21",
        "AllScore": 56000,
        "Score": 42000,
        "SpinScore": 0,
        "Data": null,
        "Remove": null,
        "HitLine": null,
        "HitBlock": null,
        "DataType": null,
        "Mode": 1,
        "FreeSpin": {
            "MaxCount": 12,
            "LeftCount": 8,
            "SpinScore": 0
        },
        "Bet": 10000,
        "Balance": 512890548700,
        "IsFree": true,
        "WinMultiPlier": 6,
        "CroSymbols": {
            "1": {
                "FrameType": 0,
                "PosFirst": 7,
                "PosLast": 9,
                "Color": 8
            },
            "2": {
                "FrameType": 1,
                "PosFirst": 10,
                "PosLast": 12,
                "Color": 10
            },
            "3": {
                "FrameType": 1,
                "PosFirst": 17,
                "PosLast": 18,
                "Color": 4
            },
            "4": {
                "FrameType": 0,
                "PosFirst": 20,
                "PosLast": 21,
                "Color": 3
            },
            "5": {
                "FrameType": 1,
                "PosFirst": 22,
                "PosLast": 23,
                "Color": 11
            }
        },
        "WaysNum": 8000,
        "SymbolNumOfReels": [
            5,
            4,
            4,
            5,
            4,
            5
        ],
        "IsEnd": false,
        "SymbolWinInfos": {
            "10": {
                "Score": 1000,
                "Ways": 1,
                "SymbolPayoutValue": 2,
                "BottomSymbols": [
                    [
                        3
                    ],
                    [
                        5
                    ],
                    [
                        10,
                        11,
                        12
                    ],
                    [
                        15
                    ]
                ],
                "BottomPos": [
                    3,
                    5,
                    10,
                    11,
                    12,
                    15
                ],
                "TopPos": null,
                "Formula": "0.02 x 6",
                "FormulaDetail": "1.00 / 20 x 2 x 1 x 6",
                "WinAxisNum": 4
            },
            "8": {
                "Score": 6000,
                "Ways": 2,
                "SymbolPayoutValue": 6,
                "BottomSymbols": [
                    [
                        1
                    ],
                    [
                        7,
                        8,
                        9
                    ],
                    [
                        13
                    ],
                    [
                        14
                    ],
                    [
                        19
                    ]
                ],
                "BottomPos": [
                    1,
                    7,
                    8,
                    9,
                    13,
                    14,
                    19
                ],
                "TopPos": null,
                "Formula": "0.10 x 6",
                "FormulaDetail": "1.00 / 20 x 6 x 2 x 6",
                "WinAxisNum": 4
            }
        },
        "WinPosition": {
            "BottomNormal": [
                1,
                7,
                8,
                9,
                13,
                14,
                19,
                3,
                5,
                15
            ],
            "BottomSpecial": [
                10,
                11,
                12
            ],
            "TopNormal": null
        },
        "PanColor": {
            "Top": [
                1,
                9,
                4,
                4
            ],
            "Bottom": [
                5,
                8,
                9,
                10,
                9,
                10,
                6,
                8,
                8,
                8,
                10,
                10,
                10,
                8,
                8,
                10,
                11,
                4,
                4,
                8,
                3,
                3,
                11,
                11,
                4,
                6,
                6,
                5,
                5,
                5
            ]
        },
        "PanChanges": {
            "CrossSymbolFrameTypeChange": {},
            "CrossSymbolPosChange": {
                "1": {
                    "OldPos": [
                        6,
                        7,
                        8
                    ],
                    "NewPos": [
                        7,
                        8,
                        9
                    ]
                }
            },
            "CrossSymbolColorChange": {},
            "BottomNewSymbols": [
                [
                    5,
                    8
                ],
                [
                    10
                ],
                [],
                [
                    10
                ],
                [],
                []
            ],
            "TopNewSymbols": [
                4
            ]
        },
        "RoundInfo": {
            "Current": 2,
            "Total": 3
        },
        "ScNum": 1,
        "GetGamesTimes": 0,
        "ProfitScore": 42000,
        "Scores": null
    }
}

