forked from noxious/server
Storage class is now OOP
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import fs from 'fs'
|
||||
|
||||
import sharp from 'sharp'
|
||||
import { Server } from 'socket.io'
|
||||
|
||||
import { BaseCommand } from '#application/base/baseCommand'
|
||||
import { CharacterGender, CharacterRace } from '#application/enums'
|
||||
import { getPublicPath } from '#application/storage'
|
||||
import Storage from '#application/storage'
|
||||
import { UUID } from '#application/types'
|
||||
import { Character } from '#entities/character'
|
||||
import { CharacterHair } from '#entities/characterHair'
|
||||
@@ -44,7 +43,7 @@ export default class InitCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
private async importTiles(): Promise<void> {
|
||||
for (const tile of fs.readdirSync(getPublicPath('tiles'))) {
|
||||
for (const tile of fs.readdirSync(Storage.getPublicPath('tiles'))) {
|
||||
const newTile = new Tile()
|
||||
newTile.setId(tile.split('.')[0] as UUID).setName('New tile')
|
||||
|
||||
@@ -53,18 +52,18 @@ export default class InitCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
private async importObjects(): Promise<void> {
|
||||
for (const object of fs.readdirSync(getPublicPath('objects'))) {
|
||||
for (const object of fs.readdirSync(Storage.getPublicPath('objects'))) {
|
||||
const newMapObject = new MapObject()
|
||||
newMapObject
|
||||
.setId(object.split('.')[0] as UUID)
|
||||
.setName('New object')
|
||||
.setFrameWidth(
|
||||
(await sharp(getPublicPath('objects', object))
|
||||
(await sharp(Storage.getPublicPath('objects', object))
|
||||
.metadata()
|
||||
.then((metadata) => metadata.height)) ?? 0
|
||||
)
|
||||
.setFrameHeight(
|
||||
(await sharp(getPublicPath('objects', object))
|
||||
(await sharp(Storage.getPublicPath('objects', object))
|
||||
.metadata()
|
||||
.then((metadata) => metadata.width)) ?? 0
|
||||
)
|
||||
|
Reference in New Issue
Block a user