1 Star 0 Fork 74

张贤龙/猫国建设者(Kittens Game)

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
KGP.min.js 2.94 KB
一键复制 编辑 原始数据 按行查看 历史
petercheney 提交于 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 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/xianlongok/cat-zh.git
[email protected]:xianlongok/cat-zh.git
xianlongok
cat-zh
猫国建设者(Kittens Game)
main

搜索帮助