Character Creator
Added the character creation page.
This commit is contained in:
Binary file not shown.
@@ -192,7 +192,44 @@ app.get('/games/:gameId/items', (req, res) => {
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
// Player Part
|
||||
|
||||
// Create Player Character
|
||||
app.post('/games/character/create', upload.single('image'), (req, res) => {
|
||||
const {
|
||||
charName, race, sex, age, job, description,
|
||||
maxHealth, maxMana, strength, dexterity, agility, endurance,
|
||||
gameId, playerId
|
||||
} = req.body;
|
||||
|
||||
const imageBuffer = req.file ? req.file.buffer : null;
|
||||
|
||||
const stmt = db.prepare(`
|
||||
INSERT INTO PlayerCharacter (
|
||||
GameID, PlayerID, CharName, Race, Sex, Age, Job,
|
||||
description, maxHealth, currentHealth, maxMana, currentMana,
|
||||
Strength, Dexterity, Agility, Endurance, Level, Gold, Img
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, 0, ?)
|
||||
`);
|
||||
|
||||
stmt.run([
|
||||
gameId, playerId, charName, race, sex, age, job,
|
||||
description, maxHealth, maxHealth, maxMana, maxMana,
|
||||
strength, dexterity, agility, endurance, imageBuffer
|
||||
], function(err) {
|
||||
if (err) {
|
||||
console.error('Database error:', err);
|
||||
return res.status(500).json({ error: 'Internal server error' });
|
||||
}
|
||||
res.status(201).json({
|
||||
message: 'Character created successfully!',
|
||||
characterId: this.lastID
|
||||
});
|
||||
});
|
||||
stmt.finalize();
|
||||
});
|
||||
|
||||
// Fetch all Player Characters of Player
|
||||
app.get('/games/:userId/characters', (req, res) => {
|
||||
const userId = req.params.userId;
|
||||
|
||||
Reference in New Issue
Block a user