// 导入BoleMbti脚本

// 引用Parse JS SDK
const Parse = require("parse/node");
Parse.initialize("dev"); // 设置applicationId
Parse.serverURL = "http://web2023.fmode.cn:9999/parse"; // 设置serverURL

let game= [
    {
        "name": "王者荣耀",
        "image": "assets/image/WangZhiRongYao.webp",
        "detail": "一款由腾讯游戏开发的多人在线战术竞技游戏，玩家分为两支对抗的队伍，在地图上展开战斗，每个玩家控制一个英雄，通过策略和技能展开战斗。",
        "rating": 9.3
    },
    {
        "name": "和平精英",
        "image": "assets/image/HePinJinYing.webp",
        "detail": "一款由腾讯游戏开发的大逃杀游戏，玩家需要在庞大的地图上收集资源、武器和装备，与其他玩家展开生存竞争，最终成为最后生存的玩家。",
        "rating": 9.3
    },
    {
        "name": "我的世界",
        "image": "assets/image/WoDeShiJie.webp",
        "detail": "一款沙盒游戏，玩家可以在一个由方块构建的世界中自由创造和探索，可以建造各种建筑、挖掘资源、与怪物战斗等。",
        "rating": 9.6
    },
    {
        "name": "迷你世界",
        "image": "assets/image/MiNiShiJie.png",
        "detail": "一款类似于我的世界的沙盒游戏，玩家可以在游戏中创造自己的世界，进行建筑、探险和社交。",
        "rating": 9.4
    },
    {
        "name": "绝区零",
        "image": "assets/image/JueQuLing.png",
        "detail": "一款射击游戏，玩家需要在大型地图上与其他玩家展开战斗，通过收集装备和展现枪法来获得胜利。",
        "rating": 9.1
    },
    {
        "name": "星穹铁道",
        "image": "assets/image/XingQuTieDao.jpg",
        "detail": "一款太空题材的建造游戏，玩家可以建造自己的太空站和铁路系统，探索宇宙并经营资源",
        "rating": 9.2
    },
    {
        "name": "原神",
        "image": "assets/image/YuanShen.png",
        "detail": "一款开放世界动作角色扮演游戏，玩家可以在广阔的世界中探索、战斗、解谜，并收集各种角色和装备。",
        "rating": 9.3
    },
    {
        "name": "极品飞车",
        "image": "assets/image/JiPinFeiChe.jpg",
        "detail": "一款经典的赛车游戏系列，玩家可以驾驶各种豪车在城市街道或赛道上展开竞速。",
        "rating": 9.5
    },
    {
        "name": "植物大战僵尸",
        "image": "assets/image/ZhiWuDaZhanJiangShi.jpg",
        "detail": "一款塔防游戏，玩家需要通过种植各种植物来抵御僵尸的进攻，保卫自己的花园。",
        "rating": 9.6
    },
    {
        "name": "火影忍者",
        "image": "assets/image/HuoYingRenZhe.jpg",
        "detail": "以日本漫画《火影忍者》为题材的动作格斗游戏，玩家可以扮演各种火影忍者中的角色展开战斗。",
        "rating": 9.6
    },
    {
        "name": "光遇",
        "image": "assets/image/GuangYu.webp",
        "detail": "一款探索冒险游戏，玩家扮演一只可爱的生物，在神秘的世界中探索、解谜和与其他玩家互动。",
        "rating": 9.7
    },
    {
        "name": "第五人格",
        "image": "assets/image/DiWuRenGe.png",
        "detail": "一款对抗式对称竞技游戏，玩家分为求生者和猎人两个阵营，在特定地图上展开战斗。",
        "rating": 9.0
    },
    {
        "name": "金铲铲",
        "image": "assets/image/JinChuanChuan.jpg",
        "detail": "一款模拟经营游戏，玩家扮演矿工，在地下挖掘宝藏、经营矿山并发展自己的挖矿帝国。",
        "rating": 9.0
    },
    {
        "name": "荣耀战魂",
        "detail": "一款热血战斗类游戏，挑战无尽的敌人，成为最强战士！",
        "rating": 8.5,
        "image": "https://tse4-mm.cn.bing.net/th/id/OIP-C.GtA5Cqk96Z6vJQJ1GfmS3AHaEo?w=270&h=180&c=7&r=0&o=5&dpr=1.8&pid=1.7"
    },
    {
        "name": "未来之战",
        "detail": "探索未知的星际世界，解开宇宙的秘密，战胜外星入侵者！",
        "rating": 9.0,
        "image": "https://tse1-mm.cn.bing.net/th/id/OIP-C.xFMW3-PBF4PLh--FNbM_NgHaLH?rs=1&pid=ImgDetMain"
    },
    {
        "name": "幻想之旅",
        "detail": "踏上奇幻冒险之旅，与精灵、巨龙共同征服魔法世界！",
        "rating": 8.0,
        "image": "https://img.zcool.cn/community/031f6cf58edd65ba8012049ef8b0c09.jpg"
    },
    {
        "name": "机械战争",
        "detail": "操控强大的机甲，与机器人对抗，保卫人类的未来！",
        "rating": 8.8,
        "image": "https://img.zcool.cn/community/01ebca5544f20c0000019ae90d1897.jpg@1280w_1l_2o_100sh.jpg"
    },
    {
        "name": "魔法学院",
        "detail": "学习魔法，拯救魔法学院，成为最强大法师！",
        "rating": 9.2,
        "image": "https://tse3-mm.cn.bing.net/th/id/OIP-C.YPQO8Zw6Gm6PY5MH0ACqywHaEK?rs=1&pid=ImgDetMain"
    },
    {
        "name": "未来之城",
        "detail": "建设未来之城，发展科技，引领人类文明的新时代！",
        "rating": 8.7,
        "image": "https://x0.ifengimg.com/ucms/2023_42/95176231911BD26060B4A8880FF34A1B7B58D2DC_size302_w1920_h1080.jpg"
    },
    {
        "name": "神秘遗迹",
        "detail": "探索神秘遗迹，解开古老谜团，获得无尽宝藏！",
        "rating": 9.5,
        "image": "https://tse3-mm.cn.bing.net/th/id/OIP-C.Kwd17FuPInfoA8Lj8-_ibAFNC7?w=273&h=180&c=7&r=0&o=5&dpr=1.8&pid=1.7g"
    },
    {
        "name": "魔幻冒险",
        "detail": "穿越魔幻世界，与精灵、巫师展开冒险之旅！",
        "rating": 8.3,
        "image": "https://tse2-mm.cn.bing.net/th/id/OIP-C.g2_hsuoPD9tPa_hkaMJuzQHaEL?w=255&h=180&c=7&r=0&o=5&dpr=1.8&pid=1.7"
    },
    {
        "name": "宇宙探险",
        "detail": "乘坐飞船探索宇宙，发现新星球，迎接未知挑战！",
        "rating": 8.9,
        "image": "https://tse2-mm.cn.bing.net/th/id/OIP-C.xEOiLpMk1BoyDrA6vABo-QAAAA?w=234&h=180&c=7&r=0&o=5&dpr=1.8&pid=1.7"
    },
    {
        "name": "魔法战争",
        "detail": "魔法与科技的战争，选择你的阵营，改变世界的命运！",
        "rating": 9.1,
        "image": "https://tse2-mm.cn.bing.net/th/id/OIP-C.ExIXu-NcDFJZnc1mSoGBlQHaEK?w=331&h=186&c=7&r=0&o=5&dpr=1.8&pid=1.7"
    },
    {
        "name": "神秘之门",
        "detail": "穿越神秘之门，探索古老文明，解开宇宙之谜！",
        "rating": 9.3,
        "image": "https://tse4-mm.cn.bing.net/th/id/OIP-C.hnVlYEIVfosbC-Y6VVBmswHaEj?w=263&h=180&c=7&r=0&o=5&dpr=1.8&pid=1.7"
    },
    {
        "name": "魔法学堂",
        "detail": "进入魔法学堂，学习魔法技能，成为顶尖法师！",
        "rating": 8.6,
        "image": "https://tse2-mm.cn.bing.net/th/id/OIP-C.PoR7whHmHNI9oSK-820PBAHaEH?w=311&h=180&c=7&r=0&o=5&dpr=1.8&pid=1.7"
    },
    {
        "name": "未来战争",
        "detail": "投身未来战争，驾驶高科技战机，改变战局！",
        "rating": 9.0,
        "image": "https://tse4-mm.cn.bing.net/th/id/OIP-C.9JjRXloW6NgnRnuYElk12QHaD4?w=331&h=180&c=7&r=0&o=5&dpr=1.8&pid=1.7"
    },
    {
        "name": "魔幻王国",
        "detail": "建立属于你的魔幻王国，统治整个魔法世界！",
        "rating": 8.8,
        "image": "https://tse2-mm.cn.bing.net/th/id/OIP-C.Hc1WCGyGHFT3Zxo6KLGDsgHaHa?w=170&h=180&c=7&r=0&o=5&dpr=1.8&pid=1.7"
    },
    {
        "name": "星际探索",
        "detail": "探索星际宇宙，发现新星球，迎接星际冒险！",
        "rating": 9.2,
        "image": "https://tse2-mm.cn.bing.net/th/id/OIP-C.TRZd41t7CzD9kcdl2uXCswHaE3?w=282&h=186&c=7&r=0&o=5&dpr=1.8&pid=1.7"
    },
    {
        "name": "未知之境",
        "detail": "探索未知之境，挑战神秘力量，解锁隐藏的秘密！",
        "rating": 9.4,
        "image": "https://tse2-mm.cn.bing.net/th/id/OIP-C.RDsooGjNtcjThT3JwxPA3gHaEK?w=268&h=180&c=7&r=0&o=5&dpr=1.8&pid=1.7"
    },
    {
        "name": "魔法传说",
        "detail": "传说中的魔法世界，英雄与魔法共存，开启传奇之旅！",
        "rating": 8.9,
        "image": "https://tse4-mm.cn.bing.net/th/id/OIP-C.7VeAlbRM-KxeGwsS-YymOwAAAA?w=187&h=333&c=7&r=0&o=5&dpr=1.8&pid=1.7"
    },
    {
        "name": "未来之旅",
        "detail": "穿越时空，踏上未来之旅，改变历史的走向！",
        "rating": 9.1,
        "image": "https://tse4-mm.cn.bing.net/th/id/OIP-C.ScDPIUG5rZo7wffi3-B49QHaEK?w=288&h=180&c=7&r=0&o=5&dpr=1.8&pid=1.7"
    },
    {
        "name": "神秘之夜",
        "detail": "夜幕降临，揭开神秘之夜的面纱，迎接挑战与冒险！",
        "rating": 8.7,
        "image": "https://tse2-mm.cn.bing.net/th/id/OIP-C.mw6-eCoPb6KLjNi9XlCeuAHaEX?w=293&h=180&c=7&r=0&o=5&dpr=1.8&pid=1.7"
    },
    {
        "name": "魔法之战",
        "detail": "魔法与剑术的较量，决定魔法世界的未来命运！",
        "rating": 9.3,
        "image": "https://tse2-mm.cn.bing.net/th/id/OIP-C.BRj8r1RuaxC1gbwebXS21gAAAA?w=127&h=188&c=7&r=0&o=5&dpr=1.8&pid=1.7"
    }
]
  

function importAll(){
    
    let LQLGame= []
    Object.keys(game).forEach(key=>{
        LQLGame.push({
            // result:key,
            name:game[key]?.name,
            detail:game[key]?.detail,
            rating:game[key]?.rating,
            image:game[key]?.image,
        })
    })

    console.log(LQLGame)
    LQLGame.forEach(async mbti => {
        // 查重
        let exists = await checkExists(mbti)
        if(exists?.id) return;
        // 新增
        let LQLGame = Parse.Object.extend("LQLGame");
        let bm = new LQLGame();
        bm.set(mbti);
        bm.save();
    });
}

async function checkExists(mbti){
    let query = new Parse.Query("LQLGame");
    //query.equalTo("result",mbti?.result);
    query.equalTo("name",mbti?.name);
    await query.first();
    return await query.first();
}

importAll()