import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'; import { User } from './user'; import { Zone } from './zone'; import { CharacterType } from './characterType'; import { CharacterHair } from './characterHair'; import { CharacterItem } from './characterItem'; import { CharacterEquipment } from './characterEquipment'; import { Chat } from './chat'; @Entity() export class Character { @PrimaryKey() id!: number; @ManyToOne(() => User) user!: User; @Property({ unique: true }) name!: string; @Property() online = false; @Property() role = 'player'; @OneToMany(() => Chat, chat => chat.character) chats = new Collection(this); // Position @ManyToOne(() => Zone) zone!: Zone; @Property() positionX = 0; @Property() positionY = 0; @Property() rotation = 0; // Customization @ManyToOne(() => CharacterType, { nullable: true }) characterType?: CharacterType; @ManyToOne(() => CharacterHair, { nullable: true }) characterHair?: CharacterHair; // Inventory @OneToMany(() => CharacterItem, item => item.character) items = new Collection(this); @OneToMany(() => CharacterEquipment, equipment => equipment.character) equipment = new Collection(this); // Stats @Property() alignment = 50; @Property() hitpoints = 100; @Property() mana = 100; @Property() level = 1; @Property() experience = 0; @Property() strength = 10; @Property() dexterity = 10; @Property() intelligence = 10; @Property() wisdom = 10; }