mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2025-07-13 15:52:44 +08:00
2 lines
4.4 KiB
JavaScript
2 lines
4.4 KiB
JavaScript
var u=r=>{throw TypeError(r)};var I=(r,o,e)=>o.has(r)||u("Cannot "+e);var t=(r,o,e)=>(I(r,o,"read from private field"),e?e.call(r):o.get(r)),y=(r,o,e)=>o.has(r)?u("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(r):o.set(r,e),p=(r,o,e,s)=>(I(r,o,"write to private field"),s?s.call(r,e):o.set(r,e),e);var n,l,a,h;class g extends ui.view.DefaultTheme.PropertyUI{constructor(){super();y(this,n);y(this,l);y(this,a);y(this,h);const e=p(this,n,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])]),p(this,l,core.getPropertyPoints()),p(this,h,core.propertyAllocateLimit),this.labLeftPropertyPoint.text=t(this,l),p(this,a,{[t(this,n).CHR]:0,[t(this,n).INT]:0,[t(this,n).STR]:0,[t(this,n).MNY]:0}),this.updateAllocate()}next(){const e=t(this,l)-this.total;if(e>0)return $$event("message",["F_PropertyPointLeft",e]);$ui.switchView(UI.pages.TRAJECTORY,{propertyAllocate:t(this,a),talents:this.listSelectedTalents.array,enableExtend:!0})}get total(){return t(this,a)[t(this,n).CHR]+t(this,a)[t(this,n).INT]+t(this,a)[t(this,n).STR]+t(this,a)[t(this,n).MNY]}updateAllocate(){const e=t(this,a)[t(this,n).CHR],s=t(this,a)[t(this,n).INT],i=t(this,a)[t(this,n).STR],c=t(this,a)[t(this,n).MNY];this.inputCharm.text=""+e,this.inputIntelligence.text=""+s,this.inputStrength.text=""+i,this.inputMoney.text=""+c,this.labLeftPropertyPoint.text=t(this,l)-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}check(e,s,i){return!(i<e||i>s)}random(){let e=t(this,l);const s=new Array(4).fill(t(this,h)[1]);for(;e>0;){const i=Math.round(Math.random()*(Math.min(e,t(this,h)[1])-1))+1;for(;;){const c=Math.floor(Math.random()*4)%4;if(!(s[c]-i<0)){s[c]-=i,e-=i;break}}}t(this,a)[t(this,n).CHR]=t(this,h)[1]-s[0],t(this,a)[t(this,n).INT]=t(this,h)[1]-s[1],t(this,a)[t(this,n).STR]=t(this,h)[1]-s[2],t(this,a)[t(this,n).MNY]=t(this,h)[1]-s[3],this.updateAllocate()}onPropertyAllocate(e,s){this.check(t(this,h)[0],t(this,h)[1],t(this,a)[e]+s)&&this.check(0,t(this,l),this.total+s)&&(t(this,a)[e]+=s,this.updateAllocate())}onPropertyAllocateInput(e,s){let i=parseInt(s.text)||0;const c=this.total;c+i<0?i=t(this,h)[0]*4-c:c+i>t(this,l)&&(i=t(this,l)-c),i<t(this,h)[0]?i=t(this,h)[0]:i>t(this,h)[1]&&(i=t(this,h)[1]);const d=i-t(this,a)[e];d?this.onPropertyAllocate(e,d):this.updateAllocate()}renderTalent(e){const s=e.dataSource;e.label=$_.format($lang.F_TalentSelection,s);const i=$ui.common.card[s.grade].normal;$_.deepMapSet(e,i)}}n=new WeakMap,l=new WeakMap,a=new WeakMap,h=new WeakMap;export{g as default};
|