From a8fed0a87fd8a0ed22f03abf0ea46bb457eaacb8 Mon Sep 17 00:00:00 2001 From: JianMiau Date: Wed, 6 Dec 2023 13:56:43 +0800 Subject: [PATCH] =?UTF-8?q?[add]=20=E5=8F=AF=E7=94=A8=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintignore | 3 +- .gitignore | 4 +- build-templates/shared/jsons/slotset.json | 7 + index.html | 2 +- src/Common/DataReceived/MainControlData.ts | 6 +- src/Common/MainControl/MainControl.ts | 77 +++++- .../ResourceItem/Items/CardCouponItem.ts | 4 +- src/Common/ResourceItem/Items/LpPointItem.ts | 4 +- src/Common/ResourceItem/Items/MoneyItem.ts | 4 +- .../CatanEngine/TableV3/TableManager.ts | 8 +- src/UI/Lobby/SDGame.tsx | 143 +++++++--- src/UI/Lobby/SlotList.tsx | 4 +- src/UI/Login.tsx | 3 +- src/components/CustomA/index.tsx | 21 ++ src/context/GameItemsContext.tsx | 5 +- src/define/Game/Base/SlotBase.ts | 261 +++++++++--------- src/define/Game/Slot1306.ts | 13 + src/index.css | 1 + src/modules/GameManager.ts | 10 + src/modules/data/SlotData.ts | 8 + src/utils/Tools.ts | 11 + 21 files changed, 414 insertions(+), 185 deletions(-) create mode 100644 build-templates/shared/jsons/slotset.json create mode 100644 src/components/CustomA/index.tsx create mode 100644 src/define/Game/Slot1306.ts create mode 100644 src/modules/GameManager.ts create mode 100644 src/modules/data/SlotData.ts create mode 100644 src/utils/Tools.ts diff --git a/.eslintignore b/.eslintignore index 13b0ba2..6cb8fe8 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ src/FormTable -src/FormTableExt \ No newline at end of file +src/FormTableExt +src/FormTableSD \ No newline at end of file diff --git a/.gitignore b/.gitignore index f3611f6..e861e2f 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,6 @@ dist-ssr /src/FormTable /src/FormTable/* /src/FormTableExt -/src/FormTableExt/* \ No newline at end of file +/src/FormTableExt/* +/src/FormTableSD +/src/FormTableSD/* \ No newline at end of file diff --git a/build-templates/shared/jsons/slotset.json b/build-templates/shared/jsons/slotset.json new file mode 100644 index 0000000..6d4e2b3 --- /dev/null +++ b/build-templates/shared/jsons/slotset.json @@ -0,0 +1,7 @@ +{ + "#slotset" : + { + "cols" : ["Id","Pl","NameTw","NameCn","NameEn","NameSetting","FormName","Roll","Version","Web"], + "rows" : [[1,1,"福氣財神","福气财神","Fortune God of Wealth","Slot001",["line","slot_001"],1,202306061,null],[2,1,"火焰巨輪","火焰巨轮","Fire Wheel","Slot002",["line","slot_002"],1,202306061,null],[5,1,"雷電","雷电","Lightning Wild","Slot005",["line","slot_005"],null,202306061,null],[7,1,"惡魔與天使","恶魔与天使","Devil and Angel","Slot007",["line","slot_007"],null,202306061,null],[8,1,"拿摩多鯊魚","拿摩多鲨鱼","SHARK RAMPAGE","Slot008",["line","slot_008"],null,202306061,null],[9,1,"美女與野獸","美女与野兽","Beauty and the Beast","Slot009",["line","slot_009"],null,202306061,null],[10,1,"紅利金貓","红利金猫","Bonus Golden Cat","Slot010",["line","slot_010"],1,202306061,null],[12,1,"魔法少女","魔法少女","Little Witch","Slot012",["slot_012"],null,202306061,null],[15,1,"神鬼戰士","神鬼战士","Gladiator","Slot015",["line","slot_015"],null,202306061,null],[16,1,"風暴女王","风暴女王","Storm Queen","Slot016",["line","slot_016"],1,202306061,null],[18,1,"搖錢樹","摇钱树","Money Tree","Slot018",["line","slot_018"],1,202306061,null],[23,1,"888巨輪","888巨轮","888 Wheel","Slot023",["line","slot_023"],1,202306061,null],[24,1,"多發多財","多发多财","FaFa Fortunes","Slot024",["slot_024"],1,202306061,null],[25,1,"鑽石之都","钻石之都","Diamond City","Slot025",["line","slot_025"],1,202306061,null],[26,1,"紅利金鑽","红利金钻","VIP GOLD","Slot026",["line","slot_026"],1,202306061,null],[27,1,"富貴神龍","富贵神龙","Fortune Dragon","Slot027",["line","slot_027"],1,202306061,null],[28,1,"龍宮金輪","龙宫金轮","Dragon Palace","Slot028",["slot_028"],null,202306061,null],[29,1,"10倍經典","10倍经典","10X Classic","Slot029",["line","slot_029"],1,202306061,null],[30,1,"龍鳳呈祥","龙凤呈祥","Dragon & Phoenix","Slot030",["slot_030"],null,202306061,null],[31,1,"水滸群英傳","水浒群英传","WaterMargin","Slot031",["line","slot_031"],null,202306061,null],[32,1,"埃及豔后","埃及艳后","Cleopatra","Slot032",["line","slot_032"],null,202306061,null],[33,1,"香水玫瑰","香水玫瑰","Perfume rose","Slot033",["line","slot_033"],1,202306061,null],[34,1,"招財金貓","招财金猫","Fortune Kitty","Slot034",["line","slot_034"],1,202306061,null],[35,1,"多金多銀","多金多银","Gold & Silver","Slot035",["slot_035"],null,202306061,null],[36,1,"驚奇之星","惊奇之星","Fantastic Stars","Slot036",["line","slot_036"],null,202306061,null],[37,1,"幸運七","幸运七","Lucky 7","Slot037",["line","slot_037"],null,202306061,null],[39,1,"閃電倒轉","闪电倒转","Lightning Rewind","Slot039",["line","slot_039"],null,202306061,null],[40,1,"海之姬","海之姬","Queen of Ocean","Slot040",["slot_040"],1,202306061,null],[44,1,"五龍稱霸","五龙称霸","Dragon 5","Slot044",["line","slot_044"],null,202306061,null],[47,1,"財神降臨","财神降临","God of wealth","Slot047",["line","slot_047"],null,202306061,null],[48,1,"福星88","福星88","Fortune 88","Slot048",["slot_048"],1,202306061,null],[49,1,"幸運熊貓","幸运熊猫","Lucky Panda","Slot049",["line","slot_049"],1,202306061,null],[50,1,"吉鼓發財","吉鼓发财","Dancing drums","Slot050",["slot_050"],1,202306061,null],[51,1,"皇帝 88","皇帝 88","Emperor 88","Slot051",["line","slot_051"],1,202306061,null],[56,1,"彩色筆","彩色笔","Color Spin","Slot056",["line","slot_056"],1,202306061,null],[58,1,"鳳凰之怒","凤凰之怒","Phoenix Fury","Slot058",["line","slot_058"],null,202306061,null],[59,1,"多發多財單機版","多发多财单机版","FaFa Fortunes","Slot059",["line","slot_059"],null,202306061,null],[60,1,"無限連段","無限連段","Combo","Slot060",["slot_060"],null,202306061,null],[62,1,"常勝將軍","常勝將軍","All Win Man","Slot062",["line","slot_062"],null,202306061,null],[64,1,"小姐姐釣大魚","小姐姐釣大魚","Miss Fish","Slot064",["slot_064"],null,202306061,null],[65,1,"天妃娘娘","天妃娘娘","Mrs Sky","Slot065",["line","slot_065"],null,202306061,null],[66,1,"拔劍稱王","拔劍稱王","King","Slot066",["line","slot_066"],null,202306061,null],[67,1,"快上車","快上車","Car","Slot067",["line","slot_067"],null,202306061,null],[68,1,"阿拉丁","阿拉丁","Magic","Slot068",["line","slot_068"],null,202306061,null],[1101,1,"百搭八星彩","百搭八星彩","8 Bingo Stars","Bingo8stars",["bingo_8stars"],null,202306061,null],[1102,1,"連環九星彩","连环九星彩","9 Bingo Stars","Bingo9stars",["bingo_9stars"],null,202306061,null],[1201,1,"賞金勇者傳說EX","賞金勇者傳說EX","BOUNTY HUNTER EX","Slot1201",["slot_1201"],null,202306061,null],[1202,1,"壽司轉轉樂","壽司轉轉樂","Sushi","Slot1202",["slot_1202"],null,202306061,null],[1301,1,"夢幻餐廳","梦幻餐厅","Dream Restaurant","Cluster1301",["cluster_1301"],null,202306061,null],[1302,1,"莎菈的鍊金工房","莎菈的鍊金工房","Atelier Sarah:The Midas touch","Cluster1302",["cluster_1302"],null,202306061,null],[1303,1,"逗陣甜星3+1","逗陣甜星3+1","Candy Explosion","Cluster1303",["cluster_1303"],null,202306061,null],[1304,1,"逗陣寶貝龍","逗陣寶貝龍","Cluster1304","Cluster1304",["cluster_1304"],null,202306061,null],[1305,1,"紅心國王","紅心國王","Cluster1305","Cluster1305",["cluster_1305"],null,202306061,null],[1401,1,"哈辣瑪莉","哈辣玛莉","Other1401","Bar1401",["bar_1401"],null,202306061,null],[1501,1,"招財貓小鋼珠","招財貓小鋼珠","Pachinko1501","Slot1501",["slot_1501"],null,202306061,null],[1701,1,"一錘千金","一錘千金","Slot1701","Slot1701",["slot_1701"],1,202306061,null],[2001,1,"西遊塔防捕魚機","西游塔防捕鱼机","Journey to the West Tower Defense","Monkeytower",["monkeytower"],null,202306061,null],[2003,null,"大佬捕魚","大佬捕魚","Fish2003","Fish2003",["fish2003"],null,202306061,null],[2004,0,"海豹捕魚機","海豹捕魚機","Fish2004","Fish2004",["fish2004"],null,202306061,null],[3002,1,"雙星骰寶","双星骰宝","Double Star SicBo","TwoSicbo",["two_sicbo"],null,202306061,null],[3003,1,"九龍骰寶","九龙骰宝","Nine Dragon SicBo","NineSicbo",["nine_sicbo"],null,202306061,null],[3012,1,"三寶百家樂","三宝百家乐","San Bo Baccarat","TripleBaccarat",["triple_baccarat"],null,202306061,1],[3031,1,"色碟","色碟","色碟","Table3031",["table3031"],null,202306061,null]] + } +} \ No newline at end of file diff --git a/index.html b/index.html index 5529195..63b1b57 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,7 @@ history.go(1); }; - 來博娛樂城 + LP_Bot diff --git a/src/Common/DataReceived/MainControlData.ts b/src/Common/DataReceived/MainControlData.ts index 04b26ce..253ae49 100644 --- a/src/Common/DataReceived/MainControlData.ts +++ b/src/Common/DataReceived/MainControlData.ts @@ -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"; } diff --git a/src/Common/MainControl/MainControl.ts b/src/Common/MainControl/MainControl.ts index b31450f..0bcdb1d 100644 --- a/src/Common/MainControl/MainControl.ts +++ b/src/Common/MainControl/MainControl.ts @@ -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() { /** 每次啟動APP */ @@ -55,6 +57,60 @@ export class MainControl extends BaseSingleton() { MainControl.DataReceivedEvent.DispatchCallback([MainControl.DataType.ServerData, resp]); } + + //#region DownloadForm Function + + /** + * 載入外載表設定檔 + * @param formType FormType + */ + public static async DownloadForm(formType: DownloadForm.FormType): Promise { + 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[] = []; + 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 { + // 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 } @@ -66,4 +122,23 @@ export module MainControl { } } -export default MainControl; \ No newline at end of file +export default MainControl; + +//#region DownloadForm + +export module DownloadForm { + export enum FormType { + Formread = "formread", + } + + export class DownloadFormData { + + /** 已下載的表 */ + public static DownloadSuccess: Map = new Map(); + + /** Bag需要的表(xxxx.json) */ + public static formreadForm: string[] = ["slotset"]; + } +} + +//#endregion \ No newline at end of file diff --git a/src/Common/ResourceItem/Items/CardCouponItem.ts b/src/Common/ResourceItem/Items/CardCouponItem.ts index e875afe..097918e 100644 --- a/src/Common/ResourceItem/Items/CardCouponItem.ts +++ b/src/Common/ResourceItem/Items/CardCouponItem.ts @@ -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; diff --git a/src/Common/ResourceItem/Items/LpPointItem.ts b/src/Common/ResourceItem/Items/LpPointItem.ts index bec0d89..203f142 100644 --- a/src/Common/ResourceItem/Items/LpPointItem.ts +++ b/src/Common/ResourceItem/Items/LpPointItem.ts @@ -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; diff --git a/src/Common/ResourceItem/Items/MoneyItem.ts b/src/Common/ResourceItem/Items/MoneyItem.ts index 0a1dcd7..b8b3684 100644 --- a/src/Common/ResourceItem/Items/MoneyItem.ts +++ b/src/Common/ResourceItem/Items/MoneyItem.ts @@ -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; diff --git a/src/Engine/CatanEngine/TableV3/TableManager.ts b/src/Engine/CatanEngine/TableV3/TableManager.ts index b7ebfd8..d7e2c31 100644 --- a/src/Engine/CatanEngine/TableV3/TableManager.ts +++ b/src/Engine/CatanEngine/TableV3/TableManager.ts @@ -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]; } } diff --git a/src/UI/Lobby/SDGame.tsx b/src/UI/Lobby/SDGame.tsx index 5052e0c..3ff93ad 100644 --- a/src/UI/Lobby/SDGame.tsx +++ b/src/UI/Lobby/SDGame.tsx @@ -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(undefined); + const [isOK, setIsOK] = useState(false); + const [isSpin, setIsSpin] = useState(false); const [slotData, setSlotData] = useState(undefined); + const [items, setItems] = useState([]); + const [bet, setBet] = useState(0); + const [delay, setDelay] = useState(0.1); + const [isRatioStop, setIsRatio] = useState(false); + const [ratioStop, setRatio] = useState(200); + const [isCountStop, setIsSpinCount] = useState(false); + const [countStop, setSpinCount] = useState(200); + const [log, setLog] = useState([]); let conn: NetConnector = undefined; function* onLoad(): IterableIterator { @@ -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 { @@ -48,39 +60,76 @@ const SDGame = (props: ISDGame) => { } } - function* slotIn(slotid: number): IterableIterator { - let req: SlotInRequest = new SlotInRequest(slotid); + function* slotIn(): IterableIterator { + let req: SlotInRequest = new SlotInRequest(GameManager.SlotData.SlotId); yield req.SendAsync(true); let resp: INetResponse = 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: ( + { setBet(br[i]); GameManager.SlotData.NowBet = br[i]; }}> + {br[i]} + + ), + }); + } + 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 { - 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 { + 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 (<>
- -
- Bet: 20 -

