[add] 可用版本

This commit is contained in:
建喵 2023-12-06 13:56:43 +08:00
parent d80118bb68
commit a8fed0a87f
21 changed files with 414 additions and 185 deletions

View File

@ -1,2 +1,3 @@
src/FormTable
src/FormTableExt
src/FormTableSD

2
.gitignore vendored
View File

@ -28,3 +28,5 @@ dist-ssr
/src/FormTable/*
/src/FormTableExt
/src/FormTableExt/*
/src/FormTableSD
/src/FormTableSD/*

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,7 @@
history.go(1);
};
</script>
<title>來博娛樂城</title>
<title>LP_Bot</title>
</head>
<body oncontextmenu="return false">

View File

@ -1,6 +1,6 @@
import { CoroutineV2 } from "@/Engine/CatanEngine/CoroutineV2/CoroutineV2";
import { INetResponse } from "@/Engine/CatanEngine/NetManagerV2/Core/INetResponse";
import CSSettingsV3 from "@/FormTable/CSSettingsV3";
import CSSettingsSDV3 from "@/FormTable/CSSettingsV3";
import { gameSync } from "@/utils/setRPCData";
import MainControl from "../MainControl/MainControl";
import CSMessage from "../Message/CSMessage";
@ -76,9 +76,9 @@ export default class MainControlData {
console.debug("Disconnected Error Type : " + this._disconnectErrorType);
let str: string = null;
if (this._disconnectErrorType < 10 && this._disconnectErrorType >= 0) {
str = CSSettingsV3.prototype.CommonString(55 + this._disconnectErrorType);
str = CSSettingsSDV3.prototype.CommonString(55 + this._disconnectErrorType);
} else if (this._disconnectErrorType > 100 && this._disconnectErrorType < 110) {
str = CSSettingsV3.prototype.CommonString(65 + this._disconnectErrorType - 101);
str = CSSettingsSDV3.prototype.CommonString(65 + this._disconnectErrorType - 101);
} else {
str = "Server Disconnected";
}

View File

@ -2,8 +2,10 @@ import { Action } from "@/Engine/CatanEngine/CSharp/System/Action";
import { INetResponse } from "@/Engine/CatanEngine/NetManagerV2/Core/INetResponse";
import { NetConnector } from "@/Engine/CatanEngine/NetManagerV2/NetConnector";
import { NetManager } from "@/Engine/CatanEngine/NetManagerV2/NetManager";
import { TableManager } from "@/Engine/CatanEngine/TableV3/TableManager";
import BaseSingleton from "@/Engine/Utils/Singleton/BaseSingleton";
import BusinessTypeSetting from "@/_BusinessTypeSetting/BusinessTypeSetting";
import { Tools } from "@/utils/Tools";
export class MainControl extends BaseSingleton<MainControl>() {
/** 每次啟動APP */
@ -55,6 +57,60 @@ export class MainControl extends BaseSingleton<MainControl>() {
MainControl.DataReceivedEvent.DispatchCallback([MainControl.DataType.ServerData, resp]);
}
//#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 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 = "https://sd2-dev-patch.sdegaming.com/_Debug/shared/jsons/" + fileUrl;
// fileUrl = "https://patch.sdegaming.com/slot2/patch/_Release/shared/jsons/" + fileUrl;
// fileUrl = "http://patch-dev.online-bj.com/shared/jsons/" + fileUrl;
// fileUrl = "http://jianmiau.tk/_BJ_Source/BJ-Internal-Dev/shared/jsons/" + fileUrl;
fileUrl = "./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
}
@ -67,3 +123,22 @@ export module MainControl {
}
export default MainControl;
//#region DownloadForm
export module DownloadForm {
export enum FormType {
Formread = "formread",
}
export class DownloadFormData {
/** 已下載的表 */
public static DownloadSuccess: Map<string, boolean> = new Map<string, boolean>();
/** Bag需要的表(xxxx.json) */
public static formreadForm: string[] = ["slotset"];
}
}
//#endregion

View File

