Browse Source

优化本地Chrome打开的提示

解决空卡片能力值计算的报错
tags/v8.0
枫谷剑仙 6 years ago
parent
commit
a587e29d79
2 changed files with 29 additions and 47 deletions
  1. +27
    -45
      script.js
  2. +2
    -2
      universal_function.js

+ 27
- 45
script.js View File

@@ -224,60 +224,42 @@ window.onload = function()
return true;
}
});

//处理返回的数据
function dealIdata(responseText)
{
var idata;
try
{
ms = JSON.parse(responseText);
initialize();//初始化
var idataQer = getQueryString("d") || getQueryString("data");
if (idataQer)
{
idata = JSON.parse(idataQer);
}
}catch(e)
{
console.log("初始数据JSON解码出错",e);
return;
}
if (idata)
{
formation.loadObj(idata);
refreshAll(formation);
}
}
GM_xmlhttpRequest({
method: "GET",
url:"monsters-info/mon_"+dataSource.code+".json",
onload: function(response) {
ms = JSON.parse(response.response);
initialize();//初始化
var idata;
try
{
var idataQer = getQueryString("d") || getQueryString("data");
if (idataQer)
{
idata = JSON.parse(idataQer);
}
}catch(e)
{
console.log("初始数据JSON解码出错",e);
return;
}
if (idata)
{
//formation = idata;
formation.loadObj(idata);
refreshAll(formation);
}
dealIdata(response.response);
},
onerror: function(response) {
var isChrome = navigator.userAgent.indexOf("Chrome") >=0;
if (isChrome && location.host.length==0)
{
console.info("因为是Chrome本地打开,正在尝试读取XML");
var idata;
try
{
ms = JSON.parse(response.response);
initialize();//初始化
var idataQer = getQueryString("d") || getQueryString("data");
if (idataQer)
{
idata = JSON.parse(idataQer);
}
}catch(e)
{
console.error("网络请求返回错误,尝试解码仍错误。",e);
return;
}
if (idata)
{
//formation = idata;
formation.loadObj(idata);
refreshAll(formation);
}
console.info("因为是Chrome本地打开,正在尝试读取JSON");
dealIdata(response.response);
}else
{
console.error("怪物数据获取错误",response);


+ 2
- 2
universal_function.js View File

@@ -150,8 +150,8 @@ function calculateAbility(monid,level,plus,awoken,latent,weaponId,weaponAwoken)
if (awoken == undefined) awoken = 0;
if (latent == undefined) latent = [];
if (monid<=0) return null;
var m = ms[monid]; //怪物数据
if (monid ==0 || m==undefined) return null;
var plusAdd = [10,5,3]; //加值的增加值
var awokenAdd = [ //对应加三维觉醒的序号与增加值
[{index:1,value:500},{index:65,value:-5000}],
@@ -162,7 +162,7 @@ function calculateAbility(monid,level,plus,awoken,latent,weaponId,weaponAwoken)
[{index:1,scale:0.015},{index:12,scale:0.03},{index:25,scale:0.045}],
[{index:2,scale:0.01},{index:12,scale:0.02},{index:26,scale:0.03}],
[{index:3,scale:0.1},{index:12,scale:0.2},{index:27,scale:0.3}]
];
];
var abilitys = m.ability.map(function(ab,idx){
var n_base = Math.round(valueAt(level,m.maxLv,ab));
//var n_base = Math.round((ab[1]-ab[0])*(level-1)/98+ab[0]); //99级以内的增加


Loading…
Cancel
Save