押注:
-
{ SlotScript.SelectBet(data) }">
diff --git a/src/script/BJ_Casino_Bot.ts b/src/script/BJ_Casino_Bot.ts
index fd6612f..2128383 100644
--- a/src/script/BJ_Casino_Bot.ts
+++ b/src/script/BJ_Casino_Bot.ts
@@ -2,6 +2,7 @@ import dayjs from "dayjs";
import { Ref, ref } from "vue";
import CSMessage from "./Base/CSMessage";
import { AccountLoginRequest, CustomLoginRequest } from "./Base/Request/AccountRequest";
+import { BJ_Casino_BotController } from "./BJ_Casino_BotController";
import { BJ_Casino_Bot_Lobby } from "./BJ_Casino_Bot_Lobby";
import { BJ_Casino_Bot_Login } from "./BJ_Casino_Bot_Login";
import { BJ_Casino_Bot_Slot } from "./BJ_Casino_Bot_Slot";
@@ -16,6 +17,8 @@ export class BJ_Casino_Bot {
public UserData: BJ_Casino_UserData = null;
+ public BotController: BJ_Casino_BotController = null;
+
public LoginScript: BJ_Casino_Bot_Login = null;
public LobbyScript: BJ_Casino_Bot_Lobby = null;
@@ -45,8 +48,6 @@ export class BJ_Casino_Bot {
//#region private
- private _client: any;
-
private _conn: NetConnector = null;
//#endregion
@@ -56,8 +57,7 @@ export class BJ_Casino_Bot {
/**
*
*/
- constructor(client: any) {
- this._client = client;
+ constructor() {
this.onLoad();
}
@@ -71,15 +71,16 @@ export class BJ_Casino_Bot {
public async Login(a: string, p: string): Promise
{
let self: this = this;
+ this.IsLogin.value = true;
// const URL: string = "https://game.online-bj.com";
// const Port: string = "9005";
- const URL: string = "http://220.134.195.1";
- const Port: string = "19005";
+ // const URL: string = "http://220.134.195.1";
+ // const Port: string = "19005";
+ const { host: URL, port: Port } = this.BotController.GetServer();
await this.ConnectAsync(URL, +Port);
// 取得帳號資料
let resp: any = await this._accountLogin(a, p);
await this._getAccountInfo(resp.a, resp.pw);
- this.IsLogin.value = true;
this.LobbyShow.value = true;
this.SetUI();
}
@@ -87,7 +88,13 @@ export class BJ_Casino_Bot {
public async Logout(): Promise {
NetManager.Disconnect();
this.IsLogin.value = false;
+
this.LobbyShow.value = false;
+ this.LobbyScript.IsSlotIn.value = false;
+
+ this.SlotShow.value = false;
+ this.SlotScript.IsSpin.value = false;
+ this.SlotScript.IsRun = false;
}
private async _accountLogin(account: string, password: string): Promise {
@@ -95,6 +102,7 @@ export class BJ_Casino_Bot {
await req.SendAsync(true);
let resp: INetResponse = req.Result;
if (!resp.IsValid) {
+ this.IsLogin.value = false;
CSMessage.NetError(resp.Method, resp.Status, "Registe Account Error!");
return;
}
@@ -107,6 +115,7 @@ export class BJ_Casino_Bot {
await req.SendAsync(true);
let resp: INetResponse = req.Result;
if (!resp.IsValid) {
+ this.IsLogin.value = false
CSMessage.NetError(resp.Method, resp.Status, "Login Account Error!");
return;
}
@@ -121,14 +130,18 @@ export class BJ_Casino_Bot {
this.Exp.value = this.UserData.Exp;
}
- public AddLog(log: string): void {
+ public AddLog(log: string, ...args: any[]): void {
let AIDLog: string = ``;
if (this.UserData?.AID) {
AIDLog = `AID: ${this.UserData.AID} `;
}
- console.log(`${AIDLog}${log}`);
+ console.log(`${AIDLog}${log}`, ...args);
let time: string = dayjs().format("YYYY/MM/DD HH:mm:ss.SSS");
- this.Log.value += `${time} ${log}\n`;
+ if (args.length > 0) {
+ this.Log.value += `${time} ${log}, ${args}\n`;
+ } else {
+ this.Log.value += `${time} ${log}\n`;
+ }
const textarea: HTMLElement | null = document.getElementById("DIV_LOG");
if (textarea) {
textarea.scrollTop = textarea.scrollHeight;
diff --git a/src/script/BJ_Casino_BotController.ts b/src/script/BJ_Casino_BotController.ts
index dfb1d35..9944d95 100644
--- a/src/script/BJ_Casino_BotController.ts
+++ b/src/script/BJ_Casino_BotController.ts
@@ -1,16 +1,22 @@
// import { BJ_Casino_Data } from "./BJ_Casino_Data";
import dayjs from "dayjs";
+import { Ref, ref } from "vue";
export class BJ_Casino_BotController {
//#region Lifecycle
- // public BJ_Casino: BJ_Casino_Data | undefined;
+ public Hostport: any[] = ["不選擇環境", "內版", "肉乾", "賴宏", "40", "送審", "外版", "testing1", "testing2", "testing3"];
+
+ public ServerIndedx: number = 6;
+
+ public ServerDefault: Ref = ref(this.Hostport[this.ServerIndedx]);
//#endregion
- //#region private
+ //#region get set
- private _client: any;
+ // public get Host(): string { return this.Host; }
+ // public get Port(): string { return this.Port; }
//#endregion
@@ -19,8 +25,7 @@ export class BJ_Casino_BotController {
/**
*
*/
- constructor(client: any) {
- this._client = client;
+ constructor() {
import("dayjs/locale/zh-tw");
dayjs.locale("zh-tw");
// this.BJ_Casino = client.BJ_Casino;
@@ -43,9 +48,84 @@ export class BJ_Casino_BotController {
//#region Custom
- // public SendData() {
- // this._client.RankData.value = this.BJ_Casino?.RankWinMoneyData;
- // }
+ public GetServer(): any {
+ let resp: Object = {};
+ switch (this.ServerIndedx) {
+ // 不選擇環境
+ case 0:
+ // 外網連內版
+ case 1: {
+ resp["host"] = "http://220.134.195.1";
+ resp["port"] = "19005";
+ break;
+ }
+
+ // 肉乾
+ case 2: {
+ resp["host"] = "http://192.168.5.230";
+ resp["port"] = "9006";
+ break;
+ }
+
+ // 賴宏
+ case 3: {
+ resp["host"] = "http://192.168.5.134";
+ resp["port"] = "9005";
+ break;
+ }
+
+ // 40
+ case 4: {
+ resp["host"] = "http://192.168.5.12";
+ resp["port"] = "9487";
+ break;
+ }
+
+ // 送審
+ case 5: {
+ resp["host"] = "https://submit.online-bj.com";
+ resp["port"] = "9005";
+ break;
+ }
+
+ // 外版
+ case 6: {
+ resp["host"] = "https://game.online-bj.com";
+ resp["port"] = "9005";
+ break;
+ }
+
+ // testing1
+ case 7: {
+ resp["host"] = "http://bj-testing1.casino.catan.com.tw";
+ resp["port"] = "9005";
+ break;
+ }
+
+ // testing2
+ case 8: {
+ resp["host"] = "http://bj-testing2.casino.catan.com.tw";
+ resp["port"] = "9005";
+ break;
+ }
+
+ // testing3
+ case 9: {
+ resp["host"] = "http://bj-testing3.casino.catan.com.tw";
+ resp["port"] = "9005";
+ break;
+ }
+
+ default: {
+ break;
+ }
+ }
+ return resp;
+ }
+
+ public SelectServer(data: number): void {
+ this.ServerIndedx = data;
+ }
//#endregion
}
diff --git a/src/script/BJ_Casino_Bot_Lobby.ts b/src/script/BJ_Casino_Bot_Lobby.ts
index d143c6e..16ce2a8 100644
--- a/src/script/BJ_Casino_Bot_Lobby.ts
+++ b/src/script/BJ_Casino_Bot_Lobby.ts
@@ -9,8 +9,7 @@ import { Tools } from "./Tools";
export class BJ_Casino_Bot_Lobby {
//#region public
- public LobbyCongig: any[] = [2, [
- "不選擇資源路徑",
+ public LobbyCongig: any[] = [1, [
"體驗聽",
"一般聽",
"高手聽",
@@ -18,11 +17,11 @@ export class BJ_Casino_Bot_Lobby {
]];
public LobbyShow: Ref = ref(false);
- public Lobby: Ref = ref(0);
+ public Lobby: Ref = ref(1);
+ public LobbyDefault: Ref = ref(this.LobbyCongig[1][this.Lobby.value]);
public InputSlot: Ref = ref("");
public Slot: number;
public Table: Ref = ref(0);
- public LobbyDefault: Ref = ref("");
public IsSlotIn: Ref = ref(false);
@@ -45,8 +44,7 @@ export class BJ_Casino_Bot_Lobby {
}
public async onLoad(): Promise {
- this.Lobby.value = this.LobbyCongig[0];
- this.LobbyDefault.value = this.LobbyCongig[1][this.Lobby.value];
+ //
}
//#endregion
@@ -76,9 +74,10 @@ export class BJ_Casino_Bot_Lobby {
//#region Onclick
public async OnclickSlotIn(hall: number, slot: number): Promise {
- if (this.IsSlotIn.value) {
+ 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);
@@ -93,16 +92,20 @@ export class BJ_Casino_Bot_Lobby {
const element: any = data[i];
if (element[0].length > 0) {
let aid: string = element[0][0];
- if (aid === this._bj_Casino_Bot.UserData.AID) {
- table = i + 1;
- break;
- } else {
+ if (+aid === +this._bj_Casino_Bot.UserData.AID) {
table = i + 1;
break;
}
+ } else {
+ table = i + 1;
+ break;
}
}
let resp_slotIn: any = await this._slotIn(hall, slot, table);
+ if (!resp_slotIn.IsValid) {
+ this.IsSlotIn.value = false;
+ return;
+ }
this.Slot = slot;
this.Table.value = table;
this._bj_Casino_Bot.SlotScript.GameIn(resp_slotIn);
@@ -119,7 +122,7 @@ export class BJ_Casino_Bot_Lobby {
await Tools.Sleep(0.5);
}
await this._slotOut();
- this.Slot = null!;
+ this.Slot = null;
this.Table.value = 0;
this._bj_Casino_Bot.SlotShow.value = false;
}
@@ -137,8 +140,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: ${hall}, table: ${uid}`);
- return resp;
+ this._bj_Casino_Bot.AddLog(`進機台成功 slot: ${slot}, hall: ${this.LobbyDefault.value}, table: ${uid}`);
} else {
switch (resp.Status) {
case 11:
@@ -150,8 +152,10 @@ export class BJ_Casino_Bot_Lobby {
default:
break;
}
+ this._bj_Casino_Bot.AddLog(resp.Method, resp.Status, "進遊戲失敗");
CSMessage.NetError(resp.Method, resp.Status, "進遊戲失敗");
}
+ return resp;
}
private async _slotOut(): Promise {
diff --git a/src/script/BJ_Casino_Bot_Slot.ts b/src/script/BJ_Casino_Bot_Slot.ts
index fe87b83..8354a43 100644
--- a/src/script/BJ_Casino_Bot_Slot.ts
+++ b/src/script/BJ_Casino_Bot_Slot.ts
@@ -6,17 +6,17 @@ import { Tools } from "./Tools";
export class BJ_Casino_Bot_Slot {
//#region public
- public BetDefault: Ref = ref("");
+ public BetIndex: Ref = ref("");
public SpinDelay: Ref = ref(1);
- public Slot: SlotBase = null!;
+ public Slot: SlotBase = null;
- public GameInData: any = null!;
+ public GameInData: any = null;
public BetGroup: number[] = [];
- public NowBetIndex: number = null!;
+ public NowBetIndex: number = null;
public IsSpin: Ref = ref(false);
@@ -32,7 +32,7 @@ export class BJ_Casino_Bot_Slot {
//#region get set
- public get NowBet(): number { return this.BetGroup[this.NowBetIndex]; }
+ public get NowBet(): number { return +this.BetGroup[this.NowBetIndex]; }
//#endregion
@@ -55,7 +55,7 @@ export class BJ_Casino_Bot_Slot {
let Data: any = gameInData.Data;
this.BetGroup = Data.br;
this.NowBetIndex = Data.db;
- this.BetDefault.value = this.BetGroup[Data.db].toString();
+ this.BetIndex.value = this.BetGroup[Data.db].toString();
}
//#endregion
@@ -63,6 +63,10 @@ export class BJ_Casino_Bot_Slot {
//#region Custom
public async Spin(): Promise {
+ if (this._bj_Casino_Bot.UserData.Money < this.NowBet) {
+ this.NoMoney();
+ return;
+ }
this.IsRun = true;
await this.Slot.Spin();
await Tools.Sleep(this.SpinDelay.value * 1000);
@@ -78,6 +82,12 @@ export class BJ_Casino_Bot_Slot {
this._bj_Casino_Bot.AddLog(`改變Bet: ${this.NowBet}`);
}
+ public NoMoney(): void {
+ this.IsSpin.value = false;
+ this.IsRun = false;
+ this._bj_Casino_Bot.AddLog(`金額不足: ${this._bj_Casino_Bot.UserData.Money}`);
+ }
+
//#endregion
//#region Onclick
diff --git a/src/script/BJ_Casino_Data.ts b/src/script/BJ_Casino_Data.ts
index d83942a..12bf996 100644
--- a/src/script/BJ_Casino_Data.ts
+++ b/src/script/BJ_Casino_Data.ts
@@ -24,7 +24,7 @@ export class BJ_Casino_Data {
//#region private
- private _conn: NetConnector = null!;
+ private _conn: NetConnector = null;
private _ws: any;
private _rankMagnificationData: any[] = [];
diff --git a/src/script/Base/BusinessTypeSetting.ts b/src/script/Base/BusinessTypeSetting.ts
index ec08773..6c0d7dd 100644
--- a/src/script/Base/BusinessTypeSetting.ts
+++ b/src/script/Base/BusinessTypeSetting.ts
@@ -68,17 +68,17 @@ export default class BusinessTypeSetting {
public static IsB2B: boolean = false;
/** 商業LOGO圖代碼(讀同一張表但UI有改的設定) */
- public static Logo: number = null!;
+ public static Logo: number = null;
/** 連線IP(網頁版會接網址參數所以要多開變數直接指定) */
- public static UseHost: string = null!;
+ public static UseHost: string = null;
/** 連接阜(網頁版會接網址參數所以要多開變數直接指定) */
- public static UsePort: number = null!;
+ public static UsePort: number = null;
/** 資源伺服器網址 */
- public static UsePatch: string = null!;
+ public static UsePatch: string = null;
/** 帳號 */
- public static Account: string = null!;
+ public static Account: string = null;
/** 密碼 */
- public static Password: string = null!;
+ public static Password: string = null;
// =======================================================================================
/** 執行環境ProductEnum.ServerType */
diff --git a/src/script/Engine/CatanEngine/NetManagerV2/NetConnector.ts b/src/script/Engine/CatanEngine/NetManagerV2/NetConnector.ts
index 77ba94a..934c397 100644
--- a/src/script/Engine/CatanEngine/NetManagerV2/NetConnector.ts
+++ b/src/script/Engine/CatanEngine/NetManagerV2/NetConnector.ts
@@ -17,7 +17,7 @@ export class NetConnector {
}
private _host: string;
- private _ws: WebSocket = null!;
+ private _ws: WebSocket = null;
private _waitings: WsRequestEnumerator[] = [];
constructor(host: string, port: number, ip: string) {
@@ -119,7 +119,7 @@ export class NetConnector {
this._ws.onopen = null;
this._ws.onmessage = null;
this._ws.onclose = () => { };
- this._ws = null!;
+ this._ws = null;
this.CleanWaitings();
this.OnDisconnected.DispatchCallback();