全站通知:

Widget:角色消耗计算器

来自原神WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

<script type='text/javascript'src="https://wiki.biligame.com/ys/MediaWiki:vue3-global.js?action=raw&ctype=text/javascript"></script> <script type="text/javascript" src="https://wiki.biligame.com/ys/MediaWiki:lz-string.js?action=raw&ctype=text/javascript"></script> <script type="text/javascript" src="https://wiki.biligame.com/ys/MediaWiki:Dom-to-Image.js?action=raw&ctype=text/javascript"></script>

<script> (window.RLQ = window.RLQ || []).push([["jquery"], function () { $(function () {

timer = setInterval(function () { if (typeof Counter == undefined) { console.log("尝试加载计算器"); } else { $("#onload").css("display", "none"); $("#app").css("display", ""); clearInterval(timer); } }, 100);

function packUpHelp() { $("#roleComputeInstructions").css("display", "none"); $(".wiki-header:eq(0),.visible-md-block:eq(0)").removeClass("wiki-nav"); localStorage.setItem("computeHelp", 1); clearInterval(help); } function showHelp() { $("#roleComputeInstructions").css("display", ""); $(".wiki-header:eq(0),.visible-md-block:eq(0)").toggleClass("wiki-nav"); } if (localStorage.getItem("computeHelp") == null || localStorage.getItem("computeHelp") != 1) { help = setInterval(function () { $(".wiki-header:eq(0),.visible-md-block:eq(0)").addClass("wiki-nav"); }, 100); } else { $(".wiki-header:eq(0),.visible-md-block:eq(0)").removeClass("wiki-nav"); $("#roleComputeInstructions").css("display", "none"); }


// 素材转换 function compound(packHave, need, costBox) { // 减去背包数量 $.each(packHave, function (index, item) { if (item > need[index]) { packHave[index] = item - need[index] need[index] = 0 } else { packHave[index] = 0 need[index] = need[index] - item } }) // 开始循环合成 var newObj = Object.keys(need) $.each(newObj, function (index, item) { if (index != 0) { var 需求基础数量 = need[item] * costBox[item] for (var i = 0; i < index; i++) { if (need[item] * costBox[item] <= packHave[newObj[i]] * costBox[newObj[i]]) { packHave[newObj[i]] = packHave[newObj[i]] - 需求基础数量 / costBox[newObj[i]] 需求基础数量 = 0 need[item] = 0 } else { var 低级素材基础数量 = Math.floor(packHave[newObj[i]] * costBox[newObj[i]] / costBox[item]) packHave[newObj[i]] = packHave[newObj[i]] - 低级素材基础数量 * costBox[item] / costBox[newObj[i]] 需求基础数量 = 需求基础数量 - 低级素材基础数量 * costBox[item] need[item] = need[item] - 低级素材基础数量 } } } }) return need }

function TFSwitchBack(e) { return e == 1 ? true : false } function TFSwitch(e) { return e == true ? 1 : 0 } // 数据转换 function DataTran(exportData) { $.each(exportData.data.角色, function (index, item) { exportData.data.角色[index][1][0] = TFSwitchBack(item[1][0]) exportData.data.角色[index][1][1] = TFSwitchBack(item[1][1]) exportData.data.角色[index][2][2][0] = TFSwitchBack(item[2][2][0]) exportData.data.角色[index][2][2][1] = TFSwitchBack(item[2][2][1]) exportData.data.角色[index][2][2][2] = TFSwitchBack(item[2][2][2]) exportData.data.角色[index][2][2][3] = TFSwitchBack(item[2][2][3]) }) $.each(exportData.data.武器, function (index, item) { exportData.data.武器[index][1][0] = TFSwitchBack(item[1][0]) exportData.data.武器[index][1][1] = TFSwitchBack(item[1][1]) exportData.data.武器[index][2][1][0] = TFSwitchBack(item[2][1][0]) exportData.data.武器[index][2][1][1] = TFSwitchBack(item[2][1][1]) exportData.data.武器[index][2][1][2] = TFSwitchBack(item[2][1][2]) exportData.data.武器[index][2][1][3] = TFSwitchBack(item[2][1][3]) }) return exportData }

var roleDataData = JSON.parse($("#role-data").text().replace(/\n/g, "")); var yingMainData = JSON.parse($("#yingMainDataId").text().replace(/\n/g, "")); var yingData = JSON.parse($("#yingDataId").text().replace(/\n/g, "")); var yingSkillData = JSON.parse($("#yingSkillDataId").text().replace(/\n/g, "")); var skillevolveData = JSON.parse($("#skillevolveId").text().replace(/\n/g, "")); var worldResourceData = JSON.parse($("#worldResourceId").text().replace(/\n/g, "")); var roleEvolveData = JSON.parse($("#roleEvolveId").text().replace(/\n/g, "")); var roleLevelData = JSON.parse($("#levelDataId").text().replace(/\n/g, "")); var stoneData = JSON.parse($("#newStoneDataId").text().replace(/\n/g, "")); var monsterRData = JSON.parse($("#monsterRData").text().replace(/\n/g, "")); var monsterSRData = JSON.parse($("#monsterSRData").text().replace(/\n/g, "")); var skillData = JSON.parse($("#skillBookDataId").text().replace(/\n/g, "")); var weaponData = JSON.parse($("#weapon-data").text().replace(/\n/g, "")); var weaponEvolveData = JSON.parse($("#weaponEvolveDataId").text().replace(/\n/g, "")); var weaponLevelData = JSON.parse($("#weaponLevelDataId").text().replace(/\n/g, "")); var weaponMatData = JSON.parse($("#weaponMatDataId").text().replace(/\n/g, "")); var imgUrlData = JSON.parse($("#img-data").text().replace(/\n/g, "")); var roleSkillData = JSON.parse($("#role-skill-data").text().replace(/\n/g, ""));

var skillBossData = JSON.parse($("#skill-data").text().replace(/\n/g, "")); var techanData = JSON.parse($("#techan-data").text().replace(/\n/g, "")); var BOSSData = JSON.parse($("#BOSS-data").text().replace(/\n/g, "")); var dataTimeData = JSON.parse($("#dataTimeId").text().replace(/\n/g, "")); var EZNameData = JSON.parse($("#EZNameId").text().replace(/\n/g, ""));



roleSkillData = roleSkillData.concat(yingSkillData);

var roleData = roleDataData roleData = roleData.concat(yingMainData);

var roleList = { 火: [], 水: [], 风: [], 雷: [], 草: [], 冰: [], 岩: [] }; roleData.forEach(function (i) { if (i.元素属性 == "元素属性") { } else { roleList[i.元素属性].push(i.名称); } }); var weaponList = { 单手剑: [], 双手剑: [], 长柄武器: [], 法器: [], 弓: [] }; weaponData.forEach(function (i) { if (i.类型 == "类型") { } else { weaponList[i.类型].push(i.名称); } });

// 构建转换参考 var 参考 = [] var 参考花费 = [1, 3, 9, 27] var 参考数据 = Object.assign({}, monsterRData, monsterSRData, weaponMatData, skillData, stoneData) $.each(参考数据, function (index, item) { var data = [[], []] $.each(Object.keys(item), function (ziIndex, ziItem) { data[0].push(item[ziItem]) data[1].push(参考花费[ziIndex]) }) 参考.push(data) }) function onload() { app.mount("#app"); console.log("%c加载消耗计算器 %cBY:congeal_Plulme v.4.0.1", "background: #4a5366;padding:4px 8px;color:#fff", " background: #d3bc8e;padding:4px 8px;")

}

var Counter = { data() { return { bgOn: false, 导入信息: {}, 世界等级: { 冒险等级: 55, 世界等级: 8, 藏金之花: 60000, 启示之花下限: 110000, 启示之花上限: 135000, 技能书期望: 10.12, 武器素材期望: 16.708, 世界BOSS期望: 2.56, 周常BOSS期望: 2.4 }, 背包素材: {}, 需要素材: {}, 需要素材转换后: {}, needSumIni: {}, 需要摩拉: { 摩拉: 0 }, 需要经验书: { 流浪者的经验: 0, 冒险家的经验: 0, 大英雄的经验: 0 }, 需要精锻矿: { 精锻用杂矿: 0, 精锻用良矿: 0, 精锻用魔矿: 0 }, 副本次数: { 藏金之花: 0, 启示之花: 0, 忘却之峡: 0, 太山府: 0, 菫色之庭: 0, 昏识塔: 0, }, 设置包: { 背包: false, 设置: false, 材料开关: [false, false, false, false, false, false, false, false, false,] }, 材料输入开关: { 流浪者的经验: false, 冒险家的经验: false, 大英雄的经验: false, 精锻用杂矿: false, 精锻用良矿: false, 精锻用魔矿: false, 摩拉: false }, 树脂: 0, originalResinNum: [],

世界资源表: worldResourceData,

角色列表: roleList, 武器列表: weaponList,

经验书经验表: { 流浪者的经验: 1000, 冒险家的经验: 5000, 大英雄的经验: 20000, }, 精锻矿经验表: { 精锻用杂矿: 400, 精锻用良矿: 2000, 精锻用魔矿: 10000, }, weaponImgUrl: { 单手剑: "https://patchwiki.biligame.com/images/ys/b/be/5r5azhvpy607pv4cy5oe4mfopjhf95c.png", 双手剑: "https://patchwiki.biligame.com/images/ys/b/b4/ejkrzn8d29iol2l3jxvl16yyu1ax5u8.png", 弓: "https://patchwiki.biligame.com/images/ys/9/97/j2rwp0l05x2pq2hrl7u0uj8orkrnerm.png", 法器: "https://patchwiki.biligame.com/images/ys/c/cc/3h3isyesntctnqppo4xdolkhni9ljq2.png", 长柄武器: "https://patchwiki.biligame.com/images/ys/9/9d/lcvapu6a8d4xus2iem089w33e2ub630.png" }, elementImgUrl: { 火: "https://patchwiki.biligame.com/images/ys/b/bc/hgvazo61lbm6du06ezyst8a2n81lnxt.png", 水: "https://patchwiki.biligame.com/images/ys/f/f7/5qn0uclpchd8i1chpom3gurzwe2yqfh.png", 风: "https://patchwiki.biligame.com/images/ys/1/16/19jtvt2xkys021rmwocztvqbmdi9ioy.png", 雷: "https://patchwiki.biligame.com/images/ys/3/32/b251173mt26zjsqf48gopzgciddgy6q.png", 草: "https://patchwiki.biligame.com/images/ys/5/5d/2ej6app0j3joh61henb69cls5jklxi7.png", 冰: "https://patchwiki.biligame.com/images/ys/e/eb/erldqsepa75zrk9sd5dx564i9w3kp00.png", 岩: "https://patchwiki.biligame.com/images/ys/a/aa/m3bligsxs4gww7pcoezem3k5c9p49mr.png" }, imgUrl: imgUrlData, 角色包: { key: 0, show: { 属性: "火", 角色选择: false, 材料显示: false, 技能开关: false, 是否计算: true, 是否折叠: false }, roleData: { 名称: "刻晴", 晶石: "最胜紫晶", 头领石: "雷光棱镜", 特产: "石珀", 素材: "花蜜", 技能书: "繁荣", 技能Boss材料: "北风之环" }, roleLevel: [1, 90], skillBefore: [1, 1, 1], skillAfter: [1, 1, 1], needMaterial: { 流浪者的经验: 3, 冒险家的经验: 0, 大英雄的经验: 418, 最胜紫晶碎屑: 1, 最胜紫晶断片: 9, 最胜紫晶块: 9, 最胜紫晶: 6, 雷光棱镜: 46, 石珀: 168, 骗骗花蜜: 18, 微光花蜜: 30, 原素花蜜: 36, 摩拉: 2092400 }, evolve: { 前突破显示: false, 后突破显示: false, 前突破: true, 后突破: true }, warning: "", warning2: "", skillMaterial: { "「繁荣」的教导": 0, "「繁荣」的指引": 0, "「繁荣」的哲学": 0, 骗骗花蜜: 0, 微光花蜜: 0, 原素花蜜: 0, 北风之环: 0, 智识之冕: 0, 摩拉: 0 }, skillSum: ["技能1", "技能2", "技能3"], }, 武器包: { key: 0, show: { 属性: "单手剑", 武器选择: false, 材料显示: false, 是否计算: true, 是否折叠: false }, weaponData: { 名称: "雾切之回光", 稀有度: "5", 突破石: "远海夷地", R素材: "刀镡", SR素材: "机关", }, warning: "", weaponLevel: [1, 90], evolve: { 前突破显示: false, 后突破显示: false, 前突破: true, 后突破: true }, needMaterial: { 精锻用杂矿: 0, 精锻用良矿: 0, 精锻用魔矿: 0, 远海夷地的瑚枝: 0, 远海夷地的玉枝: 0, 远海夷地的琼枝: 0, 远海夷地的金枝: 0, 混沌机关: 0, 混沌枢纽: 0, 混沌真眼: 0, 破旧的刀镡: 0, 影打刀镡: 0, 名刀镡: 0, 摩拉: 0 }, }, 角色: [], 武器: [], Wiki储存: "" } }, created() { this.originalResinCom() var that = this

// 初始化背包素材 that.背包素材.摩拉 = 0 that.背包素材.流浪者的经验 = 0 that.背包素材.冒险家的经验 = 0 that.背包素材.大英雄的经验 = 0 that.背包素材.精锻用杂矿 = 0 that.背包素材.精锻用良矿 = 0 that.背包素材.精锻用魔矿 = 0 $.each(stoneData, function (index, item) { $.each(item, function (moreIndex, moreItem) { that.背包素材[moreItem] = 0 }) }) $.each(BOSSData, function (index, item) { that.背包素材[item] = 0 }) $.each(techanData, function (index, item) { that.背包素材[item] = 0 }) $.each(monsterRData, function (index, item) { $.each(item, function (moreIndex, moreItem) { that.背包素材[moreItem] = 0 }) }) $.each(monsterSRData, function (index, item) { $.each(item, function (moreIndex, moreItem) { that.背包素材[moreItem] = 0 }) }) $.each(skillData, function (index, item) { $.each(item, function (moreIndex, moreItem) { that.背包素材[moreItem] = 0 }) }) $.each(weaponMatData, function (index, item) { $.each(item, function (moreIndex, moreItem) { that.背包素材[moreItem] = 0 }) }) $.each(skillBossData, function (moreIndex, moreItem) { that.背包素材[moreItem] = 0 }) that.背包素材.智识之冕 = 0

// 读取缓存 var data = JSON.parse(localStorage.getItem("computeDataNew"));

if (localStorage.getItem("computeDataNew")) { $.each(that.背包素材, function (index, item) { if (data.背包素材[index] !== undefined) { that.背包素材[index] = data.背包素材[index]; } }) if (data.角色包.show.是否折叠 == undefined) { data.角色包.show.是否折叠 = false } if (data.武器包.show.是否折叠 == undefined) { data.武器包.show.是否折叠 = false } this.角色 = data.角色 this.角色包 = data.角色包 this.武器 = data.武器 this.武器包 = data.武器包 this.背包素材 = that.背包素材 this.世界等级 = data.世界等级

if (data.versions !== 3) { console.log("不是3"); console.log(that.角色); $.each(that.角色, function (index, item) { if (item.show.是否折叠 == undefined) { item.show.是否折叠 = false } }) $.each(that.武器, function (index, item) { if (item.show.是否折叠 == undefined) { item.show.是否折叠 = false } }) } } else { // 初始化部分数值 that.角色.push(JSON.parse(JSON.stringify(this.角色包))) that.武器.push(JSON.parse(JSON.stringify(this.武器包))) } }, computed: { allNeedMaterial() { var that = this var needMola = { "摩拉": 0 } var needExp = { "流浪者的经验": 0, "冒险家的经验": 0, "大英雄的经验": 0 } var needOre = { "精锻用杂矿": 0, "精锻用良矿": 0, "精锻用魔矿": 0 } var needSum = {} var needSum1 = {} var needSum2 = {} var needSum3 = {} var needSum4 = {} var needSum5 = {} var needSum6 = {} var needSum7 = {} var needSum8 = {} var needSum9 = { "智识之冕": 0 } var packOre = { "精锻用杂矿": that.背包素材.精锻用杂矿, "精锻用良矿": that.背包素材.精锻用良矿, "精锻用魔矿": that.背包素材.精锻用魔矿 } var packExp = { "流浪者的经验": that.背包素材.流浪者的经验, "冒险家的经验": that.背包素材.冒险家的经验, "大英雄的经验": that.背包素材.大英雄的经验 }



$.each(this.角色, function (index, item) { if (item.show.是否计算 == true) { // 数据初始化 var LBefore = item.roleLevel[0]; var LAfter = item.roleLevel[1]; var levelDiff = LAfter - LBefore;

// 判断输入等级 if (levelDiff < 0) { item.warning = "请正确输入等级"; return; } else { item.warning = ""; } // 判断技能等级输入 for (var h in item.skillBefore) { if (item.skillAfter[h] - item.skillBefore[h] < 0) { item.warning2 = "请正确输入等级"; return; } else { item.warning2 = ""; } }

// 突破按钮显示控制 if (LBefore == 20 || LBefore == 40 || LBefore == 50 || LBefore == 60 || LBefore == 70 || LBefore == 80) { item.evolve.前突破显示 = true; } else { item.evolve.前突破显示 = false; item.evolve.前突破 = false; } if (LAfter == 20 || LAfter == 40 || LAfter == 50 || LAfter == 60 || LAfter == 70 || LAfter == 80) { item.evolve.后突破显示 = true; } else { item.evolve.后突破显示 = false; item.evolve.后突破 = false; }

// 计算前后等阶 if (LBefore > 10) { var ascensionNumStart = parseInt(LBefore / 10); } else { var ascensionNumStart = 1; } if (LAfter > 10) { var ascensionNumEnd = Math.ceil(LAfter / 10); } else { var ascensionNumEnd = 1; } // 是否突破判定 if (item.evolve.前突破 == false) { ascensionNumStart = ascensionNumStart + 1; } if (item.evolve.后突破 == false) { ascensionNumEnd = ascensionNumEnd - 1; } //计算经验 var g = LBefore; var expSum = 0; for (var i = 1; i < levelDiff + 1; i++) { expSum = expSum + Number(roleLevelData[g]); g = g + 1; } item.needMaterial.经验总计 = expSum; // 换算经验书 var book3 = Math.floor(expSum / that.经验书经验表.大英雄的经验); var book2Sou = expSum % that.经验书经验表.大英雄的经验; var book2 = Math.floor(book2Sou / that.经验书经验表.冒险家的经验); var book1Sou = book2Sou % that.经验书经验表.冒险家的经验; var book1 = Math.ceil(book1Sou / that.经验书经验表.流浪者的经验); // 计算升级要的摩拉(不含突破 var roleUpMola = book3 * 4000 + book2 * 1000 + book1 * 200;

var iniData = { "晶石2": 0, "晶石3": 0, "晶石4": 0, "晶石5": 0, "石头": 0, "特产": 0, "普怪素材1": 0, "普怪素材2": 0, "普怪素材3": 0, "摩拉": 0, } var finData = {} var skillIniData = { "技能书2": 0, "技能书3": 0, "技能书4": 0, "技能素材1": 0, "技能素材2": 0, "技能素材3": 0, "技能素材4": 0, "技能素材5": 0, "摩拉": 0 } var skillFinData = {} if (item.roleData.名称.indexOf("旅行者") == -1) { // 计算除旅行者外角色升级突破素材 for (var i = ascensionNumStart; i < ascensionNumEnd + 1; i++) { var tuPoData = roleEvolveData.find((h) => i == h.等阶); $.each(iniData, function (sumIndex, sumItem) { iniData[sumIndex] = iniData[sumIndex] + Number(tuPoData[sumIndex]) }) } finData = { [stoneData[item.roleData.晶石].晶石2]: iniData.晶石2, [stoneData[item.roleData.晶石].晶石3]: iniData.晶石3, [stoneData[item.roleData.晶石].晶石4]: iniData.晶石4, [stoneData[item.roleData.晶石].晶石5]: iniData.晶石5, [item.roleData.头领石]: iniData.石头, [item.roleData.特产]: iniData.特产, [monsterRData[item.roleData.素材].普怪素材1]: iniData.普怪素材1, [monsterRData[item.roleData.素材].普怪素材2]: iniData.普怪素材2, [monsterRData[item.roleData.素材].普怪素材3]: iniData.普怪素材3, "摩拉": iniData.摩拉 + roleUpMola, } item.needMaterial = Object.assign({ "流浪者的经验": book1, "冒险家的经验": book2, "大英雄的经验": book3 }, finData);

// 计算技能突破素材 $.each(item.skillBefore, function (skillIndex, skillItem) { for (var i = item.skillBefore[skillIndex] + 1; i < item.skillAfter[skillIndex] + 1; i++) { var skillTuPoData = skillevolveData.find((h) => i == h.等阶); $.each(skillIniData, function (sumIndex, sumItem) { skillIniData[sumIndex] = skillIniData[sumIndex] + Number(skillTuPoData[sumIndex]) }) } }) skillFinData = { [skillData[item.roleData.技能书].技能书2]: skillIniData.技能书2, [skillData[item.roleData.技能书].技能书3]: skillIniData.技能书3, [skillData[item.roleData.技能书].技能书4]: skillIniData.技能书4, [monsterRData[item.roleData.素材].普怪素材1]: skillIniData.技能素材1, [monsterRData[item.roleData.素材].普怪素材2]: skillIniData.技能素材2, [monsterRData[item.roleData.素材].普怪素材3]: skillIniData.技能素材3, [item.roleData.技能Boss材料]: skillIniData.技能素材4, "智识之冕": skillIniData.技能素材5, "摩拉": skillIniData.摩拉, } item.skillMaterial = skillFinData; // 技能整合 for (var i in Object.keys(skillFinData)) { if (i < 3) { if (Object.keys(skillFinData)[i] in needSum6) { needSum6[Object.keys(skillFinData)[i]] = needSum6[Object.keys(skillFinData)[i]] + skillFinData[Object.keys(skillFinData)[i]] } else { needSum6[Object.keys(skillFinData)[i]] = skillFinData[Object.keys(skillFinData)[i]] } } else if (i < 6) { if (Object.keys(skillFinData)[i] in needSum2) { needSum2[Object.keys(skillFinData)[i]] = needSum2[Object.keys(skillFinData)[i]] + skillFinData[Object.keys(skillFinData)[i]] } else { needSum2[Object.keys(skillFinData)[i]] = skillFinData[Object.keys(skillFinData)[i]] } } else if (i < 7) { if (Object.keys(skillFinData)[i] in needSum8) { needSum8[Object.keys(skillFinData)[i]] = needSum8[Object.keys(skillFinData)[i]] + skillFinData[Object.keys(skillFinData)[i]] } else { needSum8[Object.keys(skillFinData)[i]] = skillFinData[Object.keys(skillFinData)[i]] } } else if (i < 8) { needSum9.智识之冕 = needSum9.智识之冕 + skillFinData[Object.keys(skillFinData)[i]] } } } else { // 计算旅行者 for (var i = ascensionNumStart; i < ascensionNumEnd + 1; i++) { var tuPoData = roleEvolveData.find((h) => i == h.等阶); $.each(iniData, function (sumIndex, sumItem) { iniData[sumIndex] = iniData[sumIndex] + Number(tuPoData[sumIndex]) }) } finData = { [stoneData[item.roleData.晶石].晶石2]: iniData.晶石2, [stoneData[item.roleData.晶石].晶石3]: iniData.晶石3, [stoneData[item.roleData.晶石].晶石4]: iniData.晶石4, [stoneData[item.roleData.晶石].晶石5]: iniData.晶石5, 头领石: 0, [item.roleData.特产]: iniData.特产, [monsterRData[item.roleData.素材].普怪素材1]: iniData.普怪素材1, [monsterRData[item.roleData.素材].普怪素材2]: iniData.普怪素材2, [monsterRData[item.roleData.素材].普怪素材3]: iniData.普怪素材3, "摩拉": iniData.摩拉 + roleUpMola, } item.needMaterial = Object.assign({ "流浪者的经验": book1, "冒险家的经验": book2, "大英雄的经验": book3 }, finData); // 计算旅行者技能突破素材 var yingMola = { 摩拉: 0 } var yingJiNeng = {} var yingmonster = {} var yingBoss = {} var yinghuanGuan = {} $.each(item.skillBefore, function (skillIndex, skillItem) { var data = yingData[item.roleData.名称].find(i => i.技能.indexOf(skillIndex + 1) != -1) for (var i = item.skillBefore[skillIndex] + 1; i < item.skillAfter[skillIndex] + 1; i++) { var data1 = data.材料.find((n) => i == n.等阶); $.each(Object.keys(data1), function (minIndex, minItem) { switch (minIndex) { case 1: yingMola.摩拉 = yingMola.摩拉 + Number(data1.摩拉) break; case 2: if (minItem in yingJiNeng) { yingJiNeng[minItem] = yingJiNeng[minItem] + data1[minItem] } else { yingJiNeng[minItem] = data1[minItem] } break; case 3: if (minItem in yingmonster) { yingmonster[minItem] = yingmonster[minItem] + data1[minItem] } else { yingmonster[minItem] = data1[minItem] } break; case 4: if (minItem in yingBoss) { yingBoss[minItem] = yingBoss[minItem] + data1[minItem] } else { yingBoss[minItem] = data1[minItem] } break; case 5: if (minItem in yinghuanGuan) { yinghuanGuan[minItem] = yinghuanGuan[minItem] + data1[minItem] } else { yinghuanGuan[minItem] = data1[minItem] } break; }

}) } }) $.each(yingmonster, function (caiIndex, caiItem) { if (caiIndex in needSum2) { needSum2[caiIndex] = needSum2[caiIndex] + caiItem } else if (caiIndex != undefined) { needSum2[caiIndex] = caiItem } }) $.each(yingJiNeng, function (caiIndex, caiItem) { if (caiIndex in needSum6) { needSum6[caiIndex] = needSum6[caiIndex] + caiItem } else if (caiIndex != undefined) { needSum6[caiIndex] = caiItem } }) $.each(yingBoss, function (caiIndex, caiItem) { if (caiIndex in needSum8) { needSum8[caiIndex] = needSum8[caiIndex] + caiItem } else if (caiIndex != undefined) { needSum8[caiIndex] = caiItem } }) $.each(yinghuanGuan, function (caiIndex, caiItem) { if (caiIndex in needSum9) { needSum9[caiIndex] = needSum9[caiIndex] + caiItem } else if (caiIndex != undefined) { needSum9[caiIndex] = caiItem } })

Object.assign(skillFinData, yingJiNeng, yingmonster, yingBoss, yinghuanGuan, yingMola,) item.skillMaterial = skillFinData;


} // 添加总计 素材、摩拉、经验书 needMola.摩拉 = needMola.摩拉 + finData.摩拉 + skillFinData.摩拉 var ExpNeed = { "流浪者的经验": book1, "冒险家的经验": book2, "大英雄的经验": book3 } var newNeedExp = compound(packExp, ExpNeed, { "流浪者的经验": 1, "冒险家的经验": 5, "大英雄的经验": 20 }); needExp.流浪者的经验 = needExp.流浪者的经验 + newNeedExp.流浪者的经验 needExp.冒险家的经验 = needExp.冒险家的经验 + newNeedExp.冒险家的经验 needExp.大英雄的经验 = needExp.大英雄的经验 + newNeedExp.大英雄的经验

// 整合素材 for (var i in Object.keys(finData)) { if (i < 4) { if (Object.keys(finData)[i] in needSum1) { needSum1[Object.keys(finData)[i]] = needSum1[Object.keys(finData)[i]] + finData[Object.keys(finData)[i]] } else { needSum1[Object.keys(finData)[i]] = finData[Object.keys(finData)[i]] } } else if (i < 5) { if (Object.keys(finData)[i] in needSum4) { needSum4[Object.keys(finData)[i]] = needSum4[Object.keys(finData)[i]] + finData[Object.keys(finData)[i]] } else { needSum4[Object.keys(finData)[i]] = finData[Object.keys(finData)[i]] } } else if (i < 6) { if (Object.keys(finData)[i] in needSum5) { needSum5[Object.keys(finData)[i]] = needSum5[Object.keys(finData)[i]] + finData[Object.keys(finData)[i]] } else { needSum5[Object.keys(finData)[i]] = finData[Object.keys(finData)[i]] } } else if (i < 9) { if (Object.keys(finData)[i] in needSum2) { needSum2[Object.keys(finData)[i]] = needSum2[Object.keys(finData)[i]] + finData[Object.keys(finData)[i]] } else { needSum2[Object.keys(finData)[i]] = finData[Object.keys(finData)[i]] } } } } })

// 武器计算 $.each(this.武器, function (index, item) { if (item.show.是否计算 == true) {

var LBefore = item.weaponLevel[0]; var LAfter = item.weaponLevel[1]; var levelDiff = LAfter - LBefore;

// 判断输入等级 if (levelDiff < 0) { item.warning = "请正确输入等级"; return; } else { item.warning = ""; } // 突破按钮显示控制 if (LBefore == 20 || LBefore == 40 || LBefore == 50 || LBefore == 60 || LBefore == 70 || LBefore == 80) { item.evolve.前突破显示 = true; } else { item.evolve.前突破显示 = false; item.evolve.前突破 = false; } if (LAfter == 20 || LAfter == 40 || LAfter == 50 || LAfter == 60 || LAfter == 70 || LAfter == 80) { item.evolve.后突破显示 = true; } else { item.evolve.后突破显示 = false; item.evolve.后突破 = false; }

// 计算前后等阶 if (LBefore > 10) { var ascensionNumStart = parseInt(LBefore / 10); } else { var ascensionNumStart = 1; } if (LAfter > 10) { var ascensionNumEnd = Math.ceil(LAfter / 10); } else { var ascensionNumEnd = 1; } // 是否突破判定 if (item.evolve.前突破 == false) { ascensionNumStart = ascensionNumStart + 1; } if (item.evolve.后突破 == false) { ascensionNumEnd = ascensionNumEnd - 1; }


// 计算经验 var initialNumber = LBefore; var expSum = 0; var weaponExp = weaponLevelData[item.weaponData.稀有度];

for (var i = LBefore; i < LAfter; i++) { expSum = expSum + weaponExp[initialNumber]; initialNumber = initialNumber + 1; } // 转化精锻矿 var ore3 = Math.floor(expSum / that.精锻矿经验表.精锻用魔矿); var ore2Sou = expSum % that.精锻矿经验表.精锻用魔矿; var ore2 = Math.floor(ore2Sou / that.精锻矿经验表.精锻用良矿); var ore1Sou = ore2Sou % that.精锻矿经验表.精锻用良矿; var ore1 = Math.ceil(ore1Sou / that.精锻矿经验表.精锻用杂矿);

var expMola = ore3 * 1000 + ore2 * 200 + ore1 * 40;

var iniData = { 武器突破素材2: 0, 武器突破素材3: 0, 武器突破素材4: 0, 武器突破素材5: 0, 普怪素材1: 0, 普怪素材2: 0, 普怪素材3: 0, 精怪素材1: 0, 精怪素材2: 0, 精怪素材3: 0, 摩拉: 0 } var finData = {}

for (var i = ascensionNumStart; i < ascensionNumEnd + 1; i++) { var tuPoData = weaponEvolveData[item.weaponData.稀有度].find((h) => i == h.等阶); $.each(iniData, function (sumIndex, sumItem) { iniData[sumIndex] = iniData[sumIndex] + Number(tuPoData[sumIndex]) }) } finData = { [weaponMatData[item.weaponData.突破石].武器素材2]: iniData.武器突破素材2, [weaponMatData[item.weaponData.突破石].武器素材3]: iniData.武器突破素材3, [weaponMatData[item.weaponData.突破石].武器素材4]: iniData.武器突破素材4, [weaponMatData[item.weaponData.突破石].武器素材5]: iniData.武器突破素材5, [monsterRData[item.weaponData.R素材].普怪素材1]: iniData.普怪素材1, [monsterRData[item.weaponData.R素材].普怪素材2]: iniData.普怪素材2, [monsterRData[item.weaponData.R素材].普怪素材3]: iniData.普怪素材3, [monsterSRData[item.weaponData.SR素材].精怪素材1]: iniData.精怪素材1, [monsterSRData[item.weaponData.SR素材].精怪素材2]: iniData.精怪素材2, [monsterSRData[item.weaponData.SR素材].精怪素材3]: iniData.精怪素材3, "摩拉": iniData.摩拉 + expMola, } item.needMaterial = Object.assign({ "精锻用杂矿": ore1, "精锻用良矿": ore2, "精锻用魔矿": ore3 }, finData);

var packEXP = JSON.parse(JSON.stringify(that.背包素材)) needMola.摩拉 = needMola.摩拉 + finData.摩拉 // 精锻矿合成 oreNeed = { "精锻用杂矿": ore1, "精锻用良矿": ore2, "精锻用魔矿": ore3 } newNeedOre = compound(packOre, oreNeed, { "精锻用杂矿": 4, "精锻用良矿": 20, "精锻用魔矿": 100 }); needOre.精锻用杂矿 = needOre.精锻用杂矿 + newNeedOre.精锻用杂矿 needOre.精锻用良矿 = needOre.精锻用良矿 + newNeedOre.精锻用良矿 needOre.精锻用魔矿 = needOre.精锻用魔矿 + newNeedOre.精锻用魔矿

//添加素材 for (var i in Object.keys(finData)) { if (i < 4) { if (Object.keys(finData)[i] in needSum7) { needSum7[Object.keys(finData)[i]] = needSum7[Object.keys(finData)[i]] + finData[Object.keys(finData)[i]] } else { needSum7[Object.keys(finData)[i]] = finData[Object.keys(finData)[i]] } } else if (i < 7) { if (Object.keys(finData)[i] in needSum2) { needSum2[Object.keys(finData)[i]] = needSum2[Object.keys(finData)[i]] + finData[Object.keys(finData)[i]] } else { needSum2[Object.keys(finData)[i]] = finData[Object.keys(finData)[i]] } } else if (i < 10) { if (Object.keys(finData)[i] in needSum3) { needSum3[Object.keys(finData)[i]] = needSum3[Object.keys(finData)[i]] + finData[Object.keys(finData)[i]] } else { needSum3[Object.keys(finData)[i]] = finData[Object.keys(finData)[i]] } }

} } })

Object.assign(needSum, needSum1, needSum2, needSum3, needSum4, needSum5, needSum6, needSum7, needSum8, needSum9) // console.log(JSON.parse(JSON.stringify({ "1晶石": needSum1, "2R素材": needSum2, "3SR素材": needSum3, "4石头": needSum4, "5特产": needSum5, "6技能书": needSum6, "7武器石": needSum7, "8BOSS": needSum8, "9皇冠": needSum9 }))); var newNeedSum = {} $.each(needSum, function (sumIndex, sumItem) { if (sumItem !== 0) { newNeedSum[sumIndex] = sumItem } })

// 根据背包物品顺序排序 let newDictionaries = Object.keys(this.背包素材) const newNewNeedSum = {}; newDictionaries.forEach((key) => { if (newNeedSum[key]) { newNewNeedSum[key] = newNeedSum[key]; } }); newNeedSum = newNewNeedSum


// 减去背包素材 var newpack = JSON.parse(JSON.stringify(that.背包素材)) var newNeedSucai = {} // 判断周几素材 function timeC(e) { var name = e.slice(0, 4) name = name.replace(/(「)([\s\S]*?)(」)([\s\S]*)/g, "$2"); var time $.each(dataTimeData, function (index, item) { if (item.indexOf(name) != -1) { time = index return false } else { time = 0 } }) return time } $.each(newNeedSum, function (index, item) { var TF = that.需要素材转换后[index] == undefined ? false : that.需要素材转换后[index][2] var time = timeC(index) if (item <= newpack[index]) { newNeedSucai[index] = [0, time, TF] newpack[index] = newpack[index] - item } else if (item > newpack[index]) { var data = 参考.find(i => i[0].indexOf(index) != -1) if (data != undefined) { if (data[0].indexOf(index) == 0) { // 1阶素材(不可合成 newNeedSucai[index] = [item - newpack[index], time, TF] newpack[index] = newpack[index] - item if (newpack[index] < 0) { newpack[index] = 0 } } else { // 可合成素材 var 剩余数量 = item - newpack[index] var 剩余数量初始 = item - newpack[index] var cost = data[1][data[0].indexOf(index)] var 可用同类 = {} $.each(data[0], function (otherIndex, otherItem) { if (otherIndex < data[0].indexOf(index)) { 可用同类[otherItem] = newpack[otherItem] } }) $.each(可用同类, function (otherIndex, otherItem) { var cost2 = data[1][data[0].indexOf(otherIndex)] var 同类数量 = Math.floor(otherItem * cost2 / cost) if (同类数量 < 剩余数量) { newpack[otherIndex] = newpack[otherIndex] - 同类数量 * cost / cost2 newNeedSucai[index] = [剩余数量 - 同类数量, time, TF] newpack[index] = 0 剩余数量 = 剩余数量 - 同类数量 } else { newNeedSucai[index] = [0, time, TF] newpack[otherIndex] = newpack[otherIndex] - 剩余数量 * cost / cost2 newpack[index] = 0 剩余数量 = 0 } }) } } else { newNeedSucai[index] = [item - newpack[index], time, TF] newpack[index] = newpack[index] - item } } }) // that.needSumIni = { needSum1: needSum1, needSum2: needSum2, needSum3: needSum3, needSum4: needSum4, needSum5: needSum5, needSum6: needSum6, needSum8: needSum8, needSum9: needSum9 } $.each(needExp, function (index, item) { if (item == 0) { delete needExp[index] } }) $.each(needOre, function (index, item) { if (item == 0) { delete needOre[index] } }) that.需要素材 = newNeedSum that.需要素材转换后 = newNeedSucai that.需要摩拉 = needMola that.需要经验书 = needExp that.需要精锻矿 = needOre

// 触发缓存 this.addStorage() }, // 藏金之花 molaFlowerSum() { var mola = (this.需要摩拉.摩拉 - this.背包素材.摩拉) if (mola < 0) { mola = 0 } return Math.ceil(mola / (this.世界等级.藏金之花))

}, // 启示之花 roleFlowerSum() { var that = this var EXP = 0 $.each(that.需要经验书, function (index, item) { EXP = EXP + that.经验书经验表[index] * item }) return Math.ceil(EXP / (this.世界等级.启示之花下限 + this.世界等级.启示之花上限) * 2) }, // 体力计算 powerProject() { var that = this var 天赋武器 = { 1: [{}, {}], 2: [{}, {}], 3: [{}, {}], } var Boss素材 = {} var 周常素材 = {} var 其他 = {} var 树脂 = { 技能武器树脂: [0, 0, 0], 世界BOSS树脂: 0, 周常BOSS树脂: 0, }

