From fb3b1f5ba6a7fe4ab65bffc76a8b03c6c2da5e65 Mon Sep 17 00:00:00 2001 From: Marces Zastrow Date: Wed, 8 Jan 2025 13:48:06 +0100 Subject: [PATCH] ++ Updated Game Page --- backend/database.db | Bin 40960 -> 40960 bytes frontend/src/pages/games.jsx | 105 ++++++++++++++++++----------------- 2 files changed, 54 insertions(+), 51 deletions(-) diff --git a/backend/database.db b/backend/database.db index 07c5f38b4ec5ffcad438cca7667f41d463fe6c3c..743abed89d148995d4a2d058b99472a7db375f3e 100644 GIT binary patch delta 147 zcmZoTz|?SnX@az%Is*d(7ZAgMz(gHmd36T8szP2a0R~QXUq*gb{G)`h~cWuZCC>l= delta 94 zcmZoTz|?SnX@az%5(5JR7ZAe$_e33Ic_jwDszP2a0R~R?U`Bpc{eol6AZEeQZ(8+RKNt1W7w@v=URloTNhs|^VdzBX# diff --git a/frontend/src/pages/games.jsx b/frontend/src/pages/games.jsx index 7574d36..c24dc77 100644 --- a/frontend/src/pages/games.jsx +++ b/frontend/src/pages/games.jsx @@ -2,7 +2,7 @@ import { useState, useEffect, useContext } from 'react'; import { Link, useParams } from 'react-router-dom'; import axios from 'axios'; import { UserContext } from '../context/UserContext'; -import { Box, Typography, Grid, Card, CardContent, CardMedia, Button } from '@mui/material'; +import { Box, Typography, Grid2, Card, CardContent, CardMedia, Button } from '@mui/material'; import defaultCharacterImage from '../assets/default-character.png'; const GamesPage = () => { @@ -13,7 +13,9 @@ const GamesPage = () => { useEffect(() => { const fetchCharacter = async () => { try { + console.log(`Fetching character for gameId: ${gameId}, userId: ${userId}`); // Debug output const response = await axios.get(`http://localhost:5000/games/${gameId}/${userId}/character`); + console.log('Character data:', response.data); // Debug output setCharacter(response.data); } catch (error) { console.error('Error fetching character:', error); @@ -37,78 +39,79 @@ const GamesPage = () => { } return ( - - - {/* Character Info Section */} - - {character.CharName} - - {/* Health Bar */} - - + + + {/* Character Image and Details */} + + + + + + Age: {character.Age} + Race: {character.Race} + Sex: {character.Sex} + Job: {character.Job} + + + + + + {/* CharName, Health and Mana Bars */} + + {character.CharName} + + + Health - {character.CurrentHealth}/{character.MaxHealth} + {character.currentHealth}/{character.maxHealth} - - + + - {/* Mana Bar */} - - + + Mana - {character.CurrentMana}/{character.MaxMana} + {character.currentMana}/{character.maxMana} - - + + - - {/* Character Description */} + + {/* Character Info Section */} - Description - {character.Looks} + Description + {character.description} {/* Inventory */} - Inventory - - {character.Items?.map((item, index) => ( - - + Inventory + + {character.inventory?.map((item, index) => ( + + {item.name} Quantity: {item.quantity} - + ))} - + - - - {/* Character Image and Details */} - - - - - Age: {character.Age} - Race: {character.Race} - Sex: {character.Sex} - Job: {character.Job} - - - - + + ); }; -export default GamesPage; \ No newline at end of file +export default GamesPage; \ No newline at end of file