Files
LP_Bot/src/context/GameItemsContext.tsx

50 lines
1.1 KiB
TypeScript
Raw Normal View History

2025-12-08 15:50:23 +08:00
import { createContext, ReactNode, useState } from "react";
2023-11-23 16:33:21 +08:00
2025-12-08 15:50:23 +08:00
export let gameObj: GameItemsContextType = null;
2023-11-23 16:33:21 +08:00
2025-12-08 15:50:23 +08:00
export const GameItemsContext = createContext<GameItemsContextType>({
player: null,
setPlayer: null,
gameData: null,
setGameData: null
});
2023-11-23 16:33:21 +08:00
2025-12-08 15:50:23 +08:00
export const GameItemsProvider = ({ children }: { children: ReactNode }) => {
const [player, setPlayer] = useState<PlayerData>({});
const [gameData, setGameData] = useState<GameData>({});
2023-11-23 16:33:21 +08:00
2025-12-08 15:50:23 +08:00
const game: GameItemsContextType = gameObj = {
2023-11-24 11:15:26 +08:00
player,
2023-12-05 17:27:18 +08:00
setPlayer,
gameData,
setGameData
2023-11-23 16:33:21 +08:00
};
return (
<GameItemsContext.Provider value={game}>
{children}
</GameItemsContext.Provider>
);
2025-12-08 15:50:23 +08:00
};
interface GameItemsContextType {
player: PlayerData;
setPlayer: (v: PlayerData) => void;
gameData: GameData;
setGameData: (v: GameData) => void;
2023-11-23 16:33:21 +08:00
}
2023-12-05 17:27:18 +08:00
2025-12-08 15:50:23 +08:00
export interface PlayerData {
id?: string;
pw?: string;
token?: string;
[key: string]: any;
2023-12-05 17:27:18 +08:00
}
2025-12-08 15:50:23 +08:00
interface GameData {
slotData?: SlotData[];
slotList?: number[];
nowSlotId?: number;
2023-12-05 17:27:18 +08:00
}
2025-12-08 15:50:23 +08:00
export type SlotData = [componyID: number, slotId: number, vip: number, status: number, tag: number]