$.each(this.需要素材转换后, function (index, item) { if (skillBossData.indexOf(index) != -1) { 周常素材[index] = item } else if (BOSSData.indexOf(index) != -1) { Boss素材[index] = item } else if (item[1] != 0) { if (index.indexOf('「') != -1) { 天赋武器[item[1]][0][index] = item[0] } else { 天赋武器[item[1]][1][index] = item[0] } } else { 其他[index] = item } }) $.each(天赋武器, function (index, item) { var 天赋数量 = 0 var 武器素材数量 = 0 $.each(item[0], function (moreIndex, moreItem) { var data = 参考.find(i => i[0].indexOf(moreIndex) != -1) var cost = data[1][data[0].indexOf(moreIndex)] 天赋数量 = 天赋数量 + moreItem * cost }) $.each(item[1], function (moreIndex, moreItem) { var data = 参考.find(i => i[0].indexOf(moreIndex) != -1) var cost = data[1][data[0].indexOf(moreIndex)] 武器素材数量 = 武器素材数量 + moreItem * cost }) 树脂.技能武器树脂[index - 1] = 树脂.技能武器树脂[index - 1] + Math.ceil(天赋数量 / that.世界等级.技能书期望) * 20 树脂.技能武器树脂[index - 1] = 树脂.技能武器树脂[index - 1] + Math.ceil(武器素材数量 / that.世界等级.技能书期望) * 20 }) $.each(Boss素材, function (index, item) { 树脂.世界BOSS树脂 = 树脂.世界BOSS树脂 + Math.ceil(item[0] / that.世界等级.世界BOSS期望) * 40 }) if (that.世界等级.周常BOSS期望 == 0) { 树脂.周常BOSS树脂 = "该世界等级无法获取" } else { $.each(周常素材, function (index, item) { 树脂.周常BOSS树脂 = 树脂.周常BOSS树脂 + Math.ceil(item[0] / that.世界等级.周常BOSS期望) * 60 }) } $.each(天赋武器, function (mainIndex, mainItem) { $.each(mainItem, function (indexArr, itemArr) { $.each(itemArr, function (index, item) { if (item == 0) { delete itemArr[index] } }) }) }) $.each([Boss素材, 周常素材, 其他], function (mainIndex, mainItem) { var data = {} $.each(mainItem, function (index, item) { if (item[0] == 0) { delete mainItem[index] } }) }) // console.log(天赋武器, Boss素材, 周常素材, 其他, 树脂); return [天赋武器, Boss素材, 周常素材, 其他, 树脂] }, }, mounted: function () { setInterval(this.originalResinCom, 1000); }, methods: { // 树脂计算 originalResinCom() { // 补全两位 var checkTime = function (i) { if (i < 10) { i = "0" + i; } return i; } let lack = 200 - this.树脂; let newToday = new Date(new Date().getTime() + lack * 8 * 60 * 1000); let today = new Date(); let eTime = `${newToday.getFullYear()}/${checkTime(newToday.getMonth() + 1)}/${checkTime(newToday.getDate())} ${checkTime(newToday.getHours())}:${newToday.getMinutes()}:${checkTime(newToday.getSeconds())}`; let nowTime = `${today.getFullYear()}/${checkTime(today.getMonth() + 1)}/${checkTime(today.getDate())} ${checkTime(today.getHours())}:${checkTime(today.getMinutes())}:${checkTime(today.getSeconds())}`; this.originalResinNum = [eTime, nowTime]; }, // 下拉选择世界等级 selected() { var that = this var data = worldResourceData.find((i) => i.冒险等级 == that.世界等级.冒险等级); that.世界等级.世界等级 = data.世界等级; that.世界等级.藏金之花 = data.藏金之花奖励; that.世界等级.启示之花下限 = data.启示之花奖励下限; that.世界等级.启示之花上限 = data.启示之花奖励上限; that.世界等级.技能书期望 = data.技能书期望; that.世界等级.武器素材期望 = data.武器素材期望; that.世界等级.世界BOSS期望 = data.世界BOSS期望; that.世界等级.周常BOSS期望 = data.周常BOSS期望; },

