1
0
forked from noxious/server

Created base entities, extended normal entities with these

This commit is contained in:
2025-01-06 18:03:12 +01:00
parent be9ee97385
commit 24586855cb
42 changed files with 2006 additions and 1858 deletions

View File

@ -0,0 +1,60 @@
import { randomUUID } from 'node:crypto'
import { Enum, ManyToOne, PrimaryKey } from '@mikro-orm/core'
import { BaseEntity } from '#application/base/baseEntity'
import { CharacterEquipmentSlotType } from '#application/enums'
import { UUID } from '#application/types'
import { Character } from '#entities/character'
import { CharacterItem } from '#entities/characterItem'
export class BaseCharacterEquipment extends BaseEntity {
@PrimaryKey()
id = randomUUID()
@Enum(() => CharacterEquipmentSlotType)
slot!: CharacterEquipmentSlotType
@ManyToOne({ deleteRule: 'cascade' })
character!: Character
@ManyToOne({ deleteRule: 'cascade' })
characterItem!: CharacterItem
setId(id: UUID) {
this.id = id
return this
}
getId() {
return this.id
}
setSlot(slot: CharacterEquipmentSlotType) {
this.slot = slot
return this
}
getSlot() {
return this.slot
}
setCharacter(character: Character) {
this.character = character
return this
}
getCharacter() {
return this.character
}
setCharacterItem(characterItem: CharacterItem) {
this.characterItem = characterItem
return this
}
getCharacterItem() {
return this.characterItem
}
}