npm run format

This commit is contained in:
2024-12-25 02:06:58 +01:00
parent c35e27799e
commit b4989aac26
28 changed files with 252 additions and 243 deletions

View File

@ -1,84 +1,84 @@
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
import { User } from './user';
import { Zone } from './zone';
import { CharacterType } from './characterType';
import { CharacterHair } from './characterHair';
import { CharacterItem } from './characterItem';
import { CharacterEquipment } from './characterEquipment';
import { Chat } from './chat';
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
import { User } from './user'
import { Zone } from './zone'
import { CharacterType } from './characterType'
import { CharacterHair } from './characterHair'
import { CharacterItem } from './characterItem'
import { CharacterEquipment } from './characterEquipment'
import { Chat } from './chat'
@Entity()
export class Character {
@PrimaryKey()
id!: number;
id!: number
@ManyToOne(() => User)
user!: User;
user!: User
@Property({ unique: true })
name!: string;
name!: string
@Property()
online = false;
online = false
@Property()
role = 'player';
role = 'player'
@OneToMany(() => Chat, chat => chat.character)
chats = new Collection<Chat>(this);
@OneToMany(() => Chat, (chat) => chat.character)
chats = new Collection<Chat>(this)
// Position
@ManyToOne(() => Zone)
zone!: Zone;
zone!: Zone
@Property()
positionX = 0;
positionX = 0
@Property()
positionY = 0;
positionY = 0
@Property()
rotation = 0;
rotation = 0
// Customization
@ManyToOne(() => CharacterType, { nullable: true })
characterType?: CharacterType;
characterType?: CharacterType
@ManyToOne(() => CharacterHair, { nullable: true })
characterHair?: CharacterHair;
characterHair?: CharacterHair
// Inventory
@OneToMany(() => CharacterItem, item => item.character)
items = new Collection<CharacterItem>(this);
@OneToMany(() => CharacterItem, (item) => item.character)
items = new Collection<CharacterItem>(this)
@OneToMany(() => CharacterEquipment, equipment => equipment.character)
equipment = new Collection<CharacterEquipment>(this);
@OneToMany(() => CharacterEquipment, (equipment) => equipment.character)
equipment = new Collection<CharacterEquipment>(this)
// Stats
@Property()
alignment = 50;
alignment = 50
@Property()
hitpoints = 100;
hitpoints = 100
@Property()
mana = 100;
mana = 100
@Property()
level = 1;
level = 1
@Property()
experience = 0;
experience = 0
@Property()
strength = 10;
strength = 10
@Property()
dexterity = 10;
dexterity = 10
@Property()
intelligence = 10;
intelligence = 10
@Property()
wisdom = 10;
}
wisdom = 10
}

View File

@ -1,19 +1,19 @@
import { Entity, Enum, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
import { Character } from './character';
import { CharacterItem } from './characterItem';
import { CharacterEquipmentSlotType } from '#utilities/enums';
import { Entity, Enum, ManyToOne, PrimaryKey } from '@mikro-orm/core'
import { Character } from './character'
import { CharacterItem } from './characterItem'
import { CharacterEquipmentSlotType } from '#utilities/enums'
@Entity()
export class CharacterEquipment {
@PrimaryKey()
id!: number;
id!: number
@Enum(() => CharacterEquipmentSlotType)
slot!: CharacterEquipmentSlotType;
slot!: CharacterEquipmentSlotType
@ManyToOne(() => Character)
character!: Character;
character!: Character
@ManyToOne(() => CharacterItem)
characterItem!: CharacterItem;
}
characterItem!: CharacterItem
}

View File

@ -1,25 +1,25 @@
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
import { Character } from './character';
import { Sprite } from './sprite';
import { CharacterGender } from '#utilities/enums';
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
import { Character } from './character'
import { Sprite } from './sprite'
import { CharacterGender } from '#utilities/enums'
@Entity()
export class CharacterHair {
@PrimaryKey()
id!: number;
id!: number
@Property()
name!: string;
name!: string
@Property()
gender: CharacterGender = CharacterGender.MALE;
gender: CharacterGender = CharacterGender.MALE
@Property()
isSelectable = false;
isSelectable = false
@ManyToOne(() => Sprite, { nullable: true })
sprite?: Sprite;
sprite?: Sprite
@OneToMany(() => Character, character => character.characterHair)
characters = new Collection<Character>(this);
}
@OneToMany(() => Character, (character) => character.characterHair)
characters = new Collection<Character>(this)
}

View File