// 展开角色选择列表 roleListOn(key) { this.角色.find(function (e) { if (e.key == key) { e.show.角色选择 = !e.show.角色选择 } }) },

// 选择角色列表属性 chooseRoleSort(key, sort) { this.角色.find(function (e) { if (e.key == key) { e.show.属性 = sort } }) },

// 选择角色 chooseRole(role, key, copTF, kills, thats) { var that = this if (thats) { that = thats } that.角色.find(function (e) { if (e.key == key) { e.roleData.名称 = role e.show.角色选择 = false var data = roleData.find((i) => role == i.名称); if (kills) { if (copTF[1] == undefined) { e.show.是否计算 = copTF } else { e.show.是否计算 = copTF[0] e.show.是否折叠 = copTF[1] } e.show.技能开关 = kills[0]; e.roleLevel = kills[1]; e.evolve = { 前突破: kills[2][0], 前突破显示: kills[2][1], 后突破: kills[2][2], 后突破显示: kills[2][3] }; e.skillBefore = kills[3]; e.skillAfter = kills[4]; } e.roleData.晶石 = data.突破晶石素材系列; e.roleData.头领石 = data.突破首领素材; e.roleData.特产 = data.突破特产素材; e.roleData.素材 = data.突破怪物素材系列; e.roleData.技能书 = data.技能天赋素材系列; e.roleData.技能Boss材料 = data.技能周本素材; var skill = roleSkillData.find(i => i.名称 == role) if (skill == undefined) { e.skillSum = ["技能1", "技能2", "技能3"] } else { e.skillSum = [skill.角色技能1, skill.角色技能2, skill.角色技能3] } } }) that.bgOn = false; }, // 角色等级输入判定 roleLevelListen(key) { this.角色.find(function (item) { if (item.key == key) { if (item.roleLevel[0] > 90) { item.roleLevel[0] = 90; } else if (item.roleLevel[0] < 1) { item.roleLevel[0] = 1; } else if (item.roleLevel[0] == "") { item.roleLevel[0] = 1; } if (item.roleLevel[1] > 90) { item.roleLevel[1] = 90; } else if (item.roleLevel[1] < 1) { item.roleLevel[1] = 1; } else if (item.roleLevel[1] == "") { item.roleLevel[1] = 90; } } }) },

