worked on wall logics
This commit is contained in:
parent
890a4bdb88
commit
893e69244d
15
package-lock.json
generated
15
package-lock.json
generated
@ -320,9 +320,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.11.3",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
|
||||
"integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==",
|
||||
"version": "8.12.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz",
|
||||
"integrity": "sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
@ -332,10 +332,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-walk": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz",
|
||||
"integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==",
|
||||
"version": "8.3.3",
|
||||
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz",
|
||||
"integrity": "sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"acorn": "^8.11.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
|
@ -34,6 +34,20 @@ CREATE TABLE `Zone` (
|
||||
`width` INTEGER NOT NULL,
|
||||
`height` INTEGER NOT NULL,
|
||||
`tiles` JSON NOT NULL,
|
||||
`walls` JSON NOT NULL,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `ZoneDecoration` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`zoneId` INTEGER NOT NULL,
|
||||
`type` INTEGER NOT NULL,
|
||||
`position_x` INTEGER NOT NULL,
|
||||
`position_y` INTEGER NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
@ -50,13 +64,16 @@ CREATE TABLE `Chat` (
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `Character` ADD CONSTRAINT `Character_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `Character` ADD CONSTRAINT `Character_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `Character` ADD CONSTRAINT `Character_zoneId_fkey` FOREIGN KEY (`zoneId`) REFERENCES `Zone`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `Character` ADD CONSTRAINT `Character_zoneId_fkey` FOREIGN KEY (`zoneId`) REFERENCES `Zone`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `Chat` ADD CONSTRAINT `Chat_characterId_fkey` FOREIGN KEY (`characterId`) REFERENCES `Character`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `ZoneDecoration` ADD CONSTRAINT `ZoneDecoration_zoneId_fkey` FOREIGN KEY (`zoneId`) REFERENCES `Zone`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `Chat` ADD CONSTRAINT `Chat_zoneId_fkey` FOREIGN KEY (`zoneId`) REFERENCES `Zone`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `Chat` ADD CONSTRAINT `Chat_characterId_fkey` FOREIGN KEY (`characterId`) REFERENCES `Character`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `Chat` ADD CONSTRAINT `Chat_zoneId_fkey` FOREIGN KEY (`zoneId`) REFERENCES `Zone`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
@ -29,7 +29,7 @@ model User {
|
||||
model Character {
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
name String @unique
|
||||
hitpoints Int @default(100)
|
||||
mana Int @default(100)
|
||||
@ -40,26 +40,39 @@ model Character {
|
||||
position_y Int
|
||||
rotation Int
|
||||
zoneId Int
|
||||
zone Zone @relation(fields: [zoneId], references: [id])
|
||||
zone Zone @relation(fields: [zoneId], references: [id], onDelete: Cascade)
|
||||
chats Chat[]
|
||||
}
|
||||
|
||||
model Zone {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
width Int
|
||||
height Int
|
||||
tiles Json
|
||||
characters Character[]
|
||||
chats Chat[]
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
width Int
|
||||
height Int
|
||||
tiles Json
|
||||
walls Json
|
||||
decorations ZoneDecoration[]
|
||||
characters Character[]
|
||||
chats Chat[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model ZoneDecoration {
|
||||
id Int @id @default(autoincrement())
|
||||
zoneId Int
|
||||
zone Zone @relation(fields: [zoneId], references: [id], onDelete: Cascade)
|
||||
type Int
|
||||
position_x Int
|
||||
position_y Int
|
||||
}
|
||||
|
||||
model Chat {
|
||||
id Int @id @default(autoincrement())
|
||||
characterId Int
|
||||
character Character @relation(fields: [characterId], references: [id])
|
||||
character Character @relation(fields: [characterId], references: [id], onDelete: Cascade)
|
||||
zoneId Int
|
||||
zone Zone @relation(fields: [zoneId], references: [id])
|
||||
zone Zone @relation(fields: [zoneId], references: [id], onDelete: Cascade)
|
||||
message String
|
||||
createdAt DateTime
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ interface IZoneLoad {
|
||||
width: number;
|
||||
height: number;
|
||||
tiles: number[][];
|
||||
walls: number[][];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -21,6 +22,8 @@ export default function (socket: TSocket, io: Server) {
|
||||
socket.on('gm:zone_editor:zone:save', async (data: IZoneLoad) => {
|
||||
console.log(`---GM ${socket.character?.id} has saved zone via zone editor.`);
|
||||
|
||||
console.log(data);
|
||||
|
||||
if (!data.zoneId) {
|
||||
console.log(`---Zone id not provided.`);
|
||||
return;
|
||||
@ -38,7 +41,8 @@ export default function (socket: TSocket, io: Server) {
|
||||
data.name,
|
||||
data.width,
|
||||
data.height,
|
||||
data.tiles
|
||||
data.tiles,
|
||||
data.walls
|
||||
);
|
||||
|
||||
zone = await ZoneRepository.getById(data.zoneId);
|
||||
|
@ -33,14 +33,15 @@ class ZoneRepository {
|
||||
}
|
||||
}
|
||||
|
||||
async create(name: string, width: number, height: number, tiles: any): Promise<Zone> {
|
||||
async create(name: string, width: number, height: number, tiles: number[][], walls: number[][]): Promise<Zone> {
|
||||
try {
|
||||
return await prisma.zone.create({
|
||||
data: {
|
||||
name: name,
|
||||
width: width,
|
||||
height: height,
|
||||
tiles: tiles
|
||||
tiles: tiles,
|
||||
walls: walls,
|
||||
}
|
||||
});
|
||||
} catch (error: any) {
|
||||
@ -49,7 +50,7 @@ class ZoneRepository {
|
||||
}
|
||||
}
|
||||
|
||||
async update(id: number, name: string, width: number, height: number, tiles: any): Promise<Zone> {
|
||||
async update(id: number, name: string, width: number, height: number, tiles: number[][], walls: number[][]): Promise<Zone> {
|
||||
try {
|
||||
return await prisma.zone.update({
|
||||
where: {
|
||||
@ -59,7 +60,8 @@ class ZoneRepository {
|
||||
name: name,
|
||||
width: width,
|
||||
height: height,
|
||||
tiles: tiles
|
||||
tiles: tiles,
|
||||
walls: walls,
|
||||
}
|
||||
});
|
||||
} catch (error: any) {
|
||||
|
@ -16,6 +16,17 @@ class ZoneService
|
||||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
|
||||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
], [
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
|
||||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
|
||||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
|
||||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
|
||||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
|
||||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
|
||||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
|
||||
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
])
|
||||
console.log("Demo zone created.");
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user