This commit is contained in:
建喵 2022-08-09 14:14:14 +08:00
parent bdd124b229
commit 41ec8bd70e
10 changed files with 248 additions and 243 deletions

View File

@ -1,27 +1,27 @@
{ {
"name": "bj-casino-rank", "name": "bj-casino-rank",
"private": true, "private": true,
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite --host",
"build": "vite build", "build": "vite build",
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {
"@ant-design/icons-vue": "^6.1.0", "@ant-design/icons-vue": "^6.1.0",
"@popperjs/core": "^2.11.5", "@popperjs/core": "^2.11.5",
"axios": "^0.26.1", "axios": "^0.26.1",
"bootstrap": "^5.1.3", "bootstrap": "^5.1.3",
"dayjs": "^1.11.2", "dayjs": "^1.11.2",
"element-plus": "^2.1.9", "element-plus": "^2.1.9",
"vue": "^3.2.25", "vue": "^3.2.25",
"vue-loading-overlay": "^5.0.3" "vue-loading-overlay": "^5.0.3"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^17.0.39", "@types/node": "^17.0.39",
"@vitejs/plugin-vue": "^2.3.0", "@vitejs/plugin-vue": "^2.3.0",
"typescript": "^4.5.4", "typescript": "^4.5.4",
"vite": "^2.9.0", "vite": "^2.9.0",
"vue-tsc": "^0.29.8" "vue-tsc": "^0.29.8"
} }
} }

View File

