Added better security for character loading, worked on zone joining and moving logic

This commit is contained in:
2024-06-03 20:40:01 +02:00
parent 87826f74ea
commit 93cb7b7887
7 changed files with 82 additions and 14 deletions

View File

@ -16,6 +16,20 @@ class CharacterRepository {
}
}
async getByUserAndId(userId: number, characterId: number): Promise<Character | null> {
try {
return await prisma.character.findFirst({
where: {
userId,
id: characterId,
},
});
} catch (error: any) {
// Handle error
throw new Error(`Failed to get character by user ID and character ID: ${error.message}`);
}
}
async getById(id: number): Promise<Character | null> {
try {
return await prisma.character.findUnique({