// 技能等级输入判定 roleSkillListen(key) { this.角色.find(function (item) { if (item.key == key) { item.skillBefore.forEach(function (i, index) { if (i > 10) { item.skillBefore[index] = 10; } else if (i < 1) { item.skillBefore[index] = 1; } else if (i == "") { item.skillBefore[index] = 1; } }); item.skillAfter.forEach(function (i, index) { if (i > 10) { item.skillAfter[index] = 10; } else if (i < 1) { item.skillAfter[index] = 1; } else if (i == "") { item.skillAfter[index] = 1; } }); } }) },

// 角色是否突破 evolve(key, index) { this.角色.find(function (e) { if (e.key == key) { e.evolve[index] = !e.evolve[index]; } }) },

// 判断是否计算技能 evolutionShow(key) { this.角色.find(function (e) { if (e.key == key) { e.show.技能开关 = !e.show.技能开关; e.skillBefore = [1, 1, 1]; e.skillAfter = [1, 1, 1]; } }) },

// 展开角色所需素材 materialBoxOn(key) { this.角色.find(function (e) { if (e.key == key) { e.show.材料显示 = !e.show.材料显示; } }) }, // 角色是否计入总计 roleCop(key) { this.角色.find(function (e) { if (e.key == key) { e.show.是否计算 = !e.show.是否计算; } }) }, // 武器是否计入总计 weaponCop(key) { this.武器.find(function (e) { if (e.key == key) { e.show.是否计算 = !e.show.是否计算; } }) }, // 设置等级输入范围判定 LevelListen(key) { if (key == "角色") { if (this.角色包.roleLevel[0] > 90) { this.角色包.roleLevel[0] = 90; } else if (this.角色包.roleLevel[0] < 1) { this.角色包.roleLevel[0] = 1; } else if (this.角色包.roleLevel[0] == "") { this.角色包.roleLevel[0] = 1; } if (this.角色包.roleLevel[1] > 90) { this.角色包.roleLevel[1] = 90; } else if (this.角色包.roleLevel[1] < 1) { this.角色包.roleLevel[1] = 1; } else if (this.角色包.roleLevel[1] == "") { this.角色包.roleLevel[1] = 90; } } else if (key == "武器") { if (this.武器包.weaponLevel[0] > 90) { this.武器包.weaponLevel[0] = 90; } else if (this.武器包.weaponLevel[0] < 1) { this.武器包.weaponLevel[0] = 1; } else if (this.武器包.weaponLevel[0] == "") { this.武器包.weaponLevel[0] = 1; } if (this.武器包.weaponLevel[1] > 90) { this.武器包.weaponLevel[1] = 90; } else if (this.武器包.weaponLevel[1] < 1) { this.武器包.weaponLevel[1] = 1; } else if (this.武器包.weaponLevel[1] == "") { this.武器包.weaponLevel[1] = 90; } } }, // 武器输入范围判定 weaponLevelListen(key) { this.武器.find(function (item) { if (item.key == key) { if (item.weaponData.稀有度 == 3 || item.weaponData.稀有度 == 4 || item.weaponData.稀有度 == 5) { if (item.weaponLevel[0] > 90) { item.weaponLevel[0] = 90; } else if (item.weaponLevel[0] < 1 || item.weaponLevel[0] == "") { item.weaponLevel[0] = 1; } if (item.weaponLevel[1] > 90) { item.weaponLevel[1] = 90; } else if (item.weaponLevel[1] < 1 || item.weaponLevel[1] == "") { item.weaponLevel[1] = 1; } } else { if (item.weaponLevel[0] > 70) { item.weaponLevel[0] = 70; } else if (item.weaponLevel[0] < 1 || item.weaponLevel[0] == "") { item.weaponLevel[0] = 1; } if (item.weaponLevel[1] > 70) { item.weaponLevel[1] = 70; } else if (item.weaponLevel[1] < 1 || item.weaponLevel[1] == "") { item.weaponLevel[1] = 1; } } } }) },

