From 41ec8bd70ea3bc494f0c46ab8c0e9270ea889826 Mon Sep 17 00:00:00 2001 From: JianMiau Date: Tue, 9 Aug 2022 14:14:14 +0800 Subject: [PATCH] [mod] --- package.json | 52 +-- src/script/BJ_Casino_Bot_Slot.ts | 2 +- src/script/Common/Game/Base/SlotBase.ts | 301 +++++++++--------- src/script/Common/Game/Slot1201.ts | 1 + src/script/Common/Game/Slot48.ts | 1 + src/script/Common/Game/Slot62.ts | 1 + src/script/Common/MainControl/MainControl.ts | 113 +++---- .../CatanEngine/NetManagerV2/NetConnector.ts | 2 +- vite.config.ts | 10 +- 進度表.txt | 8 +- 10 files changed, 248 insertions(+), 243 deletions(-) diff --git a/package.json b/package.json index 410e0d4..f277665 100644 --- a/package.json +++ b/package.json @@ -1,27 +1,27 @@ { - "name": "bj-casino-rank", - "private": true, - "version": "0.0.0", - "scripts": { - "dev": "vite", - "build": "vite build", - "preview": "vite preview" - }, - "dependencies": { - "@ant-design/icons-vue": "^6.1.0", - "@popperjs/core": "^2.11.5", - "axios": "^0.26.1", - "bootstrap": "^5.1.3", - "dayjs": "^1.11.2", - "element-plus": "^2.1.9", - "vue": "^3.2.25", - "vue-loading-overlay": "^5.0.3" - }, - "devDependencies": { - "@types/node": "^17.0.39", - "@vitejs/plugin-vue": "^2.3.0", - "typescript": "^4.5.4", - "vite": "^2.9.0", - "vue-tsc": "^0.29.8" - } -} + "name": "bj-casino-rank", + "private": true, + "version": "0.0.0", + "scripts": { + "dev": "vite --host", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "@ant-design/icons-vue": "^6.1.0", + "@popperjs/core": "^2.11.5", + "axios": "^0.26.1", + "bootstrap": "^5.1.3", + "dayjs": "^1.11.2", + "element-plus": "^2.1.9", + "vue": "^3.2.25", + "vue-loading-overlay": "^5.0.3" + }, + "devDependencies": { + "@types/node": "^17.0.39", + "@vitejs/plugin-vue": "^2.3.0", + "typescript": "^4.5.4", + "vite": "^2.9.0", + "vue-tsc": "^0.29.8" + } +} \ No newline at end of file diff --git a/src/script/BJ_Casino_Bot_Slot.ts b/src/script/BJ_Casino_Bot_Slot.ts index b58c937..14872ab 100644 --- a/src/script/BJ_Casino_Bot_Slot.ts +++ b/src/script/BJ_Casino_Bot_Slot.ts @@ -75,7 +75,7 @@ export class BJ_Casino_Bot_Slot { this.NoMoney(); return; } - if (this.IsCountStop) { + if (this.IsCountStop.value) { if (this.CountStop.value <= 0) { this.OnclickStop(); return; diff --git a/src/script/Common/Game/Base/SlotBase.ts b/src/script/Common/Game/Base/SlotBase.ts index 570558c..e5eb9d5 100644 --- a/src/script/Common/Game/Base/SlotBase.ts +++ b/src/script/Common/Game/Base/SlotBase.ts @@ -8,174 +8,175 @@ import { CommonSlotFgSpinRequest, CommonSlotSpinRequest } from "../Request/Commo import { Slot_ChoiceRequest } from "../Request/SlotRequest"; export class SlotBase { - //#region public + //#region public - public get ID(): number { return this._bj_Casino_Bot.LobbyScript.Slot; } - 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 get ID(): number { return this._bj_Casino_Bot.LobbyScript.Slot; } + public get FreeID(): number { return 1; } + public get FreeCount(): number { return +this.GameRunData["free"][1]; } + public get HasChoiceFreeGame(): boolean { return false; } + public get SlotReqRespIsCount(): boolean { return false; } + public get HasRetriggerFreeSpin(): boolean { return false; } + public GameRunData: JSON = null; - //#endregion + //#endregion - //#region protected + //#region protected - protected _bj_Casino_Bot: BJ_Casino_Bot; + protected _bj_Casino_Bot: BJ_Casino_Bot; - protected _bj_Slot: BJ_Casino_Bot_Slot; + protected _bj_Slot: BJ_Casino_Bot_Slot; - //#endregion + //#endregion - //#region Lifecycle + //#region Lifecycle - /** - * - */ - constructor(bj_Casino_Bot: BJ_Casino_Bot, bj_Slot: BJ_Casino_Bot_Slot,) { - this._bj_Casino_Bot = bj_Casino_Bot; - this._bj_Slot = bj_Slot; - this.onLoad(); - } + /** + * + */ + constructor(bj_Casino_Bot: BJ_Casino_Bot, bj_Slot: BJ_Casino_Bot_Slot,) { + this._bj_Casino_Bot = bj_Casino_Bot; + this._bj_Slot = bj_Slot; + this.onLoad(); + } - public async onLoad(): Promise { - // - } + public async onLoad(): Promise { + // + } - //#endregion + //#endregion - //#region Custom + //#region Custom - public async Spin(): Promise { - let gameRunData: JSON = null; - let req: CommonSlotSpinRequest = new CommonSlotSpinRequest(this.ID, this._bj_Slot.NowBet); - await req.SendAsync(); - let resp: INetResponse = req.Result; - if (resp.IsValid) { - gameRunData = this.GameRunData = resp.Data; - } else { - CSMessage.NetError(resp.Method, resp.Status); - } - 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 choiceFreeGame: boolean = gameRunData["rs"] === 0; - if (resources) { - winMoney = this._getWinMoney(resources); - } - if (choiceFreeGame && this.HasChoiceFreeGame) { - free = true; - } - if (free) { - 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(); - let ratio: number = winMoney > 0 ? NumberEx.divide(winMoney, this._bj_Slot.NowBet) : 0; - if (this._bj_Slot.IsRatioStop && ratio >= this._bj_Slot.RatioStop.value) { - this._bj_Slot.OnclickStop(); - } - if (this._bj_Slot.IsCountStop && this._bj_Slot.CountStop.value === 0) { - this._bj_Slot.OnclickStop(); - } - this._bj_Casino_Bot.AddLog(`Slot${this.ID} Spin Bet: ${this._bj_Slot.NowBet}, Money: ${money}${winMoneyLog}${freeLog}`); - } + public async Spin(): Promise { + let gameRunData: JSON = null; + let req: CommonSlotSpinRequest = new CommonSlotSpinRequest(this.ID, this._bj_Slot.NowBet); + await req.SendAsync(); + let resp: INetResponse = req.Result; + if (resp.IsValid) { + gameRunData = this.GameRunData = resp.Data; + } else { + CSMessage.NetError(resp.Method, resp.Status); + } + 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 choiceFreeGame: boolean = gameRunData["rs"] === 0; + if (resources) { + winMoney = this._getWinMoney(resources); + } + if (choiceFreeGame && this.HasChoiceFreeGame) { + free = true; + } + if (free) { + 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(); + let ratio: number = winMoney > 0 ? NumberEx.divide(winMoney, this._bj_Slot.NowBet) : 0; + if (this._bj_Slot.IsRatioStop.value && ratio >= this._bj_Slot.RatioStop.value) { + this._bj_Slot.OnclickStop(); + } + if (this._bj_Slot.IsCountStop.value && this._bj_Slot.CountStop.value === 0) { + this._bj_Slot.OnclickStop(); + } + this._bj_Casino_Bot.AddLog(`Slot${this.ID} Spin Bet: ${this._bj_Slot.NowBet}, Money: ${money}${winMoneyLog}${freeLog}`); + } - 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); - await req.SendAsync(); - 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]; - } + 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); + await req.SendAsync(); + 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 _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 _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 _getFreeCount(): Promise { + if (this.HasChoiceFreeGame) { + return await this._getChoiceFreeCount(); + } else { + return this.FreeCount; + } + } - 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 { - let slotNameSetting: string = CSSettingsV3.Slotset[this.ID].NameSetting; - let free_info_id: number = result.Data; - let slotSetting: any = CSSettingsV3[slotNameSetting]; - let freeInfo: any = slotSetting.FreeInfo; - let count: number = freeInfo[free_info_id].Spins; - return count; - } - } - return 0; - } + 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 { + let slotNameSetting: string = CSSettingsV3.Slotset[this.ID].NameSetting; + let free_info_id: number = result.Data; + let slotSetting: any = CSSettingsV3[slotNameSetting]; + let freeInfo: any = slotSetting.FreeInfo; + let count: number = freeInfo[free_info_id].Spins; + return count; + } + } + return 0; + } - protected _getFreeID(): number { - return this.FreeID; - } + protected _getFreeID(): number { + return this.FreeID; + } - //#endregion + //#endregion } -export default SlotBase; \ No newline at end of file +export default SlotBase; diff --git a/src/script/Common/Game/Slot1201.ts b/src/script/Common/Game/Slot1201.ts index 6a7942e..6d38f80 100644 --- a/src/script/Common/Game/Slot1201.ts +++ b/src/script/Common/Game/Slot1201.ts @@ -5,6 +5,7 @@ export class Slot1201 extends SlotBase { //#region public public get FreeCount(): number { return +this.GameRunData["free"]; } + public get HasRetriggerFreeSpin(): boolean { return true; } //#endregion } diff --git a/src/script/Common/Game/Slot48.ts b/src/script/Common/Game/Slot48.ts index 1698a90..50e5230 100644 --- a/src/script/Common/Game/Slot48.ts +++ b/src/script/Common/Game/Slot48.ts @@ -8,6 +8,7 @@ export class Slot48 extends SlotBase { public get FreeID(): number { return 3; } public get HasChoiceFreeGame(): boolean { return true; } public get SlotReqRespIsCount(): boolean { return true; } + public get HasRetriggerFreeSpin(): boolean { return true; } //#endregion } diff --git a/src/script/Common/Game/Slot62.ts b/src/script/Common/Game/Slot62.ts index b06a28d..1a7691a 100644 --- a/src/script/Common/Game/Slot62.ts +++ b/src/script/Common/Game/Slot62.ts @@ -7,6 +7,7 @@ export class Slot62 extends SlotBase { public get ID(): number { return 62; } public get FreeID(): number { return 3; } public get HasChoiceFreeGame(): boolean { return true; } + public get HasRetriggerFreeSpin(): boolean { return true; } //#endregion diff --git a/src/script/Common/MainControl/MainControl.ts b/src/script/Common/MainControl/MainControl.ts index 2fafc94..c4a2917 100644 --- a/src/script/Common/MainControl/MainControl.ts +++ b/src/script/Common/MainControl/MainControl.ts @@ -3,73 +3,74 @@ import { Tools } from "../../Tools"; export class MainControl { - //#region DownloadForm Function + //#region DownloadForm Function - /** - * 載入外載表設定檔 - * @param formtype FormType - */ - public static async DownloadForm(formtype: DownloadForm.FormType): Promise { - if (DownloadForm.DownloadFormData.DownloadSuccess.has(formtype)) { - console.warn(`CSSettingsV3 ${formtype} 已經載過`); - return; - } - DownloadForm.DownloadFormData.DownloadSuccess.set(formtype, true); - let needForm: string[] = DownloadForm.DownloadFormData[`${formtype}Form`]; - let parallel: Promise[] = []; - for (let i: number = 0; i < needForm.length; i++) { - parallel.push(this.DownloadFormSetting(needForm[i])); - } - // set Form - await Promise.all(parallel); - } + /** + * 載入外載表設定檔 + * @param formtype FormType + */ + public static async DownloadForm(formtype: DownloadForm.FormType): Promise { + if (DownloadForm.DownloadFormData.DownloadSuccess.has(formtype)) { + console.warn(`CSSettingsV3 ${formtype} 已經載過`); + return; + } + DownloadForm.DownloadFormData.DownloadSuccess.set(formtype, true); + let needForm: string[] = DownloadForm.DownloadFormData[`${formtype}Form`]; + let parallel: Promise[] = []; + for (let i: number = 0; i < needForm.length; i++) { + parallel.push(this.DownloadFormSetting(needForm[i])); + } + // set Form + await Promise.all(parallel); + } - /** - * 載入外載表設定檔 - * @param formname 設定檔名稱 - */ - public static async DownloadFormSetting(formname: string): Promise { - // http://patch-dev.online-bj.com/shared/jsons/slot_050.json - let fileUrl: string = `${formname}.json`; - fileUrl = "http://patch-dev.online-bj.com/shared/jsons/" + fileUrl; - fileUrl = fileUrl + "?v=" + Date.now(); - let isdownloading: boolean = true; - let xhr: XMLHttpRequest = new XMLHttpRequest(); - // xhr.withCredentials = true; - xhr.onreadystatechange = function (): void { - if (xhr.readyState === 4 && (xhr.status >= 200 && xhr.status < 400)) { - let res: any = {}; - res.json = JSON.parse(xhr.responseText); - res.name = formname; - TableManager.AddJsonAsset(res); - isdownloading = false; - } - }; - xhr.open("GET", fileUrl); - xhr.send(); - while (isdownloading) { - await Tools.Sleep(100); - } - } + /** + * 載入外載表設定檔 + * @param formname 設定檔名稱 + */ + public static async DownloadFormSetting(formname: string): Promise { + // http://patch-dev.online-bj.com/shared/jsons/slot_050.json + let fileUrl: string = `${formname}.json`; + fileUrl = "http://patch-dev.online-bj.com/shared/jsons/" + fileUrl; + // fileUrl = "http://jianmiau.tk/_BJ_Source/BJ-Internal-Dev/shared/jsons/" + fileUrl; + fileUrl = fileUrl + "?v=" + Date.now(); + let isdownloading: boolean = true; + let xhr: XMLHttpRequest = new XMLHttpRequest(); + // xhr.withCredentials = true; + xhr.onreadystatechange = function (): void { + if (xhr.readyState === 4 && (xhr.status >= 200 && xhr.status < 400)) { + let res: any = {}; + res.json = JSON.parse(xhr.responseText); + res.name = formname; + TableManager.AddJsonAsset(res); + isdownloading = false; + } + }; + xhr.open("GET", fileUrl); + xhr.send(); + while (isdownloading) { + await Tools.Sleep(100); + } + } - //#endregion + //#endregion } export default MainControl; //#region DownloadForm export module DownloadForm { - export enum FormType { - Formread = "formread", - } + export enum FormType { + Formread = "formread", + } - export class DownloadFormData { + export class DownloadFormData { - /** 已下載的表 */ - public static DownloadSuccess: Map = new Map(); + /** 已下載的表 */ + public static DownloadSuccess: Map = new Map(); - /** Bag需要的表(xxxx.json) */ - public static formreadForm: string[] = ["formread", "slotset"]; - } + /** Bag需要的表(xxxx.json) */ + public static formreadForm: string[] = ["formread", "slotset"]; + } } //#endregion \ No newline at end of file diff --git a/src/script/Engine/CatanEngine/NetManagerV2/NetConnector.ts b/src/script/Engine/CatanEngine/NetManagerV2/NetConnector.ts index 934c397..293209f 100644 --- a/src/script/Engine/CatanEngine/NetManagerV2/NetConnector.ts +++ b/src/script/Engine/CatanEngine/NetManagerV2/NetConnector.ts @@ -27,7 +27,7 @@ export class NetConnector { checkHttp = "https"; host = host.replace("https://", ""); } else { - checkHttp = window.location.href.substring(0, 5); + checkHttp = "http"; host = host.replace("http://", ""); } if (true) { diff --git a/vite.config.ts b/vite.config.ts index ad61010..47e47c0 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,8 +1,8 @@ -import vue from '@vitejs/plugin-vue' -import { defineConfig } from 'vite' +import vue from "@vitejs/plugin-vue"; +import { defineConfig } from "vite"; // https://vitejs.dev/config/ export default defineConfig({ - base: "./", - plugins: [vue()] -}) + base: "./", + plugins: [vue()], +}); diff --git a/進度表.txt b/進度表.txt index b57d68a..1b6c880 100644 --- a/進度表.txt +++ b/進度表.txt @@ -1,4 +1,4 @@ -1. 沒錢變顏色 -2. 自動帶入帳號登入 -3. 自動設定全部行為 -4. 多個模板 \ No newline at end of file +1. 自動帶入帳號登入 +2. 自動設定全部行為 +3. 多個模板 +4. 沒錢變顏色 \ No newline at end of file