@betorigami/games 1.14.0 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -12045,7 +12045,7 @@ var Yi=Object.create;var{getPrototypeOf:Xi,defineProperty:$6,getOwnPropertyNames
|
|
|
12045
12045
|
:host {
|
|
12046
12046
|
height: 100%;
|
|
12047
12047
|
}
|
|
12048
|
-
`;class k6{queue=[];inflight=0;maxQueueSize;maxConcurrent;executor;constructor(a,i={}){this.executor=a,this.maxQueueSize=i.maxQueueSize??30,this.maxConcurrent=i.maxConcurrent??5}enqueue(a){if(this.queue.length>=this.maxQueueSize)return Promise.reject(new Error("Queue is full. Please slow down."));return new Promise((i,e)=>{this.queue.push({input:a,resolve:i,reject:e}),this.processQueue()})}async processQueue(){if(this.inflight>=this.maxConcurrent)return;let a=this.queue.shift();if(!a)return;this.inflight++;try{let i=await this.executor(a.input);a.resolve(i)}catch(i){a.reject(i instanceof Error?i:new Error(String(i)))}finally{this.inflight--,this.processQueue()}}get pendingCount(){return this.queue.length}get inflightCount(){return this.inflight}get totalCount(){return this.queue.length+this.inflight}get isIdle(){return this.queue.length===0&&this.inflight===0}clear(a="Request cancelled"){while(this.queue.length>0)this.queue.shift()?.reject(new Error(a))}}class ya extends Z1{static styles=[...Z1.styles,Fi];pendingResultsByBetId=new Map;betQueue=new k6((a)=>this.handleBetExecution(a),{maxQueueSize:3,maxConcurrent:5});get isGameInProgress(){return this.autobetInProgress||this.autobetStopping||this.ballsInFlight>0}get plinkoApi(){return this.isDemoMode?new u6(this.gameData.edge):new c6(this.gameData.authToken,this.gameData.baseUrl)}triggerBinHaptic(a){let i=Math.max(...this.binMultipliers),e=1,r=Math.max(0.000001,i-1),l=Math.max(0,Math.min(1,(a-1)/r)),n=Math.round(40+l*140);this.gameData?.hapticController?.trigger(n)}constructor(){super();this.history=[];this.riskLevel="MEDIUM_RISK";this.rowCount=12;this.ballsInFlight=0;new j1(this,[{key:" ",callback:()=>i2.clickBetButton(this.manualOrAuto,this._plinkoManualEl,this._plinkoAutoEl),options:{repeat:!0,repeatInterval:200,disabled:()=>{if(!this.gameData?.hotkeysOpenEnabled)return!0;return i2.isBetButtonDisabled(this.manualOrAuto,this._plinkoManualEl,this._plinkoAutoEl)}}}])}get binMultipliers(){return K0(this.gameData.edge,this.riskLevel,this.rowCount)}async handleBetExecution(a){if(!this.gameData?.currency)return{success:!1,error:R("alerts.gameError",this.gameData?.language||$)};let i=O(this.gameData.balance);try{if(this.isDemoMode&&i.lt(a))throw new Error(R("alerts.insufficientBalance",this.gameData?.language||$));this.gameData.updateBalance(i.minus(a));let e=await this.plinkoApi.startBet({language:this.gameData.language,currency:this.gameData.currency,amount:a,riskLevel:this.riskLevel,rowCount:this.rowCount});if(e.success){let{data:r}=e,l=Number(r.multiplier),t=r.betActions.filter((d)=>d.data?.PLINKO)[1]?.data?.PLINKO,o=(t&&"result"in t?t.result:[]).reduce((d,u)=>d+u,0);if(r.id)this.pendingResultsByBetId.set(r.id,{multiplier:l,payout:r.payout?O(r.payout):O(0)});if(this.updateHistoryWithBet(r),this.gameData.instantBetEnabled)this._plinkoContentEl?.triggerInstantResult?.(this.gameData.edge,l,r.id);else this._plinkoContentEl?.dropBallForResult(o,r.id);return e}else throw new Error(e.error)}catch(e){this.gameData.updateBalance(i);let r=e instanceof Error?e.message:R("alerts.gameError",this.gameData?.language||$);return this.showError(r),{success:!1,error:r}}}async queuedBetExecution(a){try{return await this.betQueue.enqueue(a)}catch(i){return{success:!1,error:i instanceof Error?i.message:R("errors.requestDropped",this.gameData?.language||$)}}}async plinkoPlay(){this.gameData?.soundController?.play("bet"),await this.queuedBetExecution(this.gameData?.betAmount??"0")}async executeAutobet(a,i){let e=await this.handleBetExecution(i);if(!e.success)return{pnl:O(0),gameOutcome:"Draw",hasError:!0,errorMessage:e.error||R("alerts.errorProcessingBet",this.gameData?.language||$)};let{data:r}=e,l=O(r.payout??0).minus(r.amount??0),n=D1(Number(r.multiplier));
|
|
12048
|
+
`;class k6{queue=[];inflight=0;maxQueueSize;maxConcurrent;executor;constructor(a,i={}){this.executor=a,this.maxQueueSize=i.maxQueueSize??30,this.maxConcurrent=i.maxConcurrent??5}enqueue(a){if(this.queue.length>=this.maxQueueSize)return Promise.reject(new Error("Queue is full. Please slow down."));return new Promise((i,e)=>{this.queue.push({input:a,resolve:i,reject:e}),this.processQueue()})}async processQueue(){if(this.inflight>=this.maxConcurrent)return;let a=this.queue.shift();if(!a)return;this.inflight++;try{let i=await this.executor(a.input);a.resolve(i)}catch(i){a.reject(i instanceof Error?i:new Error(String(i)))}finally{this.inflight--,this.processQueue()}}get pendingCount(){return this.queue.length}get inflightCount(){return this.inflight}get totalCount(){return this.queue.length+this.inflight}get isIdle(){return this.queue.length===0&&this.inflight===0}clear(a="Request cancelled"){while(this.queue.length>0)this.queue.shift()?.reject(new Error(a))}}class ya extends Z1{static styles=[...Z1.styles,Fi];pendingResultsByBetId=new Map;betQueue=new k6((a)=>this.handleBetExecution(a),{maxQueueSize:3,maxConcurrent:5});get isGameInProgress(){return this.autobetInProgress||this.autobetStopping||this.ballsInFlight>0}get plinkoApi(){return this.isDemoMode?new u6(this.gameData.edge):new c6(this.gameData.authToken,this.gameData.baseUrl)}triggerBinHaptic(a){let i=Math.max(...this.binMultipliers),e=1,r=Math.max(0.000001,i-1),l=Math.max(0,Math.min(1,(a-1)/r)),n=Math.round(40+l*140);this.gameData?.hapticController?.trigger(n)}constructor(){super();this.history=[];this.riskLevel="MEDIUM_RISK";this.rowCount=12;this.ballsInFlight=0;new j1(this,[{key:" ",callback:()=>i2.clickBetButton(this.manualOrAuto,this._plinkoManualEl,this._plinkoAutoEl),options:{repeat:!0,repeatInterval:200,disabled:()=>{if(!this.gameData?.hotkeysOpenEnabled)return!0;return i2.isBetButtonDisabled(this.manualOrAuto,this._plinkoManualEl,this._plinkoAutoEl)}}}])}get binMultipliers(){return K0(this.gameData.edge,this.riskLevel,this.rowCount)}async handleBetExecution(a){if(!this.gameData?.currency)return{success:!1,error:R("alerts.gameError",this.gameData?.language||$)};let i=O(this.gameData.balance);try{if(this.isDemoMode&&i.lt(a))throw new Error(R("alerts.insufficientBalance",this.gameData?.language||$));this.gameData.updateBalance(i.minus(a));let e=await this.plinkoApi.startBet({language:this.gameData.language,currency:this.gameData.currency,amount:a,riskLevel:this.riskLevel,rowCount:this.rowCount});if(e.success){let{data:r}=e,l=Number(r.multiplier),t=r.betActions.filter((d)=>d.data?.PLINKO)[1]?.data?.PLINKO,o=(t&&"result"in t?t.result:[]).reduce((d,u)=>d+u,0);if(r.id)this.pendingResultsByBetId.set(r.id,{multiplier:l,payout:r.payout?O(r.payout):O(0)});if(this.updateHistoryWithBet(r),this.gameData.instantBetEnabled)this._plinkoContentEl?.triggerInstantResult?.(this.gameData.edge,l,r.id);else this._plinkoContentEl?.dropBallForResult(o,r.id);return e}else throw new Error(e.error)}catch(e){this.gameData.updateBalance(i);let r=e instanceof Error?e.message:R("alerts.gameError",this.gameData?.language||$);return this.showError(r),{success:!1,error:r}}}async queuedBetExecution(a){try{return await this.betQueue.enqueue(a)}catch(i){return{success:!1,error:i instanceof Error?i.message:R("errors.requestDropped",this.gameData?.language||$)}}}async plinkoPlay(){this.gameData?.soundController?.play("bet"),await this.queuedBetExecution(this.gameData?.betAmount??"0")}async executeAutobet(a,i){let e=await this.handleBetExecution(i);if(!e.success)return{pnl:O(0),gameOutcome:"Draw",hasError:!0,errorMessage:e.error||R("alerts.errorProcessingBet",this.gameData?.language||$)};let{data:r}=e,l=O(r.payout??0).minus(r.amount??0),n=D1(Number(r.multiplier));return{pnl:l,gameOutcome:n,hasError:!1}}resolveMultiplierAndWin(a){let i=a.detail.id;if(this.pendingResultsByBetId.has(i)){let e=this.pendingResultsByBetId.get(i),r=e.multiplier,l=e.payout;this.pendingResultsByBetId.delete(i);let n=O(r).gt(1),t=n?O0[this.rowCount].background[za(this.gameData.edge,r,this.rowCount,this.riskLevel)]:void 0;return this.history=[...this.history,{multiplier:r,won:n,id:i,payout:l.toString(),color:t}],{multiplier:r,hasWon:n,betId:i,payout:l}}return console.error(`No pending result found for betId: ${i}`),{multiplier:1,hasWon:!1,betId:i,payout:O(0)}}_getPitchFromMultiplier(a){let i=Math.min(...this.binMultipliers),e=Math.max(...this.binMultipliers);return 1+(a-i)/(e-i||1)*0.5}playResultSound(a){let i=this._getPitchFromMultiplier(a);this.gameData?.soundController?.play("plinko-drop",void 0,i)}handleBinHit(a){let{multiplier:i,payout:e}=this.resolveMultiplierAndWin(a);this.gameData?.updateBalance(O(this.gameData.balance).plus(e)),this.triggerBinHaptic(i),this.playResultSound(i)}render(){let a=this.gameData?.mainWidth>=768,i=Math.max(...this.binMultipliers)||1,e=$1(this.gameData);return Z`
|
|
12049
12049
|
<origami-game-layout style=${e} .gameType=${"PLINKO"} data-is-desktop=${a}>
|
|
12050
12050
|
<origami-game-sidebar
|
|
12051
12051
|
slot="control-panel"
|