@ -75,7 +75,7 @@ export class BJ_Casino_Bot_Slot {
this.NoMoney(); this.NoMoney();
return; return;
} }
if (this.IsCountStop) { if (this.IsCountStop.value) {
if (this.CountStop.value <= 0) { if (this.CountStop.value <= 0) {
this.OnclickStop(); this.OnclickStop();
return; return;

View File

@ -8,174 +8,175 @@ import { CommonSlotFgSpinRequest, CommonSlotSpinRequest } from "../Request/Commo
import { Slot_ChoiceRequest } from "../Request/SlotRequest"; import { Slot_ChoiceRequest } from "../Request/SlotRequest";
export class SlotBase { export class SlotBase {
//#region public //#region public
public get ID(): number { return this._bj_Casino_Bot.LobbyScript.Slot; } public get ID(): number { return this._bj_Casino_Bot.LobbyScript.Slot; }
public get FreeID(): number { return 1; } public get FreeID(): number { return 1; }
public get HasChoiceFreeGame(): boolean { return false; } public get FreeCount(): number { return +this.GameRunData["free"][1]; }
public get SlotReqRespIsCount(): boolean { return false; } public get HasChoiceFreeGame(): boolean { return false; }
public get HasRetriggerFreeSpin(): boolean { return false; } public get SlotReqRespIsCount(): boolean { return false; }
public GameRunData: JSON = null; 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,) { constructor(bj_Casino_Bot: BJ_Casino_Bot, bj_Slot: BJ_Casino_Bot_Slot,) {
this._bj_Casino_Bot = bj_Casino_Bot; this._bj_Casino_Bot = bj_Casino_Bot;
this._bj_Slot = bj_Slot; this._bj_Slot = bj_Slot;
this.onLoad(); this.onLoad();
} }
public async onLoad(): Promise<void> { public async onLoad(): Promise<void> {
// //
} }
//#endregion //#endregion
//#region Custom //#region Custom
public async Spin(): Promise<void> { public async Spin(): Promise<void> {
let gameRunData: JSON = null; let gameRunData: JSON = null;
let req: CommonSlotSpinRequest = new CommonSlotSpinRequest(this.ID, this._bj_Slot.NowBet); let req: CommonSlotSpinRequest = new CommonSlotSpinRequest(this.ID, this._bj_Slot.NowBet);
await req.SendAsync(); await req.SendAsync();
let resp: INetResponse<JSON> = req.Result; let resp: INetResponse<JSON> = req.Result;
if (resp.IsValid) { if (resp.IsValid) {
gameRunData = this.GameRunData = resp.Data; gameRunData = this.GameRunData = resp.Data;
} else { } else {
CSMessage.NetError(resp.Method, resp.Status); CSMessage.NetError(resp.Method, resp.Status);
} }
let money: number = gameRunData["money"] ? +gameRunData["money"] : 0; let money: number = gameRunData["money"] ? +gameRunData["money"] : 0;
let winMoney: number = 0; let winMoney: number = 0;
let winMoneyLog: string = ""; let winMoneyLog: string = "";
let freeLog: string = ""; let freeLog: string = "";
let resources: any[] = gameRunData["get"]; let resources: any[] = gameRunData["get"];
let free: any = gameRunData["free"]; let free: any = gameRunData["free"];
let choiceFreeGame: boolean = gameRunData["rs"] === 0; let choiceFreeGame: boolean = gameRunData["rs"] === 0;
if (resources) { if (resources) {
winMoney = this._getWinMoney(resources); winMoney = this._getWinMoney(resources);
} }
if (choiceFreeGame && this.HasChoiceFreeGame) { if (choiceFreeGame && this.HasChoiceFreeGame) {
free = true; free = true;
} }
if (free) { if (free) {
let freeCount: number = await this._getFreeCount(); let freeCount: number = await this._getFreeCount();
let fswinMoney: number = 0; let fswinMoney: number = 0;
let fsmoney: number = 0; let fsmoney: number = 0;
[freeCount, fswinMoney, fsmoney] = await this.FreeSpin(freeCount); [freeCount, fswinMoney, fsmoney] = await this.FreeSpin(freeCount);
if (fsmoney > 0) { if (fsmoney > 0) {
money = fsmoney; money = fsmoney;
} }
if (fswinMoney > 0) { if (fswinMoney > 0) {
winMoney = fswinMoney; winMoney = fswinMoney;
} }
freeLog = `, hasFree: ${freeCount}`; freeLog = `, hasFree: ${freeCount}`;
} }
if (winMoney > 0) { if (winMoney > 0) {
winMoneyLog = `, winMoney: ${winMoney}`; winMoneyLog = `, winMoney: ${winMoney}`;
} }
this._bj_Casino_Bot.UserData.Money = money; this._bj_Casino_Bot.UserData.Money = money;
this._bj_Casino_Bot.SetUI(); this._bj_Casino_Bot.SetUI();
let ratio: number = winMoney > 0 ? NumberEx.divide(winMoney, this._bj_Slot.NowBet) : 0; let ratio: number = winMoney > 0 ? NumberEx.divide(winMoney, this._bj_Slot.NowBet) : 0;
if (this._bj_Slot.IsRatioStop && ratio >= this._bj_Slot.RatioStop.value) { if (this._bj_Slot.IsRatioStop.value && ratio >= this._bj_Slot.RatioStop.value) {
this._bj_Slot.OnclickStop(); this._bj_Slot.OnclickStop();
} }
if (this._bj_Slot.IsCountStop && this._bj_Slot.CountStop.value === 0) { if (this._bj_Slot.IsCountStop.value && this._bj_Slot.CountStop.value === 0) {
this._bj_Slot.OnclickStop(); this._bj_Slot.OnclickStop();
} }
this._bj_Casino_Bot.AddLog(`Slot${this.ID} Spin Bet: ${this._bj_Slot.NowBet}, Money: ${money}${winMoneyLog}${freeLog}`); this._bj_Casino_Bot.AddLog(`Slot${this.ID} Spin Bet: ${this._bj_Slot.NowBet}, Money: ${money}${winMoneyLog}${freeLog}`);
} }
public async FreeSpin(freeCount: number): Promise<number[]> { public async FreeSpin(freeCount: number): Promise<number[]> {
let fswinMoney: number = 0; let fswinMoney: number = 0;
let fsmoney: number = 0; let fsmoney: number = 0;
for (let i: number = 0; i < freeCount; i++) { for (let i: number = 0; i < freeCount; i++) {
let gameRunData: JSON = null; let gameRunData: JSON = null;
let req: CommonSlotFgSpinRequest = new CommonSlotFgSpinRequest(this.ID); let req: CommonSlotFgSpinRequest = new CommonSlotFgSpinRequest(this.ID);
await req.SendAsync(); await req.SendAsync();
let resp: INetResponse<JSON> = req.Result; let resp: INetResponse<JSON> = req.Result;
if (resp.IsValid) { if (resp.IsValid) {
gameRunData = resp.Data; gameRunData = resp.Data;
if (this.HasRetriggerFreeSpin) { if (this.HasRetriggerFreeSpin) {
let retriggercount: number = this._getRetriggerFreeSpinCount(gameRunData); let retriggercount: number = this._getRetriggerFreeSpinCount(gameRunData);
freeCount += retriggercount; freeCount += retriggercount;
} }
if (i === freeCount - 1) { if (i === freeCount - 1) {
let resources: any[] = gameRunData["get"]; let resources: any[] = gameRunData["get"];
if (resources) { if (resources) {
fswinMoney = this._getWinMoney(resources); fswinMoney = this._getWinMoney(resources);
} }
fsmoney = gameRunData["money"] ? +gameRunData["money"] : 0; fsmoney = gameRunData["money"] ? +gameRunData["money"] : 0;
} }
} else { } else {
CSMessage.NetError(resp.Method, resp.Status); CSMessage.NetError(resp.Method, resp.Status);
} }
this._bj_Casino_Bot.AddLog(`Slot${this.ID} FreeSpin MaxCount: ${freeCount}, Count: ${i + 1}`); this._bj_Casino_Bot.AddLog(`Slot${this.ID} FreeSpin MaxCount: ${freeCount}, Count: ${i + 1}`);
} }
return [freeCount, fswinMoney, fsmoney]; return [freeCount, fswinMoney, fsmoney];
} }
protected _getWinMoney(resources: any[]): number { protected _getWinMoney(resources: any[]): number {
for (let i: number = 0; i < resources.length; i++) { for (let i: number = 0; i < resources.length; i++) {
const resource: any[] = resources[i]; const resource: any[] = resources[i];
if (resource[0] === 1) { if (resource[0] === 1) {
return resource[1]; return resource[1];
} }
} }
return 0; return 0;
} }
protected _getRetriggerFreeSpinCount(gameRunData: JSON): number { protected _getRetriggerFreeSpinCount(gameRunData: JSON): number {
if (gameRunData["free"]) { if (gameRunData["free"]) {
return gameRunData["free"][1]; return gameRunData["free"][1];
} }
return 0; return 0;
} }
protected async _getFreeCount(): Promise<number> { protected async _getFreeCount(): Promise<number> {
if (this.HasChoiceFreeGame) { if (this.HasChoiceFreeGame) {
return await this._getChoiceFreeCount(); return await this._getChoiceFreeCount();
} else { } else {
return this.GameRunData["free"][1]; return this.FreeCount;
} }
} }
protected async _getChoiceFreeCount(): Promise<number> { protected async _getChoiceFreeCount(): Promise<number> {
let id: number = this._getFreeID(); let id: number = this._getFreeID();
let request: Slot_ChoiceRequest = new Slot_ChoiceRequest(id); let request: Slot_ChoiceRequest = new Slot_ChoiceRequest(id);
await request.SendAsync(true); await request.SendAsync(true);
var result: INetResponse<number> = request.Result; var result: INetResponse<number> = request.Result;
if (result.IsValid) { if (result.IsValid) {
if (this.SlotReqRespIsCount) { if (this.SlotReqRespIsCount) {
return result.Data; return result.Data;
} else { } else {
let slotNameSetting: string = CSSettingsV3.Slotset[this.ID].NameSetting; let slotNameSetting: string = CSSettingsV3.Slotset[this.ID].NameSetting;
let free_info_id: number = result.Data; let free_info_id: number = result.Data;
let slotSetting: any = CSSettingsV3[slotNameSetting]; let slotSetting: any = CSSettingsV3[slotNameSetting];
let freeInfo: any = slotSetting.FreeInfo; let freeInfo: any = slotSetting.FreeInfo;
let count: number = freeInfo[free_info_id].Spins; let count: number = freeInfo[free_info_id].Spins;
return count; return count;
} }
} }
return 0; return 0;
} }
protected _getFreeID(): number { protected _getFreeID(): number {
return this.FreeID; return this.FreeID;
} }
//#endregion //#endregion
} }
export default SlotBase; export default SlotBase;

View File

@ -5,6 +5,7 @@ export class Slot1201 extends SlotBase {
//#region public //#region public
public get FreeCount(): number { return +this.GameRunData["free"]; } public get FreeCount(): number { return +this.GameRunData["free"]; }
public get HasRetriggerFreeSpin(): boolean { return true; }
//#endregion //#endregion
} }

View File

@ -8,6 +8,7 @@ export class Slot48 extends SlotBase {
public get FreeID(): number { return 3; } public get FreeID(): number { return 3; }
public get HasChoiceFreeGame(): boolean { return true; } public get HasChoiceFreeGame(): boolean { return true; }
public get SlotReqRespIsCount(): boolean { return true; } public get SlotReqRespIsCount(): boolean { return true; }
public get HasRetriggerFreeSpin(): boolean { return true; }
//#endregion //#endregion
} }

View File

@ -7,6 +7,7 @@ export class Slot62 extends SlotBase {
public get ID(): number { return 62; } public get ID(): number { return 62; }
public get FreeID(): number { return 3; } public get FreeID(): number { return 3; }
public get HasChoiceFreeGame(): boolean { return true; } public get HasChoiceFreeGame(): boolean { return true; }
public get HasRetriggerFreeSpin(): boolean { return true; }
//#endregion //#endregion

View File

@ -3,73 +3,74 @@ import { Tools } from "../../Tools";
export class MainControl { export class MainControl {
//#region DownloadForm Function //#region DownloadForm Function
/** /**
* *
* @param formtype FormType * @param formtype FormType
*/ */
public static async DownloadForm(formtype: DownloadForm.FormType): Promise<void> { public static async DownloadForm(formtype: DownloadForm.FormType): Promise<void> {
if (DownloadForm.DownloadFormData.DownloadSuccess.has(formtype)) { if (DownloadForm.DownloadFormData.DownloadSuccess.has(formtype)) {
console.warn(`CSSettingsV3 ${formtype} 已經載過`); console.warn(`CSSettingsV3 ${formtype} 已經載過`);
return; return;
} }
DownloadForm.DownloadFormData.DownloadSuccess.set(formtype, true); DownloadForm.DownloadFormData.DownloadSuccess.set(formtype, true);
let needForm: string[] = DownloadForm.DownloadFormData[`${formtype}Form`]; let needForm: string[] = DownloadForm.DownloadFormData[`${formtype}Form`];
let parallel: Promise<void>[] = []; let parallel: Promise<void>[] = [];
for (let i: number = 0; i < needForm.length; i++) { for (let i: number = 0; i < needForm.length; i++) {
parallel.push(this.DownloadFormSetting(needForm[i])); parallel.push(this.DownloadFormSetting(needForm[i]));
} }
// set Form // set Form
await Promise.all(parallel); await Promise.all(parallel);
} }
/** /**
* *
* @param formname * @param formname
*/ */
public static async DownloadFormSetting(formname: string): Promise<void> { public static async DownloadFormSetting(formname: string): Promise<void> {
// http://patch-dev.online-bj.com/shared/jsons/slot_050.json // http://patch-dev.online-bj.com/shared/jsons/slot_050.json
let fileUrl: string = `${formname}.json`; let fileUrl: string = `${formname}.json`;
fileUrl = "http://patch-dev.online-bj.com/shared/jsons/" + fileUrl; fileUrl = "http://patch-dev.online-bj.com/shared/jsons/" + fileUrl;
fileUrl = fileUrl + "?v=" + Date.now(); // fileUrl = "http://jianmiau.tk/_BJ_Source/BJ-Internal-Dev/shared/jsons/" + fileUrl;
let isdownloading: boolean = true; fileUrl = fileUrl + "?v=" + Date.now();
let xhr: XMLHttpRequest = new XMLHttpRequest(); let isdownloading: boolean = true;
// xhr.withCredentials = true; let xhr: XMLHttpRequest = new XMLHttpRequest();
xhr.onreadystatechange = function (): void { // xhr.withCredentials = true;
if (xhr.readyState === 4 && (xhr.status >= 200 && xhr.status < 400)) { xhr.onreadystatechange = function (): void {
let res: any = {}; if (xhr.readyState === 4 && (xhr.status >= 200 && xhr.status < 400)) {
res.json = JSON.parse(xhr.responseText); let res: any = {};
res.name = formname; res.json = JSON.parse(xhr.responseText);
TableManager.AddJsonAsset(res); res.name = formname;
isdownloading = false; TableManager.AddJsonAsset(res);
} isdownloading = false;
}; }
xhr.open("GET", fileUrl); };
xhr.send(); xhr.open("GET", fileUrl);
while (isdownloading) { xhr.send();
await Tools.Sleep(100); while (isdownloading) {
} await Tools.Sleep(100);
} }
}
//#endregion //#endregion
} }
export default MainControl; export default MainControl;
//#region DownloadForm //#region DownloadForm
export module DownloadForm { export module DownloadForm {
export enum FormType { export enum FormType {
Formread = "formread", Formread = "formread",
} }
export class DownloadFormData { export class DownloadFormData {
/** 已下載的表 */ /** 已下載的表 */
public static DownloadSuccess: Map<string, boolean> = new Map<string, boolean>(); public static DownloadSuccess: Map<string, boolean> = new Map<string, boolean>();
/** Bag需要的表(xxxx.json) */ /** Bag需要的表(xxxx.json) */
public static formreadForm: string[] = ["formread", "slotset"]; public static formreadForm: string[] = ["formread", "slotset"];
} }
} }
//#endregion //#endregion

View File

@ -27,7 +27,7 @@ export class NetConnector {
checkHttp = "https"; checkHttp = "https";
host = host.replace("https://", ""); host = host.replace("https://", "");
} else { } else {
checkHttp = window.location.href.substring(0, 5); checkHttp = "http";
host = host.replace("http://", ""); host = host.replace("http://", "");
} }
if (true) { if (true) {

View File

@ -1,8 +1,8 @@
import vue from '@vitejs/plugin-vue' import vue from "@vitejs/plugin-vue";
import { defineConfig } from 'vite' import { defineConfig } from "vite";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
base: "./", base: "./",
plugins: [vue()] plugins: [vue()],
}) });

View File

@ -1,4 +1,4 @@
1. 沒錢變顏色 1. 自動帶入帳號登入
2. 自動帶入帳號登入 2. 自動設定全部行為
3. 自動設定全部行為 3. 多個模板
4. 多個模板 4. 沒錢變顏色