forked from noxious/server
Added ORM entities
This commit is contained in:
84
src/entities/character.ts
Normal file
84
src/entities/character.ts
Normal file
@ -0,0 +1,84 @@
|
||||
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<Chat>(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<CharacterItem>(this);
|
||||
|
||||
@OneToMany(() => CharacterEquipment, equipment => equipment.character)
|
||||
equipment = new Collection<CharacterEquipment>(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;
|
||||
}
|
Reference in New Issue
Block a user