[add] Login Out

[add] Spin
This commit is contained in:
建喵 2022-05-29 14:59:37 +08:00
parent 1f37d21bf0
commit a8b6946ecf
17 changed files with 428 additions and 69 deletions

View File

@ -4,7 +4,7 @@
border-style: double;
border-color: #000000;
padding: 5px;
height: 130px;
height: 180px;
}
.BJ_Casino_BotController {

View File

@ -2,6 +2,7 @@
import { BJ_Casino_Bot } from "../script/BJ_Casino_Bot";
import BJ_Casino_Bot_Info from './BJ_Casino_Bot_Info.vue';
import BJ_Casino_Bot_Lobby from './BJ_Casino_Bot_Lobby.vue';
import BJ_Casino_Bot_Login from "./BJ_Casino_Bot_Login.vue";
import BJ_Casino_Bot_Slot from './BJ_Casino_Bot_Slot.vue';
const props = defineProps<{ BJ_Casino: any }>()
@ -15,14 +16,19 @@ const disabled = false;
<template>
<!-- Info -->
<div class="BJ_Casino_Bot" style="float: left;text-align: left;width:10%;">
<div class="BJ_Casino_Bot" style="float: left;text-align: left;width:10%;" v-show="!Script.IsLogin.value">
<BJ_Casino_Bot_Login :Client="self" :Script="Script" />
</div>
<!-- Info -->
<div class="BJ_Casino_Bot" style="float: left;text-align: left;width:10%;" v-show="Script.IsLogin.value">
<BJ_Casino_Bot_Info :Client="self" :Script="Script" />
</div>
<!-- Game -->
<div class="BJ_Casino_Bot" style="float: left;text-align: left;width:60%;">
<div class="BJ_Casino_Bot" style="float: left;text-align: left;width:40%;">
<!-- Lobby -->
<div style="float: left;width:30%;" v-show="Script.LobbyShow.value">
<div style="float: left;width:40%;" v-show="Script.LobbyShow.value">
<BJ_Casino_Bot_Lobby :Client="self" :Script="Script" />
</div>
@ -34,7 +40,6 @@ const disabled = false;
<!-- Log -->
<div class="BJ_Casino_Bot" style="text-align: left;">
<el-input id="DIV_LOG" v-model="Script.Log.value" :rows="5" type="textarea" placeholder="Please input"
style="width:20%;" />
<el-input id="DIV_LOG" v-model="Script.Log.value" :rows="7" type="textarea" style="width:50%;" />
</div>
</template>

View File

@ -10,4 +10,7 @@ const props = defineProps<{ Client: any, Script: BJ_Casino_Bot }>()
Level:{{ Script.Level.value }}<br>
Exp:{{ Script.Exp.value }}<br>
Money:{{ Script.Money.value }}<br>
<el-button type="success" @click.native="() => { props.Script.Logout() }" round>
登出
</el-button>
</template>

View File

@ -18,13 +18,18 @@ props.Script.LobbyScript = LobbyScript;
</div>
<div>
機台:
<el-input v-model="LobbyScript.Slot.value" style="width:20%;" />
<el-input v-model="LobbyScript.InputSlot.value" style="width:20%;" />
桌號:{{ LobbyScript.Table }}
</div>
<div>
<el-button type="success"
@click.native="() => { LobbyScript.OnclickSlotIn(LobbyScript.Lobby.value, +LobbyScript.Slot.value) }" round>
@click.native="() => { LobbyScript.OnclickSlotIn(LobbyScript.Lobby.value, +LobbyScript.InputSlot.value) }"
round v-show="!LobbyScript.IsSlotIn.value">
確定
</el-button>
<el-button type="success" @click.native="() => { LobbyScript.OnclickSlotOut() }" round
v-show="LobbyScript.IsSlotIn.value">
離開
</el-button>
</div>
</template>

View File

@ -0,0 +1,23 @@
<script setup lang="ts">
import { BJ_Casino_Bot } from '../script/BJ_Casino_Bot';
import { BJ_Casino_Bot_Login } from '../script/BJ_Casino_Bot_Login';
const props = defineProps<{ Client: any, Script: BJ_Casino_Bot }>()
const LoginScript = new BJ_Casino_Bot_Login(props.Script);
props.Script.LoginScript = LoginScript;
</script>
<template>
<div>
帳號:
<el-input type="account" v-model="LoginScript.Account.value" :rows="5" />
密碼:
<el-input type="password" v-model="LoginScript.Password.value" :rows="5" />
<div>
<el-button type="success" @click.native="() => { LoginScript.OnclickLogin() }" round>
登入
</el-button>
</div>
</div>
</template>

View File

@ -1,4 +1,5 @@
<script setup lang="ts">import { BJ_Casino_Bot } from '../script/BJ_Casino_Bot';
<script setup lang="ts">
import { BJ_Casino_Bot } from '../script/BJ_Casino_Bot';
import { BJ_Casino_Bot_Slot } from '../script/BJ_Casino_Bot_Slot';
@ -17,10 +18,12 @@ props.Script.SlotScript = SlotScript;
延遲:
<el-input v-model="SlotScript.SpinDelay.value" :rows="5" style="width:5%;" />
<div>
<el-button type="success" @click.native="() => { SlotScript.OnclickSpin() }" round>
<el-button type="success" @click.native="() => { SlotScript.OnclickSpin() }" round
v-show="!SlotScript.IsSpin.value">
Spin
</el-button>
<el-button type="success" @click.native="() => { SlotScript.OnclickStop() }" round>
<el-button type="success" @click.native="() => { SlotScript.OnclickStop() }" round
v-show="SlotScript.IsSpin.value">
Stop
</el-button>
</div>

View File

@ -1,6 +1,7 @@
import "@popperjs/core";
import "bootstrap";
import "bootstrap/dist/css/bootstrap.min.css";
// import dayjs from "dayjs";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import locale from "element-plus/lib/locale/lang/zh-tw";
@ -10,3 +11,5 @@ import "./script/Engine/CatanEngine/CSharp/String";
createApp(App).use(ElementPlus, { locale }).mount("#app");
// import("dayjs/locale/zh-tw");
// dayjs.locale("zh-tw");

View File

@ -1,7 +1,9 @@
import dayjs from "dayjs";
import { Ref, ref } from "vue";
import CSMessage from "./Base/CSMessage";
import { AccountLoginRequest, CustomLoginRequest } from "./Base/Request/AccountRequest";
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";
import { BJ_Casino_UserData } from "./BJ_Casino_Userdata";
import { INetResponse } from "./Engine/CatanEngine/NetManagerV2/Core/INetResponse";
@ -12,14 +14,16 @@ import { Tools } from "./Tools";
export class BJ_Casino_Bot {
//#region public
public UserData: BJ_Casino_UserData = null!;
public UserData: BJ_Casino_UserData = null;
public LobbyScript: BJ_Casino_Bot_Lobby = null!;
public LoginScript: BJ_Casino_Bot_Login = null;
public SlotScript: BJ_Casino_Bot_Slot = null!;
public LobbyScript: BJ_Casino_Bot_Lobby = null;
// Main
public Log: Ref<string> = ref("");
public SlotScript: BJ_Casino_Bot_Slot = null;
// Login
public IsLogin: Ref<boolean> = ref(false);
// Info
public AID: Ref<string> = ref("");
@ -34,13 +38,16 @@ export class BJ_Casino_Bot {
// Slot
public SlotShow: Ref<boolean> = ref(false);
// Log
public Log: Ref<string> = ref("");
//#endregion
//#region private
private _client: any;
private _conn: NetConnector = null!;
private _conn: NetConnector = null;
//#endregion
@ -55,28 +62,34 @@ export class BJ_Casino_Bot {
}
public async onLoad(): Promise<void> {
await this._login();
// await this._login();
}
//#endregion
//#region Custom
private async _login(): Promise<void> {
public async Login(a: string, p: string): Promise<void> {
let self: this = this;
// const URL: string = "https://game.online-bj.com";
// const Port: string = "9005";
const URL: string = "http://220.134.195.1";
const Port: string = "19005";
await this.ConnectAsync(URL, +Port);
let a: string = "TS000001";
let p: string = "a123456";
// 取得帳號資料
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();
this.SetUI();
}
public async Logout(): Promise<void> {
NetManager.Disconnect();
this.IsLogin.value = false;
this.LobbyShow.value = false;
}
private async _accountLogin(account: string, password: string): Promise<any> {
let req: CustomLoginRequest = new CustomLoginRequest(account, password);
await req.SendAsync(true);
@ -100,7 +113,7 @@ export class BJ_Casino_Bot {
this.UserData = new BJ_Casino_UserData(resp.Data["id"].toString(), resp.Data["name"].toString(), +resp.Data["m"], +resp.Data["lv"], +resp.Data["exp"]);
}
private _setUI(): void {
public SetUI(): void {
this.AID.value = this.UserData.AID;
this.NickName.value = this.UserData.NickName;
this.Money.value = this.UserData.Money;
@ -109,9 +122,14 @@ export class BJ_Casino_Bot {
}
public AddLog(log: string): void {
console.log(log);
this.Log.value += log + "\n";
const textarea: HTMLElement | null = document.getElementById("DIV_LOG")!;
let AIDLog: string = ``;
if (this.UserData?.AID) {
AIDLog = `AID: ${this.UserData.AID} `;
}
console.log(`${AIDLog}${log}`);
let time: string = dayjs().format("YYYY/MM/DD HH:mm:ss.SSS");
this.Log.value += `${time} ${log}\n`;
const textarea: HTMLElement | null = document.getElementById("DIV_LOG");
if (textarea) {
textarea.scrollTop = textarea.scrollHeight;
}
@ -158,7 +176,11 @@ export class BJ_Casino_Bot {
}
private _onNetDataReceived(resp: INetResponse<any>): void {
this.AddLog(`[事件] 收到server呼叫: ${resp.Method}(${JSON.stringify(resp.Data)}), 狀態: ${resp.Status}`);
let AIDLog: string = ``;
if (this.UserData?.AID) {
AIDLog = `AID: ${this.UserData.AID} `;
}
console.log(`${AIDLog}[事件] 收到server呼叫: ${resp.Method}(${JSON.stringify(resp.Data)}), 狀態: ${resp.Status}`);
// MainControl.DataReceivedEvent.DispatchCallback([MainControl.DataType.ServerData, resp]);
}

View File

@ -1,4 +1,5 @@
// import { BJ_Casino_Data } from "./BJ_Casino_Data";
import dayjs from "dayjs";
export class BJ_Casino_BotController {
//#region Lifecycle
@ -20,6 +21,8 @@ export class BJ_Casino_BotController {
*/
constructor(client: any) {
this._client = client;
import("dayjs/locale/zh-tw");
dayjs.locale("zh-tw");
// this.BJ_Casino = client.BJ_Casino;
// this.onLoad();
}

View File

@ -2,8 +2,9 @@ import { Ref, ref } from "vue";
import CSMessage from "./Base/CSMessage";
import { BJ_Casino_Bot } from "./BJ_Casino_Bot";
import { SeatListRequest } from "./Common/ChooseSeat/ChooseSeatRequest";
import { SlotInRequest } from "./Common/Subgame/GameRequest";
import { SlotInRequest, SlotOutRequest } from "./Common/Subgame/GameRequest";
import { INetResponse } from "./Engine/CatanEngine/NetManagerV2/Core/INetResponse";
import { Tools } from "./Tools";
export class BJ_Casino_Bot_Lobby {
//#region public
@ -18,10 +19,13 @@ export class BJ_Casino_Bot_Lobby {
public LobbyShow: Ref<boolean> = ref(false);
public Lobby: Ref<number> = ref(0);
public Slot: Ref<string> = ref("");
public InputSlot: Ref<string> = ref("");
public Slot: number;
public Table: Ref<number> = ref(0);
public LobbyDefault: Ref<string> = ref("");
public IsSlotIn: Ref<boolean> = ref(false);
//#endregion
//#region private
@ -72,6 +76,10 @@ export class BJ_Casino_Bot_Lobby {
//#region Onclick
public async OnclickSlotIn(hall: number, slot: number): Promise<void> {
if (this.IsSlotIn.value) {
return;
}
this.IsSlotIn.value = true;
let table: number = 1;
let req: SeatListRequest = new SeatListRequest(hall, slot);
await req.SendAsync(true);
@ -95,12 +103,35 @@ export class BJ_Casino_Bot_Lobby {
}
}
let resp_slotIn: any = await this._slotIn(hall, slot, table);
this.Slot = slot;
this.Table.value = table;
this._bj_Casino_Bot.SlotScript.GameIn(resp_slotIn);
this._bj_Casino_Bot.SlotShow.value = true;
return;
}
public async OnclickSlotOut(): Promise<void> {
this._bj_Casino_Bot.SlotScript.IsSpin.value = false;
if (!this.IsSlotIn.value) {
return;
}
this.IsSlotIn.value = false;
while (this._bj_Casino_Bot.SlotScript.IsRun) {
await Tools.Sleep(0.5);
}
await this._slotOut();
this.Slot = null!;
this.Table.value = 0;
this._bj_Casino_Bot.SlotShow.value = false;
}
public OnclickChangeSlot(): void {
// await this._login();
}
//#endregion
//#region Server Method
private async _slotIn(hall: number, slot: number, uid: number): Promise<any> {
let req: SlotInRequest = new SlotInRequest(slot, hall, uid);
await req.SendAsync(true);
@ -123,11 +154,14 @@ export class BJ_Casino_Bot_Lobby {
}
}
public OnclickChangeSlot(): void {
// await this._login();
private async _slotOut(): Promise<any> {
let req: SlotOutRequest = new SlotOutRequest();
await req.SendAsync(true);
let resp: INetResponse<JSON> = <INetResponse<JSON>><unknown>req.Result;
if (resp.IsValid) {
this._bj_Casino_Bot.AddLog(`離開機台成功`);
}
}
//#endregion
//#endregion
}

View File

@ -0,0 +1,42 @@
import { Ref, ref } from "vue";
import { BJ_Casino_Bot } from "./BJ_Casino_Bot";
export class BJ_Casino_Bot_Login {
//#region public
public Account: Ref<string> = ref("");
public Password: Ref<string> = ref("");
//#endregion
//#region private
private _bj_Casino_Bot: BJ_Casino_Bot;
//#endregion
//#region Lifecycle
/**
*
*/
constructor(bj_Casino_Bot: BJ_Casino_Bot) {
this._bj_Casino_Bot = bj_Casino_Bot;
this.onLoad();
}
public async onLoad(): Promise<void> {
//
}
//#endregion
//#region Onclick
public async OnclickLogin(): Promise<void> {
this._bj_Casino_Bot.Login(this.Account.value, this.Password.value);
}
//#endregion
}

View File

@ -1,5 +1,6 @@
import { Ref, ref } from "vue";
import { BJ_Casino_Bot } from "./BJ_Casino_Bot";
import SlotBase from "./Common/Game/Base/SlotBase";
import { Tools } from "./Tools";
export class BJ_Casino_Bot_Slot {
@ -9,22 +10,24 @@ export class BJ_Casino_Bot_Slot {
public SpinDelay: Ref<number> = ref(1);
public Slot: SlotBase = null!;
public GameInData: any = null!;
public BetGroup: number[] = [];
public NowBetIndex: number = null!;
public IsSpin: Ref<boolean> = ref(false);
public IsRun: boolean = false;
//#endregion
//#region private
private _bj_Casino_Bot: BJ_Casino_Bot;
private _isSpin: boolean = false;
private _isRun: boolean = false;
//#endregion
//#region get set
@ -60,13 +63,13 @@ export class BJ_Casino_Bot_Slot {
//#region Custom
public async Spin(): Promise<void> {
this._isRun = true;
this._bj_Casino_Bot.AddLog(`Spin Bet: ${this.NowBet}`);
this.IsRun = true;
await this.Slot.Spin();
await Tools.Sleep(this.SpinDelay.value * 1000);
if (this._isSpin) {
if (this.IsSpin.value && this._bj_Casino_Bot.LobbyScript.IsSlotIn.value) {
this.Spin();
} else {
this._isRun = false;
this.IsRun = false;
}
}
@ -80,15 +83,27 @@ export class BJ_Casino_Bot_Slot {
//#region Onclick
public async OnclickSpin(): Promise<void> {
if (this._isRun) {
if (this.IsRun) {
return;
}
this._isSpin = true;
let id: string = this._bj_Casino_Bot.LobbyScript.InputSlot.value;
let slot: any;
try {
slot = await import(/* @vite-ignore */`./Common/Game/Slot${id}`);
} catch (error) {
// this._bj_Casino_Bot.AddLog(`Slot${id} Spin error: ${error}`);
}
if (!slot) {
slot = await import(/* @vite-ignore */`./Common/Game/Base/SlotBase`);
}
const slot_default: typeof SlotBase = slot.default;
this.Slot = new slot_default(this._bj_Casino_Bot, this);
this.IsSpin.value = true;
this.Spin();
}
public async OnclickStop(): Promise<void> {
this._isSpin = false;
this.IsSpin.value = false;
}
//#endregion

View File

@ -1,4 +1,4 @@
import moment from "moment";
import dayjs from "dayjs";
import CSMessage from "./Base/CSMessage";
import { AccountLoginRequest } from "./Base/Request/AccountRequest";
import { AppRankHistory, AppRankInfo } from "./Base/Request/RankRequest";
@ -192,18 +192,18 @@ export class BJ_Casino_Data {
let id: number = +data["id"];
this._nowSearchMagnificationID = id;
this._nowContestID = id;
this._nowContestDate = moment().format("MM/DD");
this._nowContestDate = dayjs().format("MM/DD");
for (let i: number = 0; i < this.ContestData.length; i++) {
const contest: string = this.ContestData[i];
let str: string[] = contest.split("~");
let my: moment.Moment = this._getMomentFormString(this._nowContestDate);
let start: moment.Moment = this._getMomentFormString(str[0]);
let end: moment.Moment = this._getMomentFormString(str[1]);
let my = this._getdayjsFormString(this._nowContestDate);
let start: dayjs.Dayjs = this._getdayjsFormString(str[0]);
let end: dayjs.Dayjs = this._getdayjsFormString(str[1]);
let diff: number = my.diff(end, "day");
if (diff <= 0) {
this._nowContestIndex = i;
this._nowContestStart = moment(start).format("MM/DD");
this._nowContestEnd = moment(end).format("MM/DD");
this._nowContestStart = dayjs(start).format("MM/DD");
this._nowContestEnd = dayjs(end).format("MM/DD");
this._nowContestStartIndex = this._contestIDFormDate(this._nowContestStart);
this._nowContestEndIndex = this._contestIDFormDate(this._nowContestEnd);
break;
@ -365,9 +365,9 @@ export class BJ_Casino_Data {
await this.RunSetWeek(nowContestIndex);
// const contest: string = this.ContestData[nowContestIndex];
// let str: string[] = contest.split("~");
// let my: moment.Moment = this._getMomentFormString(this._nowContestDate);
// let start: moment.Moment = this._getMomentFormString(str[0]);
// let end: moment.Moment = this._getMomentFormString(str[1]);
// let my: dayjs.Dayjs = this._getdayjsFormString(this._nowContestDate);
// let start: dayjs.Dayjs = this._getdayjsFormString(str[0]);
// let end: dayjs.Dayjs = this._getdayjsFormString(str[1]);
// let diff: number = my.diff(start, "day");
// if (diff < 0) {
// alert(`還沒開放`);
@ -377,8 +377,8 @@ export class BJ_Casino_Data {
// this._isOK[0] = false;
// this._isOK[1] = false;
// this._nowContestStart = moment(start).format("MM/DD");
// this._nowContestEnd = moment(end).format("MM/DD");
// this._nowContestStart = dayjs(start).format("MM/DD");
// this._nowContestEnd = dayjs(end).format("MM/DD");
// this._nowContestStartIndex = this._contestIDFormDate(this._nowContestStart);
// this._nowContestEndIndex = this._nowSearchMagnificationID = this._contestIDFormDate(this._nowContestEnd);
// this.Title = `${this._nowContestStart}~${this._nowContestEnd}`;
@ -404,9 +404,9 @@ export class BJ_Casino_Data {
public async RunSetWeek(nowContestIndex: number): Promise<void> {
const contest: string = this.ContestData[nowContestIndex];
let str: string[] = contest.split("~");
let my: moment.Moment = this._getMomentFormString(this._nowContestDate);
let start: moment.Moment = this._getMomentFormString(str[0]);
let end: moment.Moment = this._getMomentFormString(str[1]);
let my: dayjs.Dayjs = this._getdayjsFormString(this._nowContestDate);
let start: dayjs.Dayjs = this._getdayjsFormString(str[0]);
let end: dayjs.Dayjs = this._getdayjsFormString(str[1]);
let diff: number = my.diff(start, "day");
if (diff < 0) {
alert(`還沒開放`);
@ -417,8 +417,8 @@ export class BJ_Casino_Data {
this._isOK[0] = false;
this._isOK[1] = false;
this._nowContestStart = moment(start).format("MM/DD");
this._nowContestEnd = moment(end).format("MM/DD");
this._nowContestStart = dayjs(start).format("MM/DD");
this._nowContestEnd = dayjs(end).format("MM/DD");
this._nowContestStartIndex = this._contestIDFormDate(this._nowContestStart);
this._nowContestEndIndex = this._contestIDFormDate(this._nowContestEnd);
if (this._isIDupup) {
@ -472,8 +472,8 @@ export class BJ_Casino_Data {
//#region Get
private _contestIDFormDate(date: string): number {
let my: moment.Moment = this._getMomentFormString(this._nowContestDate);
let target: moment.Moment = this._getMomentFormString(date);
let my: dayjs.Dayjs = this._getdayjsFormString(this._nowContestDate);
let target: dayjs.Dayjs = this._getdayjsFormString(date);
let diffday: number = my.diff(target, "day");
let id: number = this._nowContestID - diffday;
if (id < 0) {
@ -490,19 +490,19 @@ export class BJ_Casino_Data {
if (diffid < 0) {
diffid = 0;
}
let date: string = moment().subtract(diffid, "day").format("MM/DD");
let date: string = dayjs().subtract(diffid, "day").format("MM/DD");
return date;
}
private _getMomentFormString(str: string): moment.Moment {
private _getdayjsFormString(str: string): dayjs.Dayjs {
let data: string[] = str.split("/");
let m: number = +data[0] - 1;
let d: number = +data[1];
let date: Date = new Date();
date.setMonth(m);
date.setDate(d);
let mymoment: moment.Moment = moment(date);
return mymoment;
let mydayjs: dayjs.Dayjs = dayjs(date);
return mydayjs;
}
//#endregion

View File

@ -0,0 +1,93 @@
import CSMessage from "../../../Base/CSMessage";
import { BJ_Casino_Bot } from "../../../BJ_Casino_Bot";
import { BJ_Casino_Bot_Slot } from "../../../BJ_Casino_Bot_Slot";
import { INetResponse } from "../../../Engine/CatanEngine/NetManagerV2/Core/INetResponse";
import { CommonSlotFgSpinRequest, CommonSlotSpinRequest } from "../Request/CommonSlotRequest";
export default class SlotBase {
//#region public
public get ID(): number { return this._bj_Casino_Bot.LobbyScript.Slot; }
//#endregion
//#region protected
protected _bj_Casino_Bot: BJ_Casino_Bot;
protected _bj_Slot: BJ_Casino_Bot_Slot;
//#endregion
//#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();
}
public async onLoad(): Promise<void> {
//
}
//#endregion
//#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 = resp.Data;
} else {
CSMessage.NetError(resp.Method, resp.Status);
}
let money: number = +gameRunData["money"];
let winMoney: number = 0;
let winMoneyLog: string = "";
let freeLog: string = "";
let resources: any[] = gameRunData["get"];
let free: any[] = gameRunData["free"];
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;
}
}
}
if (free) {
let freeCount: number = free[1];
await this.FreeSpin(freeCount);
freeLog = `, hasFree: True, free: ${freeCount}`;
}
this._bj_Casino_Bot.UserData.Money = money;
this._bj_Casino_Bot.SetUI();
this._bj_Casino_Bot.AddLog(`Slot${this.ID} Spin Bet: ${this._bj_Slot.NowBet}, Money: ${money}${winMoneyLog}${freeLog}`);
}
public async FreeSpin(freeCount: number): Promise<void> {
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;
} else {
CSMessage.NetError(resp.Method, resp.Status);
}
this._bj_Casino_Bot.AddLog(`Slot${this.ID} FreeSpin MaxCount: ${freeCount}, Count: ${i + 1}`);
}
}
//#endregion
}

View File

@ -0,0 +1,78 @@
//=======================================================================================
import { NetRequest } from "../../../Engine/CatanEngine/NetManagerV2/NetRequest";
/**共用MAIN SPIN協定 */
export interface SpinRequest {
pay: number;
}
export class CommonSlotSpinRequest extends NetRequest<SpinRequest, JSON> {
private _id: number = 0;
get Method(): string {
return "slot" + this._id + ".spin";
}
constructor(slotId: number, totalBet: number) {
super();
this._id = slotId;
this.Data = {
pay: totalBet,
};
}
}
//=======================================================================================
export class CommonSlotFgSpinRequest extends NetRequest<any, JSON> {
private _id: number = 0;
get Method(): string {
return "slot" + this._id + ".fgspin";
}
constructor(slotId: number) {
super();
this._id = slotId;
}
}
//=======================================================================================
export class CommonSlotCollectUnlockRequest extends NetRequest<any, JSON> {
private _id: number = 0;
get Method(): string {
return "collect" + this._id + ".unlock";
}
constructor(slotId: number, grid: number) {
super();
this._id = slotId;
this.Data = {
Grid: grid,
};
}
}
//=======================================================================================
export class CommonSlotCollectSpinRequest extends NetRequest<any, JSON> {
private _id: number = 0;
get Method(): string {
return "collect" + this._id + ".spin";
}
constructor(slotId: number) {
super();
this._id = slotId;
}
}
//=======================================================================================
/**賓果 ChangeSet協定 */
export class CommonBingoChangeSet extends NetRequest<any, JSON> {
private _id: number = 0;
get Method(): string {
return "slot" + this._id + ".chset";
}
constructor(slotId: number) {
super();
this._id = slotId;
}
}
//=======================================================================================

View File

@ -0,0 +1,28 @@
import SlotBase from "./Base/SlotBase";
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<void> {
//
}
//#endregion
//#region Custom
//#endregion
}

View File

@ -4,12 +4,14 @@
"useDefineForClassFields": true,
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"strict": false,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": false,
"esModuleInterop": true,
// "strictNullChecks": false, // nullundefined
// "strictPropertyInitialization": false, //
"lib": [
"esnext",
"dom"