@betorigami/games 1.22.8 → 1.22.9
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 +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -11565,7 +11565,7 @@ var R7=Object.create;var{getPrototypeOf:I7,defineProperty:n4,getOwnPropertyNames
|
|
|
11565
11565
|
height: 100%;
|
|
11566
11566
|
}
|
|
11567
11567
|
`;class Ke extends F1{static styles=[...F1.styles,_6];constructor(){super();this.isManualPlaying=!1;this.resultGems=null;new L1(this,[{key:" ",callback:()=>y1.clickBetButton(this.manualOrAuto,this._diamondsManualEl,this._diamondsAutoEl),options:{repeat:!0,repeatInterval:200,disabled:()=>{if(!this.gameData?.hotkeysOpenEnabled)return!0;return y1.isBetButtonDisabled(this.manualOrAuto,this._diamondsManualEl,this._diamondsAutoEl)}}}])}get isToggleDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get diamondsApi(){return this.isDemoMode?new wr(this.gameData.edge):new vr(this.gameData.authToken,this.gameData.baseUrl)}animationCompletedPromise(){return new Promise((a)=>{let e=()=>{this.removeEventListener("diamonds-reveal-complete",e),a()};this.addEventListener("diamonds-reveal-complete",e)})}async handleBetExecution(a,e){if(this.resultGems=null,!this.gameData?.currency)return{success:!1,error:S("alerts.gameError",this.gameData?.language||A)};let i=O(this.gameData.balance);try{this.gameData.updateBalance(i.minus(a));let r;if(this.isDemoMode&&i.lt(a))r={success:!1,error:S("alerts.insufficientBalance",this.gameData?.language||A)};else r=await this.diamondsApi.startBet({amount:a,currency:this.gameData.currency,language:this.gameData.language,meta:e?U1(e):void 0});if(r.success){let{data:n}=r,t=this.animationCompletedPromise(),o=Number(n.multiplier??0),{betActions:l}=n,s=l[l.length-1];if(s?.data?.DIAMONDS){let{result:d}=s.data.DIAMONDS;this.resultGems=d}this.updateHistoryWithBet(n);let c=this.isDemoMode?O(this.gameData.balance).minus(n.amount??0).plus(n.payout??0):O(n.afterBalance??0);if(await t,this.gameData.updateBalance(c),O(o).gt(1))this.playWinFeedback();return r}else throw new Error(r.error)}catch(r){this.gameData.updateBalance(i);let n=r instanceof Error?r.message:S("alerts.gameError",this.gameData?.language||A);return this.showError(n),{success:!1,error:n}}}async diamondsManualPlay(){this.isManualPlaying=!0,await this.handleBetExecution(this.gameData?.betAmount??"0"),this.isManualPlaying=!1}async executeAutobet(a,e){let i=await this.handleBetExecution(e,a);if(!i.success)return{pnl:O(0),gameOutcome:"Draw",hasError:!0,errorMessage:i.error||S("alerts.errorProcessingBet",this.gameData?.language||A)};let r=i.data,n=O(r.payout??0).minus(r.amount??0),t=Number(r.multiplier),o=D1(t);return await h1(600),{pnl:n,gameOutcome:o,hasError:!1}}render(){let a=this.gameData?.mainWidth>=768,e=yn(this.gameData.edge),i=$1(this.gameData);return Z`
|
|
11568
|
-
<origami-game-layout style
|
|
11568
|
+
<origami-game-layout style="${i} --season-corner-display: none;" .gameType=${"DIAMONDS"} data-is-desktop=${a}>
|
|
11569
11569
|
<origami-game-sidebar
|
|
11570
11570
|
slot="control-panel"
|
|
11571
11571
|
data-is-desktop=${a}
|
|
@@ -12836,7 +12836,7 @@ var R7=Object.create;var{getPrototypeOf:I7,defineProperty:n4,getOwnPropertyNames
|
|
|
12836
12836
|
gap: 8px;
|
|
12837
12837
|
}
|
|
12838
12838
|
`;var _o=(a,e)=>{return Math.floor(Math.random()*(e-a+1))+a};class Wr{edge;constructor(a){this.edge=a}async startBet(a){let{amount:e,gameInputs:i}=a,r=_o(J0,z1),n=Ha[i.mode],t,o;if(i.mode==="ROLL_BETWEEN_TWO")t=i.firstBounds,o=i.secondBounds;else t=i.bounds;let{winChancePercent:l,isWin:s}=n.evaluateOutcome(t,o,r),c=O(l).eq(0)?O(0):O(100-this.edge).div(l).round(4),d=s?c:O(0),m=O(e).mul(d).toString(),h={id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",gameId:"ADVANCED_DICE",currency:a.currency??u1,amount:e,payout:m,afterBalance:"1000",multiplier:d.toString(),tenantUserId:"mock-user",clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{id:crypto.randomUUID(),data:{ADVANCED_DICE:i},type:"START_BET",actionIndex:0,betAmount:e,payoutAmount:null},{id:crypto.randomUUID(),data:{ADVANCED_DICE:{result:[r]}},type:"END_BET",actionIndex:1,betAmount:null,payoutAmount:m}]};return await h1(250),{success:!0,data:h}}}class $r{authToken;baseUrl;constructor(a,e){this.authToken=a,this.baseUrl=e+"/games/advanced-dice"}async startBet(a){try{let e=await fetch(`${this.baseUrl}/play`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.authToken}`,"X-Origami-Trace":q1()},body:JSON.stringify({currency:a.currency,amount:a.amount,gameInputs:a.gameInputs,meta:a.meta})}),i=await e.json();if(e.ok&&!!i.id)return{success:!0,data:i};let r="alerts.gameError";switch(i?.errorCode){case"INSUFFICIENT_BALANCE":r="alerts.insufficientBalance";break;case"LIMIT_REACHED":r="alerts.betLimitReached";break}return{success:!1,error:S(r,a.language)}}catch(e){return{success:!1,error:S("alerts.gameError",a.language)}}}}class R0 extends F1{static styles=[...F1.styles,u7];get isToggleDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get areInputsDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}static ROLL_TYPE_ORDER=["ROLL_BETWEEN","ROLL_OUTSIDE","ROLL_BETWEEN_TWO"];constructor(){super();this.isManualPlaying=!1;this.showDice=!1;this.isWin=!0;this.resultValue=null;this.history=[];this.rollType="ROLL_BETWEEN";this.bounds={lower:2500,upper:7500};this.secondBounds={lower:6250,upper:8750};this._multiplierInputValid=!0;this._winChanceInputValid=!0;this._boundsInputValid=!0;new L1(this,[{key:" ",callback:()=>y1.clickBetButton(this.manualOrAuto,this._diceManualEl,this._diceAutoEl),options:{repeat:!0,repeatInterval:200,disabled:()=>{if(!this.gameData?.hotkeysOpenEnabled)return!0;return y1.isBetButtonDisabled(this.manualOrAuto,this._diceManualEl,this._diceAutoEl)}}},{key:"q",callback:ha(()=>this.gameData,this.cycleRollType.bind(this)),options:{disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}}])}cycleRollType(){let e=(R0.ROLL_TYPE_ORDER.indexOf(this.rollType)+1)%R0.ROLL_TYPE_ORDER.length;this.handleRollTypeChange(R0.ROLL_TYPE_ORDER[e])}get advancedDiceApi(){return this.isDemoMode?new Wr(this.gameData.edge):new $r(this.gameData.authToken,this.gameData.baseUrl)}buildGameInputs(){switch(this.rollType){case"ROLL_BETWEEN":return{mode:"ROLL_BETWEEN",bounds:this.bounds};case"ROLL_OUTSIDE":return{mode:"ROLL_OUTSIDE",bounds:this.bounds};case"ROLL_BETWEEN_TWO":return{mode:"ROLL_BETWEEN_TWO",firstBounds:this.bounds,secondBounds:this.secondBounds}}}calculateWinChance(){return Ha[this.rollType].calculateWinChance(this.bounds,this.secondBounds)}calculateMultiplier(){let a=this.calculateWinChance();return v1.calculateMultiplier(a,this.gameData.edge)}isValidWinChance(){let a=this.calculateWinChance(),e=v1.getMaxWinChance(this.gameData.edge,this.gameData.advancedDiceMinMultiplier);return a>=ia&&a<=e}async dicePlay(){this.isManualPlaying=!0,this.showDice=!1,await this.handleBetExecution(this.gameData.betAmount),this.isManualPlaying=!1}async handleBetExecution(a,e){if(!this.gameData.currency)throw new Error(S("alerts.gameError",this.gameData?.language||A));let i=this.buildGameInputs(),r={language:this.gameData.language,amount:a,currency:this.gameData.currency,gameInputs:i,meta:e?U1(e):void 0},n;if(this.isDemoMode&&O(this.gameData.balance).lt(r.amount))n={success:!1,error:S("alerts.insufficientBalance",this.gameData?.language||"en")};else n=await this.advancedDiceApi.startBet(r);if(n.success){if(!this.gameData.instantBetEnabled)this.gameData.soundEffects?.play(f1.diceRoll());let t=this.isDemoMode?O(this.gameData.balance).minus(n.data.amount??0).plus(n.data.payout??0):O(n.data.afterBalance??0);this.gameData.updateBalance(t),this.showDice=!0;let{betActions:o}=n.data,l=o[o.length-1];if(!l)throw new Error("No action data received");let{result:s}=l.data.ADVANCED_DICE,c=s[0];if(this.resultValue=c,this.isWin=O(n.data.multiplier??0).gt(1),this.isWin)setTimeout(()=>{this.playWinFeedback()},300);this.addToHistory(c/100,this.isWin,n.data.id??""),this.updateHistoryWithBet(n.data)}else if(!e)this.showError(n.error);return n}addToHistory(a,e,i){this.history=[...this.history,{multiplier:a,won:e,id:i}]}async executeAutobet(a,e){let i=await this.handleBetExecution(e,a);if(!i.success)return{pnl:O(0),gameOutcome:"Draw",hasError:!0,errorMessage:i.error||S("alerts.gameError",this.gameData?.language||A)};let r=i.data,n=O(r.payout??0).minus(r.amount??0),t=D1(Number(r.multiplier));return await this.ensureMinimumDisplayTime(this.isWin,300,300),await h1(this.getAutobetDelay()),{pnl:n,gameOutcome:t,hasError:!1}}handleRollTypeChange(a){this.rollType=a;let e=Jn[a];if(e.bounds)this.bounds={...e.bounds};if(e.firstBounds)this.bounds={...e.firstBounds};if(e.secondBounds)this.secondBounds={...e.secondBounds}}handleBoundsChange(a){if(this.bounds=a.detail.bounds,a.detail.secondBounds)this.secondBounds=a.detail.secondBounds}handleMultiplierInputChange(a){this._multiplierInputValid=v1.isValidMultiplier(a.detail.multiplier,this.gameData.edge,this.gameData.advancedDiceMinMultiplier)}handleWinChanceInputChange(a){this._winChanceInputValid=v1.isValidWinChance(a.detail.winChance,this.gameData.edge,this.gameData.advancedDiceMinMultiplier)}handleBoundsInputValidityChange(a){this._boundsInputValid=a.detail.isValid}render(){let a=this.calculateMultiplier(),e=O(a).mul(this.gameData.betAmount).minus(this.gameData.betAmount).toFixed(4),i=!this._multiplierInputValid||!this._winChanceInputValid||!this._boundsInputValid||!this.isValidWinChance(),r=$1(this.gameData),n=this.gameData.mainWidth>=768;return Z`
|
|
12839
|
-
<origami-game-layout style
|
|
12839
|
+
<origami-game-layout style=${r} .gameType=${"ADVANCED_DICE"} data-is-desktop=${n}>
|
|
12840
12840
|
<origami-game-sidebar
|
|
12841
12841
|
data-is-desktop=${n}
|
|
12842
12842
|
?toggleDisabled=${this.isToggleDisabled}
|