server/src/entities/characterEquipment.ts

62 lines
1.2 KiB
TypeScript

import { randomUUID } from 'node:crypto'
import { Entity, Enum, ManyToOne, PrimaryKey } from '@mikro-orm/core'
import { Character } from './character'
import { CharacterItem } from './characterItem'
import { BaseEntity } from '#application/base/baseEntity'
import { CharacterEquipmentSlotType } from '#application/enums'
import { UUID } from '#application/types'
@Entity()
export class CharacterEquipment 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
}
}