@ -1,22 +1,22 @@
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
import { Character } from './character';
import { Item } from './item';
import { CharacterEquipment } from './characterEquipment';
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
import { Character } from './character'
import { Item } from './item'
import { CharacterEquipment } from './characterEquipment'
@Entity()
export class CharacterItem {
@PrimaryKey()
id!: number;
id!: number
@ManyToOne(() => Character)
character!: Character;
character!: Character
@ManyToOne(() => Item)
item!: Item;
item!: Item
@Property()
quantity!: number;
quantity!: number
@OneToMany(() => CharacterEquipment, equipment => equipment.characterItem)
characterEquipment = new Collection<CharacterEquipment>(this);
}
@OneToMany(() => CharacterEquipment, (equipment) => equipment.characterItem)
characterEquipment = new Collection<CharacterEquipment>(this)
}

View File

@ -1,34 +1,34 @@
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
import { Character } from './character';
import { Sprite } from './sprite';
import { CharacterGender, CharacterRace } from '#utilities/enums';
import { Character } from './character'
import { Sprite } from './sprite'
import { CharacterGender, CharacterRace } from '#utilities/enums'
@Entity()
export class CharacterType {
@PrimaryKey()
id!: number;
id!: number
@Property()
name!: string;
name!: string
@Enum(() => CharacterGender)
gender!: CharacterGender;
gender!: CharacterGender
@Enum(() => CharacterRace)
race!: CharacterRace;
race!: CharacterRace
@Property()
isSelectable = false;
isSelectable = false
@OneToMany(() => Character, character => character.characterType)
characters = new Collection<Character>(this);
@OneToMany(() => Character, (character) => character.characterType)
characters = new Collection<Character>(this)
@ManyToOne(() => Sprite, { nullable: true })
sprite?: Sprite;
sprite?: Sprite
@Property()
createdAt = new Date();
createdAt = new Date()
@Property()
updatedAt = new Date();
}
updatedAt = new Date()
}

View File

@ -1,21 +1,21 @@
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core';
import { Character } from './character';
import { Zone } from './zone';
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
import { Character } from './character'
import { Zone } from './zone'
@Entity()
export class Chat {
@PrimaryKey()
id!: number;
id!: number
@ManyToOne(() => Character)
character!: Character;
character!: Character
@ManyToOne(() => Zone)
zone!: Zone;
zone!: Zone
@Property()
message!: string;
message!: string
@Property()
createdAt = new Date();
}
createdAt = new Date()
}

View File

@ -1,37 +1,37 @@
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
import { Sprite } from './sprite';
import { CharacterItem } from './characterItem';
import { ItemType, ItemRarity } from '#utilities/enums';
import { Sprite } from './sprite'
import { CharacterItem } from './characterItem'
import { ItemType, ItemRarity } from '#utilities/enums'
@Entity()
export class Item {
@PrimaryKey()
id!: string;
id!: string
@Property()
name!: string;
name!: string
@Property({ nullable: true })
description?: string;
description?: string
@Enum(() => ItemType)
itemType!: ItemType;
itemType!: ItemType
@Property()
stackable = false;
stackable = false
@Enum(() => ItemRarity)
rarity: ItemRarity = ItemRarity.COMMON;
rarity: ItemRarity = ItemRarity.COMMON
@ManyToOne(() => Sprite, { nullable: true })
sprite?: Sprite;
sprite?: Sprite
@Property()
createdAt = new Date();
createdAt = new Date()
@Property()
updatedAt = new Date();
updatedAt = new Date()
@OneToMany(() => CharacterItem, characterItem => characterItem.item)
characters = new Collection<CharacterItem>(this);
}
@OneToMany(() => CharacterItem, (characterItem) => characterItem.item)
characters = new Collection<CharacterItem>(this)
}

View File

@ -1,17 +1,17 @@
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core';
import { User } from './user';
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
import { User } from './user'
@Entity()
export class PasswordResetToken {
@PrimaryKey()
id!: number;
id!: number
@ManyToOne(() => User)
user!: User;
user!: User
@Property({ unique: true })
token!: string;
token!: string
@Property()
createdAt = new Date();
}
createdAt = new Date()
}

View File

