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",
"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"
}
}

View File

@ -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;

View File

@ -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<void> {
//
}
public async onLoad(): Promise<void> {
//
}
//#endregion
//#endregion
//#region Custom
//#region Custom
public async Spin(): Promise<void> {
let gameRunData: JSON = null;
let req: CommonSlotSpinRequest = new CommonSlotSpinRequest(this.ID, this._bj_Slot.NowBet);
await req.SendAsync();
let resp: INetResponse<JSON> = 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<void> {
let gameRunData: JSON = null;
let req: CommonSlotSpinRequest = new CommonSlotSpinRequest(this.ID, this._bj_Slot.NowBet);
await req.SendAsync();
let resp: INetResponse<JSON> = 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<number[]> {
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<JSON> = 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<number[]> {
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<JSON> = 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<number> {
if (this.HasChoiceFreeGame) {
return await this._getChoiceFreeCount();
} else {
return this.GameRunData["free"][1];
}
}
protected async _getFreeCount(): Promise<number> {
if (this.HasChoiceFreeGame) {
return await this._getChoiceFreeCount();
} else {
return this.FreeCount;
}
}
protected async _getChoiceFreeCount(): Promise<number> {
let id: number = this._getFreeID();
let request: Slot_ChoiceRequest = new Slot_ChoiceRequest(id);
await request.SendAsync(true);
var result: INetResponse<number> = 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<number> {
let id: number = this._getFreeID();
let request: Slot_ChoiceRequest = new Slot_ChoiceRequest(id);
await request.SendAsync(true);
var result: INetResponse<number> = 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;
export default SlotBase;

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -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<void> {
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<void>[] = [];
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<void> {
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<void>[] = [];
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<void> {
// 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<void> {
// 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<string, boolean> = new Map<string, boolean>();
/** 已下載的表 */
public static DownloadSuccess: Map<string, boolean> = new Map<string, boolean>();
/** Bag需要的表(xxxx.json) */
public static formreadForm: string[] = ["formread", "slotset"];
}
/** Bag需要的表(xxxx.json) */
public static formreadForm: string[] = ["formread", "slotset"];
}
}
//#endregion

View File

@ -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) {

View File

@ -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()],
});

View File

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