Added getter & setter functions to all entities

This commit is contained in:
2024-12-26 15:15:18 +01:00
parent 6a27ccff31
commit 691abb7c4f
33 changed files with 1500 additions and 168 deletions

View File

@ -82,4 +82,211 @@ export class Character extends BaseEntity {
@Property()
wisdom = 10
setId(id: number) {
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
}
setZone(zone: Zone | undefined) {
this.zone = zone
return this
}
getZone() {
return this.zone
}
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 | undefined) {
this.characterType = characterType
return this
}
getCharacterType() {
return this.characterType
}
setCharacterHair(characterHair: CharacterHair | 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
}
}

View File

@ -17,4 +17,40 @@ export class CharacterEquipment extends BaseEntity {
@ManyToOne(() => CharacterItem)
characterItem!: CharacterItem
setId(id: number) {
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
}
}

View File

@ -23,4 +23,58 @@ export class CharacterHair extends BaseEntity {
@OneToMany(() => Character, (character) => character.characterHair)
characters = new Collection<Character>(this)
setId(id: number) {
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
}
setCharacters(characters: Collection<Character>) {
this.characters = characters
return this
}
getCharacters() {
return this.characters
}
}

View File

@ -20,4 +20,49 @@ export class CharacterItem extends BaseEntity {
@OneToMany(() => CharacterEquipment, (equipment) => equipment.characterItem)
characterEquipment = new Collection<CharacterEquipment>(this)
setId(id: number) {
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
}
setCharacterEquipment(characterEquipment: Collection<CharacterEquipment>) {
this.characterEquipment = characterEquipment
return this
}
getCharacterEquipment() {
return this.characterEquipment
}
}

View File

@ -32,4 +32,85 @@ export class CharacterType extends BaseEntity {
@Property()
updatedAt = new Date()
setId(id: number) {
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
}
setCharacters(characters: Collection<Character>) {
this.characters = characters
return this
}
getCharacters() {
return this.characters
}
}

View File

@ -19,4 +19,49 @@ export class Chat extends BaseEntity {
@Property()
createdAt = new Date()
setId(id: number) {
this.id = id
return this
}
getId() {
return this.id
}
setCharacter(character: Character) {
this.character = character
return this
}
getCharacter() {
return this.character
}
setZone(zone: Zone) {
this.zone = zone
return this
}
getZone() {
return this.zone
}
setMessage(message: string) {
this.message = message
return this
}
getMessage() {
return this.message
}
setCreatedAt(createdAt: Date) {
this.createdAt = createdAt
return this
}
getCreatedAt() {
return this.createdAt
}
}

View File

@ -3,11 +3,13 @@ import { BaseEntity } from '#application/bases/baseEntity'
import { Sprite } from './sprite'
import { CharacterItem } from './characterItem'
import { ItemType, ItemRarity } from '#application/enums'
import { randomUUID } from 'node:crypto'
import { UUID } from '#application/types'
@Entity()
export class Item extends BaseEntity {
@PrimaryKey()
id!: string
id = randomUUID()
@Property()
name!: string
@ -35,4 +37,94 @@ export class Item extends BaseEntity {
@OneToMany(() => CharacterItem, (characterItem) => characterItem.item)
characters = new Collection<CharacterItem>(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
}
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
}
setCharacters(characters: Collection<CharacterItem>) {
this.characters = characters
return this
}
getCharacters() {
return this.characters
}
}

View File

@ -2,6 +2,7 @@ import { randomUUID } from 'node:crypto'
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
import { BaseEntity } from '#application/bases/baseEntity'
import { ZoneObject } from './zoneObject'
import { UUID } from '#application/types'
@Entity()
export class MapObject extends BaseEntity {
@ -40,4 +41,112 @@ export class MapObject extends BaseEntity {
@OneToMany(() => ZoneObject, (zoneObject) => zoneObject.mapObject)
zoneObjects = new Collection<ZoneObject>(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
}
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
}
setZoneObjects(zoneObjects: Collection<ZoneObject>) {
this.zoneObjects = zoneObjects
return this
}
getZoneObjects() {
return this.zoneObjects
}
}