// 展开武器选择列表 weaponListOn(key) { this.武器.find(function (e) { if (e.key == key) { e.show.武器选择 = !e.show.武器选择 } }) }, // 选择武器列表属性 chooseWeaponSort(key, sort) { this.武器.find(function (e) { if (e.key == key) { e.show.属性 = sort } }) }, // 选择武器 chooseWeapon(role, key, copTF, kills, thats) { var that = this if (thats) { var that = thats } that.武器.find(function (e) { if (e.key == key) { e.weaponData.名称 = role e.show.武器选择 = false var data = weaponData.find((i) => role == i.名称); if (kills) { if (copTF[1] == undefined) { e.show.是否计算 = copTF } else { e.show.是否计算 = copTF[0] e.show.是否折叠 = copTF[1] } e.weaponLevel = kills[0]; e.evolve = { 前突破: kills[1][0], 前突破显示: kills[1][1], 后突破: kills[1][2], 后突破显示: kills[1][3] }; } e.weaponData.稀有度 = data.稀有度; e.weaponData.突破石 = data.武器突破素材系列; e.weaponData.R素材 = data.普通怪物素材系列; e.weaponData.SR素材 = data.精英怪物素材系列; } }) this.bgOn = false; },

// 是否显示武器材料box weaponMaterialBoxOn(key) { this.武器.find(function (e) { if (e.key == key) { e.show.材料显示 = !e.show.材料显示; } }) }, // 武器是否突破 weaponEvolve(key, index) { this.武器.find(function (e) { if (e.key == key) { e.evolve[index] = !e.evolve[index]; } }) },


