Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
KGP.min.js 2.94 KB
Copy Edit Raw Blame History
petercheney authored 2022-11-13 12:34 . 更新版本号
setTimeout(()=>{initKGP()},201+Math.max(-Date.now()+game.timer.timestampStart,-200));function initKGP(){if(localStorage["zh.kgp.enable"]!=="disable"&&!window.KGPInterval){if(game.resPool){window.KGPInterval=setInterval(()=>initKGPLeftColumn(),200);$('<style type="text/css" id="KGPBorder">.res-table { border-spacing: 0px 3px; }</style>').appendTo("head")}else{setTimeout(()=>initKGP(),500)}}else{if(KGPInterval){clearInterval(KGPInterval);window.KGPInterval=undefined;initKGPLeftColumn(false);document.getElementById("KGPBorder").remove()}}}function initKGPLeftColumn(r=true){const e=$("#leftColumnViewport > div > div:nth-child(1) > div:nth-child(2) > div").find(".res-row");const l=KGP.resMap;e.each(function(e,t){if(!r){return t.removeAttribute("style")}let n=t.className.split(" ")[1].substring(9);if(n==="kittens"||n==="zebras"){return}let i=$(t);let a=l[n];if(a){let e=a.maxValue;let t=a.value;KGP.changeCSS(t,e,i)}});KGP.updateTooltip()}window.KGP={resMap:game.resPool.resourceMap,resRow:undefined,tool:undefined,updateTooltip:function(){let c=this.resMap;if(game.tooltipUpdateFunc){let t=game.tooltipUpdateFunc;let e=$("#tooltip").find(".price-block");if(!t.length){game.tooltipUpdateFunc=e=>{t();KGP.updateTooltip()}}e.each((e,a)=>{let t=a.textContent;let s=t.replace("/","");if(s!==t){let t=$(a);s=s.replace("*"," ");s=s.replace("+"," ");let e=s.trim().split(" ");let n=e[0];let i=n.length;let r,l;for(let e=0;e<i;e++){if(parseFloat(n[e])+1){l=n.substring(0,e);r=n.substring(e,i);break}}let o=KGP.getAmountFromFormatted(e[2]);r=KGP.getAmountFromFormatted(r);if(e.length<4){let e,i,a;switch(l){case"眼泪":e=t.find(".noRes");e.text((e,t)=>{let n=Math.ceil((o-r)/game.bld.getBuildingExt("ziggurat").meta.on)*2500;let i=c["unicorns"].perTickCached;if(n-c["unicorns"].value>0&&i){n=(n-c["unicorns"].value)/(game.getTicksPerSecondUI()*i);return t+" ("+game.toDisplaySeconds(n)+")"}});break;case"反物质":i=game.getEffect("antimatterProduction");if(o<=c["antimatter"].maxValue&&i){e=t.find(".noRes");e.text((e,t)=>{let n=Math.ceil((o-r)/i);return t+" ("+n+"游戏年)"})}break;case"遗物":a=game.getEffect("relicPerDay");if(a){e=t.find(".noRes");e.text((e,t)=>{let n=game.time.isAccelerated?1.33:2;let i=Math.ceil((o-r)/a)*n;return t+" ("+game.toDisplaySeconds(i)+")"})}break}}KGP.changeCSS(r,o,t)}})}},changeCSS:function(t,n,i){if(n>0&&t>0){let e=100*t/n;i.css("background-repeat","no-repeat");i.css("background-position","bottom left");i.css("background-size",Math.min(200,e)+"% 1px");if(e>95){i.css("background-image","linear-gradient(0, red, red)")}else if(e>75){i.css("background-image","linear-gradient(0, orange, orange)")}else{i.css("background-image","linear-gradient(0, green, green)")}}},getAmountFromFormatted:function(e){if(!e){return 0}const t=e.slice(-1);const n=!isNaN(Number(t));const i=n?Number(e):Number(e.substring(0,e.length-1));if(n){return i}switch(t){case"K":return i*1e3;case"M":return i*1e6;case"G":return i*1e9;case"T":return i*1e12;case"P":return i*1e15;default:return 0}}};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化