@betorigami/games 1.16.1 → 1.16.2

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.
Files changed (2) hide show
  1. package/dist/index.mjs +1 -1
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -9919,7 +9919,7 @@ var Yi=Object.create;var{getPrototypeOf:Ni,defineProperty:C6,getOwnPropertyNames
9919
9919
  grid-template-columns: 1fr 1fr 1fr;
9920
9920
  gap: 8px;
9921
9921
  }
9922
- `;class da{edge;constructor(a){this.edge=a}async startBet(a){let{amount:i,direction:e,selectedValue:r}=a,l=da.getRandomValueInRange(0,1e4),n=0;if(l>r)if(e==="ABOVE")n=O(s1.getMultiplier(this.edge,r,e)).toNumber();else n=0;else if(e==="BELOW")n=O(s1.getMultiplier(this.edge,r,e)).toNumber();else n=0;let o=O(i).mul(n).toString(),s={id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",gameId:"dice",currency:h1,amount:i,payout:o,afterBalance:"1000",multiplier:n.toString(),tenantUserId:"mock-user",clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{id:crypto.randomUUID(),data:{DICE:{direction:e,selectedValue:r}},type:"START_BET",actionIndex:0,betAmount:i,payoutAmount:"0"},{id:crypto.randomUUID(),data:{DICE:{result:[l]}},type:"END_BET",actionIndex:1,betAmount:"0",payoutAmount:o}]};return await o1(250),{success:!0,data:s}}static getRandomValueInRange(a,i){return Math.floor(Math.random()*(i-a+1))+a}}function g3(a,i){return parseFloat(a).toFixed(i)}function G1(a){return{autobetSettings:{...a,onWinPercentage:g3(a.onWinPercentage,12),onLossPercentage:g3(a.onLossPercentage,2),stopOnLoss:g3(a.stopOnLoss,8),stopOnProfit:g3(a.stopOnProfit,8),pnlSinceStart:g3(a.pnlSinceStart,8),numberOfBets:Number(a.numberOfBets)}}}class fa extends I1{static styles=[...I1.styles,oi];get isToggleDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get areInputsDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}getManualButton(){return this._diceManualEl?.shadowRoot?.querySelector("origami-button")??null}getAutobetButton(){return this._diceAutoEl?.shadowRoot?.querySelector("origami-generic-autobet")?.shadowRoot?.querySelector(".bet-btn")??null}isSpacebarDisabled=()=>{if(!this.gameData?.hotkeysOpenEnabled)return!0;if(this.manualOrAuto==="Manual")return this.getManualButton()?.disabled??!0;return this.getAutobetButton()?.disabled??!0};handleSpacebar=()=>{if(this.isSpacebarDisabled())return;if(this.manualOrAuto==="Manual")this.dicePlay();else this.getAutobetButton()?.click()};diceRollOverToggle=()=>{this.diceDirection=this.diceDirection==="ABOVE"?"BELOW":"ABOVE",this.selectedValue=s1.getSelectedValueFromRollOver(this.selectedValue)};constructor(){super();this.diceDirection="ABOVE";this.selectedValue=5000;this.isManualPlaying=!1;this.showDice=!1;this.isWin=!0;this.resultValue=null;this.history=[];this._multiplierInputValid=!0;this._winChanceInputValid=!0;new j1(this,[{key:" ",callback:this.handleSpacebar.bind(this),options:{repeat:!0,repeatInterval:200,disabled:this.isSpacebarDisabled}},{key:"q",callback:this.diceRollOverToggle.bind(this),options:{disabled:()=>this.isManualPlaying||this.autobetInProgress||this.autobetStopping||!this.gameData?.hotkeysOpenEnabled}},{key:"w",callback:this.decreaseSlider.bind(this),options:{repeat:!0,repeatInterval:200,disabled:()=>this.isManualPlaying||this.autobetInProgress||this.autobetStopping||!this.gameData?.hotkeysOpenEnabled}},{key:"e",callback:this.increaseSlider.bind(this),options:{repeat:!0,repeatInterval:200,disabled:()=>this.isManualPlaying||this.autobetInProgress||this.autobetStopping||!this.gameData?.hotkeysOpenEnabled}}])}decreaseSlider(){let a=Math.max(5,this.selectedValue-100);if(a!==this.selectedValue)this.selectedValue=a,this.gameData?.soundController?.play("dice-tick"),this.gameData?.hapticController?.lightClick()}increaseSlider(){let a=Math.min(9995,this.selectedValue+100);if(a!==this.selectedValue)this.selectedValue=a,this.gameData?.soundController?.play("dice-tick"),this.gameData?.hapticController?.lightClick()}get diceApi(){return this.isDemoMode?new da(this.gameData.edge):new s1(this.gameData.authToken,this.gameData.baseUrl??"")}async dicePlay(){this.isManualPlaying=!0,this.showDice=!1,this.gameData?.soundController?.play("bet").catch((a)=>console.error(a));try{let a=await this.handleBetExecution(this.gameData.betAmount);if(!a.success)console.error(a.error)}catch(a){console.error("Error in dicePlay:",a)}finally{this.isManualPlaying=!1}}async handleBetExecution(a,i){if(!this.gameData.currency)throw new Error(F("alerts.gameError",this.gameData?.language||D));let e={language:this.gameData.language,amount:a,currency:this.gameData.currency,direction:this.diceDirection,selectedValue:this.selectedValue,meta:i?G1(i):void 0},r;if(this.isDemoMode&&O(this.gameData.balance).lt(e.amount))r={success:!1,error:F("alerts.insufficientBalance",this.gameData?.language||"en")};else r=await this.diceApi.startBet(e);if(r.success){if(!this.gameData.instantBetEnabled)this.gameData.soundController?.play("dice-roll").catch((d)=>{console.error("Failed to play sound:",d)});let l=this.isDemoMode?O(this.gameData.balance).minus(r.data.amount??0).plus(r.data.payout??0):O(r.data.afterBalance??0);this.gameData.updateBalance(l),this.showDice=!0;let{betActions:n}=r.data,o=n[n.length-1];if(!o)throw new Error("No action data received");let{result:s}=o.data.DICE,t=s[0];if(this.resultValue=t,!this.gameData.instantBetEnabled)this.gameData?.hapticController?.trigger([10,20,30,40,30,20,10]);if(this.isWin=this.diceDirection==="ABOVE"?t>this.selectedValue:t<this.selectedValue,this.isWin)setTimeout(()=>{this.playSeasonalWin()},300);this.addToHistory(t/100,this.isWin,r.data.id??""),this.updateHistoryWithBet(r.data)}else this.showError(r.error);return r}addToHistory(a,i,e){this.history=[...this.history,{multiplier:a,won:i,id:e}]}async executeAutobet(a,i){try{let e=await this.handleBetExecution(i,a);if(!e.success)return{pnl:O(0),gameOutcome:"Draw",hasError:!0,errorMessage:e.error||F("alerts.gameError",this.gameData?.language||D)};let r=e.data;this.updateHistoryWithBet(r);let l=O(r.payout??0).minus(r.amount??0),n=W1(Number(r.multiplier)),o=this.isWin;return await this.ensureMinimumDisplayTime(o,300,300),await o1(this.getAutobetDelay()),{pnl:l,gameOutcome:n,hasError:!1}}catch(e){return console.error("Error in executeAutobet:",e),{pnl:O(0),gameOutcome:"Draw",hasError:!0,errorMessage:F("alerts.gameError",this.gameData?.language||D)}}}render(){let a=O(s1.getMultiplier(this.gameData.edge,this.selectedValue,this.diceDirection)).mul(this.gameData.betAmount).minus(this.gameData.betAmount).toFixed(4),i=s1.getMultiplier(this.gameData.edge,this.selectedValue,this.diceDirection),e=!this._multiplierInputValid||!this._winChanceInputValid||!s1.isValidMultiplier(this.gameData.edge,i.toString()),r=this.gameData.mainWidth>=768,l=D1(this.gameData);return Z`
9922
+ `;class da{edge;constructor(a){this.edge=a}async startBet(a){let{amount:i,direction:e,selectedValue:r}=a,l=da.getRandomValueInRange(0,1e4),n=0;if(l>r)if(e==="ABOVE")n=O(s1.getMultiplier(this.edge,r,e)).toNumber();else n=0;else if(e==="BELOW")n=O(s1.getMultiplier(this.edge,r,e)).toNumber();else n=0;let o=O(i).mul(n).toString(),s={id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",gameId:"dice",currency:h1,amount:i,payout:o,afterBalance:"1000",multiplier:n.toString(),tenantUserId:"mock-user",clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{id:crypto.randomUUID(),data:{DICE:{direction:e,selectedValue:r}},type:"START_BET",actionIndex:0,betAmount:i,payoutAmount:"0"},{id:crypto.randomUUID(),data:{DICE:{result:[l]}},type:"END_BET",actionIndex:1,betAmount:"0",payoutAmount:o}]};return await o1(250),{success:!0,data:s}}static getRandomValueInRange(a,i){return Math.floor(Math.random()*(i-a+1))+a}}function g3(a,i){return parseFloat(a).toFixed(i)}function G1(a){return{autobetSettings:{...a,onWinPercentage:g3(a.onWinPercentage,2),onLossPercentage:g3(a.onLossPercentage,2),stopOnLoss:g3(a.stopOnLoss,8),stopOnProfit:g3(a.stopOnProfit,8),pnlSinceStart:g3(a.pnlSinceStart,8),numberOfBets:Number(a.numberOfBets)}}}class fa extends I1{static styles=[...I1.styles,oi];get isToggleDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get areInputsDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}getManualButton(){return this._diceManualEl?.shadowRoot?.querySelector("origami-button")??null}getAutobetButton(){return this._diceAutoEl?.shadowRoot?.querySelector("origami-generic-autobet")?.shadowRoot?.querySelector(".bet-btn")??null}isSpacebarDisabled=()=>{if(!this.gameData?.hotkeysOpenEnabled)return!0;if(this.manualOrAuto==="Manual")return this.getManualButton()?.disabled??!0;return this.getAutobetButton()?.disabled??!0};handleSpacebar=()=>{if(this.isSpacebarDisabled())return;if(this.manualOrAuto==="Manual")this.dicePlay();else this.getAutobetButton()?.click()};diceRollOverToggle=()=>{this.diceDirection=this.diceDirection==="ABOVE"?"BELOW":"ABOVE",this.selectedValue=s1.getSelectedValueFromRollOver(this.selectedValue)};constructor(){super();this.diceDirection="ABOVE";this.selectedValue=5000;this.isManualPlaying=!1;this.showDice=!1;this.isWin=!0;this.resultValue=null;this.history=[];this._multiplierInputValid=!0;this._winChanceInputValid=!0;new j1(this,[{key:" ",callback:this.handleSpacebar.bind(this),options:{repeat:!0,repeatInterval:200,disabled:this.isSpacebarDisabled}},{key:"q",callback:this.diceRollOverToggle.bind(this),options:{disabled:()=>this.isManualPlaying||this.autobetInProgress||this.autobetStopping||!this.gameData?.hotkeysOpenEnabled}},{key:"w",callback:this.decreaseSlider.bind(this),options:{repeat:!0,repeatInterval:200,disabled:()=>this.isManualPlaying||this.autobetInProgress||this.autobetStopping||!this.gameData?.hotkeysOpenEnabled}},{key:"e",callback:this.increaseSlider.bind(this),options:{repeat:!0,repeatInterval:200,disabled:()=>this.isManualPlaying||this.autobetInProgress||this.autobetStopping||!this.gameData?.hotkeysOpenEnabled}}])}decreaseSlider(){let a=Math.max(5,this.selectedValue-100);if(a!==this.selectedValue)this.selectedValue=a,this.gameData?.soundController?.play("dice-tick"),this.gameData?.hapticController?.lightClick()}increaseSlider(){let a=Math.min(9995,this.selectedValue+100);if(a!==this.selectedValue)this.selectedValue=a,this.gameData?.soundController?.play("dice-tick"),this.gameData?.hapticController?.lightClick()}get diceApi(){return this.isDemoMode?new da(this.gameData.edge):new s1(this.gameData.authToken,this.gameData.baseUrl??"")}async dicePlay(){this.isManualPlaying=!0,this.showDice=!1,this.gameData?.soundController?.play("bet").catch((a)=>console.error(a));try{let a=await this.handleBetExecution(this.gameData.betAmount);if(!a.success)console.error(a.error)}catch(a){console.error("Error in dicePlay:",a)}finally{this.isManualPlaying=!1}}async handleBetExecution(a,i){if(!this.gameData.currency)throw new Error(F("alerts.gameError",this.gameData?.language||D));let e={language:this.gameData.language,amount:a,currency:this.gameData.currency,direction:this.diceDirection,selectedValue:this.selectedValue,meta:i?G1(i):void 0},r;if(this.isDemoMode&&O(this.gameData.balance).lt(e.amount))r={success:!1,error:F("alerts.insufficientBalance",this.gameData?.language||"en")};else r=await this.diceApi.startBet(e);if(r.success){if(!this.gameData.instantBetEnabled)this.gameData.soundController?.play("dice-roll").catch((d)=>{console.error("Failed to play sound:",d)});let l=this.isDemoMode?O(this.gameData.balance).minus(r.data.amount??0).plus(r.data.payout??0):O(r.data.afterBalance??0);this.gameData.updateBalance(l),this.showDice=!0;let{betActions:n}=r.data,o=n[n.length-1];if(!o)throw new Error("No action data received");let{result:s}=o.data.DICE,t=s[0];if(this.resultValue=t,!this.gameData.instantBetEnabled)this.gameData?.hapticController?.trigger([10,20,30,40,30,20,10]);if(this.isWin=this.diceDirection==="ABOVE"?t>this.selectedValue:t<this.selectedValue,this.isWin)setTimeout(()=>{this.playSeasonalWin()},300);this.addToHistory(t/100,this.isWin,r.data.id??""),this.updateHistoryWithBet(r.data)}else this.showError(r.error);return r}addToHistory(a,i,e){this.history=[...this.history,{multiplier:a,won:i,id:e}]}async executeAutobet(a,i){try{let e=await this.handleBetExecution(i,a);if(!e.success)return{pnl:O(0),gameOutcome:"Draw",hasError:!0,errorMessage:e.error||F("alerts.gameError",this.gameData?.language||D)};let r=e.data;this.updateHistoryWithBet(r);let l=O(r.payout??0).minus(r.amount??0),n=W1(Number(r.multiplier)),o=this.isWin;return await this.ensureMinimumDisplayTime(o,300,300),await o1(this.getAutobetDelay()),{pnl:l,gameOutcome:n,hasError:!1}}catch(e){return console.error("Error in executeAutobet:",e),{pnl:O(0),gameOutcome:"Draw",hasError:!0,errorMessage:F("alerts.gameError",this.gameData?.language||D)}}}render(){let a=O(s1.getMultiplier(this.gameData.edge,this.selectedValue,this.diceDirection)).mul(this.gameData.betAmount).minus(this.gameData.betAmount).toFixed(4),i=s1.getMultiplier(this.gameData.edge,this.selectedValue,this.diceDirection),e=!this._multiplierInputValid||!this._winChanceInputValid||!s1.isValidMultiplier(this.gameData.edge,i.toString()),r=this.gameData.mainWidth>=768,l=D1(this.gameData);return Z`
9923
9923
  <origami-game-layout style=${l} .gameType=${"DICE"} data-is-desktop=${r}
9924
9924
  @dice-selected-value-change=${(n)=>{this.selectedValue=n.detail.selectedValue}}
9925
9925
  @dice-multiplier-input-change=${(n)=>{this._multiplierInputValid=s1.isValidMultiplier(this.gameData.edge,n.detail.multiplier)}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betorigami/games",
3
- "version": "1.16.1",
3
+ "version": "1.16.2",
4
4
  "author": "",
5
5
  "license": "UNLICENSED",
6
6
  "description": "",