Added missing entities( zoneEffect, zoneEventTile, zoneEventTileTeleport, zoneObject)

This commit is contained in:
2024-12-25 03:19:53 +01:00
parent b4989aac26
commit 95f4c58110
20 changed files with 489 additions and 391 deletions

42
src/entities/mapObject.ts Normal file
View File

@ -0,0 +1,42 @@
import { randomUUID } from 'node:crypto'
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
import { ZoneObject } from './zoneObject'
1
@Entity()
export class MapObject {
@PrimaryKey()
id = randomUUID()
@Property()
name!: string
@Property({ type: 'json', nullable: true })
tags?: any
@Property()
originX = 0
@Property()
originY = 0
@Property()
isAnimated = false
@Property()
frameRate = 0
@Property()
frameWidth = 0
@Property()
frameHeight = 0
@Property()
createdAt = new Date()
@Property()
updatedAt = new Date()
@OneToMany(() => ZoneObject, (zoneObject) => zoneObject.object)
zoneObjects = new Collection<ZoneObject>(this)
}

20
src/entities/tile.ts Normal file
View File

@ -0,0 +1,20 @@
import { randomUUID } from 'node:crypto'
import { Entity, PrimaryKey, Property } from '@mikro-orm/core'
@Entity()
export class Tile {
@PrimaryKey()
id = randomUUID()
@Property()
name!: string
@Property({ type: 'json', nullable: true })
tags?: any
@Property()
createdAt = new Date()
@Property()
updatedAt = new Date()
}

View File

@ -1,4 +1,8 @@
import { Collection, Entity, OneToMany, PrimaryKey } from '@mikro-orm/core'
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
import { ZoneEffect } from './zoneEffect'
import { ZoneEventTile } from './zoneEventTile'
import { ZoneEventTileTeleport } from './zoneEventTileTeleport'
import { ZoneObject } from './zoneObject'
import { Character } from './character'
import { Chat } from './chat'
@ -7,9 +11,42 @@ export class Zone {
@PrimaryKey()
id!: number
@Property()
name!: string
@Property()
width = 10
@Property()
height = 10
@Property({ type: 'json', nullable: true })
tiles?: any
@Property()
pvp = false
@OneToMany(() => ZoneEffect, (effect) => effect.zone)
zoneEffects = new Collection<ZoneEffect>(this)
@OneToMany(() => ZoneEventTile, (tile) => tile.zone)
zoneEventTiles = new Collection<ZoneEventTile>(this)
@OneToMany(() => ZoneEventTileTeleport, (teleport) => teleport.toZone)
zoneEventTileTeleports = new Collection<ZoneEventTileTeleport>(this)
@OneToMany(() => ZoneObject, (object) => object.zone)
zoneObjects = new Collection<ZoneObject>(this)
@OneToMany(() => Character, (character) => character.zone)
characters = new Collection<Character>(this)
@OneToMany(() => Chat, (chat) => chat.zone)
chats = new Collection<Chat>(this)
@Property()
createdAt = new Date()
@Property()
updatedAt = new Date()
}

View File

@ -0,0 +1,17 @@
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
import { Zone } from './zone'
@Entity()
export class ZoneEffect {
@PrimaryKey()
id!: string
@ManyToOne(() => Zone)
zone!: Zone
@Property()
effect!: string
@Property()
strength!: number
}

View File

@ -0,0 +1,25 @@
import { Entity, ManyToOne, OneToOne, PrimaryKey, Property } from '@mikro-orm/core'
import { Zone } from './zone'
import { ZoneEventTileType } from '#utilities/enums'
import { ZoneEventTileTeleport } from './zoneEventTileTeleport'
@Entity()
export class ZoneEventTile {
@PrimaryKey()
id!: string
@ManyToOne(() => Zone)
zone!: Zone
@Property()
type!: ZoneEventTileType
@Property()
positionX!: number
@Property()
positionY!: number
@OneToOne(() => ZoneEventTileTeleport, (teleport) => teleport.zoneEventTile)
teleport?: ZoneEventTileTeleport
}

View File

@ -0,0 +1,25 @@
import { randomUUID } from 'node:crypto'
import { Entity, ManyToOne, OneToOne, PrimaryKey, Property } from '@mikro-orm/core'
import { Zone } from './zone'
import { ZoneEventTile } from './ZoneEventTile'
@Entity()
export class ZoneEventTileTeleport {
@PrimaryKey()
id = randomUUID()
@OneToOne(() => ZoneEventTile)
zoneEventTile!: ZoneEventTile
@ManyToOne(() => Zone)
toZone!: Zone
@Property()
toRotation!: number
@Property()
toPositionX!: number
@Property()
toPositionY!: number
}

View File

@ -0,0 +1,28 @@
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
import { Zone } from './zone'
import { MapObject } from '#entities/mapObject'
//@TODO : Rename mapObject
@Entity()
export class ZoneObject {
@PrimaryKey()
id!: string
@ManyToOne(() => Zone)
zone!: Zone
@ManyToOne(() => MapObject)
mapObject!: MapObject
@Property()
depth = 0
@Property()
isRotated = false
@Property()
positionX = 0
@Property()
positionY = 0
}