@betorigami/games 0.7.9 → 0.7.11
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 +10 -11
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4403,9 +4403,7 @@ Please use the static 'html' tag function. See https://lit.dev/docs/templates/ex
|
|
|
4403
4403
|
}
|
|
4404
4404
|
|
|
4405
4405
|
:host([data-is-desktop='true']) {
|
|
4406
|
-
:host {
|
|
4407
4406
|
aspect-ratio: auto;
|
|
4408
|
-
}
|
|
4409
4407
|
}
|
|
4410
4408
|
|
|
4411
4409
|
.keno-tile,
|
|
@@ -4501,9 +4499,7 @@ Please use the static 'html' tag function. See https://lit.dev/docs/templates/ex
|
|
|
4501
4499
|
}
|
|
4502
4500
|
|
|
4503
4501
|
:host([data-is-desktop='true']) {
|
|
4504
|
-
:host {
|
|
4505
4502
|
--keno-tile-radius: 8px;
|
|
4506
|
-
}
|
|
4507
4503
|
|
|
4508
4504
|
.keno-tile,
|
|
4509
4505
|
.rear-button {
|
|
@@ -4703,11 +4699,9 @@ Please use the static 'html' tag function. See https://lit.dev/docs/templates/ex
|
|
|
4703
4699
|
.keno-grid {
|
|
4704
4700
|
gap: 12px;
|
|
4705
4701
|
}
|
|
4706
|
-
:host {
|
|
4707
4702
|
background-color: #272727;
|
|
4708
4703
|
padding: 12px;
|
|
4709
4704
|
border-radius: 10px;
|
|
4710
|
-
}
|
|
4711
4705
|
}
|
|
4712
4706
|
|
|
4713
4707
|
@container (min-width: 1200px) {
|
|
@@ -4715,13 +4709,14 @@ Please use the static 'html' tag function. See https://lit.dev/docs/templates/ex
|
|
|
4715
4709
|
gap: 12px;
|
|
4716
4710
|
}
|
|
4717
4711
|
}
|
|
4718
|
-
`;class y5 extends E{constructor(){super(...arguments);this.selectedTiles=[];this.resultTiles=[];this.popupShowing=!1;this.isPlaying=!1;this.gameOver=!1;this.autoselectRunning=!1;this.enableSounds=!0;this.ariaLabel="Keno Game Grid"}static styles=[r,E6];get selectedCount(){return this.selectedTiles.length}get hitCount(){return this.selectedTiles.filter((d)=>this.resultTiles.includes(d)).length}calculateTileState(d){let o=this.selectedTiles.includes(d),h=this.resultTiles.includes(d);if(this.isPlaying||this.gameOver){if(o&&h)return"WIN";if(h&&!o)return"LOSS";if(o)return"SELECTED";return"NORMAL"}if(o)return"SELECTED";return"NORMAL"}render(){let d=Array.from({length:40},(o,h)=>h+1);return l`
|
|
4712
|
+
`;class y5 extends E{constructor(){super(...arguments);this.selectedTiles=[];this.resultTiles=[];this.popupShowing=!1;this.isPlaying=!1;this.gameOver=!1;this.autoselectRunning=!1;this.enableSounds=!0;this.ariaLabel="Keno Game Grid";this.isDesktop=!1}static styles=[r,E6];get selectedCount(){return this.selectedTiles.length}get hitCount(){return this.selectedTiles.filter((d)=>this.resultTiles.includes(d)).length}calculateTileState(d){let o=this.selectedTiles.includes(d),h=this.resultTiles.includes(d);if(this.isPlaying||this.gameOver){if(o&&h)return"WIN";if(h&&!o)return"LOSS";if(o)return"SELECTED";return"NORMAL"}if(o)return"SELECTED";return"NORMAL"}render(){let d=Array.from({length:40},(o,h)=>h+1);return l`
|
|
4719
4713
|
<div
|
|
4720
4714
|
class=${d0({"keno-grid":!0,inactive:this.isPlaying,autoselecting:this.autoselectRunning})}
|
|
4721
4715
|
@click=${()=>this.emit("keno-grid-click")}
|
|
4722
4716
|
>
|
|
4723
4717
|
${d.map((o)=>{let h=this.calculateTileState(o);return l`
|
|
4724
4718
|
<origami-keno-tile
|
|
4719
|
+
data-is-desktop=${this.isDesktop}
|
|
4725
4720
|
?dimmed=${!this.isPlaying&&this.selectedCount===10&&!this.selectedTiles.includes(o)||this.isPlaying&&!this.selectedTiles.includes(o)||this.popupShowing}
|
|
4726
4721
|
?disabled=${this.isPlaying}
|
|
4727
4722
|
.number=${o}
|
|
@@ -4729,7 +4724,7 @@ Please use the static 'html' tag function. See https://lit.dev/docs/templates/ex
|
|
|
4729
4724
|
></origami-keno-tile>
|
|
4730
4725
|
`})}
|
|
4731
4726
|
</div>
|
|
4732
|
-
`}}Z([V({type:Array})],y5.prototype,"selectedTiles",void 0),Z([V({type:Array})],y5.prototype,"resultTiles",void 0),Z([V({type:Boolean})],y5.prototype,"popupShowing",void 0),Z([V({type:Boolean,reflect:!0})],y5.prototype,"isPlaying",void 0),Z([V({type:Boolean,reflect:!0})],y5.prototype,"gameOver",void 0),Z([V({type:Boolean})],y5.prototype,"autoselectRunning",void 0),Z([P()],y5.prototype,"enableSounds",void 0),Z([V({type:String,attribute:"aria-label"})],y5.prototype,"ariaLabel",void 0),y5=Z([y("origami-keno-grid")],y5);var r6=["mines","limbo","dice","keno"];class p5 extends _0{constructor(){super(...arguments);this.gameType="mines";this.inBetResultModal=!1}static styles=[r,T6];render(){switch(this.gameType){case"mines":return l`
|
|
4727
|
+
`}}Z([V({type:Array})],y5.prototype,"selectedTiles",void 0),Z([V({type:Array})],y5.prototype,"resultTiles",void 0),Z([V({type:Boolean})],y5.prototype,"popupShowing",void 0),Z([V({type:Boolean,reflect:!0})],y5.prototype,"isPlaying",void 0),Z([V({type:Boolean,reflect:!0})],y5.prototype,"gameOver",void 0),Z([V({type:Boolean})],y5.prototype,"autoselectRunning",void 0),Z([P()],y5.prototype,"enableSounds",void 0),Z([V({type:String,attribute:"aria-label"})],y5.prototype,"ariaLabel",void 0),Z([V({type:Boolean})],y5.prototype,"isDesktop",void 0),y5=Z([y("origami-keno-grid")],y5);var r6=["mines","limbo","dice","keno"];class p5 extends _0{constructor(){super(...arguments);this.gameType="mines";this.inBetResultModal=!1}static styles=[r,T6];render(){switch(this.gameType){case"mines":return l`
|
|
4733
4728
|
<origami-mines-grid .minesState=${{selectedTiles:this.minesData?.selectedTiles||[1,12,13],state:"VIEWING_RESULTS",mineLocations:this.minesData?.mineLocations||[1,2,3,5,6]}}></origami-mines-grid>
|
|
4734
4729
|
`;case"limbo":return l`
|
|
4735
4730
|
<origami-limbo-multiplier
|
|
@@ -6865,7 +6860,7 @@ Please use the static 'html' tag function. See https://lit.dev/docs/templates/ex
|
|
|
6865
6860
|
}
|
|
6866
6861
|
}
|
|
6867
6862
|
|
|
6868
|
-
`;class i3 extends E{constructor(){super(...arguments);this.selectedTiles=[];this.resultTiles=[];this.isPlaying=!1;this.gameOver=!1;this.multipliersForSelectedTiles=0;this.payout=null;this.gameWinPopupShowing=!1;this.multiplier=0;this.risk=e.CLASSIC;this.betAmount="0";this.autoselectRunning=!1}static styles=[r,Z4];get hitCount(){return this.selectedTiles.filter((d)=>this.resultTiles.includes(d)).length}render(){return l`
|
|
6863
|
+
`;class i3 extends E{constructor(){super(...arguments);this.selectedTiles=[];this.resultTiles=[];this.isPlaying=!1;this.gameOver=!1;this.multipliersForSelectedTiles=0;this.payout=null;this.gameWinPopupShowing=!1;this.multiplier=0;this.risk=e.CLASSIC;this.betAmount="0";this.autoselectRunning=!1;this.isDesktop=!1}static styles=[r,Z4];get hitCount(){return this.selectedTiles.filter((d)=>this.resultTiles.includes(d)).length}render(){return l`
|
|
6869
6864
|
<div
|
|
6870
6865
|
class=${d0({container:!0})}
|
|
6871
6866
|
>
|
|
@@ -6879,6 +6874,8 @@ Please use the static 'html' tag function. See https://lit.dev/docs/templates/ex
|
|
|
6879
6874
|
.betId=${this.betId}
|
|
6880
6875
|
></origami-game-win-popup>`:u}
|
|
6881
6876
|
<origami-keno-grid
|
|
6877
|
+
data-is-desktop=${this.isDesktop}
|
|
6878
|
+
.isDesktop=${this.isDesktop}
|
|
6882
6879
|
.selectedTiles=${this.selectedTiles}
|
|
6883
6880
|
.resultTiles=${this.resultTiles}
|
|
6884
6881
|
?isPlaying=${this.isPlaying}
|
|
@@ -6889,6 +6886,7 @@ Please use the static 'html' tag function. See https://lit.dev/docs/templates/ex
|
|
|
6889
6886
|
|
|
6890
6887
|
<origami-keno-content-bottom
|
|
6891
6888
|
class="hidden-on-mobile"
|
|
6889
|
+
data-is-desktop=${this.isDesktop}
|
|
6892
6890
|
.selectedTiles=${this.selectedTiles}
|
|
6893
6891
|
.risk=${this.risk}
|
|
6894
6892
|
.betAmount=${this.betAmount}
|
|
@@ -6897,7 +6895,7 @@ Please use the static 'html' tag function. See https://lit.dev/docs/templates/ex
|
|
|
6897
6895
|
.multipliersForSelectedTiles=${this.multipliersForSelectedTiles}
|
|
6898
6896
|
></origami-keno-content-bottom>
|
|
6899
6897
|
</div>
|
|
6900
|
-
`}}Z([V({type:Array})],i3.prototype,"selectedTiles",void 0),Z([V({type:Array})],i3.prototype,"resultTiles",void 0),Z([V({type:Boolean})],i3.prototype,"isPlaying",void 0),Z([V({type:Boolean})],i3.prototype,"gameOver",void 0),Z([V({type:Number})],i3.prototype,"multipliersForSelectedTiles",void 0),Z([V({type:Object})],i3.prototype,"payout",void 0),Z([V({type:Boolean})],i3.prototype,"gameWinPopupShowing",void 0),Z([V({type:Number})],i3.prototype,"multiplier",void 0),Z([V({type:String})],i3.prototype,"risk",void 0),Z([V({type:String})],i3.prototype,"betAmount",void 0),Z([V({type:String})],i3.prototype,"betId",void 0),Z([V({type:Boolean})],i3.prototype,"autoselectRunning",void 0),i3=Z([y("origami-keno-content")],i3);var C2=10,$4=40;class z3{authToken;baseUrl;constructor(d,o){this.authToken=d,this.baseUrl=o+"/games/keno"}async startBet(d){try{let h=await(await fetch(`${this.baseUrl}/play`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.authToken}`},body:JSON.stringify(d)})).json();if(!h.id)throw new Error("Unknown error");return{success:!0,data:h}}catch(o){return{success:!1,error:o?.message||"Unknown Error"}}}}var r8={[e.LOW_RISK]:10,[e.MEDIUM_RISK]:8,[e.CLASSIC]:8,[e.HIGH_RISK]:5},u8={[e.LOW_RISK]:{min:1.2,max:2.5},[e.MEDIUM_RISK]:{min:1.5,max:5},[e.HIGH_RISK]:{min:2,max:10},[e.CLASSIC]:{min:2,max:10}};class o2{static generateRandomTiles(d,o=[]){let h=Array.from({length:$4},(f,w)=>w+1).filter((f)=>!o.includes(f));return[...h].sort(()=>0.5-Math.random()).slice(0,Math.min(d,h.length))}static calculateMultiplier(d,o,h){let f=d.filter((g)=>o.includes(g)).length,{min:w,max:b}=u8[h],x=f===0?0:w+f/d.length*(b-w);return Number.parseFloat(x.toFixed(2))}startBet=async(d)=>{let{amount:o,riskLevel:h,selectedTiles:f}=d,w=o2.generateRandomTiles(r8[h]),b=o2.calculateMultiplier(f,w,h),x=M(o).multipliedBy(b).toString(),g={id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",usdRate:1,gameId:"keno",currency:"USDC",edge:0.01,amount:o,payout:x,afterBalance:"1000",maxPayoutReached:!1,multiplier:b,clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:"1",completedAt:new Date().toISOString(),actions:[{id:crypto.randomUUID(),data:{keno:{selectedTiles:f,resultTiles:w,multiplier:b,riskLevel:h}},type:"END_BET",actionIndex:0,originalActionId:null,betAmount:o,payoutAmount:x}]};return await H0(250),{success:!0,data:g}}}class S2 extends i1{get isToggleDisabled(){return this.autobetInProgress||this.isManualPlaying||this.autoselectRunning}get areInputsDisabled(){return this.autobetInProgress||this.isManualPlaying||this.autoselectRunning}get kenoApi(){return!!this.gameData.authToken&&!!this.gameData.baseUrl?new z3(this.gameData.authToken,this.gameData.baseUrl):new o2}async kenoPlay(){if(this.gameWinPopupShowing=!1,this.selectedTiles.length===0){alert("Please select at least one tile");return}this.gameData?.soundController?.play("bet").catch((d)=>console.error(d)),this.isManualPlaying=!0,this.resultTiles=[],this.gameOver=!1;try{let d=await this.handleBetExecution(this.gameData?.amount??"0",this.getDelay(200));if(!d.success){console.error(d.error);return}this.betId=d.data.id}catch(d){console.error("Error in kenoPlay:",d)}finally{this.isManualPlaying=!1,this.gameOver=!0}}async handleBetExecution(d,o){if(!this.gameData?.currency)throw new Error("Currency is not set");let h={amount:d,currency:this.gameData.currency,riskLevel:this.kenoRisk,selectedTiles:this.selectedTiles},f=await this.kenoApi.startBet(h);if(f.success){let{actions:w}=f.data,b=w[w.length-1]?.data.keno;if(!b)throw new Error("No keno data found");if(this.multiplier=f.data.multiplier,await this.executeInstantOrAnimated(async()=>{b.resultTiles.forEach((x)=>{if(this.selectedTiles.includes(x))this.gameData?.soundController?.play("keno-gem").catch((g)=>console.error(g));else this.gameData?.soundController?.play("secondary").catch((g)=>console.error(g))}),this.resultTiles=[...b.resultTiles]},async()=>{for(let x of b.resultTiles){if(this.selectedTiles.includes(x))this.gameData?.soundController?.play("keno-gem").catch((g)=>console.error(g));else this.gameData?.soundController?.play("secondary").catch((g)=>console.error(g));this.resultTiles=[...this.resultTiles,x],await H0(o)}}),this.gameWinPopupShowing=M(f.data.multiplier).isGreaterThan(0),this.gameWinPopupShowing)this.gameData?.soundController?.play("win").catch((x)=>console.error(x));this.payout=M(f.data.payout),this.addToHistory(M(f.data.multiplier).toNumber(),this.gameWinPopupShowing),this.emit("balance-change",{detail:{balance:Number(f.data.afterBalance),currency:this.gameData.currency}})}return f}addToHistory(d,o){let h=[...this.history,{multiplier:d,won:o}];this.history=h.slice(-5)}async executeAutobet(d,o){try{if(!this.gameData?.currency)throw new Error("Currency is not set");if(this.resultTiles=[],this.gameOver=!1,this.gameWinPopupShowing=!1,this.gameData?.instantBetEnabled)await this.forceUIUpdate();if(this.selectedTiles.length===0)return{pnl:M(0),gameOutcome:"Draw",hasError:!0,errorMessage:"Please select at least one tile"};let h={amount:o,currency:this.gameData.currency,riskLevel:this.kenoRisk,selectedTiles:this.selectedTiles},f=await this.kenoApi.startBet(h);if(!f.success)return{pnl:M(0),gameOutcome:"Draw",hasError:!0,errorMessage:f.error||"Error processing bet"};this.multiplier=f.data.multiplier;let w=f.data,b=M(w.payout).minus(w.amount),x=W1(w.multiplier),g=w.actions,i=g[g.length-1]?.data.keno;if(!i)throw new Error("No keno data found");if(await this.executeInstantOrAnimated(async()=>{i.resultTiles.forEach(($)=>{if(this.selectedTiles.includes($))this.gameData?.soundController?.play("keno-gem").catch((X)=>console.error(X));else this.gameData?.soundController?.play("secondary").catch((X)=>console.error(X))}),this.resultTiles=[...i.resultTiles]},async()=>{for(let $ of i.resultTiles){if(this.selectedTiles.includes($))this.gameData?.soundController?.play("keno-gem").catch((X)=>console.error(X));else this.gameData?.soundController?.play("secondary").catch((X)=>console.error(X));this.resultTiles=[...this.resultTiles,$],await H0(this.getDelay(200))}}),this.gameWinPopupShowing=M(w.multiplier).isGreaterThan(0),this.gameWinPopupShowing)this.gameData?.soundController?.play("win").catch(($)=>console.error($));if(this.payout=M(w.payout),this.addToHistory(w.multiplier,this.gameWinPopupShowing),await this.ensureMinimumDisplayTime(this.gameWinPopupShowing,500,500),!this.gameData?.instantBetEnabled)await H0(this.getDelay(500));return this.gameWinPopupShowing=!1,this.emit("balance-change",{detail:{balance:Number(f.data.afterBalance),currency:this.gameData.currency}}),{pnl:b,gameOutcome:x,hasError:!1}}catch(h){return console.error("Error in executeAutobet:",h),{pnl:M(0),gameOutcome:"Draw",hasError:!0,errorMessage:"An unexpected error occurred"}}finally{this.gameOver=!0}}handleTileClick=(d)=>{if(this.gameOver)this.newGame();if(this.autoselectRunning)return;if(this.gameData?.soundController?.play("click").catch((h)=>console.error(h)),this.selectedTiles.includes(d.detail.tile))this.selectedTiles=this.selectedTiles.filter((h)=>h!==d.detail.tile);else if(this.selectedTiles.length<C2)this.selectedTiles=[...this.selectedTiles,d.detail.tile]};handleRiskChange=(d)=>{this.kenoRisk=d.detail.value};autoPick=async()=>{if(this.isManualPlaying||this.autoselectRunning)return;if(this.autoselectRunning=!0,this.hadTilesBeforeAutopick=this.selectedTiles.length>0,this.resultTiles=[],this.gameWinPopupShowing=!1,this.selectedTiles.length>=C2)this.selectedTiles=[];let d=C2-this.selectedTiles.length;if(d<=0)return;let h=Array.from({length:40},(b,x)=>x+1).filter((b)=>!this.selectedTiles.includes(b));if(h.length===0)return;let w=[...h].sort(()=>0.5-Math.random()).slice(0,d);await this.executeInstantOrAnimated(async()=>{this.gameData?.soundController?.play("click").catch((b)=>console.error(b)),this.selectedTiles=[...this.selectedTiles,...w]},async()=>{for(let b of w)this.gameData?.soundController?.play("click").catch((x)=>console.error(x)),await H0(this.getDelay(200)),this.selectedTiles=[...this.selectedTiles,b]}),this.autoselectRunning=!1,this.hadTilesBeforeAutopick=!1};clearTable=()=>{if(this.isManualPlaying||this.autoselectRunning)return;this.gameData?.soundController?.play("keno-clear").catch((d)=>console.error(d)),this.gameWinPopupShowing=!1,this.selectedTiles=[],this.resultTiles=[],this.payout=null};newGame=()=>{this.gameWinPopupShowing=!1,this.resultTiles=[],this.payout=null};render(){let d=this.autoselectRunning?10:this.selectedTiles.length,o=this.selectedTiles.length>0||this.autoselectRunning,h=this.gameData?.mainWidth>768;return l`
|
|
6898
|
+
`}}Z([V({type:Array})],i3.prototype,"selectedTiles",void 0),Z([V({type:Array})],i3.prototype,"resultTiles",void 0),Z([V({type:Boolean})],i3.prototype,"isPlaying",void 0),Z([V({type:Boolean})],i3.prototype,"gameOver",void 0),Z([V({type:Number})],i3.prototype,"multipliersForSelectedTiles",void 0),Z([V({type:Object})],i3.prototype,"payout",void 0),Z([V({type:Boolean})],i3.prototype,"gameWinPopupShowing",void 0),Z([V({type:Number})],i3.prototype,"multiplier",void 0),Z([V({type:String})],i3.prototype,"risk",void 0),Z([V({type:String})],i3.prototype,"betAmount",void 0),Z([V({type:String})],i3.prototype,"betId",void 0),Z([V({type:Boolean})],i3.prototype,"autoselectRunning",void 0),Z([V({type:Boolean})],i3.prototype,"isDesktop",void 0),i3=Z([y("origami-keno-content")],i3);var C2=10,$4=40;class z3{authToken;baseUrl;constructor(d,o){this.authToken=d,this.baseUrl=o+"/games/keno"}async startBet(d){try{let h=await(await fetch(`${this.baseUrl}/play`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.authToken}`},body:JSON.stringify(d)})).json();if(!h.id)throw new Error("Unknown error");return{success:!0,data:h}}catch(o){return{success:!1,error:o?.message||"Unknown Error"}}}}var r8={[e.LOW_RISK]:10,[e.MEDIUM_RISK]:8,[e.CLASSIC]:8,[e.HIGH_RISK]:5},u8={[e.LOW_RISK]:{min:1.2,max:2.5},[e.MEDIUM_RISK]:{min:1.5,max:5},[e.HIGH_RISK]:{min:2,max:10},[e.CLASSIC]:{min:2,max:10}};class o2{static generateRandomTiles(d,o=[]){let h=Array.from({length:$4},(f,w)=>w+1).filter((f)=>!o.includes(f));return[...h].sort(()=>0.5-Math.random()).slice(0,Math.min(d,h.length))}static calculateMultiplier(d,o,h){let f=d.filter((g)=>o.includes(g)).length,{min:w,max:b}=u8[h],x=f===0?0:w+f/d.length*(b-w);return Number.parseFloat(x.toFixed(2))}startBet=async(d)=>{let{amount:o,riskLevel:h,selectedTiles:f}=d,w=o2.generateRandomTiles(r8[h]),b=o2.calculateMultiplier(f,w,h),x=M(o).multipliedBy(b).toString(),g={id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",usdRate:1,gameId:"keno",currency:"USDC",edge:0.01,amount:o,payout:x,afterBalance:"1000",maxPayoutReached:!1,multiplier:b,clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:"1",completedAt:new Date().toISOString(),actions:[{id:crypto.randomUUID(),data:{keno:{selectedTiles:f,resultTiles:w,multiplier:b,riskLevel:h}},type:"END_BET",actionIndex:0,originalActionId:null,betAmount:o,payoutAmount:x}]};return await H0(250),{success:!0,data:g}}}class S2 extends i1{get isToggleDisabled(){return this.autobetInProgress||this.isManualPlaying||this.autoselectRunning}get areInputsDisabled(){return this.autobetInProgress||this.isManualPlaying||this.autoselectRunning}get kenoApi(){return!!this.gameData.authToken&&!!this.gameData.baseUrl?new z3(this.gameData.authToken,this.gameData.baseUrl):new o2}async kenoPlay(){if(this.gameWinPopupShowing=!1,this.selectedTiles.length===0){alert("Please select at least one tile");return}this.gameData?.soundController?.play("bet").catch((d)=>console.error(d)),this.isManualPlaying=!0,this.resultTiles=[],this.gameOver=!1;try{let d=await this.handleBetExecution(this.gameData?.amount??"0",this.getDelay(200));if(!d.success){console.error(d.error);return}this.betId=d.data.id}catch(d){console.error("Error in kenoPlay:",d)}finally{this.isManualPlaying=!1,this.gameOver=!0}}async handleBetExecution(d,o){if(!this.gameData?.currency)throw new Error("Currency is not set");let h={amount:d,currency:this.gameData.currency,riskLevel:this.kenoRisk,selectedTiles:this.selectedTiles},f=await this.kenoApi.startBet(h);if(f.success){let{actions:w}=f.data,b=w[w.length-1]?.data.keno;if(!b)throw new Error("No keno data found");if(this.multiplier=f.data.multiplier,await this.executeInstantOrAnimated(async()=>{b.resultTiles.forEach((x)=>{if(this.selectedTiles.includes(x))this.gameData?.soundController?.play("keno-gem").catch((g)=>console.error(g));else this.gameData?.soundController?.play("secondary").catch((g)=>console.error(g))}),this.resultTiles=[...b.resultTiles]},async()=>{for(let x of b.resultTiles){if(this.selectedTiles.includes(x))this.gameData?.soundController?.play("keno-gem").catch((g)=>console.error(g));else this.gameData?.soundController?.play("secondary").catch((g)=>console.error(g));this.resultTiles=[...this.resultTiles,x],await H0(o)}}),this.gameWinPopupShowing=M(f.data.multiplier).isGreaterThan(0),this.gameWinPopupShowing)this.gameData?.soundController?.play("win").catch((x)=>console.error(x));this.payout=M(f.data.payout),this.addToHistory(M(f.data.multiplier).toNumber(),this.gameWinPopupShowing),this.emit("balance-change",{detail:{balance:Number(f.data.afterBalance),currency:this.gameData.currency}})}return f}addToHistory(d,o){let h=[...this.history,{multiplier:d,won:o}];this.history=h.slice(-5)}async executeAutobet(d,o){try{if(!this.gameData?.currency)throw new Error("Currency is not set");if(this.resultTiles=[],this.gameOver=!1,this.gameWinPopupShowing=!1,this.gameData?.instantBetEnabled)await this.forceUIUpdate();if(this.selectedTiles.length===0)return{pnl:M(0),gameOutcome:"Draw",hasError:!0,errorMessage:"Please select at least one tile"};let h={amount:o,currency:this.gameData.currency,riskLevel:this.kenoRisk,selectedTiles:this.selectedTiles},f=await this.kenoApi.startBet(h);if(!f.success)return{pnl:M(0),gameOutcome:"Draw",hasError:!0,errorMessage:f.error||"Error processing bet"};this.multiplier=f.data.multiplier;let w=f.data,b=M(w.payout).minus(w.amount),x=W1(w.multiplier),g=w.actions,i=g[g.length-1]?.data.keno;if(!i)throw new Error("No keno data found");if(await this.executeInstantOrAnimated(async()=>{i.resultTiles.forEach(($)=>{if(this.selectedTiles.includes($))this.gameData?.soundController?.play("keno-gem").catch((X)=>console.error(X));else this.gameData?.soundController?.play("secondary").catch((X)=>console.error(X))}),this.resultTiles=[...i.resultTiles]},async()=>{for(let $ of i.resultTiles){if(this.selectedTiles.includes($))this.gameData?.soundController?.play("keno-gem").catch((X)=>console.error(X));else this.gameData?.soundController?.play("secondary").catch((X)=>console.error(X));this.resultTiles=[...this.resultTiles,$],await H0(this.getDelay(200))}}),this.gameWinPopupShowing=M(w.multiplier).isGreaterThan(0),this.gameWinPopupShowing)this.gameData?.soundController?.play("win").catch(($)=>console.error($));if(this.payout=M(w.payout),this.addToHistory(w.multiplier,this.gameWinPopupShowing),await this.ensureMinimumDisplayTime(this.gameWinPopupShowing,500,500),!this.gameData?.instantBetEnabled)await H0(this.getDelay(500));return this.gameWinPopupShowing=!1,this.emit("balance-change",{detail:{balance:Number(f.data.afterBalance),currency:this.gameData.currency}}),{pnl:b,gameOutcome:x,hasError:!1}}catch(h){return console.error("Error in executeAutobet:",h),{pnl:M(0),gameOutcome:"Draw",hasError:!0,errorMessage:"An unexpected error occurred"}}finally{this.gameOver=!0}}handleTileClick=(d)=>{if(this.gameOver)this.newGame();if(this.autoselectRunning)return;if(this.gameData?.soundController?.play("click").catch((h)=>console.error(h)),this.selectedTiles.includes(d.detail.tile))this.selectedTiles=this.selectedTiles.filter((h)=>h!==d.detail.tile);else if(this.selectedTiles.length<C2)this.selectedTiles=[...this.selectedTiles,d.detail.tile]};handleRiskChange=(d)=>{this.kenoRisk=d.detail.value};autoPick=async()=>{if(this.isManualPlaying||this.autoselectRunning)return;if(this.autoselectRunning=!0,this.hadTilesBeforeAutopick=this.selectedTiles.length>0,this.resultTiles=[],this.gameWinPopupShowing=!1,this.selectedTiles.length>=C2)this.selectedTiles=[];let d=C2-this.selectedTiles.length;if(d<=0)return;let h=Array.from({length:40},(b,x)=>x+1).filter((b)=>!this.selectedTiles.includes(b));if(h.length===0)return;let w=[...h].sort(()=>0.5-Math.random()).slice(0,d);await this.executeInstantOrAnimated(async()=>{this.gameData?.soundController?.play("click").catch((b)=>console.error(b)),this.selectedTiles=[...this.selectedTiles,...w]},async()=>{for(let b of w)this.gameData?.soundController?.play("click").catch((x)=>console.error(x)),await H0(this.getDelay(200)),this.selectedTiles=[...this.selectedTiles,b]}),this.autoselectRunning=!1,this.hadTilesBeforeAutopick=!1};clearTable=()=>{if(this.isManualPlaying||this.autoselectRunning)return;this.gameData?.soundController?.play("keno-clear").catch((d)=>console.error(d)),this.gameWinPopupShowing=!1,this.selectedTiles=[],this.resultTiles=[],this.payout=null};newGame=()=>{this.gameWinPopupShowing=!1,this.resultTiles=[],this.payout=null};render(){let d=this.autoselectRunning?10:this.selectedTiles.length,o=this.selectedTiles.length>0||this.autoselectRunning,h=this.gameData?.mainWidth>768;return l`
|
|
6901
6899
|
<origami-game-layout>
|
|
6902
6900
|
<origami-game-sidebar
|
|
6903
6901
|
data-is-desktop=${h}
|
|
@@ -6926,7 +6924,7 @@ Please use the static 'html' tag function. See https://lit.dev/docs/templates/ex
|
|
|
6926
6924
|
.autobetInProgress=${this.autobetInProgress}
|
|
6927
6925
|
slot="controls"
|
|
6928
6926
|
.autobetStopping=${this.autobetStopping}
|
|
6929
|
-
?disableBet=${this.selectedTiles.length===0
|
|
6927
|
+
?disableBet=${this.selectedTiles.length===0}
|
|
6930
6928
|
?autoselectRunning=${this.autoselectRunning}
|
|
6931
6929
|
.selectedTilesCount=${this.selectedTiles.length}
|
|
6932
6930
|
@keno-manual-play=${this.kenoPlay}
|
|
@@ -6948,6 +6946,7 @@ Please use the static 'html' tag function. See https://lit.dev/docs/templates/ex
|
|
|
6948
6946
|
|
|
6949
6947
|
<origami-keno-content
|
|
6950
6948
|
data-is-desktop=${h}
|
|
6949
|
+
.isDesktop=${h}
|
|
6951
6950
|
slot="game-area"
|
|
6952
6951
|
.selectedTiles=${this.selectedTiles}
|
|
6953
6952
|
.resultTiles=${this.resultTiles}
|