@ -1,33 +1,33 @@
import { randomUUID } from 'node:crypto';
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
import { SpriteAction } from './spriteAction';
import { CharacterType } from './characterType';
import { CharacterHair } from './characterHair';
import { Item } from './item';
import { randomUUID } from 'node:crypto'
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
import { SpriteAction } from './spriteAction'
import { CharacterType } from './characterType'
import { CharacterHair } from './characterHair'
import { Item } from './item'
@Entity()
export class Sprite {
@PrimaryKey()
id = randomUUID();
id = randomUUID()
@Property()
name!: string;
name!: string
@Property()
createdAt = new Date();
createdAt = new Date()
@Property()
updatedAt = new Date();
updatedAt = new Date()
@OneToMany(() => SpriteAction, action => action.sprite)
spriteActions = new Collection<SpriteAction>(this);
@OneToMany(() => SpriteAction, (action) => action.sprite)
spriteActions = new Collection<SpriteAction>(this)
@OneToMany(() => CharacterType, type => type.sprite)
characterTypes = new Collection<CharacterType>(this);
@OneToMany(() => CharacterType, (type) => type.sprite)
characterTypes = new Collection<CharacterType>(this)
@OneToMany(() => CharacterHair, hair => hair.sprite)
characterHairs = new Collection<CharacterHair>(this);
@OneToMany(() => CharacterHair, (hair) => hair.sprite)
characterHairs = new Collection<CharacterHair>(this)
@OneToMany(() => Item, item => item.sprite)
items = new Collection<Item>(this);
}
@OneToMany(() => Item, (item) => item.sprite)
items = new Collection<Item>(this)
}

View File

@ -1,39 +1,39 @@
import { randomUUID } from 'node:crypto'
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core';
import { Sprite } from './sprite';
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
import { Sprite } from './sprite'
@Entity()
export class SpriteAction {
@PrimaryKey()
id = randomUUID();
id = randomUUID()
@ManyToOne(() => Sprite)
sprite!: Sprite;
sprite!: Sprite
@Property()
action!: string;
action!: string
@Property({ type: 'json', nullable: true })
sprites?: any;
sprites?: any
@Property()
originX = 0;
originX = 0
@Property()
originY = 0;
originY = 0
@Property()
isAnimated = false;
isAnimated = false
@Property()
isLooping = false;
isLooping = false
@Property()
frameWidth = 0;
frameWidth = 0
@Property()
frameHeight = 0;
frameHeight = 0
@Property()
frameRate = 0;
}
frameRate = 0
}

View File

@ -1,27 +1,27 @@
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
import { Character } from './character';
import { PasswordResetToken } from './passwordResetToken';
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
import { Character } from './character'
import { PasswordResetToken } from './passwordResetToken'
@Entity()
export class User {
@PrimaryKey()
id!: number;
id!: number
@Property({ unique: true })
username!: string;
username!: string
@Property({ unique: true })
email!: string;
email!: string
@Property()
password!: string;
password!: string
@Property()
online = false;
online = false
@OneToMany(() => Character, character => character.user)
characters = new Collection<Character>(this);
@OneToMany(() => Character, (character) => character.user)
characters = new Collection<Character>(this)
@OneToMany(() => PasswordResetToken, token => token.user)
passwordResetTokens = new Collection<PasswordResetToken>(this);
}
@OneToMany(() => PasswordResetToken, (token) => token.user)
passwordResetTokens = new Collection<PasswordResetToken>(this)
}

View File

@ -1,19 +1,19 @@
import { Entity, PrimaryKey, Property } from '@mikro-orm/core';
import { Entity, PrimaryKey, Property } from '@mikro-orm/core'
@Entity()
export class World {
@PrimaryKey()
date = new Date();
date = new Date()
@Property()
isRainEnabled = false;
isRainEnabled = false
@Property()
rainPercentage = 0;
rainPercentage = 0
@Property()
isFogEnabled = false;
isFogEnabled = false
@Property()
fogDensity = 0;
}
fogDensity = 0
}

View File

@ -1,15 +1,15 @@
import { Collection, Entity, OneToMany, PrimaryKey } from '@mikro-orm/core';
import { Character } from './character';
import { Chat } from './chat';
import { Collection, Entity, OneToMany, PrimaryKey } from '@mikro-orm/core'
import { Character } from './character'
import { Chat } from './chat'
@Entity()
export class Zone {
@PrimaryKey()
id!: number;
id!: number
@OneToMany(() => Character, character => character.zone)
characters = new Collection<Character>(this);
@OneToMany(() => Character, (character) => character.zone)
characters = new Collection<Character>(this)
@OneToMany(() => Chat, chat => chat.zone)
chats = new Collection<Chat>(this);
}
@OneToMany(() => Chat, (chat) => chat.zone)
chats = new Collection<Chat>(this)
}