diff --git a/index.html b/index.html
index 756baf9..5529195 100644
--- a/index.html
+++ b/index.html
@@ -17,7 +17,7 @@
-
+
diff --git a/src/Common/DataReceived/MainControlData.ts b/src/Common/DataReceived/MainControlData.ts
index d37e05a..04b26ce 100644
--- a/src/Common/DataReceived/MainControlData.ts
+++ b/src/Common/DataReceived/MainControlData.ts
@@ -1,23 +1,9 @@
+import { CoroutineV2 } from "@/Engine/CatanEngine/CoroutineV2/CoroutineV2";
import { INetResponse } from "@/Engine/CatanEngine/NetManagerV2/Core/INetResponse";
import CSSettingsV3 from "@/FormTable/CSSettingsV3";
-import { confirmModalObj } from "@/UI/MessageBox/ConfirmModalContext";
-import { modalObj } from "@/UIControl/ModalContext";
-import { Cocos } from "@/assets/VueScript/Cocos";
-import { CommonEventCallBack, JackpotPoolCallBack } from "@/assets/VueScript/CocosVueScript";
-import GameData_Cocos from "@/assets/VueScript/share/GameData_Cocos";
-import { chatLog, chatMessage, setChatBanTime } from "@/components/ModalContent/ChatRoomModal/chatUtils";
-import Config from "@/define/Config";
-import Player from "@/modules/player";
-import UserData from "@/modules/player/UserData";
-import { State } from "@/modules/player/define/data";
-import { ILineShareData, ModalContentType } from "@/types";
-import { CommonEventType } from "@/utils";
-import { NumberEx } from "@/utils/Number/NumberEx";
-import { activityComSync, backpackInfo, friendAllowList, friendDenyList, profileInfo, txnCenter, txnNew, txnTrade, txnUserAdd, vipInfo } from "@/utils/setRPCData";
+import { gameSync } from "@/utils/setRPCData";
import MainControl from "../MainControl/MainControl";
import CSMessage from "../Message/CSMessage";
-import CSResource from "../ResourceItem/CSResource";
-import IResourceItem from "../ResourceItem/IResourceItem";
export default class MainControlData {
@@ -46,7 +32,7 @@ export default class MainControlData {
private _disconnectErrorType: number = null;
constructor() {
- Player.DataReceivedEvent.AddCallback(this._dataReceivedEvent, this);
+ MainControl.DataReceivedEvent.AddCallback(this._dataReceivedEvent, this);
}
private _dataReceivedEvent(param: any[] = null): void {
let type: MainControl.DataType = param[0];
@@ -67,139 +53,8 @@ export default class MainControlData {
private _serverData(resp: INetResponse): void {
if (resp.IsValid) {
switch (resp.Method) {
- case "activity_com.sync": {
- activityComSync(resp.Data);
- break;
- }
- case "backpack.info": {
- backpackInfo(resp.Data);
- break;
- }
- case "chat.ban": {
- setChatBanTime(resp.Data);
- break;
- }
- case "chat.message": {
- chatMessage(resp.Data);
- break;
- }
- case "chat.log": {
- chatLog(resp.Data);
- break;
- }
- case "friend.allow_list": {
- friendAllowList(resp.Data);
- break;
- }
- case "friend.deny_list": {
- friendDenyList(resp.Data);
- break;
- }
- case "game.share": {
- const { openLineShareGame } = confirmModalObj;
- const data: ILineShareData = {
- slotID: resp.Data[0],
- winMilt: resp.Data[1]
- };
- openLineShareGame(data);
- break;
- }
case "game.sync": {
- Cocos.VicKing_Bridge.InGameGetUUID = true;
- break;
- }
- case "jackpot.get": {
- const { handleOpen, setModalType } = modalObj;
- const playerData: State = Player.data.getState();
- playerData.account.jackpotGet.push(...resp.Data);
- Player.data.setState(playerData);
- setModalType(ModalContentType.jackpot);
- handleOpen();
- break;
- }
- case "jackpot.pool": {
- const playerData: State = Player.data.getState();
- if (!Config.IsVite || MainControl.Instance.IsInGame) {
- for (let i = 0; i < playerData.game.jackpotPool.length; i++) {
- const oldJpData: [gameId: number, maxJPId: number, jp: number] = playerData.game.jackpotPool[i];
- let newJpData: [gameId: number, maxJPId: number, jp: number] = null;
- for (let j = 0; j < resp.Data.length; j++) {
- const [gameId, maxJPId, jp] = resp.Data[j];
- if (gameId === oldJpData[0]) {
- newJpData = resp.Data[j];
- break;
- }
- }
- if (!newJpData) {
- JackpotPoolCallBack.DispatchCallback(oldJpData[0], 0);
- }
- }
- }
- playerData.game.jackpotPool = resp.Data;
- Player.data.setState(playerData);
- if (!Config.IsVite || MainControl.Instance.IsInGame) {
- for (let i = 0; i < playerData.game.jackpotPool.length; i++) {
- const jpData: [gameId: number, maxJPId: number, jp: number] = playerData.game.jackpotPool[i];
- JackpotPoolCallBack.DispatchCallback(jpData[0], jpData[2]);
- }
- } else {
- Cocos.CocosEventListener.DispatchCallback(GameData_Cocos.CELT.UpdateJPPool, null);
- }
- break;
- }
- case "maintain.info": {
- const playerData: State = Player.data.getState();
- if (resp.Data) {
- resp.Data[3] = NumberEx.plus(MainControl.Instance.NowTime, resp.Data[3]);
- playerData.maintain = resp.Data;
- CommonEventCallBack.DispatchCallback(CommonEventType.Maintenance, null);
- } else {
- playerData.maintain = undefined;
- }
- Player.data.setState(playerData);
- break;
- }
- case "profile.info": {
- profileInfo(resp.Data);
- break;
- }
- case "resource.update": {
- const resourceItems: IResourceItem[] = CSResource.GetResourceItemsFromServer(resp.Data);
- UserData.DoResUpdate(resourceItems);
- break;
- }
- case "resource.bankruptcy": {
- Cocos.CocosEventListener.DispatchCallback(GameData_Cocos.CELT.Bankruptcy, null);
- break;
- }
- case "system.disconnect": {
- this._disconnectErrorType = +resp.Data["c"];
- break;
- }
- case "txn.new": {
- txnNew(resp.Data);
- break;
- }
- case "txn.center": {
- txnCenter(resp.Data);
- break;
- }
- case "txn.trade": {
- txnTrade(resp.Data);
- break;
- }
- case "txn.user_add": {
- txnUserAdd(resp.Data);
- break;
- }
- case "vip.info": {
- vipInfo(resp.Data);
- break;
- }
- case "vip.level": {
- const playerData: State = Player.data.getState();
- playerData.vip.level = resp.Data;
- Player.data.setState(playerData);
+ CoroutineV2.Single(gameSync()).Start();
break;
}
default:
@@ -207,10 +62,9 @@ export default class MainControlData {
}
} else {
switch (resp.Method) {
- case "chat.log": {
- chatLog([null, null]);
- break;
- }
+ // case "": {
+ // break;
+ // }
default:
break;
}
diff --git a/src/Common/Message/CSMessage.ts b/src/Common/Message/CSMessage.ts
index 9229721..22b1669 100644
--- a/src/Common/Message/CSMessage.ts
+++ b/src/Common/Message/CSMessage.ts
@@ -1,8 +1,4 @@
-import CSSettingsV3 from "@/FormTable/CSSettingsV3";
-import { IConfirmMessageData } from "@/UI/MessageBox/ConfirmMessage";
-import { confirmModalObj } from "@/UI/MessageBox/ConfirmModalContext";
-import { StringFormKey } from "@/define/formkey";
-
+import { IConfirmMessageData, modalObj } from "@/UIControl/ModalContext";
/** 訊息框相關 */
export default class CSMessage {
@@ -10,7 +6,7 @@ export default class CSMessage {
/** 一個按鈕的訊息框 */
public static CreateYesMsg(content: string, yesCallback: () => void = null, enterStr: string = null, title: string = null, textAlign: "center" | "left" | "right" = null) {
- enterStr = enterStr ? enterStr : CSSettingsV3.prototype.CommonString(StringFormKey.String.Confirm);
+ enterStr = enterStr ? enterStr : "確認";
let data: IConfirmMessageData = {
title: title,
content: content,
@@ -19,14 +15,14 @@ export default class CSMessage {
enterStr: enterStr,
textAlign: textAlign
};
- const { openOtherConfirm } = confirmModalObj;
- openOtherConfirm(data);
+ const { handleOpen } = modalObj;
+ handleOpen(data);
}
/** 兩個按鈕的訊息框 */
public static CreateYesNoMsg(content: string, yesCallback: () => void = null, noCallback: () => void = null, enterStr: string = null, title: string = null, cancelStr: string = null, textAlign: "center" | "left" | "right" = null) {
- enterStr = enterStr ? enterStr : CSSettingsV3.prototype.CommonString(StringFormKey.String.Confirm);
- cancelStr = cancelStr ? cancelStr : CSSettingsV3.prototype.CommonString(StringFormKey.String.Cancel);
+ enterStr = enterStr ? enterStr : "確認";
+ cancelStr = cancelStr ? cancelStr : "取消";
let data: IConfirmMessageData = {
title: title,
content: content,
@@ -37,8 +33,8 @@ export default class CSMessage {
cancelStr: cancelStr,
textAlign: textAlign
};
- const { openOtherConfirm } = confirmModalObj;
- openOtherConfirm(data);
+ const { handleOpen } = modalObj;
+ handleOpen(data);
}
/** 網路錯誤訊息 */
diff --git a/src/Engine/CatanEngine/NetManagerV2/NetConnector.ts b/src/Engine/CatanEngine/NetManagerV2/NetConnector.ts
index 43d8636..6e0f06d 100644
--- a/src/Engine/CatanEngine/NetManagerV2/NetConnector.ts
+++ b/src/Engine/CatanEngine/NetManagerV2/NetConnector.ts
@@ -82,9 +82,9 @@ export class NetConnector {
// if (CC_DEBUG && NetConfig.ShowServerLog) {
if (NetConfig.ShowServerLog) {
if (req.Data != null && req.Data != undefined && !Number.isNaN(req.Data)) {
- console.debug(`[RPC] 傳送server資料: ${req.Method}(${JSON.stringify(req.Data)})`);
+ console.log(`[RPC] 傳送server資料: ${req.Method}(${JSON.stringify(req.Data)})`);
} else {
- console.debug(`[RPC] 傳送server資料: ${req.Method}()`);
+ console.log(`[RPC] 傳送server資料: ${req.Method}()`);
}
}
@@ -185,9 +185,9 @@ export class NetConnector {
// if (CC_DEBUG && NetConfig.ShowServerLog) {
if (NetConfig.ShowServerLog) {
if (data) {
- console.debug(`[RPC] 收到server呼叫:(${resp.Status}): ${resp.Method}(${JSON.stringify(resp.Data)})`);
+ console.log(`[RPC] 收到server呼叫:(${resp.Status}): ${resp.Method}(${JSON.stringify(resp.Data)})`);
} else {
- console.debug(`[RPC] 收到server呼叫:(${resp.Status}): ${resp.Method}()`);
+ console.log(`[RPC] 收到server呼叫:(${resp.Status}): ${resp.Method}()`);
}
}
diff --git a/src/Engine/CatanEngine/NetManagerV2/NetManagerSD.ts b/src/Engine/CatanEngine/NetManagerV2/NetManagerSD.ts
new file mode 100644
index 0000000..8d77590
--- /dev/null
+++ b/src/Engine/CatanEngine/NetManagerV2/NetManagerSD.ts
@@ -0,0 +1,54 @@
+import { INetRequest } from "./Core/INetRequest";
+import { NetConnector } from "./NetConnector";
+
+export class NetManagerSD {
+ static get IsConnected() {
+ return this._connector && this._connector.IsConnected;
+ }
+
+ static get HasInit() {
+ return this._connector != null;
+ }
+
+ private static _connector: NetConnector;
+
+ static Initialize(connector: NetConnector) {
+ this._connector = connector;
+ }
+
+ static ConnectAsync() {
+ this.CheckConnector();
+ return this._connector.ConnectAsync();
+ }
+
+ /**
+ * 斷線
+ */
+ static Disconnect() {
+ this.CheckConnector();
+ this._connector.Disconnect();
+ }
+
+ /**
+ * 傳送資料給Server, 不等待回應
+ * @param req
+ */
+ static Send(req: INetRequest) {
+ this.CheckConnector();
+ this._connector.Send(req);
+ }
+
+ /**
+ * 傳送資料給Server, 並等待回應
+ * @param req
+ */
+ static SendAsync(req: INetRequest, mask: boolean) {
+ this.CheckConnector();
+ return this._connector.SendAsync(req, mask);
+ }
+
+ private static CheckConnector() {
+ if (!this._connector) throw new Error("請先呼叫CasinoNetManager.Initialize()初始化connector");
+ }
+
+}
\ No newline at end of file
diff --git a/src/Engine/CatanEngine/NetManagerV2/NetRequest.ts b/src/Engine/CatanEngine/NetManagerV2/NetRequest.ts
index 669342a..87333c9 100644
--- a/src/Engine/CatanEngine/NetManagerV2/NetRequest.ts
+++ b/src/Engine/CatanEngine/NetManagerV2/NetRequest.ts
@@ -1,5 +1,5 @@
-import { VueNetConnector } from "@/assets/VueScript/Net/VueNetConnector";
import { INetRequest } from "./Core/INetRequest";
+import { NetManager } from "./NetManager";
export abstract class NetRequest implements INetRequest {
abstract get Method(): string;
@@ -11,18 +11,11 @@ export abstract class NetRequest implements INetRequest;
- /**
- * 在大廳呼叫Cocos會收到SERVER主動通知
- * 在大廳呼叫Cocos會收到SERVER主動通知
- * 在大廳呼叫Cocos會收到SERVER主動通知
- */
SendAsync(mask: boolean = false): Iterator {
- // return NetManager.SendAsync(this, mask);
- return VueNetConnector.SendAsync(this, mask);
+ return NetManager.SendAsync(this, mask);
}
Send() {
- // NetManager.Send(this);
- VueNetConnector.Send(this);
+ NetManager.Send(this);
}
}
diff --git a/src/Engine/CatanEngine/NetManagerV2/NetRequestSD.ts b/src/Engine/CatanEngine/NetManagerV2/NetRequestSD.ts
new file mode 100644
index 0000000..959c8a2
--- /dev/null
+++ b/src/Engine/CatanEngine/NetManagerV2/NetRequestSD.ts
@@ -0,0 +1,21 @@
+import { INetRequest } from "./Core/INetRequest";
+import { NetManagerSD } from "./NetManagerSD";
+
+export abstract class NetRequestSD implements INetRequest {
+ abstract get Method(): string;
+
+ get MethodBack(): string {
+ return this.Method;
+ }
+
+ Data: TResquest;
+ Result: import("./Core/INetResponse").INetResponse;
+
+ SendAsync(mask: boolean = false): Iterator {
+ return NetManagerSD.SendAsync(this, mask);
+ }
+
+ Send() {
+ NetManagerSD.Send(this);
+ }
+}
diff --git a/src/UI/Lobby.tsx b/src/UI/Lobby.tsx
index 7efbbb7..f4d305e 100644
--- a/src/UI/Lobby.tsx
+++ b/src/UI/Lobby.tsx
@@ -1,11 +1,9 @@
-import MainControl from "@/Common/MainControl/MainControl";
-import CSMessage from "@/Common/Message/CSMessage";
-import { CoroutineV2 } from "@/Engine/CatanEngine/CoroutineV2/CoroutineV2";
-import { INetResponse } from "@/Engine/CatanEngine/NetManagerV2/Core/INetResponse";
import { useGameItems } from "@/context/GameItemsContext";
-import { CommonAccountResponse, LineLoginRequest } from "@/define/Request/RegisterRequest";
+import { Layout } from "antd";
import { useEffect } from "react";
import { useNavigate } from "react-router-dom";
+import Player from "./Lobby/Player";
+import SlotList from "./Lobby/SlotList";
const Lobby = () => {
const { player, setPlayer } = useGameItems();
@@ -17,30 +15,6 @@ const Lobby = () => {
navigate(`/`);
return;
}
- CoroutineV2.Single(onStart()).Start();
- }
-
- function* onStart() {
- yield* MainControl.Instance.ConnectAsync();
-
- }
- function* registerLineLogin() {
- let req: LineLoginRequest = new LineLoginRequest(token);
- yield req.SendAsync(true);
- let resp: INetResponse = req.Result;
- if (!resp.IsValid) {
- //取得帳號失敗直接斷開SOCKET
- if (resp.Status != 12) {
- const msg: string = "Line Info Error. Error Code:" + req.Result.Status;
- CSMessage.CreateYesMsg(msg);
- return;
- }
- console.warn("LINE帳號無綁定");
- return;
- }
- // yield* this.ServerAccountLogin(resp.Data.id, resp.Data.pw);
-
- return;
}
useEffect(() => {
@@ -48,7 +22,10 @@ const Lobby = () => {
}, []);
return (
- <>Lobby>
+
+
+ {}
+
);
};
diff --git a/src/UI/Lobby/Player.tsx b/src/UI/Lobby/Player.tsx
new file mode 100644
index 0000000..2d5dabd
--- /dev/null
+++ b/src/UI/Lobby/Player.tsx
@@ -0,0 +1,35 @@
+import { CurrencyManager } from "@/FormTableExt/Manage/Currency/CurrencyManager";
+import { useGameItems } from "@/context/GameItemsContext";
+import { useEffect } from "react";
+
+const Player = () => {
+ const { player } = useGameItems();
+ const { aId, name, m } = player;
+
+ function onLoad() {
+ }
+
+ useEffect(() => {
+ onLoad();
+ }, []);
+
+ return (
+
+
aId: {aId}
+
暱稱: {name}
+
金幣: {CurrencyManager.GetNumberWithComma(m)}
+
+ );
+};
+
+export default Player;
+
+const siderStyle: React.CSSProperties = {
+ fontSize: "1rem",
+ color: "#000000",
+ display: "flex",
+ textAlign: "left",
+ flexDirection: "column",
+ justifyContent: "center",
+ width: "20%"
+};
\ No newline at end of file
diff --git a/src/UI/Lobby/SDGame.tsx b/src/UI/Lobby/SDGame.tsx
new file mode 100644
index 0000000..5052e0c
--- /dev/null
+++ b/src/UI/Lobby/SDGame.tsx
@@ -0,0 +1,145 @@
+import CSMessage from "@/Common/Message/CSMessage";
+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 { 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";
+
+const SDGame = (props: ISDGame) => {
+ const { gameUrl, onClickSlotOut } = props;
+ const { player, setPlayer } = useGameItems();
+ const { gameData } = useGameItems();
+ const { nowSlotId } = gameData;
+ const [slotId, setSlotId] = useState(undefined);
+ const [slotData, setSlotData] = useState