From a587e29d792b99ca952325ec97657ae3ca32c2e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=AB=E8=B0=B7=E5=89=91=E4=BB=99?= Date: Mon, 11 Nov 2019 19:09:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9C=AC=E5=9C=B0Chrome?= =?UTF-8?q?=E6=89=93=E5=BC=80=E7=9A=84=E6=8F=90=E7=A4=BA=20=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E7=A9=BA=E5=8D=A1=E7=89=87=E8=83=BD=E5=8A=9B=E5=80=BC?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E7=9A=84=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script.js | 72 ++++++++++++++++--------------------------- universal_function.js | 4 +-- 2 files changed, 29 insertions(+), 47 deletions(-) diff --git a/script.js b/script.js index f3472d62..4bbeda75 100644 --- a/script.js +++ b/script.js @@ -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); diff --git a/universal_function.js b/universal_function.js index 58f2de2a..db20ec00 100644 --- a/universal_function.js +++ b/universal_function.js @@ -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级以内的增加