Improved folder and file structure, separated prisma schema into multiple ones, removed obsolete functions, worked on dynamic character sprite logics, general enhancements
This commit is contained in:
31
prisma/schema/schema.prisma
Normal file
31
prisma/schema/schema.prisma
Normal file
@ -0,0 +1,31 @@
|
||||
// CHEAT SHEET
|
||||
// 1. Create a new Prisma project
|
||||
// npx prisma init
|
||||
// 2. Create a new database schema
|
||||
// npx prisma db push
|
||||
// 3. Generate Prisma Client and type-safe models based on schema
|
||||
// npx prisma generate
|
||||
// 4. Create a new migration
|
||||
// npx prisma migrate dev --name [migration-name]
|
||||
// 5. Apply the migration
|
||||
// npx prisma migrate deploy
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
previewFeatures = ["prismaSchemaFolder"]
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Chat {
|
||||
id Int @id @default(autoincrement())
|
||||
characterId Int
|
||||
character Character @relation(fields: [characterId], references: [id], onDelete: Cascade)
|
||||
zoneId Int
|
||||
zone Zone @relation(fields: [zoneId], references: [id], onDelete: Cascade)
|
||||
message String
|
||||
createdAt DateTime
|
||||
}
|
34
prisma/schema/sprite.prisma
Normal file
34
prisma/schema/sprite.prisma
Normal file
@ -0,0 +1,34 @@
|
||||
model Sprite {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
origin_x Decimal @default(0)
|
||||
origin_y Decimal @default(0)
|
||||
isAnimated Boolean @default(false)
|
||||
frameSpeed Int @default(0)
|
||||
frameWidth Int @default(0)
|
||||
frameHeight Int @default(0)
|
||||
isLooping Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
characterSprites CharacterSprite[]
|
||||
}
|
||||
|
||||
enum SpriteAction {
|
||||
IDLE_LEFT
|
||||
IDLE_DOWN
|
||||
SIT_LEFT
|
||||
SIT_DOWN
|
||||
WALK_LEFT
|
||||
WALK_DOWN
|
||||
ATTACK_LEFT
|
||||
ATTACK_DOWN
|
||||
}
|
||||
|
||||
model CharacterSprite {
|
||||
id Int @id @default(autoincrement())
|
||||
characterTypeId Int
|
||||
spriteId String
|
||||
action SpriteAction
|
||||
characterType CharacterType @relation(fields: [characterTypeId], references: [id], onDelete: Cascade)
|
||||
sprite Sprite @relation(fields: [spriteId], references: [id], onDelete: Cascade)
|
||||
}
|
60
prisma/schema/user.prisma
Normal file
60
prisma/schema/user.prisma
Normal file
@ -0,0 +1,60 @@
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
username String @unique
|
||||
password String
|
||||
characters Character[]
|
||||
}
|
||||
|
||||
enum CharacterGender {
|
||||
MALE
|
||||
FEMALE
|
||||
}
|
||||
|
||||
enum CharacterRace {
|
||||
HUMAN
|
||||
ELF
|
||||
DWARF
|
||||
ORC
|
||||
GOBLIN
|
||||
}
|
||||
|
||||
model CharacterType {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
gender CharacterGender
|
||||
race CharacterRace
|
||||
characters Character[]
|
||||
characterSprites CharacterSprite[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model Character {
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
name String @unique
|
||||
hitpoints Int @default(100)
|
||||
mana Int @default(100)
|
||||
level Int @default(1)
|
||||
experience Int @default(0)
|
||||
role String @default("player")
|
||||
position_x Int @default(0)
|
||||
position_y Int @default(0)
|
||||
rotation Int @default(0)
|
||||
zoneId Int @default(1)
|
||||
zone Zone @relation(fields: [zoneId], references: [id], onDelete: Cascade)
|
||||
characterTypeId Int?
|
||||
characterType CharacterType? @relation(fields: [characterTypeId], references: [id], onDelete: Cascade)
|
||||
chats Chat[]
|
||||
items CharacterItem[]
|
||||
}
|
||||
|
||||
model CharacterItem {
|
||||
id Int @id @default(autoincrement())
|
||||
characterId Int
|
||||
character Character @relation(fields: [characterId], references: [id], onDelete: Cascade)
|
||||
itemId String
|
||||
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
|
||||
quantity Int
|
||||
}
|
74
prisma/schema/zone.prisma
Normal file
74
prisma/schema/zone.prisma
Normal file
@ -0,0 +1,74 @@
|
||||
model Tile {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
tags Json?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model Object {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
tags Json?
|
||||
origin_x Decimal @default(0)
|
||||
origin_y Decimal @default(0)
|
||||
isAnimated Boolean @default(false)
|
||||
frameSpeed Int @default(0)
|
||||
frameWidth Int @default(0)
|
||||
frameHeight Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
ZoneObject ZoneObject[]
|
||||
}
|
||||
|
||||
model Item {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
description String?
|
||||
stackable Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
characters CharacterItem[]
|
||||
}
|
||||
|
||||
model Zone {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
width Int @default(10)
|
||||
height Int @default(10)
|
||||
tiles Json?
|
||||
pvp Boolean @default(false)
|
||||
zoneEventTiles ZoneEventTile[]
|
||||
zoneObjects ZoneObject[]
|
||||
characters Character[]
|
||||
chats Chat[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model ZoneObject {
|
||||
id String @id @default(uuid())
|
||||
zoneId Int
|
||||
zone Zone @relation(fields: [zoneId], references: [id], onDelete: Cascade)
|
||||
objectId String
|
||||
object Object @relation(fields: [objectId], references: [id], onDelete: Cascade)
|
||||
depth Int @default(0)
|
||||
position_x Int @default(0)
|
||||
position_y Int @default(0)
|
||||
}
|
||||
|
||||
enum ZoneEventTileType {
|
||||
BLOCK
|
||||
WARP
|
||||
NPC
|
||||
ITEM
|
||||
}
|
||||
|
||||
model ZoneEventTile {
|
||||
id String @id @default(uuid())
|
||||
zoneId Int
|
||||
zone Zone @relation(fields: [zoneId], references: [id], onDelete: Cascade)
|
||||
type ZoneEventTileType
|
||||
position_x Int
|
||||
position_y Int
|
||||
}
|
Reference in New Issue
Block a user