npm run format
This commit is contained in:
parent
c35e27799e
commit
b4989aac26
File diff suppressed because one or more lines are too long
@ -1,84 +1,84 @@
|
|||||||
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
|
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
import { User } from './user';
|
import { User } from './user'
|
||||||
import { Zone } from './zone';
|
import { Zone } from './zone'
|
||||||
import { CharacterType } from './characterType';
|
import { CharacterType } from './characterType'
|
||||||
import { CharacterHair } from './characterHair';
|
import { CharacterHair } from './characterHair'
|
||||||
import { CharacterItem } from './characterItem';
|
import { CharacterItem } from './characterItem'
|
||||||
import { CharacterEquipment } from './characterEquipment';
|
import { CharacterEquipment } from './characterEquipment'
|
||||||
import { Chat } from './chat';
|
import { Chat } from './chat'
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Character {
|
export class Character {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
id!: number;
|
id!: number
|
||||||
|
|
||||||
@ManyToOne(() => User)
|
@ManyToOne(() => User)
|
||||||
user!: User;
|
user!: User
|
||||||
|
|
||||||
@Property({ unique: true })
|
@Property({ unique: true })
|
||||||
name!: string;
|
name!: string
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
online = false;
|
online = false
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
role = 'player';
|
role = 'player'
|
||||||
|
|
||||||
@OneToMany(() => Chat, chat => chat.character)
|
@OneToMany(() => Chat, (chat) => chat.character)
|
||||||
chats = new Collection<Chat>(this);
|
chats = new Collection<Chat>(this)
|
||||||
|
|
||||||
// Position
|
// Position
|
||||||
@ManyToOne(() => Zone)
|
@ManyToOne(() => Zone)
|
||||||
zone!: Zone;
|
zone!: Zone
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
positionX = 0;
|
positionX = 0
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
positionY = 0;
|
positionY = 0
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
rotation = 0;
|
rotation = 0
|
||||||
|
|
||||||
// Customization
|
// Customization
|
||||||
@ManyToOne(() => CharacterType, { nullable: true })
|
@ManyToOne(() => CharacterType, { nullable: true })
|
||||||
characterType?: CharacterType;
|
characterType?: CharacterType
|
||||||
|
|
||||||
@ManyToOne(() => CharacterHair, { nullable: true })
|
@ManyToOne(() => CharacterHair, { nullable: true })
|
||||||
characterHair?: CharacterHair;
|
characterHair?: CharacterHair
|
||||||
|
|
||||||
// Inventory
|
// Inventory
|
||||||
@OneToMany(() => CharacterItem, item => item.character)
|
@OneToMany(() => CharacterItem, (item) => item.character)
|
||||||
items = new Collection<CharacterItem>(this);
|
items = new Collection<CharacterItem>(this)
|
||||||
|
|
||||||
@OneToMany(() => CharacterEquipment, equipment => equipment.character)
|
@OneToMany(() => CharacterEquipment, (equipment) => equipment.character)
|
||||||
equipment = new Collection<CharacterEquipment>(this);
|
equipment = new Collection<CharacterEquipment>(this)
|
||||||
|
|
||||||
// Stats
|
// Stats
|
||||||
@Property()
|
@Property()
|
||||||
alignment = 50;
|
alignment = 50
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
hitpoints = 100;
|
hitpoints = 100
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
mana = 100;
|
mana = 100
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
level = 1;
|
level = 1
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
experience = 0;
|
experience = 0
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
strength = 10;
|
strength = 10
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
dexterity = 10;
|
dexterity = 10
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
intelligence = 10;
|
intelligence = 10
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
wisdom = 10;
|
wisdom = 10
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
import { Entity, Enum, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
import { Entity, Enum, ManyToOne, PrimaryKey } from '@mikro-orm/core'
|
||||||
import { Character } from './character';
|
import { Character } from './character'
|
||||||
import { CharacterItem } from './characterItem';
|
import { CharacterItem } from './characterItem'
|
||||||
import { CharacterEquipmentSlotType } from '#utilities/enums';
|
import { CharacterEquipmentSlotType } from '#utilities/enums'
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class CharacterEquipment {
|
export class CharacterEquipment {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
id!: number;
|
id!: number
|
||||||
|
|
||||||
@Enum(() => CharacterEquipmentSlotType)
|
@Enum(() => CharacterEquipmentSlotType)
|
||||||
slot!: CharacterEquipmentSlotType;
|
slot!: CharacterEquipmentSlotType
|
||||||
|
|
||||||
@ManyToOne(() => Character)
|
@ManyToOne(() => Character)
|
||||||
character!: Character;
|
character!: Character
|
||||||
|
|
||||||
@ManyToOne(() => CharacterItem)
|
@ManyToOne(() => CharacterItem)
|
||||||
characterItem!: CharacterItem;
|
characterItem!: CharacterItem
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
|
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
import { Character } from './character';
|
import { Character } from './character'
|
||||||
import { Sprite } from './sprite';
|
import { Sprite } from './sprite'
|
||||||
import { CharacterGender } from '#utilities/enums';
|
import { CharacterGender } from '#utilities/enums'
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class CharacterHair {
|
export class CharacterHair {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
id!: number;
|
id!: number
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
name!: string;
|
name!: string
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
gender: CharacterGender = CharacterGender.MALE;
|
gender: CharacterGender = CharacterGender.MALE
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
isSelectable = false;
|
isSelectable = false
|
||||||
|
|
||||||
@ManyToOne(() => Sprite, { nullable: true })
|
@ManyToOne(() => Sprite, { nullable: true })
|
||||||
sprite?: Sprite;
|
sprite?: Sprite
|
||||||
|
|
||||||
@OneToMany(() => Character, character => character.characterHair)
|
@OneToMany(() => Character, (character) => character.characterHair)
|
||||||
characters = new Collection<Character>(this);
|
characters = new Collection<Character>(this)
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
|
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
import { Character } from './character';
|
import { Character } from './character'
|
||||||
import { Item } from './item';
|
import { Item } from './item'
|
||||||
import { CharacterEquipment } from './characterEquipment';
|
import { CharacterEquipment } from './characterEquipment'
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class CharacterItem {
|
export class CharacterItem {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
id!: number;
|
id!: number
|
||||||
|
|
||||||
@ManyToOne(() => Character)
|
@ManyToOne(() => Character)
|
||||||
character!: Character;
|
character!: Character
|
||||||
|
|
||||||
@ManyToOne(() => Item)
|
@ManyToOne(() => Item)
|
||||||
item!: Item;
|
item!: Item
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
quantity!: number;
|
quantity!: number
|
||||||
|
|
||||||
@OneToMany(() => CharacterEquipment, equipment => equipment.characterItem)
|
@OneToMany(() => CharacterEquipment, (equipment) => equipment.characterItem)
|
||||||
characterEquipment = new Collection<CharacterEquipment>(this);
|
characterEquipment = new Collection<CharacterEquipment>(this)
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
import { Character } from './character';
|
import { Character } from './character'
|
||||||
import { Sprite } from './sprite';
|
import { Sprite } from './sprite'
|
||||||
import { CharacterGender, CharacterRace } from '#utilities/enums';
|
import { CharacterGender, CharacterRace } from '#utilities/enums'
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class CharacterType {
|
export class CharacterType {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
id!: number;
|
id!: number
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
name!: string;
|
name!: string
|
||||||
|
|
||||||
@Enum(() => CharacterGender)
|
@Enum(() => CharacterGender)
|
||||||
gender!: CharacterGender;
|
gender!: CharacterGender
|
||||||
|
|
||||||
@Enum(() => CharacterRace)
|
@Enum(() => CharacterRace)
|
||||||
race!: CharacterRace;
|
race!: CharacterRace
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
isSelectable = false;
|
isSelectable = false
|
||||||
|
|
||||||
@OneToMany(() => Character, character => character.characterType)
|
@OneToMany(() => Character, (character) => character.characterType)
|
||||||
characters = new Collection<Character>(this);
|
characters = new Collection<Character>(this)
|
||||||
|
|
||||||
@ManyToOne(() => Sprite, { nullable: true })
|
@ManyToOne(() => Sprite, { nullable: true })
|
||||||
sprite?: Sprite;
|
sprite?: Sprite
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
createdAt = new Date();
|
createdAt = new Date()
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
updatedAt = new Date();
|
updatedAt = new Date()
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core';
|
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
import { Character } from './character';
|
import { Character } from './character'
|
||||||
import { Zone } from './zone';
|
import { Zone } from './zone'
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Chat {
|
export class Chat {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
id!: number;
|
id!: number
|
||||||
|
|
||||||
@ManyToOne(() => Character)
|
@ManyToOne(() => Character)
|
||||||
character!: Character;
|
character!: Character
|
||||||
|
|
||||||
@ManyToOne(() => Zone)
|
@ManyToOne(() => Zone)
|
||||||
zone!: Zone;
|
zone!: Zone
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
message!: string;
|
message!: string
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
createdAt = new Date();
|
createdAt = new Date()
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,37 @@
|
|||||||
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
import { Sprite } from './sprite';
|
import { Sprite } from './sprite'
|
||||||
import { CharacterItem } from './characterItem';
|
import { CharacterItem } from './characterItem'
|
||||||
import { ItemType, ItemRarity } from '#utilities/enums';
|
import { ItemType, ItemRarity } from '#utilities/enums'
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Item {
|
export class Item {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
id!: string;
|
id!: string
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
name!: string;
|
name!: string
|
||||||
|
|
||||||
@Property({ nullable: true })
|
@Property({ nullable: true })
|
||||||
description?: string;
|
description?: string
|
||||||
|
|
||||||
@Enum(() => ItemType)
|
@Enum(() => ItemType)
|
||||||
itemType!: ItemType;
|
itemType!: ItemType
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
stackable = false;
|
stackable = false
|
||||||
|
|
||||||
@Enum(() => ItemRarity)
|
@Enum(() => ItemRarity)
|
||||||
rarity: ItemRarity = ItemRarity.COMMON;
|
rarity: ItemRarity = ItemRarity.COMMON
|
||||||
|
|
||||||
@ManyToOne(() => Sprite, { nullable: true })
|
@ManyToOne(() => Sprite, { nullable: true })
|
||||||
sprite?: Sprite;
|
sprite?: Sprite
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
createdAt = new Date();
|
createdAt = new Date()
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
updatedAt = new Date();
|
updatedAt = new Date()
|
||||||
|
|
||||||
@OneToMany(() => CharacterItem, characterItem => characterItem.item)
|
@OneToMany(() => CharacterItem, (characterItem) => characterItem.item)
|
||||||
characters = new Collection<CharacterItem>(this);
|
characters = new Collection<CharacterItem>(this)
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core';
|
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
import { User } from './user';
|
import { User } from './user'
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class PasswordResetToken {
|
export class PasswordResetToken {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
id!: number;
|
id!: number
|
||||||
|
|
||||||
@ManyToOne(() => User)
|
@ManyToOne(() => User)
|
||||||
user!: User;
|
user!: User
|
||||||
|
|
||||||
@Property({ unique: true })
|
@Property({ unique: true })
|
||||||
token!: string;
|
token!: string
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
createdAt = new Date();
|
createdAt = new Date()
|
||||||
}
|
}
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
import { randomUUID } from 'node:crypto';
|
import { randomUUID } from 'node:crypto'
|
||||||
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
|
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
import { SpriteAction } from './spriteAction';
|
import { SpriteAction } from './spriteAction'
|
||||||
import { CharacterType } from './characterType';
|
import { CharacterType } from './characterType'
|
||||||
import { CharacterHair } from './characterHair';
|
import { CharacterHair } from './characterHair'
|
||||||
import { Item } from './item';
|
import { Item } from './item'
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Sprite {
|
export class Sprite {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
id = randomUUID();
|
id = randomUUID()
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
name!: string;
|
name!: string
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
createdAt = new Date();
|
createdAt = new Date()
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
updatedAt = new Date();
|
updatedAt = new Date()
|
||||||
|
|
||||||
@OneToMany(() => SpriteAction, action => action.sprite)
|
@OneToMany(() => SpriteAction, (action) => action.sprite)
|
||||||
spriteActions = new Collection<SpriteAction>(this);
|
spriteActions = new Collection<SpriteAction>(this)
|
||||||
|
|
||||||
@OneToMany(() => CharacterType, type => type.sprite)
|
@OneToMany(() => CharacterType, (type) => type.sprite)
|
||||||
characterTypes = new Collection<CharacterType>(this);
|
characterTypes = new Collection<CharacterType>(this)
|
||||||
|
|
||||||
@OneToMany(() => CharacterHair, hair => hair.sprite)
|
@OneToMany(() => CharacterHair, (hair) => hair.sprite)
|
||||||
characterHairs = new Collection<CharacterHair>(this);
|
characterHairs = new Collection<CharacterHair>(this)
|
||||||
|
|
||||||
@OneToMany(() => Item, item => item.sprite)
|
@OneToMany(() => Item, (item) => item.sprite)
|
||||||
items = new Collection<Item>(this);
|
items = new Collection<Item>(this)
|
||||||
}
|
}
|
||||||
|
@ -1,39 +1,39 @@
|
|||||||
import { randomUUID } from 'node:crypto'
|
import { randomUUID } from 'node:crypto'
|
||||||
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core';
|
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
import { Sprite } from './sprite';
|
import { Sprite } from './sprite'
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class SpriteAction {
|
export class SpriteAction {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
id = randomUUID();
|
id = randomUUID()
|
||||||
|
|
||||||
@ManyToOne(() => Sprite)
|
@ManyToOne(() => Sprite)
|
||||||
sprite!: Sprite;
|
sprite!: Sprite
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
action!: string;
|
action!: string
|
||||||
|
|
||||||
@Property({ type: 'json', nullable: true })
|
@Property({ type: 'json', nullable: true })
|
||||||
sprites?: any;
|
sprites?: any
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
originX = 0;
|
originX = 0
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
originY = 0;
|
originY = 0
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
isAnimated = false;
|
isAnimated = false
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
isLooping = false;
|
isLooping = false
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
frameWidth = 0;
|
frameWidth = 0
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
frameHeight = 0;
|
frameHeight = 0
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
frameRate = 0;
|
frameRate = 0
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
|
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
import { Character } from './character';
|
import { Character } from './character'
|
||||||
import { PasswordResetToken } from './passwordResetToken';
|
import { PasswordResetToken } from './passwordResetToken'
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class User {
|
export class User {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
id!: number;
|
id!: number
|
||||||
|
|
||||||
@Property({ unique: true })
|
@Property({ unique: true })
|
||||||
username!: string;
|
username!: string
|
||||||
|
|
||||||
@Property({ unique: true })
|
@Property({ unique: true })
|
||||||
email!: string;
|
email!: string
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
password!: string;
|
password!: string
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
online = false;
|
online = false
|
||||||
|
|
||||||
@OneToMany(() => Character, character => character.user)
|
@OneToMany(() => Character, (character) => character.user)
|
||||||
characters = new Collection<Character>(this);
|
characters = new Collection<Character>(this)
|
||||||
|
|
||||||
@OneToMany(() => PasswordResetToken, token => token.user)
|
@OneToMany(() => PasswordResetToken, (token) => token.user)
|
||||||
passwordResetTokens = new Collection<PasswordResetToken>(this);
|
passwordResetTokens = new Collection<PasswordResetToken>(this)
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
import { Entity, PrimaryKey, Property } from '@mikro-orm/core';
|
import { Entity, PrimaryKey, Property } from '@mikro-orm/core'
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class World {
|
export class World {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
date = new Date();
|
date = new Date()
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
isRainEnabled = false;
|
isRainEnabled = false
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
rainPercentage = 0;
|
rainPercentage = 0
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
isFogEnabled = false;
|
isFogEnabled = false
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
fogDensity = 0;
|
fogDensity = 0
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
import { Collection, Entity, OneToMany, PrimaryKey } from '@mikro-orm/core';
|
import { Collection, Entity, OneToMany, PrimaryKey } from '@mikro-orm/core'
|
||||||
import { Character } from './character';
|
import { Character } from './character'
|
||||||
import { Chat } from './chat';
|
import { Chat } from './chat'
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Zone {
|
export class Zone {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
id!: number;
|
id!: number
|
||||||
|
|
||||||
@OneToMany(() => Character, character => character.zone)
|
@OneToMany(() => Character, (character) => character.zone)
|
||||||
characters = new Collection<Character>(this);
|
characters = new Collection<Character>(this)
|
||||||
|
|
||||||
@OneToMany(() => Chat, chat => chat.zone)
|
@OneToMany(() => Chat, (chat) => chat.zone)
|
||||||
chats = new Collection<Chat>(this);
|
chats = new Collection<Chat>(this)
|
||||||
}
|
}
|
||||||
|
@ -40,13 +40,15 @@ async function generateAvatar(res: Response, options: AvatarOptions) {
|
|||||||
if (characterHair?.spriteId) {
|
if (characterHair?.spriteId) {
|
||||||
const hairSpritePath = getPublicPath('sprites', characterHair.spriteId, 'front.png')
|
const hairSpritePath = getPublicPath('sprites', characterHair.spriteId, 'front.png')
|
||||||
if (fs.existsSync(hairSpritePath)) {
|
if (fs.existsSync(hairSpritePath)) {
|
||||||
avatar = avatar.composite([{
|
avatar = avatar.composite([
|
||||||
input: hairSpritePath,
|
{
|
||||||
gravity: 'north',
|
input: hairSpritePath,
|
||||||
// Top is originY in min @TODO finish me #287
|
gravity: 'north'
|
||||||
// top: Math.round(Number(characterHair.sprite!.spriteActions.find((action) => action.action === 'front')?.originY ?? 0)),
|
// Top is originY in min @TODO finish me #287
|
||||||
// left: 0
|
// top: Math.round(Number(characterHair.sprite!.spriteActions.find((action) => action.action === 'front')?.originY ?? 0)),
|
||||||
}])
|
// left: 0
|
||||||
|
}
|
||||||
|
])
|
||||||
} else {
|
} else {
|
||||||
console.error(`Hair sprite file not found: ${hairSpritePath}`)
|
console.error(`Hair sprite file not found: ${hairSpritePath}`)
|
||||||
}
|
}
|
||||||
@ -80,4 +82,4 @@ router.get('/avatar/s/:characterTypeId/:characterHairId?', async (req: Request,
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
|
@ -21,4 +21,4 @@ export abstract class BaseRepository {
|
|||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,4 +41,4 @@ class CharacterHairRepository extends BaseRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new CharacterHairRepository()
|
export default new CharacterHairRepository()
|
||||||
|
@ -23,7 +23,7 @@ class CharacterRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
@ -34,4 +34,4 @@ class UserRepository extends BaseRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new UserRepository()
|
export default new UserRepository()
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import prisma from '#utilities/prisma'
|
import prisma from '#utilities/prisma'
|
||||||
import { gameLogger } from '#utilities/logger'
|
import { gameLogger } from '#utilities/logger'
|
||||||
|
|
||||||
class ZoneService {
|
class ZoneService {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ZoneService
|
export default ZoneService
|
||||||
|
@ -38,4 +38,4 @@ export default class ItemCreateEvent {
|
|||||||
callback(false)
|
callback(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,4 +37,4 @@ export default class ItemDeleteEvent {
|
|||||||
callback(false)
|
callback(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,4 +33,4 @@ export default class ItemListEvent {
|
|||||||
const items = await itemRepository.getAll()
|
const items = await itemRepository.getAll()
|
||||||
callback(items)
|
callback(items)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,4 +52,4 @@ export default class ItemUpdateEvent {
|
|||||||
return callback(false)
|
return callback(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ export default class SpriteCopyEvent {
|
|||||||
data: {
|
data: {
|
||||||
name: `${sourceSprite.name} (Copy)`,
|
name: `${sourceSprite.name} (Copy)`,
|
||||||
spriteActions: {
|
spriteActions: {
|
||||||
create: sourceSprite.spriteActions.map(action => ({
|
create: sourceSprite.spriteActions.map((action) => ({
|
||||||
action: action.action,
|
action: action.action,
|
||||||
sprites: action.sprites as Prisma.InputJsonValue,
|
sprites: action.sprites as Prisma.InputJsonValue,
|
||||||
originX: action.originX,
|
originX: action.originX,
|
||||||
@ -74,4 +74,4 @@ export default class SpriteCopyEvent {
|
|||||||
private getErrorMessage(error: unknown): string {
|
private getErrorMessage(error: unknown): string {
|
||||||
return error instanceof Error ? error.message : String(error)
|
return error instanceof Error ? error.message : String(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,23 +78,28 @@ export default class SpriteUpdateEvent {
|
|||||||
const parsedActions = this.validateSpriteActions(payload.spriteActions)
|
const parsedActions = this.validateSpriteActions(payload.spriteActions)
|
||||||
|
|
||||||
// Process sprites
|
// Process sprites
|
||||||
const processedActions = await Promise.all(parsedActions.map(async (action) => {
|
const processedActions = await Promise.all(
|
||||||
const spriteBuffers = await this.convertBase64ToBuffers(action.sprites)
|
parsedActions.map(async (action) => {
|
||||||
const frameWidth = ISOMETRIC_CONFIG.tileWidth
|
const spriteBuffers = await this.convertBase64ToBuffers(action.sprites)
|
||||||
const frameHeight = await this.calculateOptimalHeight(spriteBuffers)
|
const frameWidth = ISOMETRIC_CONFIG.tileWidth
|
||||||
const processedFrames = await this.normalizeFrames(spriteBuffers, frameWidth, frameHeight)
|
const frameHeight = await this.calculateOptimalHeight(spriteBuffers)
|
||||||
|
const processedFrames = await this.normalizeFrames(spriteBuffers, frameWidth, frameHeight)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...action,
|
...action,
|
||||||
frameWidth,
|
frameWidth,
|
||||||
frameHeight,
|
frameHeight,
|
||||||
buffersWithDimensions: processedFrames
|
buffersWithDimensions: processedFrames
|
||||||
}
|
}
|
||||||
}))
|
})
|
||||||
|
)
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.updateDatabase(payload.id, payload.name, processedActions),
|
this.updateDatabase(payload.id, payload.name, processedActions),
|
||||||
this.saveSpritesToDisk(payload.id, processedActions.filter(a => a.buffersWithDimensions.length > 0))
|
this.saveSpritesToDisk(
|
||||||
|
payload.id,
|
||||||
|
processedActions.filter((a) => a.buffersWithDimensions.length > 0)
|
||||||
|
)
|
||||||
])
|
])
|
||||||
|
|
||||||
callback(true)
|
callback(true)
|
||||||
@ -158,9 +163,9 @@ export default class SpriteUpdateEvent {
|
|||||||
const processedInput = await sharp(buffer)
|
const processedInput = await sharp(buffer)
|
||||||
.ensureAlpha()
|
.ensureAlpha()
|
||||||
.resize({
|
.resize({
|
||||||
width: frameWidth, // Set maximum width
|
width: frameWidth, // Set maximum width
|
||||||
height: frameHeight, // Set maximum height
|
height: frameHeight, // Set maximum height
|
||||||
fit: 'inside', // Ensure image fits within dimensions
|
fit: 'inside', // Ensure image fits within dimensions
|
||||||
kernel: sharp.kernel.nearest,
|
kernel: sharp.kernel.nearest,
|
||||||
position: 'center',
|
position: 'center',
|
||||||
withoutEnlargement: true // Don't enlarge smaller images
|
withoutEnlargement: true // Don't enlarge smaller images
|
||||||
|
@ -32,4 +32,4 @@ export class Database {
|
|||||||
Database.instance = undefined
|
Database.instance = undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,4 +37,4 @@ export enum CharacterEquipmentSlotType {
|
|||||||
LEGS = 'LEGS',
|
LEGS = 'LEGS',
|
||||||
NECK = 'NECK',
|
NECK = 'NECK',
|
||||||
RING = 'RING'
|
RING = 'RING'
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user