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';
|
||||
|
||||
export class Migration20250105033941 extends Migration {
|
||||
export class Migration20250106170204 extends Migration {
|
||||
|
||||
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;`);
|
@ -8,8 +8,8 @@ import serverConfig from './src/application/config'
|
||||
export default defineConfig({
|
||||
extensions: [Migrator],
|
||||
metadataProvider: TsMorphMetadataProvider,
|
||||
entities: ['./src/entities/**/*.js'],
|
||||
entitiesTs: ['./src/entities/**/*.ts'],
|
||||
entities: ['./src/entities/*.js'],
|
||||
entitiesTs: ['./src/entities/*.ts'],
|
||||
driver: MySqlDriver,
|
||||
host: serverConfig.DB_HOST,
|
||||
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 { 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'
|
||||
import { BaseCharacter } from '#entities/base/character'
|
||||
|
||||
@Entity()
|
||||
export class Character 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
|
||||
}
|
||||
}
|
||||
export class Character extends BaseCharacter {}
|
||||
|
@ -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 { Character } from './character'
|
||||
import { CharacterItem } from './characterItem'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { CharacterEquipmentSlotType } from '#application/enums'
|
||||
import { UUID } from '#application/types'
|
||||
import { BaseCharacterEquipment } from '#entities/base/characterEquipment'
|
||||
|
||||
@Entity()
|
||||
export class CharacterEquipment extends BaseEntity {
|
||||
@PrimaryKey()
|
||||
id = randomUUID()
|
||||
|
||||
@Enum(() => CharacterEquipmentSlotType)
|
||||
slot!: CharacterEquipmentSlotType
|
||||
|
||||
@ManyToOne({ deleteRule: 'cascade' })
|
||||
character!: Character
|
||||
|
||||
@ManyToOne({ deleteRule: 'cascade' })
|
||||
characterItem!: CharacterItem
|
||||
|
||||
setId(id: UUID) {
|
||||
this.id = id
|
||||
return this
|
||||
}
|
||||
|
||||
getId() {
|
||||
return this.id
|
||||
}
|
||||
|
||||
setSlot(slot: CharacterEquipmentSlotType) {
|
||||
this.slot = slot
|
||||
return this
|
||||
}
|
||||
|
||||
getSlot() {
|
||||
return this.slot
|
||||
}
|
||||
|
||||
setCharacter(character: Character) {
|
||||
this.character = character
|
||||
return this
|
||||
}
|
||||
|
||||
getCharacter() {
|
||||
return this.character
|
||||
}
|
||||
|
||||
setCharacterItem(characterItem: CharacterItem) {
|
||||
this.characterItem = characterItem
|
||||
return this
|
||||
}
|
||||
|
||||
getCharacterItem() {
|
||||
return this.characterItem
|
||||
}
|
||||
}
|
||||
export class CharacterEquipment extends BaseCharacterEquipment {}
|
||||
|
@ -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 { Character } from './character'
|
||||
import { Sprite } from './sprite'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { CharacterGender } from '#application/enums'
|
||||
import { UUID } from '#application/types'
|
||||
import { BaseCharacterHair } from '#entities/base/characterHair'
|
||||
|
||||
@Entity()
|
||||
export class CharacterHair 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
|
||||
}
|
||||
}
|
||||
export class CharacterHair extends BaseCharacterHair {}
|
||||
|
@ -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 { Character } from './character'
|
||||
import { CharacterEquipment } from './characterEquipment'
|
||||
import { Item } from './item'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { UUID } from '#application/types'
|
||||
import { BaseCharacterItem } from '#entities/base/characterItem'
|
||||
|
||||
@Entity()
|
||||
export class CharacterItem extends BaseEntity {
|
||||
@PrimaryKey()
|
||||
id = randomUUID()
|
||||
|
||||
@ManyToOne({ deleteRule: 'cascade' })
|
||||
character!: Character
|
||||
|
||||
@ManyToOne({ deleteRule: 'cascade' })
|
||||
item!: Item
|
||||
|
||||
@Property()
|
||||
quantity!: number
|
||||
|
||||
setId(id: UUID) {
|
||||
this.id = id
|
||||
return this
|
||||
}
|
||||
|
||||
getId() {
|
||||
return this.id
|
||||
}
|
||||
|
||||
setCharacter(character: Character) {
|
||||
this.character = character
|
||||
return this
|
||||
}
|
||||
|
||||
getCharacter() {
|
||||
return this.character
|
||||
}
|
||||
|
||||
setItem(item: Item) {
|
||||
this.item = item
|
||||
return this
|
||||
}
|
||||
|
||||
getItem() {
|
||||
return this.item
|
||||
}
|
||||
|
||||
setQuantity(quantity: number) {
|
||||
this.quantity = quantity
|
||||
return this
|
||||
}
|
||||
|
||||
getQuantity() {
|
||||
return this.quantity
|
||||
}
|
||||
}
|
||||
export class CharacterItem extends BaseCharacterItem {}
|
||||
|
@ -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 { Character } from './character'
|
||||
import { Sprite } from './sprite'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { CharacterGender, CharacterRace } from '#application/enums'
|
||||
import { UUID } from '#application/types'
|
||||
import { BaseCharacterType } from '#entities/base/characterType'
|
||||
|
||||
@Entity()
|
||||
export class CharacterType 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
|
||||
}
|
||||
}
|
||||
export class CharacterType extends BaseCharacterType {}
|
||||
|
@ -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 { Character } from './character'
|
||||
import { Map } from './map'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { UUID } from '#application/types'
|
||||
import { BaseChat } from '#entities/base/chat'
|
||||
|
||||
@Entity()
|
||||
export class Chat 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
|
||||
}
|
||||
}
|
||||
export class Chat extends BaseChat {}
|
||||
|
@ -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 { CharacterItem } from './characterItem'
|
||||
import { Sprite } from './sprite'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { ItemType, ItemRarity } from '#application/enums'
|
||||
import { UUID } from '#application/types'
|
||||
import { BaseItem } from '#entities/base/item'
|
||||
|
||||
@Entity()
|
||||
export class Item 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
|
||||
}
|
||||
}
|
||||
export class Item extends BaseItem {}
|
||||
|
@ -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 { MapEffect } from './mapEffect'
|
||||
import { MapEventTile } from './mapEventTile'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { UUID } from '#application/types'
|
||||
import { PlacedMapObject } from '#entities/placedMapObject'
|
||||
import { BaseMap } from '#entities/base/map'
|
||||
|
||||
@Entity()
|
||||
export class Map 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
|
||||
}
|
||||
}
|
||||
export class Map extends BaseMap {}
|
||||
|
@ -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 { Map } from './map'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { UUID } from '#application/types'
|
||||
import { BaseMapEffect } from '#entities/base/mapEffect'
|
||||
|
||||
@Entity()
|
||||
export class MapEffect 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
|
||||
}
|
||||
}
|
||||
export class MapEffect extends BaseMapEffect {}
|
||||
|
@ -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 { Map } from './map'
|
||||
import { MapEventTileTeleport } from './mapEventTileTeleport'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { MapEventTileType } from '#application/enums'
|
||||
import { UUID } from '#application/types'
|
||||
import { BaseMapEventTile } from '#entities/base/mapEventTile'
|
||||
|
||||
@Entity()
|
||||
export class MapEventTile 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
|
||||
}
|
||||
}
|
||||
export class MapEventTile extends BaseMapEventTile {}
|
||||
|
@ -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 { Map } from './map'
|
||||
import { MapEventTile } from './mapEventTile'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { UUID } from '#application/types'
|
||||
import { BaseMapEventTileTeleport } from '#entities/base/mapEventTileTeleport'
|
||||
|
||||
@Entity()
|
||||
export class MapEventTileTeleport 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
|
||||
}
|
||||
}
|
||||
export class MapEventTileTeleport extends BaseMapEventTileTeleport {}
|
||||
|
@ -1,141 +1,6 @@
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import { Entity } from '@mikro-orm/core'
|
||||
|
||||
import { Entity, PrimaryKey, Property } from '@mikro-orm/core'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { UUID } from '#application/types'
|
||||
import { BaseMapObject } from '#entities/base/mapObject'
|
||||
|
||||
@Entity()
|
||||
export class MapObject 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
|
||||
}
|
||||
}
|
||||
export class MapObject extends BaseMapObject {}
|
||||
|
@ -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 { User } from './user'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { UUID } from '#application/types'
|
||||
import { BasePasswordResetToken } from '#entities/base/passwordResetToken'
|
||||
|
||||
@Entity()
|
||||
export class PasswordResetToken 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
|
||||
}
|
||||
}
|
||||
export class PasswordResetToken extends BasePasswordResetToken {}
|
||||
|
@ -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()
|
||||
export class PlacedMapObject 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
|
||||
}
|
||||
}
|
||||
export class PlacedMapObject extends BasePlacedMapObject {}
|
||||
|
@ -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 { SpriteAction } from './spriteAction'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { UUID } from '#application/types'
|
||||
import { BaseSprite } from '#entities/base/sprite'
|
||||
|
||||
@Entity()
|
||||
export class Sprite 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
|
||||
}
|
||||
}
|
||||
export class Sprite extends BaseSprite {}
|
||||
|
@ -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 { Sprite } from './sprite'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { UUID } from '#application/types'
|
||||
import { BaseSpriteAction } from '#entities/base/spriteAction'
|
||||
|
||||
@Entity()
|
||||
export class SpriteAction 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
|
||||
}
|
||||
}
|
||||
export class SpriteAction extends BaseSpriteAction {}
|
||||
|
@ -1,69 +1,6 @@
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import { Entity } from '@mikro-orm/core'
|
||||
|
||||
import { Entity, PrimaryKey, Property } from '@mikro-orm/core'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { UUID } from '#application/types'
|
||||
import { BaseTile } from '#entities/base/tile'
|
||||
|
||||
@Entity()
|
||||
export class Tile 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
|
||||
}
|
||||
}
|
||||
export class Tile extends BaseTile {}
|
||||
|
@ -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 bcrypt from 'bcryptjs'
|
||||
|
||||
import { Character } from './character'
|
||||
import { PasswordResetToken } from './passwordResetToken'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { UUID } from '#application/types'
|
||||
import { BaseUser } from '#entities/base/user'
|
||||
|
||||
@Entity()
|
||||
export class User 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
|
||||
}
|
||||
}
|
||||
export class User extends BaseUser {}
|
||||
|
@ -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()
|
||||
export class World 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
|
||||
}
|
||||
}
|
||||
export class World extends BaseWorld {}
|
||||
|
@ -56,7 +56,13 @@ class TeleportService {
|
||||
}
|
||||
|
||||
// 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
|
||||
socket.join(options.targetMapId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user