A modern Web3-enabled Pokemon battle game frontend built with React, TypeScript, and Web3.js.
- Web3 Wallet Integration (MetaMask)
- Responsive Material Design UI
- Real-time Battle System
- Pokemon Collection Management
- User Statistics Dashboard
- PvP and PvE Game Modes
- React 18+
- TypeScript
- Material-UI (MUI)
- Web3.js
- Socket.io Client
- Redux Toolkit
- React Router
- Axios
- Node.js 16+
- Yarn or npm
- MetaMask browser extension
- Modern web browser
Create .env file in the root directory:
REACT_APP_API_URL=http://localhost:3001
REACT_APP_WS_URL=ws://localhost:3001
REACT_APP_NETWORK_ID=1337 # Local network- Clone the repository:
git clone <repository-url>
cd Pokemon_UI- Install dependencies:
yarn install
# or
npm install- Start the development server:
yarn start
# or
npm startThe app will be available at http://localhost:3000.
src/
├── assets/ # Images, fonts, etc.
├── components/ # Reusable components
├── config/ # Configuration files
├── contexts/ # React contexts
├── hooks/ # Custom hooks
├── layouts/ # Layout components
├── pages/ # Page components
├── services/ # API services
├── store/ # Redux store
├── styles/ # Global styles
├── types/ # TypeScript types
└── utils/ # Utility functions
WalletConnect- Web3 wallet connection componentAuthGuard- Protected route wrapperSignMessage- Wallet signature component
BattleArena- Main game battle componentPokemonCard- Pokemon display cardMoveSelector- Battle move selectionGameStats- Battle statistics display
Dashboard- User's main dashboardInventory- Pokemon collection managementStatistics- User's game statisticsProfile- User profile management
-
Connection
- Connect Web3 wallet
- Sign authentication message
- Receive JWT token
-
Game Setup
- Select game mode (PvP/PvE)
- Choose Pokemon
- Create/Join game
-
Battle
- Turn-based combat
- Select moves
- Real-time updates
- Battle resolution
Using Redux Toolkit for global state management:
interface RootState {
auth: {
isAuthenticated: boolean;
user: User | null;
token: string | null;
};
game: {
currentGame: Game | null;
activeGames: Game[];
battleLog: BattleLogEntry[];
};
pokemon: {
collection: Pokemon[];
selected: Pokemon | null;
};
}const connectWallet = async () => {
const accounts = await window.ethereum.request({
method: "eth_requestAccounts",
});
return accounts[0];
};
const signMessage = async (message: string) => {
const signature = await window.ethereum.request({
method: "personal_sign",
params: [message, address],
});
return signature;
};socket.on("gameUpdate", (data: GameState) => {
dispatch(updateGameState(data));
});
socket.on("turnUpdate", (data: TurnData) => {
dispatch(updateTurn(data));
});
socket.emit("makeMove", {
gameId,
moveId,
moveType,
});Using MUI theme customization:
const theme = createTheme({
palette: {
primary: {
main: "#2196f3",
},
secondary: {
main: "#f50057",
},
},
typography: {
fontFamily: "Roboto, sans-serif",
},
});Global error boundary and toast notifications:
const ErrorBoundary: React.FC = ({ children }) => {
const [error, setError] = useState<Error | null>(null);
if (error) {
return <ErrorDisplay error={error} />;
}
return children;
};- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Run tests:
yarn test
# or
npm testCreate production build:
yarn build
# or
npm run buildThis project is licensed under the MIT License.