// 角色稀有度获取(背景颜色) roleStar(e) { var data = roleData.find((i) => i.名称 == e); return "bgStar" + data.稀有度.replace("星", ""); }, // 武器稀有度获取(背景颜色) weaponStar(e) { var data = weaponData.find((i) => i.名称 == e); return "bgStar" + data.稀有度; },

// 单位转换 molachange(e) { if (e > 10000) { var a = e / 10000; a = a.toFixed(2) + "万"; return a; } else { return e; } },

// 汇总资源 技能书角标显示 skillBadge(e) { if (e.indexOf("「" && "」") !== -1) { var a = e.replace(/(「)([\s\S]*?)(」)([\s\S]*)/g, "$2"); return a; } else { return ""; } },

// 汇总计算判断 allCompute(f, g) { if (f - g > 0) { return f - g; } else { return 0; } },

// 各种面板开关 setting(e) { this.bgOn = !this.bgOn; this.设置包[e] = !this.设置包[e] },

// 开关背景 bgOpen() { this.bgOn = !this.bgOn; $(".wiki-header:eq(0),.visible-md-block:eq(0)").toggleClass("wiki-nav"); }, bgClose() { this.bgOn = false; for (var i in this.角色) { this.角色[i].show.角色选择 = false; } for (var i in this.武器) { this.武器[i].show.武器选择 = false; } for (var i in this.设置包) { this.设置包[i] = false; } for (var i in this.材料输入开关) { this.材料输入开关[i] = false; } for (var i in this.需要素材转换后) { this.需要素材转换后[i][2] = false; } $(".wiki-header:eq(0),.visible-md-block:eq(0)").removeClass("wiki-nav"); },

