1
0
forked from noxious/server

Improved entities, ran formatting, utilise getters and setters

This commit is contained in:
2024-12-26 16:45:00 +01:00
parent 691abb7c4f
commit 4a963b4359
18 changed files with 68 additions and 97 deletions

View File

@ -2,9 +2,6 @@ import { randomUUID } from 'node:crypto'
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
import { BaseEntity } from '#application/bases/baseEntity'
import { SpriteAction } from './spriteAction'
import { CharacterType } from './characterType'
import { CharacterHair } from './characterHair'
import { Item } from './item'
import { UUID } from '#application/types'
@Entity()
@ -15,24 +12,15 @@ export class Sprite extends BaseEntity {
@Property()
name!: string
@OneToMany(() => SpriteAction, (action) => action.sprite)
spriteActions = new Collection<SpriteAction>(this)
@Property()
createdAt = new Date()
@Property()
updatedAt = new Date()
@OneToMany(() => SpriteAction, (action) => action.sprite)
spriteActions = new Collection<SpriteAction>(this)
@OneToMany(() => CharacterType, (type) => type.sprite)
characterTypes = new Collection<CharacterType>(this)
@OneToMany(() => CharacterHair, (hair) => hair.sprite)
characterHairs = new Collection<CharacterHair>(this)
@OneToMany(() => Item, (item) => item.sprite)
items = new Collection<Item>(this)
setId(id: UUID) {
this.id = id
return this
@ -51,6 +39,15 @@ export class Sprite extends BaseEntity {
return this.name
}
setSpriteActions(spriteActions: Collection<SpriteAction>) {
this.spriteActions = spriteActions
return this
}
getSpriteActions() {
return this.spriteActions
}
setCreatedAt(createdAt: Date) {
this.createdAt = createdAt
return this