62 lines
1.1 KiB
TypeScript
62 lines
1.1 KiB
TypeScript
import { randomUUID } from 'node:crypto'
|
|
|
|
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
|
|
|
import { Character } from './character'
|
|
import { CharacterEquipment } from './characterEquipment'
|
|
import { Item } from './item'
|
|
|
|
import { BaseEntity } from '#application/base/baseEntity'
|
|
import { UUID } from '#application/types'
|
|
|
|
@Entity()
|
|
export class CharacterItem extends BaseEntity {
|
|
@PrimaryKey()
|
|
id = randomUUID()
|
|
|
|
@ManyToOne({ deleteRule: 'cascade' })
|
|
character!: Character
|
|
|
|
@ManyToOne({ deleteRule: 'cascade' })
|
|
item!: Item
|
|
|
|
@Property()
|
|
quantity!: number
|
|
|
|
setId(id: UUID) {
|
|
this.id = id
|
|
return this
|
|
}
|
|
|
|
getId() {
|
|
return this.id
|
|
}
|
|
|
|
setCharacter(character: Character) {
|
|
this.character = character
|
|
return this
|
|
}
|
|
|
|
getCharacter() {
|
|
return this.character
|
|
}
|
|
|
|
setItem(item: Item) {
|
|
this.item = item
|
|
return this
|
|
}
|
|
|
|
getItem() {
|
|
return this.item
|
|
}
|
|
|
|
setQuantity(quantity: number) {
|
|
this.quantity = quantity
|
|
return this
|
|
}
|
|
|
|
getQuantity() {
|
|
return this.quantity
|
|
}
|
|
}
|