@ -1,4 +1,4 @@
import CSSettingsV3 from "@/FormTable/CSSettingsV3";
import CSSettingsSDV3 from "@/FormTable/CSSettingsV3";
import { LanguageManager } from "@/FormTableExt/Manage/Language/LanguageManager";
import { ResourceInfo } from "@/define/resource";
import { backpackInfo } from "@/utils/setRPCData";
@ -7,7 +7,7 @@ import IResourceItem from "../IResourceItem";
import { ResourceItemType } from "../ResourceItemType";
export default class CardCouponItem implements IResourceItem {
public get Name(): string { return CSSettingsV3.ItemSetting.StringDetail[+CSSettingsV3.ItemSetting.CouponSetting[this.ID].CardName][LanguageManager.GetMsgId()]; }
public get Name(): string { return CSSettingsSDV3.ItemSetting.StringDetail[+CSSettingsSDV3.ItemSetting.CouponSetting[this.ID].CardName][LanguageManager.GetMsgId()]; }
public get ResourceType(): ResourceItemType { return ResourceItemType.Card_Coupon; }
public ID: number;
public Count: number;

View File

@ -1,4 +1,4 @@
import CSSettingsV3 from "@/FormTable/CSSettingsV3";
import CSSettingsSDV3 from "@/FormTable/CSSettingsV3";
import { Shop } from "@/define/formkey";
import { ResourceInfo } from "@/define/resource";
import Player from "@/modules/player";
@ -9,7 +9,7 @@ import IResourceItem from "../IResourceItem";
import { ResourceItemType } from "../ResourceItemType";
export default class LpPointItem implements IResourceItem {
public get Name(): string { return CSSettingsV3.prototype.ShopString(Shop.String.LpPoint); }
public get Name(): string { return CSSettingsSDV3.prototype.ShopString(Shop.String.LpPoint); }
public get ResourceType(): ResourceItemType { return ResourceItemType.LpPoint; }
public ID: number;
public Count: number;

View File

@ -1,4 +1,4 @@
import CSSettingsV3 from "@/FormTable/CSSettingsV3";
import CSSettingsSDV3 from "@/FormTable/CSSettingsV3";
import Config from "@/define/Config";
import { Shop } from "@/define/formkey";
import { ResourceInfo } from "@/define/resource";
@ -9,7 +9,7 @@ import IResourceItem from "../IResourceItem";
import { ResourceItemType } from "../ResourceItemType";
export default class MoneyItem implements IResourceItem {
public get Name(): string { return CSSettingsV3.prototype.ShopString(Shop.String.Money); }
public get Name(): string { return CSSettingsSDV3.prototype.ShopString(Shop.String.Money); }
public get ResourceType(): ResourceItemType { return ResourceItemType.Money; }
public ID: number;
public Count: number;

View File

@ -12,13 +12,13 @@ export class TableManager {
}
}
public static AddJsonAsset(jsonAsset: JSON) {
public static AddJsonAsset(jsonAsset: any) {
if (!jsonAsset) {
return;
}
for (const tableName in jsonAsset) {
console.debug(`TableV3 [${ tableName }] json loaded`);
this._tableJsons[tableName] = jsonAsset[tableName];
for (let tableName in jsonAsset.json) {
console.log(`TableV3 [${tableName}] json loaded`);
this._tableJsons[tableName] = jsonAsset.json[tableName];
}
}

View File

@ -3,20 +3,31 @@ import { CoroutineV2 } from "@/Engine/CatanEngine/CoroutineV2/CoroutineV2";
import { INetResponse } from "@/Engine/CatanEngine/NetManagerV2/Core/INetResponse";
import { NetConnector } from "@/Engine/CatanEngine/NetManagerV2/NetConnector";
import { NetManagerSD } from "@/Engine/CatanEngine/NetManagerV2/NetManagerSD";
import A from "@/components/CustomA";
import { useGameItems } from "@/context/GameItemsContext";
import SlotBase from "@/define/Game/Base/SlotBase";
import { SDAccountLoginRequest } from "@/define/Request/AccountRequest";
import { SlotInRequest } from "@/define/Request/SlotRequest";
import { Button, Flex } from "antd";
import { useEffect, useState } from "react";
import GameManager from "@/modules/GameManager";
import { Button, Checkbox, Dropdown, Flex, Input, MenuProps } from "antd";
import { CheckboxChangeEvent } from "antd/es/checkbox";
import { ChangeEvent, useEffect, useState } from "react";
const SDGame = (props: ISDGame) => {
const { gameUrl, onClickSlotOut } = props;
const { player, setPlayer } = useGameItems();
const { gameData } = useGameItems();
const { nowSlotId } = gameData;
const [slotId, setSlotId] = useState<number>(undefined);
const [isOK, setIsOK] = useState<boolean>(false);
const [isSpin, setIsSpin] = useState<boolean>(false);
const [slotData, setSlotData] = useState<Object>(undefined);
const [items, setItems] = useState<MenuProps["items"]>([]);
const [bet, setBet] = useState<number>(0);
const [delay, setDelay] = useState<number>(0.1);
const [isRatioStop, setIsRatio] = useState<boolean>(false);
const [ratioStop, setRatio] = useState<number>(200);
const [isCountStop, setIsSpinCount] = useState<boolean>(false);
const [countStop, setSpinCount] = useState<number>(200);
const [log, setLog] = useState<string[]>([]);
let conn: NetConnector = undefined;
function* onLoad(): IterableIterator<any> {
@ -27,15 +38,16 @@ const SDGame = (props: ISDGame) => {
const host: string = queryParameters.get("host");
const port: number = 9005;
setSlotId(slotid);
GameManager.SlotData.SlotId = slotid;
conn = new NetConnector("https://" + host, port);
conn.OnDataReceived.AddCallback(onNetDataReceived);
conn.OnDisconnected.AddCallback(onNetDisconnected);
setSlotClass();
NetManagerSD.Initialize(conn);
console.log("[SDsocket] connecting...");
yield NetManagerSD.ConnectAsync();
yield* login(token);
yield* slotIn(slotid);
yield* slotIn();
}
function* login(token: string): IterableIterator<any> {
@ -48,39 +60,76 @@ const SDGame = (props: ISDGame) => {
}
}
function* slotIn(slotid: number): IterableIterator<any> {
let req: SlotInRequest = new SlotInRequest(slotid);
function* slotIn(): IterableIterator<any> {
let req: SlotInRequest = new SlotInRequest(GameManager.SlotData.SlotId);
yield req.SendAsync(true);
let resp: INetResponse<JSON> = req.Result;
if (resp.IsValid) {
setSlotData(resp.Data);
const br: number[] = resp.Data["br"];
const db: number = resp.Data["db"];
const betGroup: MenuProps["items"] = [];
for (let i = 0; i < br.length; i++) {
betGroup.push({
key: i,
label: (
<A href="#" onClick={() => { setBet(br[i]); GameManager.SlotData.NowBet = br[i]; }}>
{br[i]}
</A>
),
});
}
setItems(betGroup);
setBet(br[db]);
GameManager.SlotData.NowBet = br[db];
setIsOK(true);
}
}
async function OnclickSpin() {
async function setSlotClass() {
let slot: any;
const slotGroup: typeof import("../../define/Game/Base/Slot") = await import(/* @vite-ignore */`../../define/Game/Base/Slot`);
try {
slot = slotGroup[`Slot${slotId}`];
slot = slotGroup[`Slot${GameManager.SlotData.SlotId}`];
} catch (error) {
//
}
if (!slot) {
slot = slotGroup.SlotBase;
}
const slotClass: SlotBase = new slot(slotId);
// this.IsSpin.value = true;
CoroutineV2.Single(spin(slotClass)).Start();
GameManager.SlotData.SlotClass = new slot(GameManager.SlotData.SlotId, setRPCLog);
}
function* spin(slotClass: SlotBase): IterableIterator<any> {
yield* slotClass.Spin(20);
// await Tools.Sleep(this.SpinDelay.value * 1000);
// if (this.IsSpin.value && this._bj_Casino_Bot.LobbyScript.IsSlotIn.value) {
// this.Spin();
// } else {
// this.IsRun = false;
// }
async function OnClickSpin() {
GameManager.SlotData.IsSpin = true;
setIsSpin(true);
CoroutineV2.Single(spin()).Start();
}
function OnClickStop() {
GameManager.SlotData.IsSpin = false;
setIsSpin(false);
}
function* spin(): IterableIterator<any> {
yield* GameManager.SlotData.SlotClass.Spin(bet, isCountStop, countStop, isRatioStop, ratioStop, OnClickStop);
yield CoroutineV2.WaitTime(delay);
if (GameManager.SlotData.IsSpin) {
yield* spin();
} else {
setIsSpin(false);
}
}
function setRPCLog(s: string) {
setLog((v) => {
if (v.length > 100) {
v.pop();
}
v.unshift(s);
return v;
});
}
/**RPC回傳.若協定錯誤斷線.原因也會在這裡收到 */
@ -101,18 +150,46 @@ const SDGame = (props: ISDGame) => {
return (<>
<div style={siderStyle}>
<Flex gap="small" wrap="wrap">
<div style={controlStyle}>
Bet: 20
<p>
<Button type="primary" onClick={OnclickSpin} style={{ width: "20%" }}>Spin</Button>
<Button type="primary" danger onClick={onClickSlotOut} style={{ width: "20%" }}></Button>
</p>
</div>
<div>
Log
</div>
</Flex>
{isOK &&
<Flex gap="small" wrap="wrap">
<div style={controlStyle}>
<p>
<Dropdown menu={{ items }} placement="bottom">
<Button>{bet}</Button>
</Dropdown>
</p>
<p>
<Input onInput={(e: ChangeEvent<HTMLInputElement>) => setDelay(+e.target.value)} type="text" value={delay} placeholder={delay.toString()} style={{ width: "10%" }} />
</p>
<p>
<Checkbox onChange={(e: CheckboxChangeEvent) => setIsRatio(e.target.checked)} />
{isRatioStop && <><Input onInput={(e: ChangeEvent<HTMLInputElement>) => setRatio(+e.target.value)} type="text" value={ratioStop} placeholder={ratioStop.toString()} style={{ width: "10%" }} /></>}
</p>
<p>
<Checkbox onChange={(e: CheckboxChangeEvent) => setIsSpinCount(e.target.checked)} />
{isCountStop && <><Input onInput={(e: ChangeEvent<HTMLInputElement>) => setSpinCount(+e.target.value)} type="text" value={countStop} placeholder={countStop.toString()} style={{ width: "10%" }} /></>}
</p>
<p>
{isSpin
? <Button type="primary" onClick={OnClickStop} style={{ width: "20%" }}>Stop</Button>
: <Button type="primary" onClick={OnClickSpin} style={{ width: "20%" }}>Spin</Button>
}
</p>
</div>
<div style={{ height: "90vh", position: "relative", top: "0%", overflowY: "scroll" }}>
{log.map((log: string, index: number) => <p key={index}>{log}</p>)}
</div>
</Flex>}
<Button type="primary" danger onClick={onClickSlotOut} style={{ width: "20%", position: "fixed", bottom: "1%" }}></Button>
</div>
</>);
};

View File

@ -1,7 +1,7 @@
import CSMessage from "@/Common/Message/CSMessage";
import { CoroutineV2 } from "@/Engine/CatanEngine/CoroutineV2/CoroutineV2";
import { INetResponse } from "@/Engine/CatanEngine/NetManagerV2/Core/INetResponse";
import CSSettingsV3 from "@/FormTable/CSSettingsV3";
import CSSettingsSDV3 from "@/FormTable/CSSettingsV3";
import BusinessTypeSetting from "@/_BusinessTypeSetting/BusinessTypeSetting";
import Image from "@/components/Image/Image";
import { useGameItems } from "@/context/GameItemsContext";
@ -29,7 +29,7 @@ const SlotList = () => {
const resp: INetResponse<RpcGameLaunchResponse> = req.Result;
if (!resp.IsValid) {
if (resp.Status === 18) {
CSMessage.CreateYesMsg(CSSettingsV3.prototype.CommonString(16));
CSMessage.CreateYesMsg(CSSettingsSDV3.prototype.CommonString(16));
}
return;
}

View File

@ -23,7 +23,8 @@ const Login = () => {
const serverType: typeof BusinessEnum.ServerType = BusinessEnum.ServerType;
const [type, setType] = useState<number>(BusinessEnum.ServerType.Internal_Dev);
const [isLogin, setIsLogin] = useState<boolean>(false);
const [token, SetToken] = useState("eyJhbGciOiJIUzI1NiJ9.Am-dhpCRUo9iBHYJ0kro12-zUlOyNAVOw9poXEkUV14hvkL2RPxVqqtrsYbS9_aoKep4EOFYROFTbv6MfVai7gomKdr07XkmTtADtkbchkfm-yuGXVzW1mYabf646_U66MnvXX2PHS-ATXDYYx5He9PJ-5lF9g5BmhtxUYPW98w.MGUUrFQbBeUBPDJeoKMilbqbg6IkwEqbu2oyJVSmw6M");
const a = "eyJhbGciOiJIUzI1NiJ9.hoaQl5V6Ni6G3xXJXSADO-aS2fopaAd8lA-K6UkTUbhU46l1B5JU2TxINvsRQPmNE1TzKPc0MD5dyFOEJmo8gpGtRWsMWiyzekENR6QwJluQa2nL83QNZaif8BhEff1vm0F_TOAA2ENDiaY7VnkeLHB-Dv3KyRo5AEAmYVFWK_A.k1rj5BHgPKCVvI7sDjBwb6dGOl4OH3131NIr5vxVrGA";
const [token, SetToken] = useState(a);
const options: Option[] = [];
for (let i = 0, names: string[] = Object.keys(serverType); i < names.length; i++) {
const key: string = names[i];

View File

@ -0,0 +1,21 @@
import { AnchorHTMLAttributes } from "react";
interface IAnchorProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
useRef?: React.LegacyRef<HTMLAnchorElement>
}
/** 阻止a標籤的href產生網頁跳轉 */
export default function A(props: IAnchorProps) {
const { useRef, children, onClick } = props;
function handleClick(event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) {
event.preventDefault(); // 阻止默认点击行为
onClick && onClick(event);
}
return (
<a {...props} ref={useRef} onClick={handleClick}>
{children}
</a>
);
}

View File

@ -1,5 +1,5 @@
import MainControlData from "@/Common/DataReceived/MainControlData";
import MainControl from "@/Common/MainControl/MainControl";
import MainControl, { DownloadForm } from "@/Common/MainControl/MainControl";
import BusinessTypeSetting, { BusinessEnum } from "@/_BusinessTypeSetting/BusinessTypeSetting";
import { GameData } from "@/define/gameData";
import { PlayerData } from "@/define/playerData";
@ -37,6 +37,9 @@ export function GameItemsProvider({ children }: GameItemsProviderProps) {
// // 設定LineTools環境
// await setLineTools(),
// DownloadForm
await MainControl.DownloadForm(DownloadForm.FormType.Formread)
]);
}

View File

@ -1,12 +1,17 @@
import CSMessage from "@/Common/Message/CSMessage";
import { INetResponse } from "@/Engine/CatanEngine/NetManagerV2/Core/INetResponse";
import { CommonSlotSpinRequest } from "../Request/CommonSlotRequest";
import CSSettingsSDV3 from "@/FormTableSD/CSSettingsSDV3";
import { gameObj } from "@/context/GameItemsContext";
import GameManager from "@/modules/GameManager";
import { NumberEx } from "@/utils/Number/NumberEx";
import { CommonSlotFgSpinRequest, CommonSlotSpinRequest } from "../Request/CommonSlotRequest";
import { Slot_ChoiceRequest } from "../Request/SlotRequest";
export class SlotBase {
//#region public
// public get ID(): number { return this._bj_Casino_Bot.LobbyScript.Slot; }
public get ID(): number { return this.id; }
public get FreeID(): number { return 1; }
public get FreeCount(): number { return +this.GameRunData["free"][1]; }
public get HasChoiceFreeGame(): boolean { return false; }
@ -20,7 +25,11 @@ export class SlotBase {
protected id: number;
// protected _bj_Slot: BJ_Casino_Bot_Slot;
//#endregion
//#region private
private addLog: (v: string) => void;
//#endregion
@ -29,8 +38,9 @@ export class SlotBase {
/**
*
*/
constructor(id: number) {
constructor(id: number, addLog: (v: string) => void) {
this.id = id;
this.addLog = addLog;
this.onLoad();
}
@ -42,7 +52,8 @@ export class SlotBase {
//#region Custom
public *Spin(bet: number): IterableIterator<any> {
public *Spin(bet: number, isCountStop: boolean, countStop: number, isRatioStop: boolean, ratioStop: number, OnClickStop: () => void): IterableIterator<any> {
const { player, setPlayer } = gameObj;
let gameRunData: JSON = null;
let req: CommonSlotSpinRequest = new CommonSlotSpinRequest(this.id, bet);
yield req.SendAsync();
@ -52,139 +63,127 @@ export class SlotBase {
} 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 = yield* this._getFreeCount();
let fsWinMoney: number = 0;
let fsMoney: number = 0;
[freeCount, fsWinMoney, fsMoney] = yield* this.FreeSpin(freeCount);
if (fsMoney > 0) {
money = fsMoney;
}
if (fsWinMoney > 0) {
winMoney = fsWinMoney;
}
freeLog = `, hasFree: ${freeCount}`;
}
if (winMoney > 0) {
winMoneyLog = `, winMoney: ${winMoney}`;
}
setPlayer({ ...player, m: money });
// this._bj_Casino_Bot.SetUI();
let ratio: number = winMoney > 0 ? NumberEx.divide(winMoney, GameManager.SlotData.NowBet) : 0;
if (isRatioStop && ratio >= ratioStop) {
OnClickStop();
}
if (isCountStop && countStop === 0) {
OnClickStop();
}
if (ratio > 100) {
this.addLog(`Slot${this.ID} Spin Bet: ${GameManager.SlotData.NowBet}, Ratio: ${ratio}, Money: ${money}${winMoneyLog}${freeLog}`);
}
this.addLog(`Slot${this.ID} Spin Bet: ${GameManager.SlotData.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();
// }
// if (ratio > 100) {
// this._bj_Casino_Bot.AddLog(`Slot${this.ID} Spin Bet: ${this._bj_Slot.NowBet}, Ratio: ${ratio}, Money: ${money}${winMoneyLog}${freeLog}`);
// }
// // this._bj_Casino_Bot.AddLog(`Slot${this.ID} Spin Bet: ${this._bj_Slot.NowBet}, Money: ${money}${winMoneyLog}${freeLog}`);
// }
public * FreeSpin(freeCount: 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);
yield 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.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 *_getFreeCount() {
if (this.HasChoiceFreeGame) {
return yield* this._getChoiceFreeCount();
} else {
return this.FreeCount;
}
}
// protected async _getFreeCount(): Promise<number> {
// if (this.HasChoiceFreeGame) {
// return await this._getChoiceFreeCount();
// } else {
// return this.FreeCount;
// }
// }
protected * _getChoiceFreeCount() {
let id: number = this._getFreeID();
let request: Slot_ChoiceRequest = new Slot_ChoiceRequest(id);
yield request.SendAsync(true);
let result: INetResponse<number> = request.Result;
if (result.IsValid) {
if (this.SlotReqRespIsCount) {
return result.Data;
} else {
let slotNameSetting: string = CSSettingsSDV3.Slotset[this.ID].NameSetting;
let free_info_id: number = result.Data;
let slotSetting: any = CSSettingsSDV3[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
}

View File

@ -0,0 +1,13 @@
import SlotBase from "./Base/SlotBase";
export class Slot1305 extends SlotBase {
//#region public
public get ID(): number { return 1306; }
public get HasRetriggerFreeSpin(): boolean { return true; }
//#endregion
}
export default Slot1305;

View File

@ -2,4 +2,5 @@ body {
margin: 0;
padding: 0;
height: 100vh;
overflow: hidden;
}

View File

@ -0,0 +1,10 @@
import SlotData from "./data/SlotData";
class GameManager {
/** SlotData */
public readonly SlotData: SlotData = new SlotData();
}
export default new GameManager();
export { GameManager };

View File

@ -0,0 +1,8 @@
import SlotBase from "@/define/Game/Base/SlotBase";
export default class SlotData {
public SlotId: number = undefined;
public SlotClass: SlotBase = undefined;
public IsSpin: boolean = false;
public NowBet: number = undefined;
}

11
src/utils/Tools.ts Normal file
View File

@ -0,0 +1,11 @@
export class Tools {
//#region Custom
public static Sleep(ms: any): Promise<unknown> {
return new Promise(resolve => setTimeout(resolve, ms));
}
//#endregion
}