mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-04-21 04:02:02 +08:00
1 line
3.9 KiB
JavaScript
1 line
3.9 KiB
JavaScript
var e=class extends ui.view.DefaultTheme.PropertyUI{constructor(){super();let e=this.#e=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]);let t=({currentTarget:e})=>{e.text=``};this.inputCharm.on(Laya.Event.MOUSE_DOWN,this,t),this.inputIntelligence.on(Laya.Event.MOUSE_DOWN,this,t),this.inputStrength.on(Laya.Event.MOUSE_DOWN,this,t),this.inputMoney.on(Laya.Event.MOUSE_DOWN,this,t),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)}#e;#t;#n;#r;init({talents:e}){this.listSelectedTalents.array=e;let t=core.remake(e.map(e=>e.id));t.length>0&&$$event(`message`,[t.map(e=>[`F_TalentReplace`,e])]),this.#t=core.getPropertyPoints(),this.#r=core.propertyAllocateLimit,this.labLeftPropertyPoint.text=this.#t,this.#n={[this.#e.CHR]:0,[this.#e.INT]:0,[this.#e.STR]:0,[this.#e.MNY]:0},this.updateAllocate()}next(){let e=this.#t-this.total;if(e>0)return $$event(`message`,[`F_PropertyPointLeft`,e]);$ui.switchView(UI.pages.TRAJECTORY,{propertyAllocate:this.#n,talents:this.listSelectedTalents.array,enableExtend:!0})}get total(){return this.#n[this.#e.CHR]+this.#n[this.#e.INT]+this.#n[this.#e.STR]+this.#n[this.#e.MNY]}updateAllocate(){let e=this.#n[this.#e.CHR],t=this.#n[this.#e.INT],n=this.#n[this.#e.STR],r=this.#n[this.#e.MNY];this.inputCharm.text=``+e,this.inputIntelligence.text=``+t,this.inputStrength.text=``+n,this.inputMoney.text=``+r,this.labLeftPropertyPoint.text=this.#t-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,t,n){return!(n<e||n>t)}random(){let e=this.#t,t=[,,,,].fill(this.#r[1]);for(;e>0;){let n=Math.round(Math.random()*(Math.min(e,this.#r[1])-1))+1;for(;;){let r=Math.floor(Math.random()*4)%4;if(!(t[r]-n<0)){t[r]-=n,e-=n;break}}}this.#n[this.#e.CHR]=this.#r[1]-t[0],this.#n[this.#e.INT]=this.#r[1]-t[1],this.#n[this.#e.STR]=this.#r[1]-t[2],this.#n[this.#e.MNY]=this.#r[1]-t[3],this.updateAllocate()}onPropertyAllocate(e,t){this.check(this.#r[0],this.#r[1],this.#n[e]+t)&&this.check(0,this.#t,this.total+t)&&(this.#n[e]+=t,this.updateAllocate())}onPropertyAllocateInput(e,t){let n=parseInt(t.text)||0,r=this.total;r+n<0?n=this.#r[0]*4-r:r+n>this.#t&&(n=this.#t-r),n<this.#r[0]?n=this.#r[0]:n>this.#r[1]&&(n=this.#r[1]);let i=n-this.#n[e];i?this.onPropertyAllocate(e,i):this.updateAllocate()}renderTalent(e){let t=e.dataSource;e.label=$_.format($lang.F_TalentSelection,t);let n=$ui.common.card[t.grade].normal;$_.deepMapSet(e,n)}};export{e as default}; |