- - -

-
-
- Log -
-
+ {isOK && + +
+

+ 押注 + + + +

+ +

+ 延遲 + ) => setDelay(+e.target.value)} type="text" value={delay} placeholder={delay.toString()} style={{ width: "10%" }} /> + 秒 +

+ +

+ 倍率 + setIsRatio(e.target.checked)} /> + {isRatioStop && <>) => setRatio(+e.target.value)} type="text" value={ratioStop} placeholder={ratioStop.toString()} style={{ width: "10%" }} />倍} +

+ +

+ 轉數 + setIsSpinCount(e.target.checked)} /> + {isCountStop && <>) => setSpinCount(+e.target.value)} type="text" value={countStop} placeholder={countStop.toString()} style={{ width: "10%" }} />轉} +

+ +

+ {isSpin + ? + : + } +

+
+
+ {log.map((log: string, index: number) =>

{log}

)} +
+
} +
); }; diff --git a/src/UI/Lobby/SlotList.tsx b/src/UI/Lobby/SlotList.tsx index 0fc6617..8c83591 100644 --- a/src/UI/Lobby/SlotList.tsx +++ b/src/UI/Lobby/SlotList.tsx @@ -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 = req.Result; if (!resp.IsValid) { if (resp.Status === 18) { - CSMessage.CreateYesMsg(CSSettingsV3.prototype.CommonString(16)); + CSMessage.CreateYesMsg(CSSettingsSDV3.prototype.CommonString(16)); } return; } diff --git a/src/UI/Login.tsx b/src/UI/Login.tsx index 7f0722f..87e8a7a 100644 --- a/src/UI/Login.tsx +++ b/src/UI/Login.tsx @@ -23,7 +23,8 @@ const Login = () => { const serverType: typeof BusinessEnum.ServerType = BusinessEnum.ServerType; const [type, setType] = useState(BusinessEnum.ServerType.Internal_Dev); const [isLogin, setIsLogin] = useState(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]; diff --git a/src/components/CustomA/index.tsx b/src/components/CustomA/index.tsx new file mode 100644 index 0000000..46815a5 --- /dev/null +++ b/src/components/CustomA/index.tsx @@ -0,0 +1,21 @@ +import { AnchorHTMLAttributes } from "react"; + +interface IAnchorProps extends AnchorHTMLAttributes { + useRef?: React.LegacyRef +} + +/** 阻止a標籤的href產生網頁跳轉 */ +export default function A(props: IAnchorProps) { + const { useRef, children, onClick } = props; + + function handleClick(event: React.MouseEvent) { + event.preventDefault(); // 阻止默认点击行为 + onClick && onClick(event); + } + + return ( + + {children} + + ); +} diff --git a/src/context/GameItemsContext.tsx b/src/context/GameItemsContext.tsx index d00c25d..cf3a7ef 100644 --- a/src/context/GameItemsContext.tsx +++ b/src/context/GameItemsContext.tsx @@ -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) ]); } diff --git a/src/define/Game/Base/SlotBase.ts b/src/define/Game/Base/SlotBase.ts index 6fb55e6..7dc8e8c 100644 --- a/src/define/Game/Base/SlotBase.ts +++ b/src/define/Game/Base/SlotBase.ts @@ -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 { + public *Spin(bet: number, isCountStop: boolean, countStop: number, isRatioStop: boolean, ratioStop: number, OnClickStop: () => void): IterableIterator { + 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 { - // let gameRunData: JSON = null; - // let req: CommonSlotSpinRequest = new CommonSlotSpinRequest(this.ID, this._bj_Slot.NowBet); - // await req.SendAsync(); - // let resp: INetResponse = 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 = 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 { - // 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 = 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 { - // 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 = 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 { - // let id: number = this._getFreeID(); - // let request: Slot_ChoiceRequest = new Slot_ChoiceRequest(id); - // await request.SendAsync(true); - // var result: INetResponse = 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 } diff --git a/src/define/Game/Slot1306.ts b/src/define/Game/Slot1306.ts new file mode 100644 index 0000000..3a8efc6 --- /dev/null +++ b/src/define/Game/Slot1306.ts @@ -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; \ No newline at end of file diff --git a/src/index.css b/src/index.css index 3b36766..f9df024 100644 --- a/src/index.css +++ b/src/index.css @@ -2,4 +2,5 @@ body { margin: 0; padding: 0; height: 100vh; + overflow: hidden; } \ No newline at end of file diff --git a/src/modules/GameManager.ts b/src/modules/GameManager.ts new file mode 100644 index 0000000..e06e1f0 --- /dev/null +++ b/src/modules/GameManager.ts @@ -0,0 +1,10 @@ +import SlotData from "./data/SlotData"; + +class GameManager { + /** SlotData */ + public readonly SlotData: SlotData = new SlotData(); +} + +export default new GameManager(); + +export { GameManager }; diff --git a/src/modules/data/SlotData.ts b/src/modules/data/SlotData.ts new file mode 100644 index 0000000..76752f9 --- /dev/null +++ b/src/modules/data/SlotData.ts @@ -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; +} diff --git a/src/utils/Tools.ts b/src/utils/Tools.ts new file mode 100644 index 0000000..0a94a8c --- /dev/null +++ b/src/utils/Tools.ts @@ -0,0 +1,11 @@ + +export class Tools { + + //#region Custom + + public static Sleep(ms: any): Promise { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + //#endregion +}