From 51cf8bd3d8110b27ef274b8da3a8f5e80b26f0ff Mon Sep 17 00:00:00 2001 From: JianMiau Date: Sat, 4 Jun 2022 13:44:55 +0800 Subject: [PATCH] [add] Slot --- deploy.sh | 25 +++++ src/script/BJ_Casino_Bot_Lobby.ts | 7 +- src/script/Common/Game/Base/SlotBase.ts | 101 +++++++++++++++--- src/script/Common/Game/Request/SlotRequest.ts | 78 ++++++++++++++ src/script/Common/Game/Slot1.ts | 19 +--- src/script/Common/Game/Slot48.ts | 13 +++ src/script/Common/Game/Slot50.ts | 11 ++ src/script/Common/Game/Slot62.ts | 35 ++++++ 8 files changed, 252 insertions(+), 37 deletions(-) create mode 100644 deploy.sh create mode 100644 src/script/Common/Game/Request/SlotRequest.ts create mode 100644 src/script/Common/Game/Slot48.ts create mode 100644 src/script/Common/Game/Slot50.ts create mode 100644 src/script/Common/Game/Slot62.ts diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..9e6a315 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +# 当发生错误时中止脚本 +set -e + +# 构建 +npm run build + +# cd 到构建输出的目录下 +cd dist + +# 部署到自定义域域名 +# echo 'www.example.com' > CNAME + +git init +git add -A +git commit -m 'deploy' + +# 部署到 https://.github.io +# git push -f git@github.com:/.github.io.git master + +# 部署到 https://.github.io/ +# git push -f git@github.com:/.git master:gh-pages + +cd - \ No newline at end of file diff --git a/src/script/BJ_Casino_Bot_Lobby.ts b/src/script/BJ_Casino_Bot_Lobby.ts index 16ce2a8..8593ff9 100644 --- a/src/script/BJ_Casino_Bot_Lobby.ts +++ b/src/script/BJ_Casino_Bot_Lobby.ts @@ -17,8 +17,8 @@ export class BJ_Casino_Bot_Lobby { ]]; public LobbyShow: Ref = ref(false); - public Lobby: Ref = ref(1); - public LobbyDefault: Ref = ref(this.LobbyCongig[1][this.Lobby.value]); + public Lobby: Ref = ref(2); + public LobbyDefault: Ref = ref(this.LobbyCongig[1][this.Lobby.value - 1]); public InputSlot: Ref = ref(""); public Slot: number; public Table: Ref = ref(0); @@ -77,7 +77,6 @@ export class BJ_Casino_Bot_Lobby { if (this.IsSlotIn.value || slot === 0 || slot == null) { return; } - hall += 1; this.IsSlotIn.value = true; let table: number = 1; let req: SeatListRequest = new SeatListRequest(hall, slot); @@ -140,7 +139,7 @@ export class BJ_Casino_Bot_Lobby { await req.SendAsync(true); let resp: INetResponse = req.Result; if (resp.IsValid) { - this._bj_Casino_Bot.AddLog(`進機台成功 slot: ${slot}, hall: ${this.LobbyDefault.value}, table: ${uid}`); + this._bj_Casino_Bot.AddLog(`進機台成功 slot: ${slot}, hall: ${this.LobbyCongig[1][hall - 1]}, table: ${uid}`); } else { switch (resp.Status) { case 11: diff --git a/src/script/Common/Game/Base/SlotBase.ts b/src/script/Common/Game/Base/SlotBase.ts index 38f00b1..b0d1dd3 100644 --- a/src/script/Common/Game/Base/SlotBase.ts +++ b/src/script/Common/Game/Base/SlotBase.ts @@ -4,13 +4,18 @@ import { BJ_Casino_Bot_Slot } from "../../../BJ_Casino_Bot_Slot"; import { INetResponse } from "../../../Engine/CatanEngine/NetManagerV2/Core/INetResponse"; import { NumberEx } from "../../../Engine/Utils/Number/NumberEx"; import { CommonSlotFgSpinRequest, CommonSlotSpinRequest } from "../Request/CommonSlotRequest"; +import { Slot_ChoiceRequest } from "../Request/SlotRequest"; export default class SlotBase { //#region public public get ID(): number { return this._bj_Casino_Bot.LobbyScript.Slot; } - public get FreeCount(): number { return this.GameRunData["free"][1]; } + public get FreeID(): number { return 1; } + public get HasChoiceFreeGame(): boolean { return false; } + public get SlotReqRespIsCount(): boolean { return false; } + public get HasRetriggerFreeSpin(): boolean { return false; } public GameRunData: JSON = null; + public ChoiceFreeCount: Object = {}; //#endregion @@ -51,26 +56,34 @@ export default class SlotBase { } else { CSMessage.NetError(resp.Method, resp.Status); } - let money: number = +gameRunData["money"]; + let money: number = gameRunData["money"] ? +gameRunData["money"] : 0; let winMoney: number = 0; let winMoneyLog: string = ""; let freeLog: string = ""; let resources: any[] = gameRunData["get"]; - let free: any[] = gameRunData["free"]; + let free: any = gameRunData["free"]; + let choiceFreeGame: boolean = gameRunData["rs"] === 0; if (resources) { - for (let i: number = 0; i < resources.length; i++) { - const resource: any[] = resources[i]; - if (resource[0] === 1) { - winMoney = resource[1]; - winMoneyLog = `, winMoney: ${winMoney}`; - break; - } - } + winMoney = this._getWinMoney(resources); + } + if (choiceFreeGame && this.HasChoiceFreeGame) { + free = true; } if (free) { - let freeCount: number = this.FreeCount; - await this.FreeSpin(freeCount); - freeLog = `, hasFree: True, free: ${freeCount}`; + let freeCount: number = await this._getFreeCount(); + let fswinMoney: number = 0; + let fsmoney: number = 0; + [freeCount, fswinMoney, fsmoney] = await this.FreeSpin(freeCount); + if (fsmoney > 0) { + money = fsmoney; + } + if (fswinMoney > 0) { + winMoney = fswinMoney; + } + freeLog = `, hasFree: ${freeCount}`; + } + if (winMoney > 0) { + winMoneyLog = `, winMoney: ${winMoney}`; } this._bj_Casino_Bot.UserData.Money = money; this._bj_Casino_Bot.SetUI(); @@ -78,7 +91,9 @@ export default class SlotBase { this._bj_Casino_Bot.AddLog(`Slot${this.ID} Spin Bet: ${this._bj_Slot.NowBet}, Money: ${money}${winMoneyLog}${freeLog}`); } - public async FreeSpin(freeCount: number): Promise { + public async FreeSpin(freeCount: number): Promise { + let fswinMoney: number = 0; + let fsmoney: number = 0; for (let i: number = 0; i < freeCount; i++) { let gameRunData: JSON = null; let req: CommonSlotFgSpinRequest = new CommonSlotFgSpinRequest(this.ID); @@ -86,11 +101,67 @@ export default class SlotBase { let resp: INetResponse = req.Result; if (resp.IsValid) { gameRunData = resp.Data; + if (this.HasRetriggerFreeSpin) { + let retriggercount: number = this._getRetriggerFreeSpinCount(gameRunData); + freeCount += retriggercount; + } + if (i === freeCount - 1) { + let resources: any[] = gameRunData["get"]; + if (resources) { + fswinMoney = this._getWinMoney(resources); + } + fsmoney = gameRunData["money"] ? +gameRunData["money"] : 0; + } } else { CSMessage.NetError(resp.Method, resp.Status); } this._bj_Casino_Bot.AddLog(`Slot${this.ID} FreeSpin MaxCount: ${freeCount}, Count: ${i + 1}`); } + return [freeCount, fswinMoney, fsmoney]; + } + + protected _getWinMoney(resources: any[]): number { + for (let i: number = 0; i < resources.length; i++) { + const resource: any[] = resources[i]; + if (resource[0] === 1) { + return resource[1]; + } + } + return 0; + } + + protected _getRetriggerFreeSpinCount(gameRunData: JSON): number { + if (gameRunData["free"]) { + return gameRunData["free"][1]; + } + return 0; + } + + protected async _getFreeCount(): Promise { + if (this.HasChoiceFreeGame) { + return await this._getChoiceFreeCount(); + } else { + return this.GameRunData["free"][1]; + } + } + + protected async _getChoiceFreeCount(): Promise { + let id: number = this._getFreeID(); + let request: Slot_ChoiceRequest = new Slot_ChoiceRequest(id); + await request.SendAsync(true); + var result: INetResponse = request.Result; + if (result.IsValid) { + if (this.SlotReqRespIsCount) { + return result.Data; + } else if (this.ChoiceFreeCount[result.Data]) { + return this.ChoiceFreeCount[result.Data]; + } + } + return 0; + } + + protected _getFreeID(): number { + return this.FreeID; } //#endregion diff --git a/src/script/Common/Game/Request/SlotRequest.ts b/src/script/Common/Game/Request/SlotRequest.ts new file mode 100644 index 0000000..8bb28a7 --- /dev/null +++ b/src/script/Common/Game/Request/SlotRequest.ts @@ -0,0 +1,78 @@ +import { NetRequest } from "../../../Engine/CatanEngine/NetManagerV2/NetRequest"; + +//======================================================================================= +interface ChoiceRequest { +} + +/**五龍選擇協定 */ +export class Slot_ChoiceRequest extends NetRequest { + get Method(): string { + return "slot.req"; + } + + constructor(id: number) { + super(); + this.Data = id; + } +} +//======================================================================================= +interface GmRequest { + pay: number; + slot: string; + type: number; +} + +export class Slot_GMRequest extends NetRequest{ + get Method(): string { + return "slot.gm"; + } + + get MethodBack(): string { + return "slot" + this._id + ".spin"; + } + + private _id: number = 1; + + constructor(id: number, totalBet: number, symbols: string, type: number) { + super(); + this._id = id; + this.Data = { + pay: totalBet, + slot: symbols, + type: type, + }; + } +} +//======================================================================================= +export class Bingo_GMRequest extends NetRequest{ + get Method(): string { + return "bingo.gm"; + } + + get MethodBack(): string { + return "slot" + this._id + ".spin"; + } + + private _id: number = 0; + + constructor(id: number, totalBet: number, bingos: string, type: number) { + super(); + this._id = id; + this.Data = { + pay: totalBet, + slot: bingos, + type: type, + }; + } +} +//======================================================================================= +/**前後端金額對不上協定 */ +export class Slot_ErrorRequest extends NetRequest { + get Method(): string { + return "slot.error"; + } + constructor() { + super(); + } +} +//======================================================================================= diff --git a/src/script/Common/Game/Slot1.ts b/src/script/Common/Game/Slot1.ts index 65efe61..8b0ebc4 100644 --- a/src/script/Common/Game/Slot1.ts +++ b/src/script/Common/Game/Slot1.ts @@ -5,24 +5,7 @@ export default class Slot1 extends SlotBase { //#region public public get ID(): number { return 1; } - - //#endregion - - //#endregion - - //#region private - - //#endregion - - //#region Lifecycle - - public async onLoad(): Promise { - // - } - - //#endregion - - //#region Custom + public get HasRetriggerFreeSpin(): boolean { return true; } //#endregion } diff --git a/src/script/Common/Game/Slot48.ts b/src/script/Common/Game/Slot48.ts new file mode 100644 index 0000000..8672ceb --- /dev/null +++ b/src/script/Common/Game/Slot48.ts @@ -0,0 +1,13 @@ +import SlotBase from "./Base/SlotBase"; + + +export default class Slot50 extends SlotBase { + //#region public + + public get ID(): number { return 48; } + public get FreeID(): number { return 3; } + public get HasChoiceFreeGame(): boolean { return true; } + public get SlotReqRespIsCount(): boolean { return true; } + + //#endregion +} diff --git a/src/script/Common/Game/Slot50.ts b/src/script/Common/Game/Slot50.ts new file mode 100644 index 0000000..c77eee0 --- /dev/null +++ b/src/script/Common/Game/Slot50.ts @@ -0,0 +1,11 @@ +import SlotBase from "./Base/SlotBase"; + + +export default class Slot50 extends SlotBase { + //#region public + + public get ID(): number { return 50; } + public get HasRetriggerFreeSpin(): boolean { return true; } + + //#endregion +} diff --git a/src/script/Common/Game/Slot62.ts b/src/script/Common/Game/Slot62.ts new file mode 100644 index 0000000..598f620 --- /dev/null +++ b/src/script/Common/Game/Slot62.ts @@ -0,0 +1,35 @@ +import SlotBase from "./Base/SlotBase"; + + +export default class Slot50 extends SlotBase { + //#region public + + public get ID(): number { return 62; } + public get FreeID(): number { return 3; } + public get HasChoiceFreeGame(): boolean { return true; } + public ChoiceFreeCount: Object = { + "1": 15, + "2": 10, + "3": 5, + "4": 3, + "5": 1, + }; + + //#endregion + + //#region Custom + + protected _getFreeID(): number { + let gameRunData: JSON = this.GameRunData; + let scatterAmount: number = gameRunData["scatter"][0][0].length; + if (scatterAmount > 4) { + return 5; + } else if (scatterAmount > 3) { + return 4; + } else { + return this.FreeID; + } + } + + //#endregion +}