余额不足时在客户端拦截,不经过spin接口
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 2m4s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 2m4s
This commit is contained in:
parent
d6d9db5f65
commit
897f305ae3
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,9 @@ import { AutoSpinPanel } from "./game/AutoSpinPanel";
|
||||
import { NodePoolManager } from "../../Loading/scripts/manager/NodePoolManager";
|
||||
import { webView } from "./game/WebView";
|
||||
import {
|
||||
callGameBalanceApi,
|
||||
cash2gold,
|
||||
getGameId,
|
||||
getHistoryUrl,
|
||||
getOddsUrl,
|
||||
getSupportUrl,
|
||||
@ -420,6 +422,12 @@ export class SlotBar extends Component {
|
||||
this.setBet(this.betGrade[this.betIndex]);
|
||||
}
|
||||
|
||||
async onClickBalance() {
|
||||
let balacneData = await callGameBalanceApi({ GameId: getGameId() });
|
||||
this.setBalance(balacneData.Balance)
|
||||
}
|
||||
|
||||
|
||||
private currentTipTween: Tween<Node> = null;
|
||||
private hideTimer: number = null;
|
||||
showTipSmall(str: string, openTurbo?: boolean) {
|
||||
|
||||
@ -283,7 +283,7 @@ export class SlotScene extends Component {
|
||||
isFreeSpin: boolean = false,
|
||||
isFeatureBuy: boolean = false
|
||||
) {
|
||||
try {
|
||||
|
||||
this.gameState.isOnReconnect = false;
|
||||
this.isReceiveMsg = false;
|
||||
this.isErr = false;
|
||||
@ -295,6 +295,13 @@ export class SlotScene extends Component {
|
||||
if (!isFreeSpin) {
|
||||
this.slotBar.setWin(0);
|
||||
}
|
||||
if (this.slotBar.getBalance() < (isFeatureBuy ? this.slotBar.getBet() * this.gameInfo.BuyMul : this.slotBar.getBet()) && !isFreeSpin && !GameDataManager.instance.frb.Ongoing) {
|
||||
//余额不足不经过服务器,在客户端拦截
|
||||
this.showErrorTip(2, "");
|
||||
this.handleErrSpin();
|
||||
return
|
||||
}
|
||||
try {
|
||||
// 如果有frb就不会扣除金额
|
||||
let frb = GameDataManager.instance.frb;
|
||||
if (frb && frb.Ongoing != null) {
|
||||
@ -412,6 +419,7 @@ export class SlotScene extends Component {
|
||||
this.slotGame.stopScroll(this.spinData, false, null);
|
||||
this.slotGame.manualStop();
|
||||
this.slotBar.setBalance(this.spinInfo.Balance);
|
||||
this.slotBar.closeAutoSpin();
|
||||
}
|
||||
|
||||
private async handleSpinResult() {
|
||||
|
||||
@ -7,7 +7,7 @@ import { PREVIEW } from "cc/env"
|
||||
const gameId = "rp_11001";
|
||||
// let apiaddr = "https://rpgames-api.rpfafafahkdev.com";
|
||||
let apiaddr = "";
|
||||
let token = "eyJQIjoxMDA5NDksIkUiOjE3Nzk5Nzk1NzUsIlMiOjEwMDEsIkQiOiJycF8xMTAwMSJ9.zFNHlm0quBGtYIxM735w8tij2YjXvkTldJ1_rCP-oqk";
|
||||
let token = "eyJQIjoxMDA5NDksIkUiOjE3ODA5NDMxOTgsIlMiOjEwMDUsIkQiOiJycF8xMTAwMSJ9.w5qJQBglbAHpEedbpdt-XRMZjG4mxAz79ov8CuOU-GQ";
|
||||
|
||||
let language = "en"
|
||||
let currency = "THB"
|
||||
@ -100,6 +100,29 @@ AbortSignal.timeout ??= function timeout(ms) {
|
||||
return ctrl.signal
|
||||
}
|
||||
|
||||
export async function callGameBalanceApi(argsObj: any) {
|
||||
const url = apiaddr + path.join("/gameapi/getPlayerBalance")
|
||||
const payload = JSON.stringify(argsObj)
|
||||
|
||||
const res = await fetch(url, {
|
||||
signal: AbortSignal.timeout(10000),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Rp-Token": token,
|
||||
},
|
||||
method: "POST",
|
||||
body: payload,
|
||||
mode: 'cors',
|
||||
})
|
||||
|
||||
if (res.status != 200) {
|
||||
const errstr = await res.text()
|
||||
throw new Error(errstr || res.statusText)
|
||||
}
|
||||
const obj = await res.json()
|
||||
return obj
|
||||
}
|
||||
|
||||
export async function callGameApi(action: string, argsObj: any) {
|
||||
const url = apiaddr + path.join("/gameapi/", gameId, action)
|
||||
const payload = JSON.stringify(argsObj)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user