// 添加角色 addRole() { var key if (this.角色.length == 0) { key = 0 } else { key = this.角色.slice(-1)[0].key } this.角色包.key = ++key this.角色.push(JSON.parse(JSON.stringify(this.角色包))) },

// 删除角色 roleDelete(key) { this.角色 = this.角色.filter((t) => t.key !== key) }, // 添加武器 addWeapon() { var key if (this.武器.length == 0) { key = 0 } else { key = this.武器.slice(-1)[0].key } this.武器包.key = ++key this.武器.push(JSON.parse(JSON.stringify(this.武器包))) },

// 删除武器 weaponDelete(key) { this.武器 = this.武器.filter((t) => t.key !== key) },

// 导入信息 loadJson(e) { var that = this var fileList = e.target.files var reader = new FileReader(); reader.onload = function (fileList) { var data = JSON.parse(fileList.target.result) // 添加已有素材 $.each(data.materials, function (index, item) { var name = Object.keys(EZNameData).find(i => EZNameData[i] == index) if (name in that.背包素材) { that.背包素材[name] = item } }) }; reader.readAsText(fileList[0], 'UTF-8') that.bgOn = false; that.设置包.设置 = false },

// 缓存 addStorage() { localStorage.setItem("computeDataNew", JSON.stringify({ versions: 3, 角色: this.角色, 角色包: this.角色包, 武器: this.武器, 武器包: this.武器包, 背包素材: this.背包素材, 世界等级: this.世界等级 })); }, //初始化角色武器 resetDdata() { if (confirm("这将会清除现有的角色与武器数据!!\n确定么")) { this.角色 = [] this.武器 = [] this.角色.push(JSON.parse(JSON.stringify(this.角色包))) this.武器.push(JSON.parse(JSON.stringify(this.武器包))) this.bgOn = false; this.设置包.设置 = false } }, //初始化背包 resetPack() { var that = this if (confirm("这将会清除现有的背包数据!!\n确定么")) { $.each(that.背包素材, function (index, item) { that.背包素材[index] = 0 }) that.bgOn = false; that.设置包.设置 = false } }, //小数点保留1位 decimal(number, key) { return number.toFixed(key) }, // 计算技能花费时间 skillNeedTime() { var that = this var data = that.powerProject[2] var day var num = 0 $.each(data, function (index, item) { if (item[0] > num) { num = item[0] } }) day = Math.ceil(num / that.世界等级.周常BOSS期望) return day },

// 星期转换 weekTurn(time) { // 选择时区(4点刷新 function getZoneTime(offset) { // 取本地时间 var localtime = new Date(); // 取本地毫秒数 var localmesc = localtime.getTime(); // 取本地时区与格林尼治所在时区的偏差毫秒数 var localOffset = localtime.getTimezoneOffset() * 60000; // 反推得到格林尼治时间 var utc = localOffset + localmesc; // 得到指定时区时间 var calctime = utc + (3600000 * offset); var nd = new Date(calctime); // return nd+" "+ nd.toDateString()+" "+nd.getHours()+":"+nd.getMinutes()+":"+nd.getSeconds(); return nd } time = Number(time) var week = [] var date = getZoneTime(4) var nowTime = date.getDay()

const weekMap = { 0: ["星期日", 0, "星期日"], 1: ["星期一/四", 1, "星期一"], 2: ["星期二/五", 2, "星期二"], 3: ["星期三/六", 3, "星期三"], 4: ["星期一/四", 1, "星期四"], 5: ["星期二/五", 2, "星期五"], 6: ["星期三/六", 3, "星期六"], };

function getWeek(time, nowTime) { const weekTime = weekMap[time][0] const [weekStr, showTime, dayStr] = weekMap[nowTime]; var color = "" if (time == weekMap[nowTime][1] || nowTime == 0) { color = "#cea289" } week.push(weekTime, showTime, dayStr, color); return week; } week = getWeek(time, nowTime) return week },

// 输入材料数据 materialsChg(name, type) { if (type == "EXP") { this.材料输入开关[name] = !this.材料输入开关[name] } else { this.需要素材转换后[name][2] = !this.需要素材转换后[name][2] } this.bgOn = !this.bgOn }, // 获取相同系列材料包 materialsTeam(name) { var data = 参考.find(i => i[0].indexOf(name) != -1) if (data != undefined) { return data[0] } else { return [name] } }, // 获取图片 getImg(name) { var url = imgUrlData[name] if (url == undefined) { return "https://patchwiki.biligame.com/images/ys/7/7f/eaj1pyft1pyhyd4v3164wp2nhkd7l3d.png" } else { return url } },

// 读取旧缓存 old() { var that = this var storageData = JSON.parse(localStorage.getItem("computeData")); if (storageData) { var jsData = storageData.角色 var wqData = storageData.武器 if (confirm("这将会读取旧版计算器数据!!\n同时移除现有数据!!!\n确定么")) { var jsData = storageData.角色 var wqData = storageData.武器 var newjs = [] $.each(jsData, function (index, item) { var data1 = Object.keys(item.levelMaterialSum) var data2 = Object.keys(item.skillMaterialSum) var 旧素材 var 旧天赋 $.each(monsterRData, function (oldIndex, oldItem) { if (oldItem.普怪素材1 == data2[3]) { 旧素材 = oldIndex } }) $.each(skillData, function (oldIndex, oldItem) { if (oldItem.技能书2 == data2[0]) { 旧天赋 = oldIndex } }) newjs.push({ key: item.key, show: { 属性: item.roleListIndexOn, 角色选择: false, 材料显示: false, 技能开关: item.evolutionOn, 是否计算: true }, roleData: { 名称: item.roleNameOn, 晶石: data1[3], 头领石: data1[4], 特产: data1[5], 素材: 旧素材, 技能书: 旧天赋, 技能Boss材料: data2[6] }, roleLevel: [item.roleLevelBefore, item.roleLevelAfter], skillBefore: item.skillBefore, skillAfter: item.skillAfter, needMaterial: item.levelMaterialSum, evolve: { 前突破显示: false, 后突破显示: false, 前突破: true, 后突破: true }, warning: "", warning2: "", skillMaterial: item.skillMaterialSum, skillSum: item.skillSun, })

}) var newwq = []

$.each(wqData, function (index, item) { var 旧数据 = weaponData.find(i => i.名称 == item.weaponNameOn) var data = Object.keys(item.needEvolve) newwq.push({ key: item.key, show: { 属性: item.weaponListIndexOn, 武器选择: false, 材料显示: false, 是否计算: true }, weaponData: { 名称: item.weaponNameOn, 稀有度: 旧数据.稀有度, 突破石: 旧数据.武器突破素材系列, R素材: 旧数据.普通怪物素材系列, SR素材: 旧数据.精英怪物素材系列, }, warning: "", weaponLevel: [item.weaponLevelBefore, item.weaponLevelAfter], evolve: { 前突破显示: false, 后突破显示: false, 前突破: true, 后突破: true }, needMaterial: { 精锻用杂矿: item.needExpOre1, 精锻用良矿: item.needExpOre2, 精锻用魔矿: item.needExpOre3, 远海夷地的瑚枝: data[0], 远海夷地的玉枝: data[1], 远海夷地的琼枝: data[2], 远海夷地的金枝: data[3], 混沌机关: data[4], 混沌枢纽: data[5], 混沌真眼: data[6], 破旧的刀镡: data[7], 影打刀镡: data[8], 名刀镡: data[9], 摩拉: item.needMola }, }) }) this.角色 = newjs this.武器 = newwq this.bgOn = false; for (var i in this.设置包) { this.设置包[i] = false; } localStorage.removeItem('computeData') } } else { alert("没有旧版数据") } },


