Removed TSC in favour of node's own Typescript exec.
This commit is contained in:
parent
52b8a9b7ad
commit
cff5fed4f7
@ -4,7 +4,6 @@ WORKDIR /usr/src/app
|
|||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
# Production stage
|
# Production stage
|
||||||
FROM node:23.7.0-alpine
|
FROM node:23.7.0-alpine
|
||||||
|
@ -45,7 +45,7 @@ echo "MySQL is ready!"
|
|||||||
|
|
||||||
# Run migrations with error handling
|
# Run migrations with error handling
|
||||||
echo "Running database migrations..."
|
echo "Running database migrations..."
|
||||||
if ! npx mikro-orm migration:up; then
|
if ! npx mikro-orm-esm migration:up; then
|
||||||
echo "Migration failed"
|
echo "Migration failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -1,104 +0,0 @@
|
|||||||
import { Migration } from '@mikro-orm/migrations';
|
|
||||||
|
|
||||||
export class Migration20250128165214 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;`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`map_effect\` (\`id\` varchar(255) not null, \`map_id\` varchar(255) not null, \`effect\` varchar(255) not null, \`strength\` int not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
this.addSql(`alter table \`map_effect\` add index \`map_effect_map_id_index\`(\`map_id\`);`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`map_event_tile\` (\`id\` varchar(255) not null, \`map_id\` varchar(255) not null, \`type\` enum('BLOCK', 'TELEPORT', 'NPC', 'ITEM') not null, \`position_x\` int not null, \`position_y\` int not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
this.addSql(`alter table \`map_event_tile\` add index \`map_event_tile_map_id_index\`(\`map_id\`);`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`map_event_tile_teleport\` (\`id\` varchar(255) not null, \`map_event_tile_id\` varchar(255) not null, \`to_map_id\` varchar(255) not null, \`to_rotation\` int not null, \`to_position_x\` int not null, \`to_position_y\` int not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
this.addSql(`alter table \`map_event_tile_teleport\` add unique \`map_event_tile_teleport_map_event_tile_id_unique\`(\`map_event_tile_id\`);`);
|
|
||||||
this.addSql(`alter table \`map_event_tile_teleport\` add index \`map_event_tile_teleport_to_map_id_index\`(\`to_map_id\`);`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`map_object\` (\`id\` varchar(255) not null, \`name\` varchar(255) not null, \`tags\` json null, \`origin_x\` numeric(10,2) not null default 0, \`origin_y\` numeric(10,2) not null default 0, \`frame_rate\` int not null default 0, \`frame_width\` int not null default 0, \`frame_height\` int not null default 0, \`created_at\` datetime not null, \`updated_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`placed_map_object\` (\`id\` varchar(255) not null, \`map_id\` varchar(255) not null, \`map_object_id\` varchar(255) not null, \`is_rotated\` tinyint(1) not null default false, \`position_x\` int not null default 0, \`position_y\` int not null default 0, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
this.addSql(`alter table \`placed_map_object\` add index \`placed_map_object_map_id_index\`(\`map_id\`);`);
|
|
||||||
this.addSql(`alter table \`placed_map_object\` add index \`placed_map_object_map_object_id_index\`(\`map_object_id\`);`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`sprite\` (\`id\` varchar(255) not null, \`name\` varchar(255) not null, \`created_at\` datetime not null, \`updated_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`item\` (\`id\` varchar(255) not null, \`name\` varchar(255) not null, \`description\` varchar(255) not null default '', \`item_type\` enum('WEAPON', 'HELMET', 'CHEST', 'LEGS', 'BOOTS', 'GLOVES', 'RING', 'NECKLACE') not null, \`stackable\` tinyint(1) not null default false, \`rarity\` enum('COMMON', 'UNCOMMON', 'RARE', 'EPIC', 'LEGENDARY') not null default 'COMMON', \`sprite_id\` varchar(255) null, \`created_at\` datetime not null, \`updated_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
this.addSql(`alter table \`item\` add index \`item_sprite_id_index\`(\`sprite_id\`);`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`character_type\` (\`id\` varchar(255) not null, \`name\` varchar(255) not null, \`gender\` enum('MALE', 'FEMALE') not null, \`race\` enum('HUMAN', 'ELF', 'DWARF', 'ORC', 'GOBLIN') not null, \`is_selectable\` tinyint(1) not null default false, \`sprite_id\` varchar(255) null, \`created_at\` datetime not null, \`updated_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
this.addSql(`alter table \`character_type\` add index \`character_type_sprite_id_index\`(\`sprite_id\`);`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`character_hair\` (\`id\` varchar(255) not null, \`name\` varchar(255) not null, \`gender\` varchar(255) not null default 'MALE', \`is_selectable\` tinyint(1) not null default false, \`sprite_id\` varchar(255) null, \`created_at\` datetime not null, \`updated_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
this.addSql(`alter table \`character_hair\` add index \`character_hair_sprite_id_index\`(\`sprite_id\`);`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`sprite_action\` (\`id\` varchar(255) not null, \`sprite_id\` varchar(255) not null, \`action\` varchar(255) not null, \`sprites\` json null, \`origin_x\` numeric(5,2) not null default 0, \`origin_y\` numeric(5,2) not null default 0, \`frame_width\` int not null default 0, \`frame_height\` int not null default 0, \`frame_rate\` int not null default 0, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
this.addSql(`alter table \`sprite_action\` add index \`sprite_action_sprite_id_index\`(\`sprite_id\`);`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`tile\` (\`id\` varchar(255) not null, \`name\` varchar(255) not null, \`tags\` json null, \`created_at\` datetime not null, \`updated_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`user\` (\`id\` varchar(255) not null, \`username\` varchar(255) not null, \`email\` varchar(255) not null, \`password\` varchar(255) not null, \`online\` tinyint(1) not null default false, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
this.addSql(`alter table \`user\` add unique \`user_username_unique\`(\`username\`);`);
|
|
||||||
this.addSql(`alter table \`user\` add unique \`user_email_unique\`(\`email\`);`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`password_reset_token\` (\`id\` varchar(255) not null, \`user_id\` varchar(255) not null, \`token\` varchar(255) not null, \`created_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
this.addSql(`alter table \`password_reset_token\` add index \`password_reset_token_user_id_index\`(\`user_id\`);`);
|
|
||||||
this.addSql(`alter table \`password_reset_token\` add unique \`password_reset_token_token_unique\`(\`token\`);`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`character\` (\`id\` varchar(255) not null, \`user_id\` varchar(255) not null, \`name\` varchar(255) not null, \`online\` tinyint(1) not null default false, \`role\` varchar(255) not null default 'player', \`map_id\` varchar(255) not null, \`position_x\` int not null default 0, \`position_y\` int not null default 0, \`rotation\` int not null default 0, \`character_type_id\` varchar(255) null, \`character_hair_id\` varchar(255) null, \`alignment\` int not null default 50, \`hitpoints\` int not null default 100, \`mana\` int not null default 100, \`level\` int not null default 1, \`experience\` int not null default 0, \`strength\` int not null default 10, \`dexterity\` int not null default 10, \`intelligence\` int not null default 10, \`wisdom\` int not null default 10, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
this.addSql(`alter table \`character\` add index \`character_user_id_index\`(\`user_id\`);`);
|
|
||||||
this.addSql(`alter table \`character\` add unique \`character_name_unique\`(\`name\`);`);
|
|
||||||
this.addSql(`alter table \`character\` add index \`character_map_id_index\`(\`map_id\`);`);
|
|
||||||
this.addSql(`alter table \`character\` add index \`character_character_type_id_index\`(\`character_type_id\`);`);
|
|
||||||
this.addSql(`alter table \`character\` add index \`character_character_hair_id_index\`(\`character_hair_id\`);`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`chat\` (\`id\` varchar(255) not null, \`character_id\` varchar(255) not null, \`map_id\` varchar(255) not null, \`message\` varchar(255) not null, \`created_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
this.addSql(`alter table \`chat\` add index \`chat_character_id_index\`(\`character_id\`);`);
|
|
||||||
this.addSql(`alter table \`chat\` add index \`chat_map_id_index\`(\`map_id\`);`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`character_item\` (\`id\` varchar(255) not null, \`character_id\` varchar(255) not null, \`item_id\` varchar(255) not null, \`quantity\` int not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
this.addSql(`alter table \`character_item\` add index \`character_item_character_id_index\`(\`character_id\`);`);
|
|
||||||
this.addSql(`alter table \`character_item\` add index \`character_item_item_id_index\`(\`item_id\`);`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`character_equipment\` (\`id\` varchar(255) not null, \`slot\` enum('HEAD', 'BODY', 'ARMS', 'LEGS', 'NECK', 'RING') not null, \`character_id\` varchar(255) not null, \`character_item_id\` varchar(255) not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
this.addSql(`alter table \`character_equipment\` add index \`character_equipment_character_id_index\`(\`character_id\`);`);
|
|
||||||
this.addSql(`alter table \`character_equipment\` add index \`character_equipment_character_item_id_index\`(\`character_item_id\`);`);
|
|
||||||
|
|
||||||
this.addSql(`create table \`world\` (\`date\` datetime not null, \`rain_percentage\` int not null default 0, \`fog_density\` int not null default 0, primary key (\`date\`)) default character set utf8mb4 engine = InnoDB;`);
|
|
||||||
|
|
||||||
this.addSql(`alter table \`map_effect\` add constraint \`map_effect_map_id_foreign\` foreign key (\`map_id\`) references \`map\` (\`id\`) on update cascade on delete cascade;`);
|
|
||||||
|
|
||||||
this.addSql(`alter table \`map_event_tile\` add constraint \`map_event_tile_map_id_foreign\` foreign key (\`map_id\`) references \`map\` (\`id\`) on update cascade on delete cascade;`);
|
|
||||||
|
|
||||||
this.addSql(`alter table \`map_event_tile_teleport\` add constraint \`map_event_tile_teleport_map_event_tile_id_foreign\` foreign key (\`map_event_tile_id\`) references \`map_event_tile\` (\`id\`) on update cascade on delete cascade;`);
|
|
||||||
this.addSql(`alter table \`map_event_tile_teleport\` add constraint \`map_event_tile_teleport_to_map_id_foreign\` foreign key (\`to_map_id\`) references \`map\` (\`id\`) on update cascade on delete cascade;`);
|
|
||||||
|
|
||||||
this.addSql(`alter table \`placed_map_object\` add constraint \`placed_map_object_map_id_foreign\` foreign key (\`map_id\`) references \`map\` (\`id\`) on update cascade on delete cascade;`);
|
|
||||||
this.addSql(`alter table \`placed_map_object\` add constraint \`placed_map_object_map_object_id_foreign\` foreign key (\`map_object_id\`) references \`map_object\` (\`id\`) on update cascade on delete cascade;`);
|
|
||||||
|
|
||||||
this.addSql(`alter table \`item\` add constraint \`item_sprite_id_foreign\` foreign key (\`sprite_id\`) references \`sprite\` (\`id\`) on update cascade on delete set null;`);
|
|
||||||
|
|
||||||
this.addSql(`alter table \`character_type\` add constraint \`character_type_sprite_id_foreign\` foreign key (\`sprite_id\`) references \`sprite\` (\`id\`) on update cascade on delete set null;`);
|
|
||||||
|
|
||||||
this.addSql(`alter table \`character_hair\` add constraint \`character_hair_sprite_id_foreign\` foreign key (\`sprite_id\`) references \`sprite\` (\`id\`) on update cascade on delete set null;`);
|
|
||||||
|
|
||||||
this.addSql(`alter table \`sprite_action\` add constraint \`sprite_action_sprite_id_foreign\` foreign key (\`sprite_id\`) references \`sprite\` (\`id\`) on update cascade on delete cascade;`);
|
|
||||||
|
|
||||||
this.addSql(`alter table \`password_reset_token\` add constraint \`password_reset_token_user_id_foreign\` foreign key (\`user_id\`) references \`user\` (\`id\`) on update cascade on delete cascade;`);
|
|
||||||
|
|
||||||
this.addSql(`alter table \`character\` add constraint \`character_user_id_foreign\` foreign key (\`user_id\`) references \`user\` (\`id\`) on update cascade on delete cascade;`);
|
|
||||||
this.addSql(`alter table \`character\` add constraint \`character_map_id_foreign\` foreign key (\`map_id\`) references \`map\` (\`id\`) on update cascade;`);
|
|
||||||
this.addSql(`alter table \`character\` add constraint \`character_character_type_id_foreign\` foreign key (\`character_type_id\`) references \`character_type\` (\`id\`) on update cascade on delete set null;`);
|
|
||||||
this.addSql(`alter table \`character\` add constraint \`character_character_hair_id_foreign\` foreign key (\`character_hair_id\`) references \`character_hair\` (\`id\`) on update cascade on delete set null;`);
|
|
||||||
|
|
||||||
this.addSql(`alter table \`chat\` add constraint \`chat_character_id_foreign\` foreign key (\`character_id\`) references \`character\` (\`id\`) on update cascade on delete cascade;`);
|
|
||||||
this.addSql(`alter table \`chat\` add constraint \`chat_map_id_foreign\` foreign key (\`map_id\`) references \`map\` (\`id\`) on update cascade on delete cascade;`);
|
|
||||||
|
|
||||||
this.addSql(`alter table \`character_item\` add constraint \`character_item_character_id_foreign\` foreign key (\`character_id\`) references \`character\` (\`id\`) on update cascade on delete cascade;`);
|
|
||||||
this.addSql(`alter table \`character_item\` add constraint \`character_item_item_id_foreign\` foreign key (\`item_id\`) references \`item\` (\`id\`) on update cascade on delete cascade;`);
|
|
||||||
|
|
||||||
this.addSql(`alter table \`character_equipment\` add constraint \`character_equipment_character_id_foreign\` foreign key (\`character_id\`) references \`character\` (\`id\`) on update cascade on delete cascade;`);
|
|
||||||
this.addSql(`alter table \`character_equipment\` add constraint \`character_equipment_character_item_id_foreign\` foreign key (\`character_item_id\`) references \`character_item\` (\`id\`) on update cascade on delete cascade;`);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
28
package.json
28
package.json
@ -1,26 +1,26 @@
|
|||||||
{
|
{
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"tsNode": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node --experimental-specifier-resolution=node dist/server.js",
|
"start": "node --experimental-specifier-resolution=node --loader ts-node/esm src/server.ts",
|
||||||
"dev": "nodemon --exec tsx src/server.ts",
|
"dev": "nodemon --exec tsx src/server.ts",
|
||||||
"build": "tsc",
|
|
||||||
"format": "prettier --write src/",
|
"format": "prettier --write src/",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"lint:fix": "eslint . --fix"
|
"lint:fix": "eslint . --fix"
|
||||||
},
|
},
|
||||||
"imports": {
|
"imports": {
|
||||||
"#root/*": "./dist/*.js",
|
"#root/*": "./src/*.js",
|
||||||
"#application/*": "./dist/application/*.js",
|
"#application/*": "./src/application/*.js",
|
||||||
"#commands/*": "./dist/commands/*.js",
|
"#commands/*": "./src/commands/*.js",
|
||||||
"#entities/*": "./dist/entities/*.js",
|
"#entities/*": "./src/entities/*.js",
|
||||||
"#controllers/*": "./dist/controllers/*.js",
|
"#controllers/*": "./src/controllers/*.js",
|
||||||
"#jobs/*": "./dist/jobs/*.js",
|
"#jobs/*": "./src/jobs/*.js",
|
||||||
"#managers/*": "./dist/managers/*.js",
|
"#managers/*": "./src/managers/*.js",
|
||||||
"#middleware/*": "./dist/middleware/*.js",
|
"#middleware/*": "./src/middleware/*.js",
|
||||||
"#models/*": "./dist/models/*.js",
|
"#models/*": "./src/models/*.js",
|
||||||
"#repositories/*": "./dist/repositories/*.js",
|
"#repositories/*": "./src/repositories/*.js",
|
||||||
"#services/*": "./dist/services/*.js",
|
"#services/*": "./src/services/*.js",
|
||||||
"#events/*": "./dist/events/*.js"
|
"#events/*": "./src/events/*.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mikro-orm/core": "^6.4.2",
|
"@mikro-orm/core": "^6.4.2",
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
import { Collection, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
import type { UUID } from '#application/types'
|
import type { UUID } from '#application/types'
|
||||||
|
import type { CharacterEquipment } from '#entities/characterEquipment'
|
||||||
|
import type { CharacterHair } from '#entities/characterHair'
|
||||||
|
import type { CharacterItem } from '#entities/characterItem'
|
||||||
|
import type { CharacterType } from '#entities/characterType'
|
||||||
|
import type { Chat } from '#entities/chat'
|
||||||
|
import type { Map } from '#entities/map'
|
||||||
|
import type { User } from '#entities/user'
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
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 {
|
export class BaseCharacter extends BaseEntity {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
@ -29,7 +29,7 @@ export class BaseCharacter extends BaseEntity {
|
|||||||
@Property()
|
@Property()
|
||||||
role = 'player'
|
role = 'player'
|
||||||
|
|
||||||
@OneToMany(() => Chat, (chat) => chat.character)
|
@OneToMany({ mappedBy: 'character' })
|
||||||
chats = new Collection<Chat>(this)
|
chats = new Collection<Chat>(this)
|
||||||
|
|
||||||
// Position - @TODO: Update to spawn point when current map is not found
|
// Position - @TODO: Update to spawn point when current map is not found
|
||||||
|
@ -3,11 +3,11 @@ import { randomUUID } from 'node:crypto'
|
|||||||
import { Enum, ManyToOne, PrimaryKey } from '@mikro-orm/core'
|
import { Enum, ManyToOne, PrimaryKey } from '@mikro-orm/core'
|
||||||
|
|
||||||
import type { UUID } from '#application/types'
|
import type { UUID } from '#application/types'
|
||||||
|
import type { Character } from '#entities/character'
|
||||||
|
import type { CharacterItem } from '#entities/characterItem'
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
import { CharacterEquipmentSlotType } from '#application/enums'
|
import { CharacterEquipmentSlotType } from '#application/enums'
|
||||||
import { Character } from '#entities/character'
|
|
||||||
import { CharacterItem } from '#entities/characterItem'
|
|
||||||
|
|
||||||
export class BaseCharacterEquipment extends BaseEntity {
|
export class BaseCharacterEquipment extends BaseEntity {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
import { ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
import type { UUID } from '#application/types'
|
import type { UUID } from '#application/types'
|
||||||
|
import type { Character } from '#entities/character'
|
||||||
|
import type { Item } from '#entities/item'
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
import { Character } from '#entities/character'
|
|
||||||
import { CharacterEquipment } from '#entities/characterEquipment'
|
|
||||||
import { Item } from '#entities/item'
|
|
||||||
|
|
||||||
export class BaseCharacterItem extends BaseEntity {
|
export class BaseCharacterItem extends BaseEntity {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
import { ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
import type { UUID } from '#application/types'
|
import type { UUID } from '#application/types'
|
||||||
|
import type { Character } from '#entities/character'
|
||||||
|
import type { Map } from '#entities/map'
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
import { Character } from '#entities/character'
|
|
||||||
import { Map } from '#entities/map'
|
|
||||||
|
|
||||||
export class BaseChat extends BaseEntity {
|
export class BaseChat extends BaseEntity {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
import { Collection, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
import type { UUID } from '#application/types'
|
import type { UUID } from '#application/types'
|
||||||
|
import type { MapEffect } from '#entities/mapEffect'
|
||||||
|
import type { MapEventTile } from '#entities/mapEventTile'
|
||||||
|
import type { PlacedMapObject } from '#entities/placedMapObject'
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
import { MapEffect } from '#entities/mapEffect'
|
|
||||||
import { MapEventTile } from '#entities/mapEventTile'
|
|
||||||
import { PlacedMapObject } from '#entities/placedMapObject'
|
|
||||||
|
|
||||||
export class BaseMap extends BaseEntity {
|
export class BaseMap extends BaseEntity {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
@ -34,13 +34,13 @@ export class BaseMap extends BaseEntity {
|
|||||||
@Property()
|
@Property()
|
||||||
updatedAt = new Date()
|
updatedAt = new Date()
|
||||||
|
|
||||||
@OneToMany(() => MapEffect, (effect) => effect.map, { orphanRemoval: true })
|
@OneToMany({ mappedBy: 'map', orphanRemoval: true })
|
||||||
mapEffects = new Collection<MapEffect>(this)
|
mapEffects = new Collection<MapEffect>(this)
|
||||||
|
|
||||||
@OneToMany(() => MapEventTile, (tile) => tile.map, { orphanRemoval: true })
|
@OneToMany({ mappedBy: 'map', orphanRemoval: true })
|
||||||
mapEventTiles = new Collection<MapEventTile>(this)
|
mapEventTiles = new Collection<MapEventTile>(this)
|
||||||
|
|
||||||
@OneToMany(() => PlacedMapObject, (placedMapObject) => placedMapObject.map, { orphanRemoval: true })
|
@OneToMany({ mappedBy: 'map', orphanRemoval: true })
|
||||||
placedMapObjects = new Collection<PlacedMapObject>(this)
|
placedMapObjects = new Collection<PlacedMapObject>(this)
|
||||||
|
|
||||||
setId(id: UUID) {
|
setId(id: UUID) {
|
||||||
|
@ -3,9 +3,9 @@ import { randomUUID } from 'node:crypto'
|
|||||||
import { ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
import { ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
import type { UUID } from '#application/types'
|
import type { UUID } from '#application/types'
|
||||||
|
import type { Map } from '#entities/map'
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
import { Map } from '#entities/map'
|
|
||||||
|
|
||||||
export class BaseMapEffect extends BaseEntity {
|
export class BaseMapEffect extends BaseEntity {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
import { Entity, Enum, ManyToOne, OneToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
import { Enum, ManyToOne, OneToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
import type { UUID } from '#application/types'
|
import type { UUID } from '#application/types'
|
||||||
|
import type { Map } from '#entities/map'
|
||||||
|
import type { MapEventTileTeleport } from '#entities/mapEventTileTeleport'
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
import { MapEventTileType } from '#application/enums'
|
import { MapEventTileType } from '#application/enums'
|
||||||
import { Map } from '#entities/map'
|
|
||||||
import { MapEventTileTeleport } from '#entities/mapEventTileTeleport'
|
|
||||||
|
|
||||||
export class BaseMapEventTile extends BaseEntity {
|
export class BaseMapEventTile extends BaseEntity {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
@ -25,7 +25,7 @@ export class BaseMapEventTile extends BaseEntity {
|
|||||||
@Property()
|
@Property()
|
||||||
positionY!: number
|
positionY!: number
|
||||||
|
|
||||||
@OneToOne(() => MapEventTileTeleport, (teleport) => teleport.mapEventTile, { eager: true })
|
@OneToOne({ eager: true })
|
||||||
teleport?: MapEventTileTeleport
|
teleport?: MapEventTileTeleport
|
||||||
|
|
||||||
setId(id: UUID) {
|
setId(id: UUID) {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
import { Entity, ManyToOne, OneToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
import { ManyToOne, OneToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
import type { UUID } from '#application/types'
|
import type { UUID } from '#application/types'
|
||||||
|
import type { Map } from '#entities/map'
|
||||||
|
import type { MapEventTile } from '#entities/mapEventTile'
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
import { Map } from '#entities/map'
|
|
||||||
import { MapEventTile } from '#entities/mapEventTile'
|
|
||||||
|
|
||||||
export class BaseMapEventTileTeleport extends BaseEntity {
|
export class BaseMapEventTileTeleport extends BaseEntity {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
import { ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
import type { UUID } from '#application/types'
|
import type { UUID } from '#application/types'
|
||||||
|
import type { User } from '#entities/user'
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
import { User } from '#entities/user'
|
|
||||||
|
|
||||||
export class BasePasswordResetToken extends BaseEntity {
|
export class BasePasswordResetToken extends BaseEntity {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
import { ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
import type { UUID } from '#application/types'
|
import type { UUID } from '#application/types'
|
||||||
|
import type { Map } from '#entities/map'
|
||||||
|
import type { MapObject } from '#entities/mapObject'
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
import { Map } from '#entities/map'
|
|
||||||
import { MapObject } from '#entities/mapObject'
|
|
||||||
|
|
||||||
//@TODO : Rename mapObject
|
|
||||||
|
|
||||||
export class BasePlacedMapObject extends BaseEntity {
|
export class BasePlacedMapObject extends BaseEntity {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
import { ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
import type { UUID } from '#application/types'
|
import type { UUID } from '#application/types'
|
||||||
|
import type { Sprite } from '#entities/sprite'
|
||||||
|
|
||||||
import { BaseEntity } from '#application/base/baseEntity'
|
import { BaseEntity } from '#application/base/baseEntity'
|
||||||
import { Sprite } from '#entities/sprite'
|
|
||||||
|
|
||||||
export interface SpriteImage {
|
export interface SpriteImage {
|
||||||
url: string
|
url: string
|
||||||
|
2079
src/migrations/.snapshot-game.json
Normal file
2079
src/migrations/.snapshot-game.json
Normal file
File diff suppressed because it is too large
Load Diff
162
src/migrations/Migration20250207212301.ts
Normal file
162
src/migrations/Migration20250207212301.ts
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
import { Migration } from '@mikro-orm/migrations'
|
||||||
|
|
||||||
|
export class Migration20250207212301 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;`
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`map_effect\` (\`id\` varchar(255) not null, \`map_id\` varchar(255) not null, \`effect\` varchar(255) not null, \`strength\` int not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
this.addSql(`alter table \`map_effect\` add index \`map_effect_map_id_index\`(\`map_id\`);`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`map_event_tile\` (\`id\` varchar(255) not null, \`map_id\` varchar(255) not null, \`type\` enum('BLOCK', 'TELEPORT', 'NPC', 'ITEM') not null, \`position_x\` int not null, \`position_y\` int not null, \`teleport_id\` varchar(255) null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
this.addSql(`alter table \`map_event_tile\` add index \`map_event_tile_map_id_index\`(\`map_id\`);`)
|
||||||
|
this.addSql(`alter table \`map_event_tile\` add unique \`map_event_tile_teleport_id_unique\`(\`teleport_id\`);`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`map_event_tile_teleport\` (\`id\` varchar(255) not null, \`map_event_tile_id\` varchar(255) not null, \`to_map_id\` varchar(255) not null, \`to_rotation\` int not null, \`to_position_x\` int not null, \`to_position_y\` int not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
this.addSql(`alter table \`map_event_tile_teleport\` add unique \`map_event_tile_teleport_map_event_tile_id_unique\`(\`map_event_tile_id\`);`)
|
||||||
|
this.addSql(`alter table \`map_event_tile_teleport\` add index \`map_event_tile_teleport_to_map_id_index\`(\`to_map_id\`);`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`map_object\` (\`id\` varchar(255) not null, \`name\` varchar(255) not null, \`tags\` json null, \`origin_x\` numeric(10,2) not null default 0, \`origin_y\` numeric(10,2) not null default 0, \`frame_rate\` int not null default 0, \`frame_width\` int not null default 0, \`frame_height\` int not null default 0, \`created_at\` datetime not null, \`updated_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`placed_map_object\` (\`id\` varchar(255) not null, \`map_id\` varchar(255) not null, \`map_object_id\` varchar(255) not null, \`is_rotated\` tinyint(1) not null default false, \`position_x\` int not null default 0, \`position_y\` int not null default 0, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
this.addSql(`alter table \`placed_map_object\` add index \`placed_map_object_map_id_index\`(\`map_id\`);`)
|
||||||
|
this.addSql(`alter table \`placed_map_object\` add index \`placed_map_object_map_object_id_index\`(\`map_object_id\`);`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`sprite\` (\`id\` varchar(255) not null, \`name\` varchar(255) not null, \`created_at\` datetime not null, \`updated_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`item\` (\`id\` varchar(255) not null, \`name\` varchar(255) not null, \`description\` varchar(255) not null default '', \`item_type\` enum('WEAPON', 'HELMET', 'CHEST', 'LEGS', 'BOOTS', 'GLOVES', 'RING', 'NECKLACE') not null, \`stackable\` tinyint(1) not null default false, \`rarity\` enum('COMMON', 'UNCOMMON', 'RARE', 'EPIC', 'LEGENDARY') not null default 'COMMON', \`sprite_id\` varchar(255) null, \`created_at\` datetime not null, \`updated_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
this.addSql(`alter table \`item\` add index \`item_sprite_id_index\`(\`sprite_id\`);`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`character_type\` (\`id\` varchar(255) not null, \`name\` varchar(255) not null, \`gender\` enum('MALE', 'FEMALE') not null, \`race\` enum('HUMAN', 'ELF', 'DWARF', 'ORC', 'GOBLIN') not null, \`is_selectable\` tinyint(1) not null default false, \`sprite_id\` varchar(255) null, \`created_at\` datetime not null, \`updated_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
this.addSql(`alter table \`character_type\` add index \`character_type_sprite_id_index\`(\`sprite_id\`);`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`character_hair\` (\`id\` varchar(255) not null, \`name\` varchar(255) not null, \`gender\` varchar(255) not null default 'MALE', \`is_selectable\` tinyint(1) not null default false, \`sprite_id\` varchar(255) null, \`created_at\` datetime not null, \`updated_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
this.addSql(`alter table \`character_hair\` add index \`character_hair_sprite_id_index\`(\`sprite_id\`);`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`sprite_action\` (\`id\` varchar(255) not null, \`sprite_id\` varchar(255) not null, \`action\` varchar(255) not null, \`sprites\` json null, \`origin_x\` numeric(5,2) not null default 0, \`origin_y\` numeric(5,2) not null default 0, \`frame_width\` int not null default 0, \`frame_height\` int not null default 0, \`frame_rate\` int not null default 0, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
this.addSql(`alter table \`sprite_action\` add index \`sprite_action_sprite_id_index\`(\`sprite_id\`);`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`tile\` (\`id\` varchar(255) not null, \`name\` varchar(255) not null, \`tags\` json null, \`created_at\` datetime not null, \`updated_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`user\` (\`id\` varchar(255) not null, \`username\` varchar(255) not null, \`email\` varchar(255) not null, \`password\` varchar(255) not null, \`online\` tinyint(1) not null default false, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
this.addSql(`alter table \`user\` add unique \`user_username_unique\`(\`username\`);`)
|
||||||
|
this.addSql(`alter table \`user\` add unique \`user_email_unique\`(\`email\`);`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`password_reset_token\` (\`id\` varchar(255) not null, \`user_id\` varchar(255) not null, \`token\` varchar(255) not null, \`created_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
this.addSql(`alter table \`password_reset_token\` add index \`password_reset_token_user_id_index\`(\`user_id\`);`)
|
||||||
|
this.addSql(`alter table \`password_reset_token\` add unique \`password_reset_token_token_unique\`(\`token\`);`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`character\` (\`id\` varchar(255) not null, \`user_id\` varchar(255) not null, \`name\` varchar(255) not null, \`online\` tinyint(1) not null default false, \`role\` varchar(255) not null default 'player', \`map_id\` varchar(255) not null, \`position_x\` int not null default 0, \`position_y\` int not null default 0, \`rotation\` int not null default 0, \`character_type_id\` varchar(255) null, \`character_hair_id\` varchar(255) null, \`alignment\` int not null default 50, \`hitpoints\` int not null default 100, \`mana\` int not null default 100, \`level\` int not null default 1, \`experience\` int not null default 0, \`strength\` int not null default 10, \`dexterity\` int not null default 10, \`intelligence\` int not null default 10, \`wisdom\` int not null default 10, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
this.addSql(`alter table \`character\` add index \`character_user_id_index\`(\`user_id\`);`)
|
||||||
|
this.addSql(`alter table \`character\` add unique \`character_name_unique\`(\`name\`);`)
|
||||||
|
this.addSql(`alter table \`character\` add index \`character_map_id_index\`(\`map_id\`);`)
|
||||||
|
this.addSql(`alter table \`character\` add index \`character_character_type_id_index\`(\`character_type_id\`);`)
|
||||||
|
this.addSql(`alter table \`character\` add index \`character_character_hair_id_index\`(\`character_hair_id\`);`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`chat\` (\`id\` varchar(255) not null, \`character_id\` varchar(255) not null, \`map_id\` varchar(255) not null, \`message\` varchar(255) not null, \`created_at\` datetime not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
this.addSql(`alter table \`chat\` add index \`chat_character_id_index\`(\`character_id\`);`)
|
||||||
|
this.addSql(`alter table \`chat\` add index \`chat_map_id_index\`(\`map_id\`);`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`character_item\` (\`id\` varchar(255) not null, \`character_id\` varchar(255) not null, \`item_id\` varchar(255) not null, \`quantity\` int not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
this.addSql(`alter table \`character_item\` add index \`character_item_character_id_index\`(\`character_id\`);`)
|
||||||
|
this.addSql(`alter table \`character_item\` add index \`character_item_item_id_index\`(\`item_id\`);`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`character_equipment\` (\`id\` varchar(255) not null, \`slot\` enum('HEAD', 'BODY', 'ARMS', 'LEGS', 'NECK', 'RING') not null, \`character_id\` varchar(255) not null, \`character_item_id\` varchar(255) not null, primary key (\`id\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
this.addSql(`alter table \`character_equipment\` add index \`character_equipment_character_id_index\`(\`character_id\`);`)
|
||||||
|
this.addSql(`alter table \`character_equipment\` add index \`character_equipment_character_item_id_index\`(\`character_item_id\`);`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`create table \`world\` (\`date\` datetime not null, \`rain_percentage\` int not null default 0, \`fog_density\` int not null default 0, primary key (\`date\`)) default character set utf8mb4 engine = InnoDB;`
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(`alter table \`map_effect\` add constraint \`map_effect_map_id_foreign\` foreign key (\`map_id\`) references \`map\` (\`id\`) on update cascade on delete cascade;`)
|
||||||
|
|
||||||
|
this.addSql(`alter table \`map_event_tile\` add constraint \`map_event_tile_map_id_foreign\` foreign key (\`map_id\`) references \`map\` (\`id\`) on update cascade on delete cascade;`)
|
||||||
|
this.addSql(
|
||||||
|
`alter table \`map_event_tile\` add constraint \`map_event_tile_teleport_id_foreign\` foreign key (\`teleport_id\`) references \`map_event_tile_teleport\` (\`id\`) on update cascade on delete set null;`
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`alter table \`map_event_tile_teleport\` add constraint \`map_event_tile_teleport_map_event_tile_id_foreign\` foreign key (\`map_event_tile_id\`) references \`map_event_tile\` (\`id\`) on update cascade on delete cascade;`
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
`alter table \`map_event_tile_teleport\` add constraint \`map_event_tile_teleport_to_map_id_foreign\` foreign key (\`to_map_id\`) references \`map\` (\`id\`) on update cascade on delete cascade;`
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(`alter table \`placed_map_object\` add constraint \`placed_map_object_map_id_foreign\` foreign key (\`map_id\`) references \`map\` (\`id\`) on update cascade on delete cascade;`)
|
||||||
|
this.addSql(
|
||||||
|
`alter table \`placed_map_object\` add constraint \`placed_map_object_map_object_id_foreign\` foreign key (\`map_object_id\`) references \`map_object\` (\`id\`) on update cascade on delete cascade;`
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(`alter table \`item\` add constraint \`item_sprite_id_foreign\` foreign key (\`sprite_id\`) references \`sprite\` (\`id\`) on update cascade on delete set null;`)
|
||||||
|
|
||||||
|
this.addSql(`alter table \`character_type\` add constraint \`character_type_sprite_id_foreign\` foreign key (\`sprite_id\`) references \`sprite\` (\`id\`) on update cascade on delete set null;`)
|
||||||
|
|
||||||
|
this.addSql(`alter table \`character_hair\` add constraint \`character_hair_sprite_id_foreign\` foreign key (\`sprite_id\`) references \`sprite\` (\`id\`) on update cascade on delete set null;`)
|
||||||
|
|
||||||
|
this.addSql(`alter table \`sprite_action\` add constraint \`sprite_action_sprite_id_foreign\` foreign key (\`sprite_id\`) references \`sprite\` (\`id\`) on update cascade on delete cascade;`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`alter table \`password_reset_token\` add constraint \`password_reset_token_user_id_foreign\` foreign key (\`user_id\`) references \`user\` (\`id\`) on update cascade on delete cascade;`
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(`alter table \`character\` add constraint \`character_user_id_foreign\` foreign key (\`user_id\`) references \`user\` (\`id\`) on update cascade on delete cascade;`)
|
||||||
|
this.addSql(`alter table \`character\` add constraint \`character_map_id_foreign\` foreign key (\`map_id\`) references \`map\` (\`id\`) on update cascade;`)
|
||||||
|
this.addSql(
|
||||||
|
`alter table \`character\` add constraint \`character_character_type_id_foreign\` foreign key (\`character_type_id\`) references \`character_type\` (\`id\`) on update cascade on delete set null;`
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
`alter table \`character\` add constraint \`character_character_hair_id_foreign\` foreign key (\`character_hair_id\`) references \`character_hair\` (\`id\`) on update cascade on delete set null;`
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(`alter table \`chat\` add constraint \`chat_character_id_foreign\` foreign key (\`character_id\`) references \`character\` (\`id\`) on update cascade on delete cascade;`)
|
||||||
|
this.addSql(`alter table \`chat\` add constraint \`chat_map_id_foreign\` foreign key (\`map_id\`) references \`map\` (\`id\`) on update cascade on delete cascade;`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`alter table \`character_item\` add constraint \`character_item_character_id_foreign\` foreign key (\`character_id\`) references \`character\` (\`id\`) on update cascade on delete cascade;`
|
||||||
|
)
|
||||||
|
this.addSql(`alter table \`character_item\` add constraint \`character_item_item_id_foreign\` foreign key (\`item_id\`) references \`item\` (\`id\`) on update cascade on delete cascade;`)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
`alter table \`character_equipment\` add constraint \`character_equipment_character_id_foreign\` foreign key (\`character_id\`) references \`character\` (\`id\`) on update cascade on delete cascade;`
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
`alter table \`character_equipment\` add constraint \`character_equipment_character_item_id_foreign\` foreign key (\`character_item_id\`) references \`character_item\` (\`id\`) on update cascade on delete cascade;`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ import serverConfig from '#application/config'
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
extensions: [Migrator],
|
extensions: [Migrator],
|
||||||
metadataProvider: TsMorphMetadataProvider,
|
metadataProvider: TsMorphMetadataProvider,
|
||||||
entities: ['./src/entities/*.js'],
|
entities: ['./dist/entities/*.js'],
|
||||||
entitiesTs: ['./src/entities/*.ts'],
|
entitiesTs: ['./src/entities/*.ts'],
|
||||||
driver: MySqlDriver,
|
driver: MySqlDriver,
|
||||||
host: serverConfig.DB_HOST,
|
host: serverConfig.DB_HOST,
|
||||||
@ -21,7 +21,7 @@ export default defineConfig({
|
|||||||
allowPublicKeyRetrieval: true
|
allowPublicKeyRetrieval: true
|
||||||
},
|
},
|
||||||
migrations: {
|
migrations: {
|
||||||
path: './migrations',
|
path: './dist/migrations',
|
||||||
pathTs: './migrations'
|
pathTs: './src/migrations'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -140,8 +140,8 @@ class CharacterMoveService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getDistance(a: Position, b: Position): number {
|
private getDistance(a: Position, b: Position): number {
|
||||||
const dx = Math.abs(a.positionX - b.positionX),
|
const dx = Math.abs(a.positionX - b.positionX)
|
||||||
dy = Math.abs(a.positionY - b.positionY)
|
const dy = Math.abs(a.positionY - b.positionY)
|
||||||
// Manhattan distance for straight paths, then Euclidean for diagonals
|
// Manhattan distance for straight paths, then Euclidean for diagonals
|
||||||
return dx + dy + (Math.sqrt(2) - 2) * Math.min(dx, dy)
|
return dx + dy + (Math.sqrt(2) - 2) * Math.min(dx, dy)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user