Improved walking
This commit is contained in:
parent
2490b08479
commit
3c0b713af0
@ -21,7 +21,7 @@ export default function (socket: TSocket, io: Server) {
|
|||||||
socket.character.position_x = data.position_x;
|
socket.character.position_x = data.position_x;
|
||||||
socket.character.position_y = data.position_y;
|
socket.character.position_y = data.position_y;
|
||||||
|
|
||||||
await CharacterRepository.update(socket.character);
|
await CharacterRepository.updatePosition(socket.character.id as number, data.position_x, data.position_y);
|
||||||
ZoneManager.updateCharacterInZone(socket.character.zoneId, socket.character);
|
ZoneManager.updateCharacterInZone(socket.character.zoneId, socket.character);
|
||||||
console.log(socket.character);
|
console.log(socket.character);
|
||||||
|
|
||||||
|
@ -23,6 +23,9 @@ class CharacterRepository {
|
|||||||
userId,
|
userId,
|
||||||
id: characterId,
|
id: characterId,
|
||||||
},
|
},
|
||||||
|
include: {
|
||||||
|
zone: true
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
// Handle error
|
// Handle error
|
||||||
@ -62,13 +65,16 @@ class CharacterRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(character: Character): Promise<Character | null> {
|
async updatePosition(id:number, position_x: number, position_y: number): Promise<Character | null> {
|
||||||
try {
|
try {
|
||||||
return await prisma.character.update({
|
return await prisma.character.update({
|
||||||
where: {
|
where: {
|
||||||
id: character.id,
|
id: id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
position_x,
|
||||||
|
position_y,
|
||||||
},
|
},
|
||||||
data: character
|
|
||||||
});
|
});
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
// Handle error
|
// Handle error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user