mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2025-07-13 15:52:44 +08:00
2 lines
5.9 KiB
JavaScript
2 lines
5.9 KiB
JavaScript
var g=r=>{throw TypeError(r)};var I=(r,c,e)=>c.has(r)||g("Cannot "+e);var t=(r,c,e)=>(I(r,c,"read from private field"),e?e.call(r):c.get(r)),b=(r,c,e)=>c.has(r)?g("Cannot add the same private member more than once"):c instanceof WeakSet?c.add(r):c.set(r,e),y=(r,c,e,s)=>(I(r,c,"write to private field"),s?s.call(r,e):c.set(r,e),e);var a,o,h,n;class f extends ui.view.CyberTheme.CyberPropertyUI{constructor(){super();b(this,a);b(this,o);b(this,h);b(this,n);const e=y(this,a,core.PropertyTypes);this.btnCharmIncrease.on(Laya.Event.CLICK,this,this.onPropertyAllocate,[e.CHR,1]),this.btnCharmReduce.on(Laya.Event.CLICK,this,this.onPropertyAllocate,[e.CHR,-1]),this.btnIntelligenceIncrease.on(Laya.Event.CLICK,this,this.onPropertyAllocate,[e.INT,1]),this.btnIntelligenceReduce.on(Laya.Event.CLICK,this,this.onPropertyAllocate,[e.INT,-1]),this.btnStrengthIncrease.on(Laya.Event.CLICK,this,this.onPropertyAllocate,[e.STR,1]),this.btnStrengthReduce.on(Laya.Event.CLICK,this,this.onPropertyAllocate,[e.STR,-1]),this.btnMoneyIncrease.on(Laya.Event.CLICK,this,this.onPropertyAllocate,[e.MNY,1]),this.btnMoneyReduce.on(Laya.Event.CLICK,this,this.onPropertyAllocate,[e.MNY,-1]),this.inputCharm.on(Laya.Event.INPUT,this,this.onPropertyAllocateInput,[e.CHR]),this.inputIntelligence.on(Laya.Event.INPUT,this,this.onPropertyAllocateInput,[e.INT]),this.inputStrength.on(Laya.Event.INPUT,this,this.onPropertyAllocateInput,[e.STR]),this.inputMoney.on(Laya.Event.INPUT,this,this.onPropertyAllocateInput,[e.MNY]);const s=({currentTarget:i})=>{i.text=""};this.inputCharm.on(Laya.Event.MOUSE_DOWN,this,s),this.inputIntelligence.on(Laya.Event.MOUSE_DOWN,this,s),this.inputStrength.on(Laya.Event.MOUSE_DOWN,this,s),this.inputMoney.on(Laya.Event.MOUSE_DOWN,this,s),this.btnRandomAllocate.on(Laya.Event.CLICK,this,this.random),this.btnNext.on(Laya.Event.CLICK,this,this.next),this.listSelectedTalents.renderHandler=Laya.Handler.create(this,this.renderTalent,null,!1)}init({talents:e}){this.listSelectedTalents.array=e;const s=core.remake(e.map(i=>i.id));s.length>0&&$$event("message",[s.map(i=>["F_TalentReplace",i])]),y(this,o,core.getPropertyPoints()),y(this,n,core.propertyAllocateLimit),this.labLeftPropertyPoint.text=t(this,o),y(this,h,{[t(this,a).CHR]:0,[t(this,a).INT]:0,[t(this,a).STR]:0,[t(this,a).MNY]:0}),this.updateAllocate()}next(){const e=t(this,o)-this.total;if(e>0)return $$event("message",["F_PropertyPointLeft",e]);$ui.switchView(UI.pages.TRAJECTORY,{propertyAllocate:t(this,h),talents:this.listSelectedTalents.array,enableExtend:!0})}get total(){return t(this,h)[t(this,a).CHR]+t(this,h)[t(this,a).INT]+t(this,h)[t(this,a).STR]+t(this,h)[t(this,a).MNY]}updateAllocate(){const e=t(this,h)[t(this,a).CHR],s=t(this,h)[t(this,a).INT],i=t(this,h)[t(this,a).STR],l=t(this,h)[t(this,a).MNY];this.inputCharm.text=""+e,this.inputIntelligence.text=""+s,this.inputStrength.text=""+i,this.inputMoney.text=""+l,this.labLeftPropertyPoint.text=t(this,o)-this.total,this.btnCharmIncrease.disabled=this.btnCharmIncrease.gray=!1,this.btnCharmReduce.disabled=this.btnCharmReduce.gray=!1,this.btnIntelligenceIncrease.disabled=this.btnIntelligenceIncrease.gray=!1,this.btnIntelligenceReduce.disabled=this.btnIntelligenceReduce.gray=!1,this.btnStrengthIncrease.disabled=this.btnStrengthIncrease.gray=!1,this.btnStrengthReduce.disabled=this.btnStrengthReduce.gray=!1,this.btnMoneyIncrease.disabled=this.btnMoneyIncrease.gray=!1,this.btnMoneyReduce.disabled=this.btnMoneyReduce.gray=!1,this.total>=t(this,o)?(this.btnCharmIncrease.disabled=this.btnCharmIncrease.gray=!0,this.btnIntelligenceIncrease.disabled=this.btnIntelligenceIncrease.gray=!0,this.btnStrengthIncrease.disabled=this.btnStrengthIncrease.gray=!0,this.btnMoneyIncrease.disabled=this.btnMoneyIncrease.gray=!0):this.total<=0&&(this.btnCharmReduce.disabled=this.btnCharmReduce.gray=!0,this.btnIntelligenceReduce.disabled=this.btnIntelligenceReduce.gray=!0,this.btnStrengthReduce.disabled=this.btnStrengthReduce.gray=!0,this.btnMoneyReduce.disabled=this.btnMoneyReduce.gray=!0),e<=t(this,n)[0]?this.btnCharmReduce.disabled=this.btnCharmReduce.gray=!0:e>=t(this,n)[1]&&(this.btnCharmIncrease.disabled=this.btnCharmIncrease.gray=!0),s<=t(this,n)[0]?this.btnIntelligenceReduce.disabled=this.btnIntelligenceReduce.gray=!0:s>=t(this,n)[1]&&(this.btnIntelligenceIncrease.disabled=this.btnIntelligenceIncrease.gray=!0),i<=t(this,n)[0]?this.btnStrengthReduce.disabled=this.btnStrengthReduce.gray=!0:i>=t(this,n)[1]&&(this.btnStrengthIncrease.disabled=this.btnStrengthIncrease.gray=!0),l<=t(this,n)[0]?this.btnMoneyReduce.disabled=this.btnMoneyReduce.gray=!0:l>=t(this,n)[1]&&(this.btnMoneyIncrease.disabled=this.btnMoneyIncrease.gray=!0)}check(e,s,i){return!(i<e||i>s)}random(){let e=t(this,o);const s=new Array(4).fill(t(this,n)[1]);for(;e>0;){const i=Math.round(Math.random()*(Math.min(e,t(this,n)[1])-1))+1;for(;;){const l=Math.floor(Math.random()*4)%4;if(!(s[l]-i<0)){s[l]-=i,e-=i;break}}}t(this,h)[t(this,a).CHR]=t(this,n)[1]-s[0],t(this,h)[t(this,a).INT]=t(this,n)[1]-s[1],t(this,h)[t(this,a).STR]=t(this,n)[1]-s[2],t(this,h)[t(this,a).MNY]=t(this,n)[1]-s[3],this.updateAllocate()}onPropertyAllocate(e,s){this.check(t(this,n)[0],t(this,n)[1],t(this,h)[e]+s)&&this.check(0,t(this,o),this.total+s)&&(t(this,h)[e]+=s,this.updateAllocate())}onPropertyAllocateInput(e,s){let i=parseInt(s.text)||0;const l=this.total;l+i<0?i=t(this,n)[0]*4-l:l+i>t(this,o)&&(i=t(this,o)-l),i<t(this,n)[0]?i=t(this,n)[0]:i>t(this,n)[1]&&(i=t(this,n)[1]);const d=i-t(this,h)[e];d?this.onPropertyAllocate(e,d):this.updateAllocate()}renderTalent(e){const s=e.dataSource,i=e.getChildByName("labTitle"),l=e.getChildByName("grade1"),d=e.getChildByName("grade2"),u=e.getChildByName("grade3"),p=e.getChildByName("labDescription");switch(i.text=s.name,p.text=s.description,s.grade){case 1:l.visible=!0,d.visible=!1,u.visible=!1;break;case 2:l.visible=!1,d.visible=!0,u.visible=!1;break;case 3:l.visible=!1,d.visible=!1,u.visible=!0;break;default:l.visible=!1,d.visible=!1,u.visible=!1;break}}}a=new WeakMap,o=new WeakMap,h=new WeakMap,n=new WeakMap;export{f as default};
|