forked from noxious/server
Improved entities, ran formatting, utilise getters and setters
This commit is contained in:
@ -42,17 +42,17 @@ export class Character extends BaseEntity {
|
||||
rotation = 0
|
||||
|
||||
// Customization
|
||||
@ManyToOne(() => CharacterType, { nullable: true })
|
||||
@ManyToOne()
|
||||
characterType?: CharacterType
|
||||
|
||||
@ManyToOne(() => CharacterHair, { nullable: true })
|
||||
@ManyToOne()
|
||||
characterHair?: CharacterHair
|
||||
|
||||
// Inventory
|
||||
@OneToMany(() => CharacterItem, (item) => item.character)
|
||||
@OneToMany({ mappedBy: 'character' })
|
||||
items = new Collection<CharacterItem>(this)
|
||||
|
||||
@OneToMany(() => CharacterEquipment, (equipment) => equipment.character)
|
||||
@OneToMany({ mappedBy: 'character' })
|
||||
equipment = new Collection<CharacterEquipment>(this)
|
||||
|
||||
// Stats
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user