// 导入数据 upload(e) { if (confirm("这将会清除现有的角色武器!!\n确定么")) { var that = this var fileList = e.target.files var reader = new FileReader(); reader.onload = function (fileList) { var importData = JSON.parse(fileList.target.result) if (importData.versions == undefined) { $.each(importData, function (index, item) { that[index] = item }) } else { that.角色 = [] var roleKey = 0 if (importData.versions == 3) { importData = DataTran(importData) } $.each(importData.data.角色, function (index, item) { that.角色包.key = ++roleKey that.角色.push(JSON.parse(JSON.stringify(that.角色包))) that.$options.methods.chooseRole(item[0], roleKey, item[1], item[2], that) }) that.武器 = [] var weaponKey = 0 $.each(importData.data.武器, function (index, item) { that.武器包.key = ++weaponKey that.武器.push(JSON.parse(JSON.stringify(that.武器包))) that.$options.methods.chooseWeapon(item[0], weaponKey, item[1], item[2], that) }) that.设置包 = importData.data.设置包 that.背包素材 = importData.data.背包素材 that.世界等级 = importData.data.世界等级 } }; reader.onloadend = function () { that.设置包.设置 = false; that.bgOn = false; } reader.readAsText(fileList[0], 'UTF-8') } }, // 导出数据 download() { var that = this var exportData = {} exportData.versions = 3 exportData.data = { 角色: [], 武器: [] } $.each(that.角色, function (index, item) { exportData.data.角色.push([item.roleData.名称, [TFSwitch(item.show.是否计算), TFSwitch(item.show.是否折叠)], [item.show.技能开关, item.roleLevel, [TFSwitch(item.evolve.前突破), TFSwitch(item.evolve.前突破显示), TFSwitch(item.evolve.后突破), TFSwitch(item.evolve.后突破显示)], item.skillBefore, item.skillAfter]]) }) $.each(that.武器, function (index, item) { exportData.data.武器.push([item.weaponData.名称, [TFSwitch(item.show.是否计算), TFSwitch(item.show.是否折叠)], [item.weaponLevel, [TFSwitch(item.evolve.前突破), TFSwitch(item.evolve.前突破显示), TFSwitch(item.evolve.后突破), TFSwitch(item.evolve.后突破显示)]]]) })

exportData.data.设置包 = that.设置包 exportData.data.背包素材 = that.背包素材 exportData.data.世界等级 = that.世界等级 var blob = new Blob([JSON.stringify(exportData)], { type: 'application/json' })

var date = new Date(); time = date.getFullYear() + "-" + date.getMonth() + 1 + "-" + date.getDate() + " " + date.getHours() + "_" + date.getMinutes() + "_" + date.getSeconds()

var fileName = "Wiki消耗计算器数据" + time // 构建下载链接 var url = window.URL.createObjectURL(blob) var link = document.createElement('a') link.href = url; link.setAttribute('download', fileName + ".json") link.click(); }, // 读取Wiki数据 loadAll() { if (this.Wiki储存 == "") { var that = this var allData = [] new mw.Api().get({ "action": "query", "format": "json", "meta": "userinfo", "formatversion": "2", "uiprop": "options", "userId": (document.cookie.match(/DedeUserID=([^;]+)/) || [])[1] || "" }).then(function (data) { var options = data.query.userinfo.options $.each([0, 1, 2], function (index, item) { var loadData = options["userjs-conputedData-" + item] if (loadData == undefined) { allData.push({ name: "没有数据,请保存" }) } else { var exportData = loadData.replace(/\^/g, '"') var exportData = exportData.slice(1) var exportData = exportData.slice(0, exportData.length - 1) exportData = JSON.parse(exportData) exportData = DataTran(exportData) allData.push(exportData) } }) that.Wiki储存 = allData }) } }, // Wiki数据导入 loadWiki(key) { var that = this var wikiData = that.Wiki储存[key].data if (wikiData !== undefined) { if (confirm("确定要读取“" + that.Wiki储存[key].name + "”么\n这会覆盖现有数据")) { that.角色 = [] var roleKey = 0 $.each(wikiData.角色, function (index, item) { that.角色包.key = ++roleKey that.角色.push(JSON.parse(JSON.stringify(that.角色包))) that.$options.methods.chooseRole(item[0], roleKey, item[1], item[2], that) }) that.武器 = [] var weaponKey = 0 $.each(wikiData.武器, function (index, item) { that.武器包.key = ++weaponKey that.武器.push(JSON.parse(JSON.stringify(that.武器包))) that.$options.methods.chooseWeapon(item[0], weaponKey, item[1], item[2], that) }) that.设置包 = wikiData.设置包 that.背包素材 = wikiData.背包素材 that.世界等级 = wikiData.世界等级 that.设置包.设置 = false } } else { alert("未储存数据") } }, // 保存数据到Wiki saveWiki(name, key) { var that = this var exportData = {} if (name == "没有数据,请保存") { exportData.name = "未命名数据" } else { exportData.name = name } exportData.versions = 3 exportData.data = { 角色: [], 武器: [] } $.each(that.角色, function (index, item) { exportData.data.角色.push([item.roleData.名称, [TFSwitch(item.show.是否计算), TFSwitch(item.show.是否折叠)], [item.show.技能开关, item.roleLevel, [TFSwitch(item.evolve.前突破), TFSwitch(item.evolve.前突破显示), TFSwitch(item.evolve.后突破), TFSwitch(item.evolve.后突破显示)], item.skillBefore, item.skillAfter]]) }) $.each(that.武器, function (index, item) { exportData.data.武器.push([item.weaponData.名称, [TFSwitch(item.show.是否计算), TFSwitch(item.show.是否折叠)], [item.weaponLevel, [TFSwitch(item.evolve.前突破), TFSwitch(item.evolve.前突破显示), TFSwitch(item.evolve.后突破), TFSwitch(item.evolve.后突破显示)]]]) }) exportData.data.设置包 = that.设置包 exportData.data.世界等级 = that.世界等级 exportData.data.背包素材 = that.背包素材 exportData = JSON.stringify(exportData).replace(/"/g, "^") function bytesLnegth(str) { var count = str.length; for (var i = 0; i < str.length; i++) { if (str.charCodeAt(i) > 255 || str.charCodeAt(i) == 34) { count++; } } return count; } if (bytesLnegth(JSON.stringify(exportData)) > 60000) { alert("角色武器太多,请勿超过700个") } else { if (confirm("确定要覆盖这个插槽么")) { new mw.Api().postWithToken('csrf', { "action": "options", "format": "json", "optionname": "userjs-conputedData-" + key, "optionvalue": JSON.stringify(exportData), }).then(function (message) { alert("储存成功") exportData = JSON.parse(exportData.replace(/\^/g, '"')) exportData = DataTran(exportData) that.Wiki储存[key] = exportData }).catch(function (err) { if (err == "notloggedin") { alert("储存失败,请登录账号") } else { console.log(err); alert("储存失败") } }) } } },

// 折叠 fold(key, type) { console.log(key); this[type].find(function (e) { if (e.key == key) { e.show.是否折叠 = !e.show.是否折叠; } }) }, allFold() { var type = this.角色[0].show.是否折叠 $.each(this.角色, function (index, item) { item.show.是否折叠 = !type }) $.each(this.武器, function (index, item) { item.show.是否折叠 = !type }) },

} }

var app = Vue.createApp(Counter); onload();

$("body").on("click", "#downImg", function () { var dom = document.getElementById("needMaterials"); domtoimage.toPng(dom).then(function (dataUrl) { var link = document.createElement('a') link.href = dataUrl; var date = new Date(); var time = date.getFullYear() + "-" + date.getMonth() + 1 + "-" + date.getDate() + " " + date.getHours() + "_" + date.getMinutes() + "_" + date.getSeconds() var fileName = "资源总汇" + time link.setAttribute("download", fileName + ".jpg") link.click(); }).catch(function (error) { alert("保存失败请重试") console.error("oops, something went wrong!", error); }); })

console.log("计算器数据本体加载完成") }) } ]) </script>