View File

@ -15,4 +15,40 @@ export class PasswordResetToken extends BaseEntity {
@Property()
createdAt = new Date()
setId(id: number) {
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
}
}

View File

@ -5,6 +5,7 @@ import { SpriteAction } from './spriteAction'
import { CharacterType } from './characterType'
import { CharacterHair } from './characterHair'
import { Item } from './item'
import { UUID } from '#application/types'
@Entity()
export class Sprite extends BaseEntity {
@ -31,4 +32,40 @@ export class Sprite extends BaseEntity {
@OneToMany(() => Item, (item) => item.sprite)
items = new Collection<Item>(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
}
setCreatedAt(createdAt: Date) {
this.createdAt = createdAt
return this
}
getCreatedAt() {
return this.createdAt
}
setUpdatedAt(updatedAt: Date) {
this.updatedAt = updatedAt
return this
}
getUpdatedAt() {
return this.updatedAt
}
}

View File

@ -2,6 +2,7 @@ import { randomUUID } from 'node:crypto'
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
import { BaseEntity } from '#application/bases/baseEntity'
import { Sprite } from './sprite'
import { UUID } from '#application/types'
@Entity()
export class SpriteAction extends BaseEntity {
@ -15,7 +16,7 @@ export class SpriteAction extends BaseEntity {
action!: string
@Property({ type: 'json', nullable: true })
sprites?: any
sprites?: string[]
@Property()
originX = 0
@ -37,4 +38,103 @@ export class SpriteAction extends BaseEntity {
@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
}
}

View File

@ -1,6 +1,7 @@
import { randomUUID } from 'node:crypto'
import { Entity, PrimaryKey, Property } from '@mikro-orm/core'
import { BaseEntity } from '#application/bases/baseEntity'
import { UUID } from '#application/types'
@Entity()
export class Tile extends BaseEntity {
@ -18,4 +19,49 @@ export class Tile extends BaseEntity {
@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
}
}

View File

@ -2,6 +2,7 @@ import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/
import { BaseEntity } from '#application/bases/baseEntity'
import { Character } from './character'
import { PasswordResetToken } from './passwordResetToken'
import bcrypt from 'bcryptjs'
@Entity()
export class User extends BaseEntity {
@ -25,4 +26,68 @@ export class User extends BaseEntity {
@OneToMany(() => PasswordResetToken, (token) => token.user)
passwordResetTokens = new Collection<PasswordResetToken>(this)
setId(id: number) {
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
}
}

View File

@ -17,4 +17,49 @@ export class World extends BaseEntity {
@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
}
}

View File

@ -50,4 +50,130 @@ export class Zone extends BaseEntity {
@Property()
updatedAt = new Date()
setId(id: number) {
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
}
setZoneEffects(zoneEffects: Collection<ZoneEffect>) {
this.zoneEffects = zoneEffects
return this
}
getZoneEffects() {
return this.zoneEffects
}
setZoneEventTiles(zoneEventTiles: Collection<ZoneEventTile>) {
this.zoneEventTiles = zoneEventTiles
return this
}
getZoneEventTiles() {
return this.zoneEventTiles
}
setZoneEventTileTeleports(zoneEventTileTeleports: Collection<ZoneEventTileTeleport>) {
this.zoneEventTileTeleports = zoneEventTileTeleports
return this
}
getZoneEventTileTeleports() {
return this.zoneEventTileTeleports
}
setZoneObjects(zoneObjects: Collection<ZoneObject>) {
this.zoneObjects = zoneObjects
return this
}
getZoneObjects() {
return this.zoneObjects
}
setCharacters(characters: Collection<Character>) {
this.characters = characters
return this
}
getCharacters() {
return this.characters
}
setChats(chats: Collection<Chat>) {
this.chats = chats
return this
}
getChats() {
return this.chats
}
setCreatedAt(createdAt: Date) {
this.createdAt = createdAt
return this
}
getCreatedAt() {
return this.createdAt
}
setUpdatedAt(updatedAt: Date) {
this.updatedAt = updatedAt
return this
}
getUpdatedAt() {
return this.updatedAt
}
}

View File

@ -2,6 +2,7 @@ import { randomUUID } from 'node:crypto'
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
import { BaseEntity } from '#application/bases/baseEntity'
import { Zone } from './zone'
import { UUID } from '#application/types'
@Entity()
export class ZoneEffect extends BaseEntity {
@ -16,4 +17,40 @@ export class ZoneEffect extends BaseEntity {
@Property()
strength!: number
setId(id: UUID) {
this.id = id
return this
}
getId() {
return this.id
}
setZone(zone: Zone) {
this.zone = zone
return this
}
getZone() {
return this.zone
}
setEffect(effect: string) {
this.effect = effect
return this
}
getEffect() {
return this.effect
}
setStrength(strength: number) {
this.strength = strength
return this
}
getStrength() {
return this.strength
}
}

View File

@ -3,11 +3,13 @@ import { BaseEntity } from '#application/bases/baseEntity'
import { Zone } from './zone'
import { ZoneEventTileType } from '#application/enums'
import { ZoneEventTileTeleport } from './zoneEventTileTeleport'
import { UUID } from '#application/types'
import { randomUUID } from 'node:crypto'
@Entity()
export class ZoneEventTile extends BaseEntity {
@PrimaryKey()
id!: string
id = randomUUID()
@ManyToOne(() => Zone)
zone!: Zone
@ -23,4 +25,58 @@ export class ZoneEventTile extends BaseEntity {
@OneToOne(() => ZoneEventTileTeleport, (teleport) => teleport.zoneEventTile)
teleport?: ZoneEventTileTeleport
setId(id: UUID) {
this.id = id
return this
}
getId() {
return this.id
}
setZone(zone: Zone) {
this.zone = zone
return this
}
getZone() {
return this.zone
}
setType(type: ZoneEventTileType) {
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: ZoneEventTileTeleport) {
this.teleport = teleport
return this
}
getTeleport() {
return this.teleport
}
}

View File

@ -3,6 +3,7 @@ import { Entity, ManyToOne, OneToOne, PrimaryKey, Property } from '@mikro-orm/co
import { BaseEntity } from '#application/bases/baseEntity'
import { Zone } from './zone'
import { ZoneEventTile } from './zoneEventTile'
import { UUID } from '#application/types'
@Entity()
export class ZoneEventTileTeleport extends BaseEntity {
@ -23,4 +24,58 @@ export class ZoneEventTileTeleport extends BaseEntity {
@Property()
toPositionY!: number
setId(id: UUID) {
this.id = id
return this
}
getId() {
return this.id
}
setZoneEventTile(zoneEventTile: ZoneEventTile) {
this.zoneEventTile = zoneEventTile
return this
}
getZoneEventTile() {
return this.zoneEventTile
}
setToZone(toZone: Zone) {
this.toZone = toZone
return this
}
getToZone() {
return this.toZone
}
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
}
}

View File

@ -2,12 +2,14 @@ import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
import { BaseEntity } from '#application/bases/baseEntity'
import { Zone } from './zone'
import { MapObject } from '#entities/mapObject'
import { UUID } from '#application/types'
import { randomUUID } from 'node:crypto'
//@TODO : Rename mapObject
@Entity()
export class ZoneObject extends BaseEntity {
@PrimaryKey()
id!: string
id = randomUUID()
@ManyToOne(() => Zone)
zone!: Zone
@ -26,4 +28,67 @@ export class ZoneObject extends BaseEntity {
@Property()
positionY = 0
setId(id: UUID) {
this.id = id
return this
}
getId() {
return this.id
}
setZone(zone: Zone) {
this.zone = zone
return this
}
getZone() {
return this.zone
}
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
}
}