Created base entities, extended normal entities with these
This commit is contained in:
parent
be9ee97385
commit
24586855cb
47
lol.js
Normal file
47
lol.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
const fs = require('fs/promises');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
function toPascalCase(str) {
|
||||||
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function transformEntities() {
|
||||||
|
const entitiesDir = './src/entities';
|
||||||
|
const baseDir = './src/entities/base';
|
||||||
|
|
||||||
|
// Create base directory if it doesn't exist
|
||||||
|
await fs.mkdir(baseDir, { recursive: true });
|
||||||
|
|
||||||
|
// Get all .ts files in entities directory
|
||||||
|
const files = await fs.readdir(entitiesDir);
|
||||||
|
const tsFiles = files.filter(file => file.endsWith('.ts') && file !== 'index.ts');
|
||||||
|
|
||||||
|
for (const file of tsFiles) {
|
||||||
|
const filePath = path.join(entitiesDir, file);
|
||||||
|
let content = await fs.readFile(filePath, 'utf-8');
|
||||||
|
|
||||||
|
// Get proper Pascal Case class name
|
||||||
|
const className = toPascalCase(path.basename(file, '.ts'));
|
||||||
|
|
||||||
|
// Create base class content
|
||||||
|
let baseContent = content
|
||||||
|
.replace(/@Entity\(\)/, '') // Remove @Entity decorator
|
||||||
|
.replace(/export class (\w+)/, `export class Base${className}`); // Add Base prefix with proper Pascal Case
|
||||||
|
|
||||||
|
// Create derived class content
|
||||||
|
const derivedContent = `import { Entity } from '@mikro-orm/core'
|
||||||
|
import { Base${className} } from '#entities/base/${file}'
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class ${className} extends Base${className} {}
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Write base class
|
||||||
|
await fs.writeFile(path.join(baseDir, file), baseContent);
|
||||||
|
|
||||||
|
// Write derived class
|
||||||
|
await fs.writeFile(filePath, derivedContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
transformEntities().catch(console.error);
|
@ -1,6 +1,6 @@
|
|||||||
import { Migration } from '@mikro-orm/migrations';
|
import { Migration } from '@mikro-orm/migrations';
|
||||||
|
|
||||||
export class Migration20250105033941 extends Migration {
|
export class Migration20250106170204 extends Migration {
|
||||||
|
|
||||||
override async up(): Promise<void> {
|
override async up(): Promise<void> {
|
||||||
this.addSql(`create table \`map\` (\`id\` varchar(255) not null, \`name\` varchar(255) not null, \`width\` int not null default 10, \`height\` int not null default 10, \`tiles\` json null, \`pvp\` tinyint(1) not null default false, \`created_at\` datetime not null, \`updated_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
this.addSql(`create table \`map\` (\`id\` varchar(255) not null, \`name\` varchar(255) not null, \`width\` int not null default 10, \`height\` int not null default 10, \`tiles\` json null, \`pvp\` tinyint(1) not null default false, \`created_at\` datetime not null, \`updated_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
@ -8,8 +8,8 @@ import serverConfig from './src/application/config'
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
extensions: [Migrator],
|
extensions: [Migrator],
|
||||||
metadataProvider: TsMorphMetadataProvider,
|
metadataProvider: TsMorphMetadataProvider,
|
||||||
entities: ['./src/entities/**/*.js'],
|
entities: ['./src/entities/*.js'],
|
||||||
entitiesTs: ['./src/entities/**/*.ts'],
|
entitiesTs: ['./src/entities/*.ts'],
|
||||||
driver: MySqlDriver,
|
driver: MySqlDriver,
|
||||||
host: serverConfig.DB_HOST,
|
host: serverConfig.DB_HOST,
|
||||||
port: serverConfig.DB_PORT,
|
port: serverConfig.DB_PORT,
|
||||||
|
296
src/entities/base/character.ts
Normal file
296
src/entities/base/character.ts
Normal file
@ -0,0 +1,296 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
import { CharacterEquipment } from '#entities/characterEquipment'
|
||||||
|
import { CharacterHair } from '#entities/characterHair'
|
||||||
|
import { CharacterItem } from '#entities/characterItem'
|
||||||
|
import { CharacterType } from '#entities/characterType'
|
||||||
|
import { Chat } from '#entities/chat'
|
||||||
|
import { Map } from '#entities/map'
|
||||||
|
import { User } from '#entities/user'
|
||||||
|
|
||||||
|
|
||||||
|
export class BaseCharacter extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
id = randomUUID()
|
||||||
|
|
||||||
|
@ManyToOne({ deleteRule: 'cascade' })
|
||||||
|
user!: User
|
||||||
|
|
||||||
|
@Property({ unique: true })
|
||||||
|
name!: string
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
online = false
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
role = 'player'
|
||||||
|
|
||||||
|
@OneToMany(() => Chat, (chat) => chat.character)
|
||||||
|
chats = new Collection<Chat>(this)
|
||||||
|
|
||||||
|
// Position - @TODO: Update to spawn point when current map is not found
|
||||||
|
@ManyToOne()
|
||||||
|
map!: Map
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
positionX = 0
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
positionY = 0
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
rotation = 0
|
||||||
|
|
||||||
|
// Customization
|
||||||
|
@ManyToOne({ deleteRule: 'set null' })
|
||||||
|
characterType?: CharacterType | null | undefined
|
||||||
|
|
||||||
|
@ManyToOne({ deleteRule: 'set null' })
|
||||||
|
characterHair?: CharacterHair | null | undefined
|
||||||
|
|
||||||
|
// Inventory
|
||||||
|
@OneToMany({ mappedBy: 'character' })
|
||||||
|
items = new Collection<CharacterItem>(this)
|
||||||
|
|
||||||
|
@OneToMany({ mappedBy: '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
|
||||||
|
|
||||||
|
setId(id: UUID) {
|
||||||
|
this.id = id
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
setUser(user: User) {
|
||||||
|
this.user = user
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getUser() {
|
||||||
|
return this.user
|
||||||
|
}
|
||||||
|
|
||||||
|
setName(name: string) {
|
||||||
|
this.name = name
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getName() {
|
||||||
|
return this.name
|
||||||
|
}
|
||||||
|
|
||||||
|
setOnline(online: boolean) {
|
||||||
|
this.online = online
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getOnline() {
|
||||||
|
return this.online
|
||||||
|
}
|
||||||
|
|
||||||
|
setRole(role: string) {
|
||||||
|
this.role = role
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getRole() {
|
||||||
|
return this.role
|
||||||
|
}
|
||||||
|
|
||||||
|
setChats(chats: Collection<Chat>) {
|
||||||
|
this.chats = chats
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getChats() {
|
||||||
|
return this.chats
|
||||||
|
}
|
||||||
|
|
||||||
|
setMap(map: Map) {
|
||||||
|
this.map = map
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getMap() {
|
||||||
|
return this.map
|
||||||
|
}
|
||||||
|
|
||||||
|
setPositionX(positionX: number) {
|
||||||
|
this.positionX = positionX
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getPositionX() {
|
||||||
|
return this.positionX
|
||||||
|
}
|
||||||
|
|
||||||
|
setPositionY(positionY: number) {
|
||||||
|
this.positionY = positionY
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getPositionY() {
|
||||||
|
return this.positionY
|
||||||
|
}
|
||||||
|
|
||||||
|
setRotation(rotation: number) {
|
||||||
|
this.rotation = rotation
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getRotation() {
|
||||||
|
return this.rotation
|
||||||
|
}
|
||||||
|
|
||||||
|
setCharacterType(characterType: CharacterType | null | undefined) {
|
||||||
|
this.characterType = characterType
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getCharacterType() {
|
||||||
|
return this.characterType
|
||||||
|
}
|
||||||
|
|
||||||
|
setCharacterHair(characterHair: CharacterHair | null | undefined) {
|
||||||
|
this.characterHair = characterHair
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getCharacterHair() {
|
||||||
|
return this.characterHair
|
||||||
|
}
|
||||||
|
|
||||||
|
setItems(items: Collection<CharacterItem>) {
|
||||||
|
this.items = items
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getItems() {
|
||||||
|
return this.items
|
||||||
|
}
|
||||||
|
|
||||||
|
setEquipment(equipment: Collection<CharacterEquipment>) {
|
||||||
|
this.equipment = equipment
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getEquipment() {
|
||||||
|
return this.equipment
|
||||||
|
}
|
||||||
|
|
||||||
|
setAlignment(alignment: number) {
|
||||||
|
this.alignment = alignment
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getAlignment() {
|
||||||
|
return this.alignment
|
||||||
|
}
|
||||||
|
|
||||||
|
setHitpoints(hitpoints: number) {
|
||||||
|
this.hitpoints = hitpoints
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getHitpoints() {
|
||||||
|
return this.hitpoints
|
||||||
|
}
|
||||||
|
|
||||||
|
setMana(mana: number) {
|
||||||
|
this.mana = mana
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getMana() {
|
||||||
|
return this.mana
|
||||||
|
}
|
||||||
|
|
||||||
|
setLevel(level: number) {
|
||||||
|
this.level = level
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getLevel() {
|
||||||
|
return this.level
|
||||||
|
}
|
||||||
|
|
||||||
|
setExperience(experience: number) {
|
||||||
|
this.experience = experience
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getExperience() {
|
||||||
|
return this.experience
|
||||||
|
}
|
||||||
|
|
||||||
|
setStrength(strength: number) {
|
||||||
|
this.strength = strength
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getStrength() {
|
||||||
|
return this.strength
|
||||||
|
}
|
||||||
|
|
||||||
|
setDexterity(dexterity: number) {
|
||||||
|
this.dexterity = dexterity
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getDexterity() {
|
||||||
|
return this.dexterity
|
||||||
|
}
|
||||||
|
|
||||||
|
setIntelligence(intelligence: number) {
|
||||||
|
this.intelligence = intelligence
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getIntelligence() {
|
||||||
|
return this.intelligence
|
||||||
|
}
|
||||||
|
|
||||||
|
setWisdom(wisdom: number) {
|
||||||
|
this.wisdom = wisdom
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getWisdom() {
|
||||||
|
return this.wisdom
|
||||||
|
}
|
||||||
|
}
|
60
src/entities/base/characterEquipment.ts
Normal file
60
src/entities/base/characterEquipment.ts
Normal 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
|
||||||
|
}
|
||||||
|
}
|
72
src/entities/base/characterHair.ts
Normal file
72
src/entities/base/characterHair.ts
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { CharacterGender } from '#application/enums'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
import { Character } from '#entities/character'
|
||||||
|
import { Sprite } from '#entities/sprite'
|
||||||
|
|
||||||
|
export class BaseCharacterHair extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
id = randomUUID()
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
name!: string
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
gender: CharacterGender = CharacterGender.MALE
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
isSelectable = false
|
||||||
|
|
||||||
|
@ManyToOne()
|
||||||
|
sprite?: Sprite
|
||||||
|
|
||||||
|
setId(id: UUID) {
|
||||||
|
this.id = id
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
setName(name: string) {
|
||||||
|
this.name = name
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getName() {
|
||||||
|
return this.name
|
||||||
|
}
|
||||||
|
|
||||||
|
setGender(gender: CharacterGender) {
|
||||||
|
this.gender = gender
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getGender() {
|
||||||
|
return this.gender
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsSelectable(isSelectable: boolean) {
|
||||||
|
this.isSelectable = isSelectable
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getIsSelectable() {
|
||||||
|
return this.isSelectable
|
||||||
|
}
|
||||||
|
|
||||||
|
setSprite(sprite: Sprite) {
|
||||||
|
this.sprite = sprite
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getSprite() {
|
||||||
|
return this.sprite
|
||||||
|
}
|
||||||
|
}
|
60
src/entities/base/characterItem.ts
Normal file
60
src/entities/base/characterItem.ts
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
import { Character } from '#entities/character'
|
||||||
|
import { CharacterEquipment } from '#entities/characterEquipment'
|
||||||
|
import { Item } from '#entities/item'
|
||||||
|
|
||||||
|
|
||||||
|
export class BaseCharacterItem 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
|
||||||
|
}
|
||||||
|
}
|
108
src/entities/base/characterType.ts
Normal file
108
src/entities/base/characterType.ts
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { CharacterGender, CharacterRace } from '#application/enums'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
import { Character } from '#entities/character'
|
||||||
|
import { Sprite } from '#entities/sprite'
|
||||||
|
|
||||||
|
export class BaseCharacterType extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
id = randomUUID()
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
name!: string
|
||||||
|
|
||||||
|
@Enum(() => CharacterGender)
|
||||||
|
gender!: CharacterGender
|
||||||
|
|
||||||
|
@Enum(() => CharacterRace)
|
||||||
|
race!: CharacterRace
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
isSelectable = false
|
||||||
|
|
||||||
|
@ManyToOne()
|
||||||
|
sprite?: Sprite
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
createdAt = new Date()
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
updatedAt = new Date()
|
||||||
|
|
||||||
|
setId(id: UUID) {
|
||||||
|
this.id = id
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
setName(name: string) {
|
||||||
|
this.name = name
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getName() {
|
||||||
|
return this.name
|
||||||
|
}
|
||||||
|
|
||||||
|
setGender(gender: CharacterGender) {
|
||||||
|
this.gender = gender
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getGender() {
|
||||||
|
return this.gender
|
||||||
|
}
|
||||||
|
|
||||||
|
setRace(race: CharacterRace) {
|
||||||
|
this.race = race
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getRace() {
|
||||||
|
return this.race
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsSelectable(isSelectable: boolean) {
|
||||||
|
this.isSelectable = isSelectable
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getIsSelectable() {
|
||||||
|
return this.isSelectable
|
||||||
|
}
|
||||||
|
|
||||||
|
setSprite(sprite: Sprite) {
|
||||||
|
this.sprite = sprite
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getSprite() {
|
||||||
|
return this.sprite
|
||||||
|
}
|
||||||
|
|
||||||
|
setCreatedAt(createdAt: Date) {
|
||||||
|
this.createdAt = createdAt
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getCreatedAt() {
|
||||||
|
return this.createdAt
|
||||||
|
}
|
||||||
|
|
||||||
|
setUpdatedAt(updatedAt: Date) {
|
||||||
|
this.updatedAt = updatedAt
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getUpdatedAt() {
|
||||||
|
return this.updatedAt
|
||||||
|
}
|
||||||
|
}
|
71
src/entities/base/chat.ts
Normal file
71
src/entities/base/chat.ts
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
import { Character } from '#entities/character'
|
||||||
|
import { Map } from '#entities/map'
|
||||||
|
|
||||||
|
|
||||||
|
export class BaseChat extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
id = randomUUID()
|
||||||
|
|
||||||
|
@ManyToOne({ deleteRule: 'cascade' })
|
||||||
|
character!: Character
|
||||||
|
|
||||||
|
@ManyToOne({ deleteRule: 'cascade' })
|
||||||
|
map!: Map
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
message!: string
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
createdAt = new Date()
|
||||||
|
|
||||||
|
setId(id: UUID) {
|
||||||
|
this.id = id
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
setCharacter(character: Character) {
|
||||||
|
this.character = character
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getCharacter() {
|
||||||
|
return this.character
|
||||||
|
}
|
||||||
|
|
||||||
|
setMap(map: Map) {
|
||||||
|
this.map = map
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getMap() {
|
||||||
|
return this.map
|
||||||
|
}
|
||||||
|
|
||||||
|
setMessage(message: string) {
|
||||||
|
this.message = message
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getMessage() {
|
||||||
|
return this.message
|
||||||
|
}
|
||||||
|
|
||||||
|
setCreatedAt(createdAt: Date) {
|
||||||
|
this.createdAt = createdAt
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getCreatedAt() {
|
||||||
|
return this.createdAt
|
||||||
|
}
|
||||||
|
}
|
120
src/entities/base/item.ts
Normal file
120
src/entities/base/item.ts
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { ItemType, ItemRarity } from '#application/enums'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
import { CharacterItem } from '#entities/characterItem'
|
||||||
|
import { Sprite } from '#entities/sprite'
|
||||||
|
|
||||||
|
export class BaseItem extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
id = randomUUID()
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
name!: string
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
description: string = ''
|
||||||
|
|
||||||
|
@Enum(() => ItemType)
|
||||||
|
itemType!: ItemType
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
stackable = false
|
||||||
|
|
||||||
|
@Enum(() => ItemRarity)
|
||||||
|
rarity: ItemRarity = ItemRarity.COMMON
|
||||||
|
|
||||||
|
@ManyToOne(() => Sprite)
|
||||||
|
sprite?: Sprite
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
createdAt = new Date()
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
updatedAt = new Date()
|
||||||
|
|
||||||
|
setId(id: UUID) {
|
||||||
|
this.id = id
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
setName(name: string) {
|
||||||
|
this.name = name
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getName() {
|
||||||
|
return this.name
|
||||||
|
}
|
||||||
|
|
||||||
|
setDescription(description: string) {
|
||||||
|
this.description = description
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getDescription() {
|
||||||
|
return this.description
|
||||||
|
}
|
||||||
|
|
||||||
|
setItemType(itemType: ItemType) {
|
||||||
|
this.itemType = itemType
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getItemType() {
|
||||||
|
return this.itemType
|
||||||
|
}
|
||||||
|
|
||||||
|
setStackable(stackable: boolean) {
|
||||||
|
this.stackable = stackable
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getStackable() {
|
||||||
|
return this.stackable
|
||||||
|
}
|
||||||
|
|
||||||
|
setRarity(rarity: ItemRarity) {
|
||||||
|
this.rarity = rarity
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getRarity() {
|
||||||
|
return this.rarity
|
||||||
|
}
|
||||||
|
|
||||||
|
setSprite(sprite: Sprite) {
|
||||||
|
this.sprite = sprite
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getSprite() {
|
||||||
|
return this.sprite
|
||||||
|
}
|
||||||
|
|
||||||
|
setCreatedAt(createdAt: Date) {
|
||||||
|
this.createdAt = createdAt
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getCreatedAt() {
|
||||||
|
return this.createdAt
|
||||||
|
}
|
||||||
|
|
||||||
|
setUpdatedAt(updatedAt: Date) {
|
||||||
|
this.updatedAt = updatedAt
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getUpdatedAt() {
|
||||||
|
return this.updatedAt
|
||||||
|
}
|
||||||
|
}
|
143
src/entities/base/map.ts
Normal file
143
src/entities/base/map.ts
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
import { MapEffect } from '#entities/mapEffect'
|
||||||
|
import { MapEventTile } from '#entities/mapEventTile'
|
||||||
|
import { PlacedMapObject } from '#entities/placedMapObject'
|
||||||
|
|
||||||
|
export class BaseMap extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
id = randomUUID()
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
name!: string
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
width = 10
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
height = 10
|
||||||
|
|
||||||
|
@Property({ type: 'json', nullable: true })
|
||||||
|
tiles?: any
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
pvp = false
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
createdAt = new Date()
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
updatedAt = new Date()
|
||||||
|
|
||||||
|
@OneToMany(() => MapEffect, (effect) => effect.map, { orphanRemoval: true })
|
||||||
|
mapEffects = new Collection<MapEffect>(this)
|
||||||
|
|
||||||
|
@OneToMany(() => MapEventTile, (tile) => tile.map, { orphanRemoval: true })
|
||||||
|
mapEventTiles = new Collection<MapEventTile>(this)
|
||||||
|
|
||||||
|
@OneToMany(() => PlacedMapObject, (placedMapObject) => placedMapObject.map, { orphanRemoval: true })
|
||||||
|
placedMapObjects = new Collection<PlacedMapObject>(this)
|
||||||
|
|
||||||
|
setId(id: UUID) {
|
||||||
|
this.id = id
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
setName(name: string) {
|
||||||
|
this.name = name
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getName() {
|
||||||
|
return this.name
|
||||||
|
}
|
||||||
|
|
||||||
|
setWidth(width: number) {
|
||||||
|
this.width = width
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getWidth() {
|
||||||
|
return this.width
|
||||||
|
}
|
||||||
|
|
||||||
|
setHeight(height: number) {
|
||||||
|
this.height = height
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getHeight() {
|
||||||
|
return this.height
|
||||||
|
}
|
||||||
|
|
||||||
|
setTiles(tiles: any) {
|
||||||
|
this.tiles = tiles
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getTiles() {
|
||||||
|
return this.tiles
|
||||||
|
}
|
||||||
|
|
||||||
|
setPvp(pvp: boolean) {
|
||||||
|
this.pvp = pvp
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getPvp() {
|
||||||
|
return this.pvp
|
||||||
|
}
|
||||||
|
|
||||||
|
setCreatedAt(createdAt: Date) {
|
||||||
|
this.createdAt = createdAt
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getCreatedAt() {
|
||||||
|
return this.createdAt
|
||||||
|
}
|
||||||
|
|
||||||
|
setUpdatedAt(updatedAt: Date) {
|
||||||
|
this.updatedAt = updatedAt
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getUpdatedAt() {
|
||||||
|
return this.updatedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
setMapEffects(mapEffects: Collection<MapEffect>) {
|
||||||
|
this.mapEffects = mapEffects
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getMapEffects() {
|
||||||
|
return this.mapEffects
|
||||||
|
}
|
||||||
|
|
||||||
|
setMapEventTiles(mapEventTiles: Collection<MapEventTile>) {
|
||||||
|
this.mapEventTiles = mapEventTiles
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getMapEventTiles() {
|
||||||
|
return this.mapEventTiles
|
||||||
|
}
|
||||||
|
|
||||||
|
setPlacedMapObjects(placedMapObjects: Collection<PlacedMapObject>) {
|
||||||
|
this.placedMapObjects = placedMapObjects
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getPlacedMapObjects() {
|
||||||
|
return this.placedMapObjects
|
||||||
|
}
|
||||||
|
}
|
58
src/entities/base/mapEffect.ts
Normal file
58
src/entities/base/mapEffect.ts
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
import { Map } from '#entities/map'
|
||||||
|
|
||||||
|
export class BaseMapEffect extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
id = randomUUID()
|
||||||
|
|
||||||
|
@ManyToOne({ deleteRule: 'cascade' })
|
||||||
|
map!: Map
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
effect!: string
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
strength!: number
|
||||||
|
|
||||||
|
setId(id: UUID) {
|
||||||
|
this.id = id
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
setMap(map: Map) {
|
||||||
|
this.map = map
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getMap() {
|
||||||
|
return this.map
|
||||||
|
}
|
||||||
|
|
||||||
|
setEffect(effect: string) {
|
||||||
|
this.effect = effect
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getEffect() {
|
||||||
|
return this.effect
|
||||||
|
}
|
||||||
|
|
||||||
|
setStrength(strength: number) {
|
||||||
|
this.strength = strength
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getStrength() {
|
||||||
|
return this.strength
|
||||||
|
}
|
||||||
|
}
|
84
src/entities/base/mapEventTile.ts
Normal file
84
src/entities/base/mapEventTile.ts
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Entity, Enum, ManyToOne, OneToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { MapEventTileType } from '#application/enums'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
import { Map } from '#entities/map'
|
||||||
|
import { MapEventTileTeleport } from '#entities/mapEventTileTeleport'
|
||||||
|
|
||||||
|
export class BaseMapEventTile extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
id = randomUUID()
|
||||||
|
|
||||||
|
@ManyToOne({ deleteRule: 'cascade' })
|
||||||
|
map!: Map
|
||||||
|
|
||||||
|
@Enum(() => MapEventTileType)
|
||||||
|
type!: MapEventTileType
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
positionX!: number
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
positionY!: number
|
||||||
|
|
||||||
|
@OneToOne(() => MapEventTileTeleport, (teleport) => teleport.mapEventTile, { eager: true })
|
||||||
|
teleport?: MapEventTileTeleport
|
||||||
|
|
||||||
|
setId(id: UUID) {
|
||||||
|
this.id = id
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
setMap(map: Map) {
|
||||||
|
this.map = map
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getMap() {
|
||||||
|
return this.map
|
||||||
|
}
|
||||||
|
|
||||||
|
setType(type: MapEventTileType) {
|
||||||
|
this.type = type
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getType() {
|
||||||
|
return this.type
|
||||||
|
}
|
||||||
|
|
||||||
|
setPositionX(positionX: number) {
|
||||||
|
this.positionX = positionX
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getPositionX() {
|
||||||
|
return this.positionX
|
||||||
|
}
|
||||||
|
|
||||||
|
setPositionY(positionY: number) {
|
||||||
|
this.positionY = positionY
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getPositionY() {
|
||||||
|
return this.positionY
|
||||||
|
}
|
||||||
|
|
||||||
|
setTeleport(teleport: MapEventTileTeleport) {
|
||||||
|
this.teleport = teleport
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getTeleport() {
|
||||||
|
return this.teleport
|
||||||
|
}
|
||||||
|
}
|
83
src/entities/base/mapEventTileTeleport.ts
Normal file
83
src/entities/base/mapEventTileTeleport.ts
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Entity, ManyToOne, OneToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
import { Map } from '#entities/map'
|
||||||
|
import { MapEventTile } from '#entities/mapEventTile'
|
||||||
|
|
||||||
|
|
||||||
|
export class BaseMapEventTileTeleport extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
id = randomUUID()
|
||||||
|
|
||||||
|
@OneToOne({ deleteRule: 'cascade' })
|
||||||
|
mapEventTile!: MapEventTile
|
||||||
|
|
||||||
|
@ManyToOne({ deleteRule: 'cascade', eager: true })
|
||||||
|
toMap!: Map
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
toRotation!: number
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
toPositionX!: number
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
toPositionY!: number
|
||||||
|
|
||||||
|
setId(id: UUID) {
|
||||||
|
this.id = id
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
setMapEventTile(mapEventTile: MapEventTile) {
|
||||||
|
this.mapEventTile = mapEventTile
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getMapEventTile() {
|
||||||
|
return this.mapEventTile
|
||||||
|
}
|
||||||
|
|
||||||
|
setToMap(toMap: Map) {
|
||||||
|
this.toMap = toMap
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getToMap() {
|
||||||
|
return this.toMap
|
||||||
|
}
|
||||||
|
|
||||||
|
setToRotation(toRotation: number) {
|
||||||
|
this.toRotation = toRotation
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getToRotation() {
|
||||||
|
return this.toRotation
|
||||||
|
}
|
||||||
|
|
||||||
|
setToPositionX(toPositionX: number) {
|
||||||
|
this.toPositionX = toPositionX
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getToPositionX() {
|
||||||
|
return this.toPositionX
|
||||||
|
}
|
||||||
|
|
||||||
|
setToPositionY(toPositionY: number) {
|
||||||
|
this.toPositionY = toPositionY
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getToPositionY() {
|
||||||
|
return this.toPositionY
|
||||||
|
}
|
||||||
|
}
|
140
src/entities/base/mapObject.ts
Normal file
140
src/entities/base/mapObject.ts
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Entity, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
|
||||||
|
export class BaseMapObject extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
id = randomUUID()
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
name!: string
|
||||||
|
|
||||||
|
@Property({ type: 'json', nullable: true })
|
||||||
|
tags?: any
|
||||||
|
|
||||||
|
@Property({ type: 'decimal', precision: 10, scale: 2 })
|
||||||
|
originX = 0
|
||||||
|
|
||||||
|
@Property({ type: 'decimal', precision: 10, scale: 2 })
|
||||||
|
originY = 0
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
isAnimated = false
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
frameRate = 0
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
frameWidth = 0
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
frameHeight = 0
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
createdAt = new Date()
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
updatedAt = new Date()
|
||||||
|
|
||||||
|
setId(id: UUID) {
|
||||||
|
this.id = id
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
setName(name: string) {
|
||||||
|
this.name = name
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getName() {
|
||||||
|
return this.name
|
||||||
|
}
|
||||||
|
|
||||||
|
setTags(tags: any) {
|
||||||
|
this.tags = tags
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getTags() {
|
||||||
|
return this.tags
|
||||||
|
}
|
||||||
|
|
||||||
|
setOriginX(originX: number) {
|
||||||
|
this.originX = originX
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getOriginX() {
|
||||||
|
return this.originX
|
||||||
|
}
|
||||||
|
|
||||||
|
setOriginY(originY: number) {
|
||||||
|
this.originY = originY
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getOriginY() {
|
||||||
|
return this.originY
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsAnimated(isAnimated: boolean) {
|
||||||
|
this.isAnimated = isAnimated
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getIsAnimated() {
|
||||||
|
return this.isAnimated
|
||||||
|
}
|
||||||
|
|
||||||
|
setFrameRate(frameRate: number) {
|
||||||
|
this.frameRate = frameRate
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getFrameRate() {
|
||||||
|
return this.frameRate
|
||||||
|
}
|
||||||
|
|
||||||
|
setFrameWidth(frameWidth: number) {
|
||||||
|
this.frameWidth = frameWidth
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getFrameWidth() {
|
||||||
|
return this.frameWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
setFrameHeight(frameHeight: number) {
|
||||||
|
this.frameHeight = frameHeight
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getFrameHeight() {
|
||||||
|
return this.frameHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
setCreatedAt(createdAt: Date) {
|
||||||
|
this.createdAt = createdAt
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getCreatedAt() {
|
||||||
|
return this.createdAt
|
||||||
|
}
|
||||||
|
|
||||||
|
setUpdatedAt(updatedAt: Date) {
|
||||||
|
this.updatedAt = updatedAt
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getUpdatedAt() {
|
||||||
|
return this.updatedAt
|
||||||
|
}
|
||||||
|
}
|
58
src/entities/base/passwordResetToken.ts
Normal file
58
src/entities/base/passwordResetToken.ts
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
import { User } from '#entities/user'
|
||||||
|
|
||||||
|
export class BasePasswordResetToken extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
id = randomUUID()
|
||||||
|
|
||||||
|
@ManyToOne({ deleteRule: 'cascade' })
|
||||||
|
user!: User
|
||||||
|
|
||||||
|
@Property({ unique: true })
|
||||||
|
token!: string
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
createdAt = new Date()
|
||||||
|
|
||||||
|
setId(id: UUID) {
|
||||||
|
this.id = id
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
setUser(user: User) {
|
||||||
|
this.user = user
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getUser() {
|
||||||
|
return this.user
|
||||||
|
}
|
||||||
|
|
||||||
|
setToken(token: string) {
|
||||||
|
this.token = token
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getToken() {
|
||||||
|
return this.token
|
||||||
|
}
|
||||||
|
|
||||||
|
setCreatedAt(createdAt: Date) {
|
||||||
|
this.createdAt = createdAt
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getCreatedAt() {
|
||||||
|
return this.createdAt
|
||||||
|
}
|
||||||
|
}
|
97
src/entities/base/placedMapObject.ts
Normal file
97
src/entities/base/placedMapObject.ts
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
import { Map } from '#entities/map'
|
||||||
|
import { MapObject } from '#entities/mapObject'
|
||||||
|
|
||||||
|
//@TODO : Rename mapObject
|
||||||
|
|
||||||
|
export class BasePlacedMapObject extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
id = randomUUID()
|
||||||
|
|
||||||
|
@ManyToOne({ deleteRule: 'cascade' })
|
||||||
|
map!: Map
|
||||||
|
|
||||||
|
@ManyToOne({ deleteRule: 'cascade', eager: true })
|
||||||
|
mapObject!: MapObject
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
depth = 0
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
isRotated = false
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
positionX = 0
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
positionY = 0
|
||||||
|
|
||||||
|
setId(id: UUID) {
|
||||||
|
this.id = id
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
setMap(map: Map) {
|
||||||
|
this.map = map
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getMap() {
|
||||||
|
return this.map
|
||||||
|
}
|
||||||
|
|
||||||
|
setMapObject(mapObject: MapObject) {
|
||||||
|
this.mapObject = mapObject
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getMapObject() {
|
||||||
|
return this.mapObject
|
||||||
|
}
|
||||||
|
|
||||||
|
setDepth(depth: number) {
|
||||||
|
this.depth = depth
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getDepth() {
|
||||||
|
return this.depth
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsRotated(isRotated: boolean) {
|
||||||
|
this.isRotated = isRotated
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getIsRotated() {
|
||||||
|
return this.isRotated
|
||||||
|
}
|
||||||
|
|
||||||
|
setPositionX(positionX: number) {
|
||||||
|
this.positionX = positionX
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getPositionX() {
|
||||||
|
return this.positionX
|
||||||
|
}
|
||||||
|
|
||||||
|
setPositionY(positionY: number) {
|
||||||
|
this.positionY = positionY
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getPositionY() {
|
||||||
|
return this.positionY
|
||||||
|
}
|
||||||
|
}
|
70
src/entities/base/sprite.ts
Normal file
70
src/entities/base/sprite.ts
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
import { SpriteAction } from '#entities/spriteAction'
|
||||||
|
|
||||||
|
export class BaseSprite extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
id = randomUUID()
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
name!: string
|
||||||
|
|
||||||
|
@OneToMany(() => SpriteAction, (action) => action.sprite)
|
||||||
|
spriteActions = new Collection<SpriteAction>(this)
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
createdAt = new Date()
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
updatedAt = new Date()
|
||||||
|
|
||||||
|
setId(id: UUID) {
|
||||||
|
this.id = id
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
setName(name: string) {
|
||||||
|
this.name = name
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getName() {
|
||||||
|
return this.name
|
||||||
|
}
|
||||||
|
|
||||||
|
setSpriteActions(spriteActions: Collection<SpriteAction>) {
|
||||||
|
this.spriteActions = spriteActions
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getSpriteActions() {
|
||||||
|
return this.spriteActions
|
||||||
|
}
|
||||||
|
|
||||||
|
setCreatedAt(createdAt: Date) {
|
||||||
|
this.createdAt = createdAt
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getCreatedAt() {
|
||||||
|
return this.createdAt
|
||||||
|
}
|
||||||
|
|
||||||
|
setUpdatedAt(updatedAt: Date) {
|
||||||
|
this.updatedAt = updatedAt
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getUpdatedAt() {
|
||||||
|
return this.updatedAt
|
||||||
|
}
|
||||||
|
}
|
142
src/entities/base/spriteAction.ts
Normal file
142
src/entities/base/spriteAction.ts
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
import { Sprite } from '#entities/sprite'
|
||||||
|
|
||||||
|
export class BaseSpriteAction extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
id = randomUUID()
|
||||||
|
|
||||||
|
@ManyToOne({ deleteRule: 'cascade' })
|
||||||
|
sprite!: Sprite
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
action!: string
|
||||||
|
|
||||||
|
@Property({ type: 'json', nullable: true })
|
||||||
|
sprites?: string[]
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
originX = 0
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
originY = 0
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
isAnimated = false
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
isLooping = false
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
frameWidth = 0
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
frameHeight = 0
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
frameRate = 0
|
||||||
|
|
||||||
|
setId(id: UUID) {
|
||||||
|
this.id = id
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
setSprite(sprite: Sprite) {
|
||||||
|
this.sprite = sprite
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getSprite() {
|
||||||
|
return this.sprite
|
||||||
|
}
|
||||||
|
|
||||||
|
setAction(action: string) {
|
||||||
|
this.action = action
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getAction() {
|
||||||
|
return this.action
|
||||||
|
}
|
||||||
|
|
||||||
|
setSprites(sprites: string[]) {
|
||||||
|
this.sprites = sprites
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getSprites() {
|
||||||
|
return this.sprites
|
||||||
|
}
|
||||||
|
|
||||||
|
setOriginX(originX: number) {
|
||||||
|
this.originX = originX
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getOriginX() {
|
||||||
|
return this.originX
|
||||||
|
}
|
||||||
|
|
||||||
|
setOriginY(originY: number) {
|
||||||
|
this.originY = originY
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getOriginY() {
|
||||||
|
return this.originY
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsAnimated(isAnimated: boolean) {
|
||||||
|
this.isAnimated = isAnimated
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getIsAnimated() {
|
||||||
|
return this.isAnimated
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsLooping(isLooping: boolean) {
|
||||||
|
this.isLooping = isLooping
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getIsLooping() {
|
||||||
|
return this.isLooping
|
||||||
|
}
|
||||||
|
|
||||||
|
setFrameWidth(frameWidth: number) {
|
||||||
|
this.frameWidth = frameWidth
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getFrameWidth() {
|
||||||
|
return this.frameWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
setFrameHeight(frameHeight: number) {
|
||||||
|
this.frameHeight = frameHeight
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getFrameHeight() {
|
||||||
|
return this.frameHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
setFrameRate(frameRate: number) {
|
||||||
|
this.frameRate = frameRate
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getFrameRate() {
|
||||||
|
return this.frameRate
|
||||||
|
}
|
||||||
|
}
|
68
src/entities/base/tile.ts
Normal file
68
src/entities/base/tile.ts
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Entity, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
|
||||||
|
export class BaseTile extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
id = randomUUID()
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
name!: string
|
||||||
|
|
||||||
|
@Property({ type: 'json', nullable: true })
|
||||||
|
tags?: any
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
createdAt = new Date()
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
updatedAt = new Date()
|
||||||
|
|
||||||
|
setId(id: UUID) {
|
||||||
|
this.id = id
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
setName(name: string) {
|
||||||
|
this.name = name
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getName() {
|
||||||
|
return this.name
|
||||||
|
}
|
||||||
|
|
||||||
|
setTags(tags: any) {
|
||||||
|
this.tags = tags
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getTags() {
|
||||||
|
return this.tags
|
||||||
|
}
|
||||||
|
|
||||||
|
setCreatedAt(createdAt: Date) {
|
||||||
|
this.createdAt = createdAt
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getCreatedAt() {
|
||||||
|
return this.createdAt
|
||||||
|
}
|
||||||
|
|
||||||
|
setUpdatedAt(updatedAt: Date) {
|
||||||
|
this.updatedAt = updatedAt
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getUpdatedAt() {
|
||||||
|
return this.updatedAt
|
||||||
|
}
|
||||||
|
}
|
97
src/entities/base/user.ts
Normal file
97
src/entities/base/user.ts
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
|
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
import bcrypt from 'bcryptjs'
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
import { UUID } from '#application/types'
|
||||||
|
import { Character } from '#entities/character'
|
||||||
|
import { PasswordResetToken } from '#entities/passwordResetToken'
|
||||||
|
|
||||||
|
|
||||||
|
export class BaseUser extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
id = randomUUID()
|
||||||
|
|
||||||
|
@Property({ unique: true })
|
||||||
|
username!: string
|
||||||
|
|
||||||
|
@Property({ unique: true })
|
||||||
|
email!: string
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
password!: string
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
online = false
|
||||||
|
|
||||||
|
@OneToMany(() => Character, (character) => character.user)
|
||||||
|
characters = new Collection<Character>(this)
|
||||||
|
|
||||||
|
@OneToMany(() => PasswordResetToken, (token) => token.user)
|
||||||
|
passwordResetTokens = new Collection<PasswordResetToken>(this)
|
||||||
|
|
||||||
|
setId(id: UUID) {
|
||||||
|
this.id = id
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
setUsername(username: string) {
|
||||||
|
this.username = username
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getUsername() {
|
||||||
|
return this.username
|
||||||
|
}
|
||||||
|
|
||||||
|
setEmail(email: string) {
|
||||||
|
this.email = email
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getEmail() {
|
||||||
|
return this.email
|
||||||
|
}
|
||||||
|
|
||||||
|
setPassword(password: string) {
|
||||||
|
this.password = bcrypt.hashSync(password, 10)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getPassword() {
|
||||||
|
return this.password
|
||||||
|
}
|
||||||
|
|
||||||
|
setOnline(online: boolean) {
|
||||||
|
this.online = online
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getOnline() {
|
||||||
|
return this.online
|
||||||
|
}
|
||||||
|
|
||||||
|
setCharacters(characters: Collection<Character>) {
|
||||||
|
this.characters = characters
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getCharacters() {
|
||||||
|
return this.characters
|
||||||
|
}
|
||||||
|
|
||||||
|
setPasswordResetTokens(passwordResetTokens: Collection<PasswordResetToken>) {
|
||||||
|
this.passwordResetTokens = passwordResetTokens
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getPasswordResetTokens() {
|
||||||
|
return this.passwordResetTokens
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
}
|
65
src/entities/base/world.ts
Normal file
65
src/entities/base/world.ts
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
import { Entity, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
|
|
||||||
|
export class BaseWorld extends BaseEntity {
|
||||||
|
@PrimaryKey()
|
||||||
|
date = new Date()
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
isRainEnabled = false
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
rainPercentage = 0
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
isFogEnabled = false
|
||||||
|
|
||||||
|
@Property()
|
||||||
|
fogDensity = 0
|
||||||
|
|
||||||
|
setDate(date: Date) {
|
||||||
|
this.date = date
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getDate() {
|
||||||
|
return this.date
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsRainEnabled(isRainEnabled: boolean) {
|
||||||
|
this.isRainEnabled = isRainEnabled
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getIsRainEnabled() {
|
||||||
|
return this.isRainEnabled
|
||||||
|
}
|
||||||
|
|
||||||
|
setRainPercentage(rainPercentage: number) {
|
||||||
|
this.rainPercentage = rainPercentage
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getRainPercentage() {
|
||||||
|
return this.rainPercentage
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsFogEnabled(isFogEnabled: boolean) {
|
||||||
|
this.isFogEnabled = isFogEnabled
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getIsFogEnabled() {
|
||||||
|
return this.isFogEnabled
|
||||||
|
}
|
||||||
|
|
||||||
|
setFogDensity(fogDensity: number) {
|
||||||
|
this.fogDensity = fogDensity
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
getFogDensity() {
|
||||||
|
return this.fogDensity
|
||||||
|
}
|
||||||
|
}
|
@ -1,297 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BaseCharacter } from '#entities/base/character'
|
||||||
|
|
||||||
import { CharacterEquipment } from './characterEquipment'
|
|
||||||
import { CharacterHair } from './characterHair'
|
|
||||||
import { CharacterItem } from './characterItem'
|
|
||||||
import { CharacterType } from './characterType'
|
|
||||||
import { Chat } from './chat'
|
|
||||||
import { Map } from './map'
|
|
||||||
import { User } from './user'
|
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Character extends BaseEntity {
|
export class Character extends BaseCharacter {}
|
||||||
@PrimaryKey()
|
|
||||||
id = randomUUID()
|
|
||||||
|
|
||||||
@ManyToOne({ deleteRule: 'cascade' })
|
|
||||||
user!: User
|
|
||||||
|
|
||||||
@Property({ unique: true })
|
|
||||||
name!: string
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
online = false
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
role = 'player'
|
|
||||||
|
|
||||||
@OneToMany(() => Chat, (chat) => chat.character)
|
|
||||||
chats = new Collection<Chat>(this)
|
|
||||||
|
|
||||||
// Position - @TODO: Update to spawn point when current map is not found
|
|
||||||
@ManyToOne()
|
|
||||||
map!: Map
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
positionX = 0
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
positionY = 0
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
rotation = 0
|
|
||||||
|
|
||||||
// Customization
|
|
||||||
@ManyToOne({ deleteRule: 'set null' })
|
|
||||||
characterType?: CharacterType | null | undefined
|
|
||||||
|
|
||||||
@ManyToOne({ deleteRule: 'set null' })
|
|
||||||
characterHair?: CharacterHair | null | undefined
|
|
||||||
|
|
||||||
// Inventory
|
|
||||||
@OneToMany({ mappedBy: 'character' })
|
|
||||||
items = new Collection<CharacterItem>(this)
|
|
||||||
|
|
||||||
@OneToMany({ mappedBy: '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
|
|
||||||
|
|
||||||
setId(id: UUID) {
|
|
||||||
this.id = id
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.id
|
|
||||||
}
|
|
||||||
|
|
||||||
setUser(user: User) {
|
|
||||||
this.user = user
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getUser() {
|
|
||||||
return this.user
|
|
||||||
}
|
|
||||||
|
|
||||||
setName(name: string) {
|
|
||||||
this.name = name
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getName() {
|
|
||||||
return this.name
|
|
||||||
}
|
|
||||||
|
|
||||||
setOnline(online: boolean) {
|
|
||||||
this.online = online
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getOnline() {
|
|
||||||
return this.online
|
|
||||||
}
|
|
||||||
|
|
||||||
setRole(role: string) {
|
|
||||||
this.role = role
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getRole() {
|
|
||||||
return this.role
|
|
||||||
}
|
|
||||||
|
|
||||||
setChats(chats: Collection<Chat>) {
|
|
||||||
this.chats = chats
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getChats() {
|
|
||||||
return this.chats
|
|
||||||
}
|
|
||||||
|
|
||||||
setMap(map: Map) {
|
|
||||||
this.map = map
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getMap() {
|
|
||||||
return this.map
|
|
||||||
}
|
|
||||||
|
|
||||||
setPositionX(positionX: number) {
|
|
||||||
this.positionX = positionX
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getPositionX() {
|
|
||||||
return this.positionX
|
|
||||||
}
|
|
||||||
|
|
||||||
setPositionY(positionY: number) {
|
|
||||||
this.positionY = positionY
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getPositionY() {
|
|
||||||
return this.positionY
|
|
||||||
}
|
|
||||||
|
|
||||||
setRotation(rotation: number) {
|
|
||||||
this.rotation = rotation
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getRotation() {
|
|
||||||
return this.rotation
|
|
||||||
}
|
|
||||||
|
|
||||||
setCharacterType(characterType: CharacterType | null | undefined) {
|
|
||||||
this.characterType = characterType
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getCharacterType() {
|
|
||||||
return this.characterType
|
|
||||||
}
|
|
||||||
|
|
||||||
setCharacterHair(characterHair: CharacterHair | null | undefined) {
|
|
||||||
this.characterHair = characterHair
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getCharacterHair() {
|
|
||||||
return this.characterHair
|
|
||||||
}
|
|
||||||
|
|
||||||
setItems(items: Collection<CharacterItem>) {
|
|
||||||
this.items = items
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getItems() {
|
|
||||||
return this.items
|
|
||||||
}
|
|
||||||
|
|
||||||
setEquipment(equipment: Collection<CharacterEquipment>) {
|
|
||||||
this.equipment = equipment
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getEquipment() {
|
|
||||||
return this.equipment
|
|
||||||
}
|
|
||||||
|
|
||||||
setAlignment(alignment: number) {
|
|
||||||
this.alignment = alignment
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getAlignment() {
|
|
||||||
return this.alignment
|
|
||||||
}
|
|
||||||
|
|
||||||
setHitpoints(hitpoints: number) {
|
|
||||||
this.hitpoints = hitpoints
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getHitpoints() {
|
|
||||||
return this.hitpoints
|
|
||||||
}
|
|
||||||
|
|
||||||
setMana(mana: number) {
|
|
||||||
this.mana = mana
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getMana() {
|
|
||||||
return this.mana
|
|
||||||
}
|
|
||||||
|
|
||||||
setLevel(level: number) {
|
|
||||||
this.level = level
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getLevel() {
|
|
||||||
return this.level
|
|
||||||
}
|
|
||||||
|
|
||||||
setExperience(experience: number) {
|
|
||||||
this.experience = experience
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getExperience() {
|
|
||||||
return this.experience
|
|
||||||
}
|
|
||||||
|
|
||||||
setStrength(strength: number) {
|
|
||||||
this.strength = strength
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getStrength() {
|
|
||||||
return this.strength
|
|
||||||
}
|
|
||||||
|
|
||||||
setDexterity(dexterity: number) {
|
|
||||||
this.dexterity = dexterity
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getDexterity() {
|
|
||||||
return this.dexterity
|
|
||||||
}
|
|
||||||
|
|
||||||
setIntelligence(intelligence: number) {
|
|
||||||
this.intelligence = intelligence
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getIntelligence() {
|
|
||||||
return this.intelligence
|
|
||||||
}
|
|
||||||
|
|
||||||
setWisdom(wisdom: number) {
|
|
||||||
this.wisdom = wisdom
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getWisdom() {
|
|
||||||
return this.wisdom
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,61 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Entity, Enum, ManyToOne, PrimaryKey } from '@mikro-orm/core'
|
import { BaseCharacterEquipment } from '#entities/base/characterEquipment'
|
||||||
|
|
||||||
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()
|
@Entity()
|
||||||
export class CharacterEquipment extends BaseEntity {
|
export class CharacterEquipment extends BaseCharacterEquipment {}
|
||||||
@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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,73 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BaseCharacterHair } from '#entities/base/characterHair'
|
||||||
|
|
||||||
import { Character } from './character'
|
|
||||||
import { Sprite } from './sprite'
|
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { CharacterGender } from '#application/enums'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class CharacterHair extends BaseEntity {
|
export class CharacterHair extends BaseCharacterHair {}
|
||||||
@PrimaryKey()
|
|
||||||
id = randomUUID()
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
name!: string
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
gender: CharacterGender = CharacterGender.MALE
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
isSelectable = false
|
|
||||||
|
|
||||||
@ManyToOne()
|
|
||||||
sprite?: Sprite
|
|
||||||
|
|
||||||
setId(id: UUID) {
|
|
||||||
this.id = id
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.id
|
|
||||||
}
|
|
||||||
|
|
||||||
setName(name: string) {
|
|
||||||
this.name = name
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getName() {
|
|
||||||
return this.name
|
|
||||||
}
|
|
||||||
|
|
||||||
setGender(gender: CharacterGender) {
|
|
||||||
this.gender = gender
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getGender() {
|
|
||||||
return this.gender
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsSelectable(isSelectable: boolean) {
|
|
||||||
this.isSelectable = isSelectable
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getIsSelectable() {
|
|
||||||
return this.isSelectable
|
|
||||||
}
|
|
||||||
|
|
||||||
setSprite(sprite: Sprite) {
|
|
||||||
this.sprite = sprite
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getSprite() {
|
|
||||||
return this.sprite
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,61 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BaseCharacterItem } from '#entities/base/characterItem'
|
||||||
|
|
||||||
import { Character } from './character'
|
|
||||||
import { CharacterEquipment } from './characterEquipment'
|
|
||||||
import { Item } from './item'
|
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class CharacterItem extends BaseEntity {
|
export class CharacterItem extends BaseCharacterItem {}
|
||||||
@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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,109 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BaseCharacterType } from '#entities/base/characterType'
|
||||||
|
|
||||||
import { Character } from './character'
|
|
||||||
import { Sprite } from './sprite'
|
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { CharacterGender, CharacterRace } from '#application/enums'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class CharacterType extends BaseEntity {
|
export class CharacterType extends BaseCharacterType {}
|
||||||
@PrimaryKey()
|
|
||||||
id = randomUUID()
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
name!: string
|
|
||||||
|
|
||||||
@Enum(() => CharacterGender)
|
|
||||||
gender!: CharacterGender
|
|
||||||
|
|
||||||
@Enum(() => CharacterRace)
|
|
||||||
race!: CharacterRace
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
isSelectable = false
|
|
||||||
|
|
||||||
@ManyToOne()
|
|
||||||
sprite?: Sprite
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
createdAt = new Date()
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
updatedAt = new Date()
|
|
||||||
|
|
||||||
setId(id: UUID) {
|
|
||||||
this.id = id
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.id
|
|
||||||
}
|
|
||||||
|
|
||||||
setName(name: string) {
|
|
||||||
this.name = name
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getName() {
|
|
||||||
return this.name
|
|
||||||
}
|
|
||||||
|
|
||||||
setGender(gender: CharacterGender) {
|
|
||||||
this.gender = gender
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getGender() {
|
|
||||||
return this.gender
|
|
||||||
}
|
|
||||||
|
|
||||||
setRace(race: CharacterRace) {
|
|
||||||
this.race = race
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getRace() {
|
|
||||||
return this.race
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsSelectable(isSelectable: boolean) {
|
|
||||||
this.isSelectable = isSelectable
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getIsSelectable() {
|
|
||||||
return this.isSelectable
|
|
||||||
}
|
|
||||||
|
|
||||||
setSprite(sprite: Sprite) {
|
|
||||||
this.sprite = sprite
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getSprite() {
|
|
||||||
return this.sprite
|
|
||||||
}
|
|
||||||
|
|
||||||
setCreatedAt(createdAt: Date) {
|
|
||||||
this.createdAt = createdAt
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getCreatedAt() {
|
|
||||||
return this.createdAt
|
|
||||||
}
|
|
||||||
|
|
||||||
setUpdatedAt(updatedAt: Date) {
|
|
||||||
this.updatedAt = updatedAt
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getUpdatedAt() {
|
|
||||||
return this.updatedAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,72 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BaseChat } from '#entities/base/chat'
|
||||||
|
|
||||||
import { Character } from './character'
|
|
||||||
import { Map } from './map'
|
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Chat extends BaseEntity {
|
export class Chat extends BaseChat {}
|
||||||
@PrimaryKey()
|
|
||||||
id = randomUUID()
|
|
||||||
|
|
||||||
@ManyToOne({ deleteRule: 'cascade' })
|
|
||||||
character!: Character
|
|
||||||
|
|
||||||
@ManyToOne({ deleteRule: 'cascade' })
|
|
||||||
map!: Map
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
message!: string
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
createdAt = new Date()
|
|
||||||
|
|
||||||
setId(id: UUID) {
|
|
||||||
this.id = id
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.id
|
|
||||||
}
|
|
||||||
|
|
||||||
setCharacter(character: Character) {
|
|
||||||
this.character = character
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getCharacter() {
|
|
||||||
return this.character
|
|
||||||
}
|
|
||||||
|
|
||||||
setMap(map: Map) {
|
|
||||||
this.map = map
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getMap() {
|
|
||||||
return this.map
|
|
||||||
}
|
|
||||||
|
|
||||||
setMessage(message: string) {
|
|
||||||
this.message = message
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getMessage() {
|
|
||||||
return this.message
|
|
||||||
}
|
|
||||||
|
|
||||||
setCreatedAt(createdAt: Date) {
|
|
||||||
this.createdAt = createdAt
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getCreatedAt() {
|
|
||||||
return this.createdAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,121 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BaseItem } from '#entities/base/item'
|
||||||
|
|
||||||
import { CharacterItem } from './characterItem'
|
|
||||||
import { Sprite } from './sprite'
|
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { ItemType, ItemRarity } from '#application/enums'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Item extends BaseEntity {
|
export class Item extends BaseItem {}
|
||||||
@PrimaryKey()
|
|
||||||
id = randomUUID()
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
name!: string
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
description: string = ''
|
|
||||||
|
|
||||||
@Enum(() => ItemType)
|
|
||||||
itemType!: ItemType
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
stackable = false
|
|
||||||
|
|
||||||
@Enum(() => ItemRarity)
|
|
||||||
rarity: ItemRarity = ItemRarity.COMMON
|
|
||||||
|
|
||||||
@ManyToOne(() => Sprite)
|
|
||||||
sprite?: Sprite
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
createdAt = new Date()
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
updatedAt = new Date()
|
|
||||||
|
|
||||||
setId(id: UUID) {
|
|
||||||
this.id = id
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.id
|
|
||||||
}
|
|
||||||
|
|
||||||
setName(name: string) {
|
|
||||||
this.name = name
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getName() {
|
|
||||||
return this.name
|
|
||||||
}
|
|
||||||
|
|
||||||
setDescription(description: string) {
|
|
||||||
this.description = description
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getDescription() {
|
|
||||||
return this.description
|
|
||||||
}
|
|
||||||
|
|
||||||
setItemType(itemType: ItemType) {
|
|
||||||
this.itemType = itemType
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getItemType() {
|
|
||||||
return this.itemType
|
|
||||||
}
|
|
||||||
|
|
||||||
setStackable(stackable: boolean) {
|
|
||||||
this.stackable = stackable
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getStackable() {
|
|
||||||
return this.stackable
|
|
||||||
}
|
|
||||||
|
|
||||||
setRarity(rarity: ItemRarity) {
|
|
||||||
this.rarity = rarity
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getRarity() {
|
|
||||||
return this.rarity
|
|
||||||
}
|
|
||||||
|
|
||||||
setSprite(sprite: Sprite) {
|
|
||||||
this.sprite = sprite
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getSprite() {
|
|
||||||
return this.sprite
|
|
||||||
}
|
|
||||||
|
|
||||||
setCreatedAt(createdAt: Date) {
|
|
||||||
this.createdAt = createdAt
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getCreatedAt() {
|
|
||||||
return this.createdAt
|
|
||||||
}
|
|
||||||
|
|
||||||
setUpdatedAt(updatedAt: Date) {
|
|
||||||
this.updatedAt = updatedAt
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getUpdatedAt() {
|
|
||||||
return this.updatedAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,145 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BaseMap } from '#entities/base/map'
|
||||||
|
|
||||||
import { MapEffect } from './mapEffect'
|
|
||||||
import { MapEventTile } from './mapEventTile'
|
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
import { PlacedMapObject } from '#entities/placedMapObject'
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Map extends BaseEntity {
|
export class Map extends BaseMap {}
|
||||||
@PrimaryKey()
|
|
||||||
id = randomUUID()
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
name!: string
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
width = 10
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
height = 10
|
|
||||||
|
|
||||||
@Property({ type: 'json', nullable: true })
|
|
||||||
tiles?: any
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
pvp = false
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
createdAt = new Date()
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
updatedAt = new Date()
|
|
||||||
|
|
||||||
@OneToMany(() => MapEffect, (effect) => effect.map, { orphanRemoval: true })
|
|
||||||
mapEffects = new Collection<MapEffect>(this)
|
|
||||||
|
|
||||||
@OneToMany(() => MapEventTile, (tile) => tile.map, { orphanRemoval: true })
|
|
||||||
mapEventTiles = new Collection<MapEventTile>(this)
|
|
||||||
|
|
||||||
@OneToMany(() => PlacedMapObject, (placedMapObject) => placedMapObject.map, { orphanRemoval: true })
|
|
||||||
placedMapObjects = new Collection<PlacedMapObject>(this)
|
|
||||||
|
|
||||||
setId(id: UUID) {
|
|
||||||
this.id = id
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.id
|
|
||||||
}
|
|
||||||
|
|
||||||
setName(name: string) {
|
|
||||||
this.name = name
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getName() {
|
|
||||||
return this.name
|
|
||||||
}
|
|
||||||
|
|
||||||
setWidth(width: number) {
|
|
||||||
this.width = width
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getWidth() {
|
|
||||||
return this.width
|
|
||||||
}
|
|
||||||
|
|
||||||
setHeight(height: number) {
|
|
||||||
this.height = height
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getHeight() {
|
|
||||||
return this.height
|
|
||||||
}
|
|
||||||
|
|
||||||
setTiles(tiles: any) {
|
|
||||||
this.tiles = tiles
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getTiles() {
|
|
||||||
return this.tiles
|
|
||||||
}
|
|
||||||
|
|
||||||
setPvp(pvp: boolean) {
|
|
||||||
this.pvp = pvp
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getPvp() {
|
|
||||||
return this.pvp
|
|
||||||
}
|
|
||||||
|
|
||||||
setCreatedAt(createdAt: Date) {
|
|
||||||
this.createdAt = createdAt
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getCreatedAt() {
|
|
||||||
return this.createdAt
|
|
||||||
}
|
|
||||||
|
|
||||||
setUpdatedAt(updatedAt: Date) {
|
|
||||||
this.updatedAt = updatedAt
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getUpdatedAt() {
|
|
||||||
return this.updatedAt
|
|
||||||
}
|
|
||||||
|
|
||||||
setMapEffects(mapEffects: Collection<MapEffect>) {
|
|
||||||
this.mapEffects = mapEffects
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getMapEffects() {
|
|
||||||
return this.mapEffects
|
|
||||||
}
|
|
||||||
|
|
||||||
setMapEventTiles(mapEventTiles: Collection<MapEventTile>) {
|
|
||||||
this.mapEventTiles = mapEventTiles
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getMapEventTiles() {
|
|
||||||
return this.mapEventTiles
|
|
||||||
}
|
|
||||||
|
|
||||||
setPlacedMapObjects(placedMapObjects: Collection<PlacedMapObject>) {
|
|
||||||
this.placedMapObjects = placedMapObjects
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getPlacedMapObjects() {
|
|
||||||
return this.placedMapObjects
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,59 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BaseMapEffect } from '#entities/base/mapEffect'
|
||||||
|
|
||||||
import { Map } from './map'
|
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class MapEffect extends BaseEntity {
|
export class MapEffect extends BaseMapEffect {}
|
||||||
@PrimaryKey()
|
|
||||||
id = randomUUID()
|
|
||||||
|
|
||||||
@ManyToOne({ deleteRule: 'cascade' })
|
|
||||||
map!: Map
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
effect!: string
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
strength!: number
|
|
||||||
|
|
||||||
setId(id: UUID) {
|
|
||||||
this.id = id
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.id
|
|
||||||
}
|
|
||||||
|
|
||||||
setMap(map: Map) {
|
|
||||||
this.map = map
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getMap() {
|
|
||||||
return this.map
|
|
||||||
}
|
|
||||||
|
|
||||||
setEffect(effect: string) {
|
|
||||||
this.effect = effect
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getEffect() {
|
|
||||||
return this.effect
|
|
||||||
}
|
|
||||||
|
|
||||||
setStrength(strength: number) {
|
|
||||||
this.strength = strength
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getStrength() {
|
|
||||||
return this.strength
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,85 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Entity, Enum, ManyToOne, OneToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BaseMapEventTile } from '#entities/base/mapEventTile'
|
||||||
|
|
||||||
import { Map } from './map'
|
|
||||||
import { MapEventTileTeleport } from './mapEventTileTeleport'
|
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { MapEventTileType } from '#application/enums'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class MapEventTile extends BaseEntity {
|
export class MapEventTile extends BaseMapEventTile {}
|
||||||
@PrimaryKey()
|
|
||||||
id = randomUUID()
|
|
||||||
|
|
||||||
@ManyToOne({ deleteRule: 'cascade' })
|
|
||||||
map!: Map
|
|
||||||
|
|
||||||
@Enum(() => MapEventTileType)
|
|
||||||
type!: MapEventTileType
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
positionX!: number
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
positionY!: number
|
|
||||||
|
|
||||||
@OneToOne(() => MapEventTileTeleport, (teleport) => teleport.mapEventTile, { eager: true })
|
|
||||||
teleport?: MapEventTileTeleport
|
|
||||||
|
|
||||||
setId(id: UUID) {
|
|
||||||
this.id = id
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.id
|
|
||||||
}
|
|
||||||
|
|
||||||
setMap(map: Map) {
|
|
||||||
this.map = map
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getMap() {
|
|
||||||
return this.map
|
|
||||||
}
|
|
||||||
|
|
||||||
setType(type: MapEventTileType) {
|
|
||||||
this.type = type
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getType() {
|
|
||||||
return this.type
|
|
||||||
}
|
|
||||||
|
|
||||||
setPositionX(positionX: number) {
|
|
||||||
this.positionX = positionX
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getPositionX() {
|
|
||||||
return this.positionX
|
|
||||||
}
|
|
||||||
|
|
||||||
setPositionY(positionY: number) {
|
|
||||||
this.positionY = positionY
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getPositionY() {
|
|
||||||
return this.positionY
|
|
||||||
}
|
|
||||||
|
|
||||||
setTeleport(teleport: MapEventTileTeleport) {
|
|
||||||
this.teleport = teleport
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getTeleport() {
|
|
||||||
return this.teleport
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,84 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Entity, ManyToOne, OneToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BaseMapEventTileTeleport } from '#entities/base/mapEventTileTeleport'
|
||||||
|
|
||||||
import { Map } from './map'
|
|
||||||
import { MapEventTile } from './mapEventTile'
|
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class MapEventTileTeleport extends BaseEntity {
|
export class MapEventTileTeleport extends BaseMapEventTileTeleport {}
|
||||||
@PrimaryKey()
|
|
||||||
id = randomUUID()
|
|
||||||
|
|
||||||
@OneToOne({ deleteRule: 'cascade' })
|
|
||||||
mapEventTile!: MapEventTile
|
|
||||||
|
|
||||||
@ManyToOne({ deleteRule: 'cascade', eager: true })
|
|
||||||
toMap!: Map
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
toRotation!: number
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
toPositionX!: number
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
toPositionY!: number
|
|
||||||
|
|
||||||
setId(id: UUID) {
|
|
||||||
this.id = id
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.id
|
|
||||||
}
|
|
||||||
|
|
||||||
setMapEventTile(mapEventTile: MapEventTile) {
|
|
||||||
this.mapEventTile = mapEventTile
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getMapEventTile() {
|
|
||||||
return this.mapEventTile
|
|
||||||
}
|
|
||||||
|
|
||||||
setToMap(toMap: Map) {
|
|
||||||
this.toMap = toMap
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getToMap() {
|
|
||||||
return this.toMap
|
|
||||||
}
|
|
||||||
|
|
||||||
setToRotation(toRotation: number) {
|
|
||||||
this.toRotation = toRotation
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getToRotation() {
|
|
||||||
return this.toRotation
|
|
||||||
}
|
|
||||||
|
|
||||||
setToPositionX(toPositionX: number) {
|
|
||||||
this.toPositionX = toPositionX
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getToPositionX() {
|
|
||||||
return this.toPositionX
|
|
||||||
}
|
|
||||||
|
|
||||||
setToPositionY(toPositionY: number) {
|
|
||||||
this.toPositionY = toPositionY
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getToPositionY() {
|
|
||||||
return this.toPositionY
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,141 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Entity, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BaseMapObject } from '#entities/base/mapObject'
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class MapObject extends BaseEntity {
|
export class MapObject extends BaseMapObject {}
|
||||||
@PrimaryKey()
|
|
||||||
id = randomUUID()
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
name!: string
|
|
||||||
|
|
||||||
@Property({ type: 'json', nullable: true })
|
|
||||||
tags?: any
|
|
||||||
|
|
||||||
@Property({ type: 'decimal', precision: 10, scale: 2 })
|
|
||||||
originX = 0
|
|
||||||
|
|
||||||
@Property({ type: 'decimal', precision: 10, scale: 2 })
|
|
||||||
originY = 0
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
isAnimated = false
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
frameRate = 0
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
frameWidth = 0
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
frameHeight = 0
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
createdAt = new Date()
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
updatedAt = new Date()
|
|
||||||
|
|
||||||
setId(id: UUID) {
|
|
||||||
this.id = id
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.id
|
|
||||||
}
|
|
||||||
|
|
||||||
setName(name: string) {
|
|
||||||
this.name = name
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getName() {
|
|
||||||
return this.name
|
|
||||||
}
|
|
||||||
|
|
||||||
setTags(tags: any) {
|
|
||||||
this.tags = tags
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getTags() {
|
|
||||||
return this.tags
|
|
||||||
}
|
|
||||||
|
|
||||||
setOriginX(originX: number) {
|
|
||||||
this.originX = originX
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getOriginX() {
|
|
||||||
return this.originX
|
|
||||||
}
|
|
||||||
|
|
||||||
setOriginY(originY: number) {
|
|
||||||
this.originY = originY
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getOriginY() {
|
|
||||||
return this.originY
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsAnimated(isAnimated: boolean) {
|
|
||||||
this.isAnimated = isAnimated
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getIsAnimated() {
|
|
||||||
return this.isAnimated
|
|
||||||
}
|
|
||||||
|
|
||||||
setFrameRate(frameRate: number) {
|
|
||||||
this.frameRate = frameRate
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getFrameRate() {
|
|
||||||
return this.frameRate
|
|
||||||
}
|
|
||||||
|
|
||||||
setFrameWidth(frameWidth: number) {
|
|
||||||
this.frameWidth = frameWidth
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getFrameWidth() {
|
|
||||||
return this.frameWidth
|
|
||||||
}
|
|
||||||
|
|
||||||
setFrameHeight(frameHeight: number) {
|
|
||||||
this.frameHeight = frameHeight
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getFrameHeight() {
|
|
||||||
return this.frameHeight
|
|
||||||
}
|
|
||||||
|
|
||||||
setCreatedAt(createdAt: Date) {
|
|
||||||
this.createdAt = createdAt
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getCreatedAt() {
|
|
||||||
return this.createdAt
|
|
||||||
}
|
|
||||||
|
|
||||||
setUpdatedAt(updatedAt: Date) {
|
|
||||||
this.updatedAt = updatedAt
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getUpdatedAt() {
|
|
||||||
return this.updatedAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,59 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BasePasswordResetToken } from '#entities/base/passwordResetToken'
|
||||||
|
|
||||||
import { User } from './user'
|
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class PasswordResetToken extends BaseEntity {
|
export class PasswordResetToken extends BasePasswordResetToken {}
|
||||||
@PrimaryKey()
|
|
||||||
id = randomUUID()
|
|
||||||
|
|
||||||
@ManyToOne({ deleteRule: 'cascade' })
|
|
||||||
user!: User
|
|
||||||
|
|
||||||
@Property({ unique: true })
|
|
||||||
token!: string
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
createdAt = new Date()
|
|
||||||
|
|
||||||
setId(id: UUID) {
|
|
||||||
this.id = id
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.id
|
|
||||||
}
|
|
||||||
|
|
||||||
setUser(user: User) {
|
|
||||||
this.user = user
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getUser() {
|
|
||||||
return this.user
|
|
||||||
}
|
|
||||||
|
|
||||||
setToken(token: string) {
|
|
||||||
this.token = token
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getToken() {
|
|
||||||
return this.token
|
|
||||||
}
|
|
||||||
|
|
||||||
setCreatedAt(createdAt: Date) {
|
|
||||||
this.createdAt = createdAt
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getCreatedAt() {
|
|
||||||
return this.createdAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,97 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BasePlacedMapObject } from '#entities/base/placedMapObject'
|
||||||
|
|
||||||
import { Map } from './map'
|
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
import { MapObject } from '#entities/mapObject'
|
|
||||||
|
|
||||||
//@TODO : Rename mapObject
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class PlacedMapObject extends BaseEntity {
|
export class PlacedMapObject extends BasePlacedMapObject {}
|
||||||
@PrimaryKey()
|
|
||||||
id = randomUUID()
|
|
||||||
|
|
||||||
@ManyToOne({ deleteRule: 'cascade' })
|
|
||||||
map!: Map
|
|
||||||
|
|
||||||
@ManyToOne({ deleteRule: 'cascade', eager: true })
|
|
||||||
mapObject!: MapObject
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
depth = 0
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
isRotated = false
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
positionX = 0
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
positionY = 0
|
|
||||||
|
|
||||||
setId(id: UUID) {
|
|
||||||
this.id = id
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.id
|
|
||||||
}
|
|
||||||
|
|
||||||
setMap(map: Map) {
|
|
||||||
this.map = map
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getMap() {
|
|
||||||
return this.map
|
|
||||||
}
|
|
||||||
|
|
||||||
setMapObject(mapObject: MapObject) {
|
|
||||||
this.mapObject = mapObject
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getMapObject() {
|
|
||||||
return this.mapObject
|
|
||||||
}
|
|
||||||
|
|
||||||
setDepth(depth: number) {
|
|
||||||
this.depth = depth
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getDepth() {
|
|
||||||
return this.depth
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsRotated(isRotated: boolean) {
|
|
||||||
this.isRotated = isRotated
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getIsRotated() {
|
|
||||||
return this.isRotated
|
|
||||||
}
|
|
||||||
|
|
||||||
setPositionX(positionX: number) {
|
|
||||||
this.positionX = positionX
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getPositionX() {
|
|
||||||
return this.positionX
|
|
||||||
}
|
|
||||||
|
|
||||||
setPositionY(positionY: number) {
|
|
||||||
this.positionY = positionY
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getPositionY() {
|
|
||||||
return this.positionY
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,71 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BaseSprite } from '#entities/base/sprite'
|
||||||
|
|
||||||
import { SpriteAction } from './spriteAction'
|
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Sprite extends BaseEntity {
|
export class Sprite extends BaseSprite {}
|
||||||
@PrimaryKey()
|
|
||||||
id = randomUUID()
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
name!: string
|
|
||||||
|
|
||||||
@OneToMany(() => SpriteAction, (action) => action.sprite)
|
|
||||||
spriteActions = new Collection<SpriteAction>(this)
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
createdAt = new Date()
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
updatedAt = new Date()
|
|
||||||
|
|
||||||
setId(id: UUID) {
|
|
||||||
this.id = id
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.id
|
|
||||||
}
|
|
||||||
|
|
||||||
setName(name: string) {
|
|
||||||
this.name = name
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getName() {
|
|
||||||
return this.name
|
|
||||||
}
|
|
||||||
|
|
||||||
setSpriteActions(spriteActions: Collection<SpriteAction>) {
|
|
||||||
this.spriteActions = spriteActions
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getSpriteActions() {
|
|
||||||
return this.spriteActions
|
|
||||||
}
|
|
||||||
|
|
||||||
setCreatedAt(createdAt: Date) {
|
|
||||||
this.createdAt = createdAt
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getCreatedAt() {
|
|
||||||
return this.createdAt
|
|
||||||
}
|
|
||||||
|
|
||||||
setUpdatedAt(updatedAt: Date) {
|
|
||||||
this.updatedAt = updatedAt
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getUpdatedAt() {
|
|
||||||
return this.updatedAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,143 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BaseSpriteAction } from '#entities/base/spriteAction'
|
||||||
|
|
||||||
import { Sprite } from './sprite'
|
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class SpriteAction extends BaseEntity {
|
export class SpriteAction extends BaseSpriteAction {}
|
||||||
@PrimaryKey()
|
|
||||||
id = randomUUID()
|
|
||||||
|
|
||||||
@ManyToOne({ deleteRule: 'cascade' })
|
|
||||||
sprite!: Sprite
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
action!: string
|
|
||||||
|
|
||||||
@Property({ type: 'json', nullable: true })
|
|
||||||
sprites?: string[]
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
originX = 0
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
originY = 0
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
isAnimated = false
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
isLooping = false
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
frameWidth = 0
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
frameHeight = 0
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
frameRate = 0
|
|
||||||
|
|
||||||
setId(id: UUID) {
|
|
||||||
this.id = id
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.id
|
|
||||||
}
|
|
||||||
|
|
||||||
setSprite(sprite: Sprite) {
|
|
||||||
this.sprite = sprite
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getSprite() {
|
|
||||||
return this.sprite
|
|
||||||
}
|
|
||||||
|
|
||||||
setAction(action: string) {
|
|
||||||
this.action = action
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getAction() {
|
|
||||||
return this.action
|
|
||||||
}
|
|
||||||
|
|
||||||
setSprites(sprites: string[]) {
|
|
||||||
this.sprites = sprites
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getSprites() {
|
|
||||||
return this.sprites
|
|
||||||
}
|
|
||||||
|
|
||||||
setOriginX(originX: number) {
|
|
||||||
this.originX = originX
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getOriginX() {
|
|
||||||
return this.originX
|
|
||||||
}
|
|
||||||
|
|
||||||
setOriginY(originY: number) {
|
|
||||||
this.originY = originY
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getOriginY() {
|
|
||||||
return this.originY
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsAnimated(isAnimated: boolean) {
|
|
||||||
this.isAnimated = isAnimated
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getIsAnimated() {
|
|
||||||
return this.isAnimated
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsLooping(isLooping: boolean) {
|
|
||||||
this.isLooping = isLooping
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getIsLooping() {
|
|
||||||
return this.isLooping
|
|
||||||
}
|
|
||||||
|
|
||||||
setFrameWidth(frameWidth: number) {
|
|
||||||
this.frameWidth = frameWidth
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getFrameWidth() {
|
|
||||||
return this.frameWidth
|
|
||||||
}
|
|
||||||
|
|
||||||
setFrameHeight(frameHeight: number) {
|
|
||||||
this.frameHeight = frameHeight
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getFrameHeight() {
|
|
||||||
return this.frameHeight
|
|
||||||
}
|
|
||||||
|
|
||||||
setFrameRate(frameRate: number) {
|
|
||||||
this.frameRate = frameRate
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getFrameRate() {
|
|
||||||
return this.frameRate
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,69 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Entity, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BaseTile } from '#entities/base/tile'
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Tile extends BaseEntity {
|
export class Tile extends BaseTile {}
|
||||||
@PrimaryKey()
|
|
||||||
id = randomUUID()
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
name!: string
|
|
||||||
|
|
||||||
@Property({ type: 'json', nullable: true })
|
|
||||||
tags?: any
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
createdAt = new Date()
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
updatedAt = new Date()
|
|
||||||
|
|
||||||
setId(id: UUID) {
|
|
||||||
this.id = id
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.id
|
|
||||||
}
|
|
||||||
|
|
||||||
setName(name: string) {
|
|
||||||
this.name = name
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getName() {
|
|
||||||
return this.name
|
|
||||||
}
|
|
||||||
|
|
||||||
setTags(tags: any) {
|
|
||||||
this.tags = tags
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getTags() {
|
|
||||||
return this.tags
|
|
||||||
}
|
|
||||||
|
|
||||||
setCreatedAt(createdAt: Date) {
|
|
||||||
this.createdAt = createdAt
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getCreatedAt() {
|
|
||||||
return this.createdAt
|
|
||||||
}
|
|
||||||
|
|
||||||
setUpdatedAt(updatedAt: Date) {
|
|
||||||
this.updatedAt = updatedAt
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getUpdatedAt() {
|
|
||||||
return this.updatedAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,98 +1,6 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
import { BaseUser } from '#entities/base/user'
|
||||||
import bcrypt from 'bcryptjs'
|
|
||||||
|
|
||||||
import { Character } from './character'
|
|
||||||
import { PasswordResetToken } from './passwordResetToken'
|
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
|
||||||
import { UUID } from '#application/types'
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class User extends BaseEntity {
|
export class User extends BaseUser {}
|
||||||
@PrimaryKey()
|
|
||||||
id = randomUUID()
|
|
||||||
|
|
||||||
@Property({ unique: true })
|
|
||||||
username!: string
|
|
||||||
|
|
||||||
@Property({ unique: true })
|
|
||||||
email!: string
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
password!: string
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
online = false
|
|
||||||
|
|
||||||
@OneToMany(() => Character, (character) => character.user)
|
|
||||||
characters = new Collection<Character>(this)
|
|
||||||
|
|
||||||
@OneToMany(() => PasswordResetToken, (token) => token.user)
|
|
||||||
passwordResetTokens = new Collection<PasswordResetToken>(this)
|
|
||||||
|
|
||||||
setId(id: UUID) {
|
|
||||||
this.id = id
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.id
|
|
||||||
}
|
|
||||||
|
|
||||||
setUsername(username: string) {
|
|
||||||
this.username = username
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getUsername() {
|
|
||||||
return this.username
|
|
||||||
}
|
|
||||||
|
|
||||||
setEmail(email: string) {
|
|
||||||
this.email = email
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getEmail() {
|
|
||||||
return this.email
|
|
||||||
}
|
|
||||||
|
|
||||||
setPassword(password: string) {
|
|
||||||
this.password = bcrypt.hashSync(password, 10)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getPassword() {
|
|
||||||
return this.password
|
|
||||||
}
|
|
||||||
|
|
||||||
setOnline(online: boolean) {
|
|
||||||
this.online = online
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getOnline() {
|
|
||||||
return this.online
|
|
||||||
}
|
|
||||||
|
|
||||||
setCharacters(characters: Collection<Character>) {
|
|
||||||
this.characters = characters
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getCharacters() {
|
|
||||||
return this.characters
|
|
||||||
}
|
|
||||||
|
|
||||||
setPasswordResetTokens(passwordResetTokens: Collection<PasswordResetToken>) {
|
|
||||||
this.passwordResetTokens = passwordResetTokens
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getPasswordResetTokens() {
|
|
||||||
return this.passwordResetTokens
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,66 +1,6 @@
|
|||||||
import { Entity, PrimaryKey, Property } from '@mikro-orm/core'
|
import { Entity } from '@mikro-orm/core'
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
import { BaseWorld } from '#entities/base/world'
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class World extends BaseEntity {
|
export class World extends BaseWorld {}
|
||||||
@PrimaryKey()
|
|
||||||
date = new Date()
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
isRainEnabled = false
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
rainPercentage = 0
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
isFogEnabled = false
|
|
||||||
|
|
||||||
@Property()
|
|
||||||
fogDensity = 0
|
|
||||||
|
|
||||||
setDate(date: Date) {
|
|
||||||
this.date = date
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getDate() {
|
|
||||||
return this.date
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsRainEnabled(isRainEnabled: boolean) {
|
|
||||||
this.isRainEnabled = isRainEnabled
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getIsRainEnabled() {
|
|
||||||
return this.isRainEnabled
|
|
||||||
}
|
|
||||||
|
|
||||||
setRainPercentage(rainPercentage: number) {
|
|
||||||
this.rainPercentage = rainPercentage
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getRainPercentage() {
|
|
||||||
return this.rainPercentage
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsFogEnabled(isFogEnabled: boolean) {
|
|
||||||
this.isFogEnabled = isFogEnabled
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getIsFogEnabled() {
|
|
||||||
return this.isFogEnabled
|
|
||||||
}
|
|
||||||
|
|
||||||
setFogDensity(fogDensity: number) {
|
|
||||||
this.fogDensity = fogDensity
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getFogDensity() {
|
|
||||||
return this.fogDensity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -56,7 +56,13 @@ class TeleportService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update character position and map
|
// Update character position and map
|
||||||
await mapCharacter.getCharacter().setPositionX(options.targetX).setPositionY(options.targetY).setRotation(options.rotation ?? 0).setMap(targetMap.getMap()).save()
|
await mapCharacter
|
||||||
|
.getCharacter()
|
||||||
|
.setPositionX(options.targetX)
|
||||||
|
.setPositionY(options.targetY)
|
||||||
|
.setRotation(options.rotation ?? 0)
|
||||||
|
.setMap(targetMap.getMap())
|
||||||
|
.save()
|
||||||
|
|
||||||
// Join new map
|
// Join new map
|
||||||
socket.join(options.targetMapId)
|
socket.join(options.targetMapId)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user