Skip to content

Commit

Permalink
fix: tree destroy (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmbanan666 authored Jan 20, 2025
1 parent 5015ad6 commit 5b3dfce
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions apps/website/server/api/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ export default defineWebSocketHandler({

const tree = activeRoom.objects.find((obj) => obj.type === 'TREE' && obj.id === parsed.data.id)
if (tree) {
activeRoom.removeObject(parsed.data.id)
activeRoom.removeObject(tree.id)

const player = activeRoom.objects.find((obj) => obj.type === 'PLAYER' && obj.id === player.id) as GameObject & GameObjectPlayer
if (player) {
await dropFromTree(player.telegramId)
const playerObject = activeRoom.objects.find((obj) => obj.type === 'PLAYER' && obj.id === player.id) as GameObject & GameObjectPlayer
if (playerObject) {
await dropFromTree(playerObject.telegramId)
}

peer.publish(activeRoom.id, JSON.stringify({ id: createId(), type: 'DESTROY_TREE', data: { id: parsed.data.id } }))
peer.publish(activeRoom.id, JSON.stringify({ id: createId(), type: 'DESTROY_TREE', data: { id: tree.id } }))
}
}
if (parsed.type === 'NEW_PLAYER_TARGET') {
Expand Down

0 comments on commit 5b3dfce

Please sign in to comment.