oops
This commit is contained in:
parent
2101d20835
commit
0a371037eb
@ -52,44 +52,30 @@ async function addHttpRoutes(app: Application) {
|
||||
})
|
||||
|
||||
app.get('/assets/:zoneId', async (req: Request, res: Response) => {
|
||||
const zoneId = parseInt(req.params.zoneId)
|
||||
|
||||
if (isNaN(zoneId) || zoneId === 0) {
|
||||
const zoneId = req.params.zoneId
|
||||
if(!zoneId || parseInt(zoneId) === 0) {
|
||||
return res.status(400).json({ message: 'Invalid zone ID' })
|
||||
}
|
||||
|
||||
const zone = await zoneRepository.getById(zoneId)
|
||||
|
||||
const zone = await zoneRepository.getById(parseInt(zoneId))
|
||||
if(!zone) {
|
||||
return res.status(404).json({ message: 'Zone not found' })
|
||||
}
|
||||
|
||||
const assets = await zoneManager.getZoneAssets(zone)
|
||||
const sprites = await spriteRepository.getAll()
|
||||
const assets = await zoneManager.getZoneAssets(zone);
|
||||
|
||||
const spritesAssets = sprites.flatMap((sprite) =>
|
||||
sprite.spriteActions.map((action) => ({
|
||||
key: `${sprite.id}-${action.action}`,
|
||||
url: `/assets/sprites/${sprite.id}/${action.action}.png`,
|
||||
group: action.isAnimated ? 'sprite_animations' : 'sprites',
|
||||
frameWidth: action.frameWidth,
|
||||
frameHeight: action.frameHeight
|
||||
}))
|
||||
)
|
||||
|
||||
const tilesAssets = assets.tiles.map((tile) => ({
|
||||
key: tile,
|
||||
url: `/assets/tiles/${tile}.png`,
|
||||
res.json([
|
||||
...assets.tiles.map(x => { return {
|
||||
key: x,
|
||||
url: '/assets/tiles/' + x + '.png',
|
||||
group: 'tiles'
|
||||
}))
|
||||
|
||||
const objectsAssets = assets.objects.map((object) => ({
|
||||
key: object,
|
||||
url: `/assets/objects/${object}.png`,
|
||||
}}),
|
||||
...assets.objects.map(x => { return {
|
||||
key: x,
|
||||
url: '/assets/objects/' + x + '.png',
|
||||
group: 'objects'
|
||||
}))
|
||||
|
||||
res.json([...spritesAssets, ...tilesAssets, ...objectsAssets])
|
||||
}})
|
||||
]);
|
||||
})
|
||||
|
||||
app.get('/assets/:type/:spriteId?/:file', (req: Request, res: Response) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user