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": {
|
"node_modules/acorn": {
|
||||||
"version": "8.11.3",
|
"version": "8.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz",
|
||||||
"integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==",
|
"integrity": "sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"acorn": "bin/acorn"
|
"acorn": "bin/acorn"
|
||||||
@ -332,10 +332,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/acorn-walk": {
|
"node_modules/acorn-walk": {
|
||||||
"version": "8.3.2",
|
"version": "8.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz",
|
||||||
"integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==",
|
"integrity": "sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"acorn": "^8.11.0"
|
||||||
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.4.0"
|
"node": ">=0.4.0"
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,20 @@ CREATE TABLE `Zone` (
|
|||||||
`width` INTEGER NOT NULL,
|
`width` INTEGER NOT NULL,
|
||||||
`height` INTEGER NOT NULL,
|
`height` INTEGER NOT NULL,
|
||||||
`tiles` JSON 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`)
|
PRIMARY KEY (`id`)
|
||||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
@ -50,13 +64,16 @@ CREATE TABLE `Chat` (
|
|||||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
-- AddForeignKey
|
-- 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
|
-- 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
|
-- 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
|
-- 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 {
|
model Character {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
userId Int
|
userId Int
|
||||||
user User @relation(fields: [userId], references: [id])
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
name String @unique
|
name String @unique
|
||||||
hitpoints Int @default(100)
|
hitpoints Int @default(100)
|
||||||
mana Int @default(100)
|
mana Int @default(100)
|
||||||
@ -40,7 +40,7 @@ model Character {
|
|||||||
position_y Int
|
position_y Int
|
||||||
rotation Int
|
rotation Int
|
||||||
zoneId Int
|
zoneId Int
|
||||||
zone Zone @relation(fields: [zoneId], references: [id])
|
zone Zone @relation(fields: [zoneId], references: [id], onDelete: Cascade)
|
||||||
chats Chat[]
|
chats Chat[]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,16 +50,29 @@ model Zone {
|
|||||||
width Int
|
width Int
|
||||||
height Int
|
height Int
|
||||||
tiles Json
|
tiles Json
|
||||||
|
walls Json
|
||||||
|
decorations ZoneDecoration[]
|
||||||
characters Character[]
|
characters Character[]
|
||||||
chats Chat[]
|
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 {
|
model Chat {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
characterId Int
|
characterId Int
|
||||||
character Character @relation(fields: [characterId], references: [id])
|
character Character @relation(fields: [characterId], references: [id], onDelete: Cascade)
|
||||||
zoneId Int
|
zoneId Int
|
||||||
zone Zone @relation(fields: [zoneId], references: [id])
|
zone Zone @relation(fields: [zoneId], references: [id], onDelete: Cascade)
|
||||||
message String
|
message String
|
||||||
createdAt DateTime
|
createdAt DateTime
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ interface IZoneLoad {
|
|||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
tiles: 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) => {
|
socket.on('gm:zone_editor:zone:save', async (data: IZoneLoad) => {
|
||||||
console.log(`---GM ${socket.character?.id} has saved zone via zone editor.`);
|
console.log(`---GM ${socket.character?.id} has saved zone via zone editor.`);
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
if (!data.zoneId) {
|
if (!data.zoneId) {
|
||||||
console.log(`---Zone id not provided.`);
|
console.log(`---Zone id not provided.`);
|
||||||
return;
|
return;
|
||||||
@ -38,7 +41,8 @@ export default function (socket: TSocket, io: Server) {
|
|||||||
data.name,
|
data.name,
|
||||||
data.width,
|
data.width,
|
||||||
data.height,
|
data.height,
|
||||||
data.tiles
|
data.tiles,
|
||||||
|
data.walls
|
||||||
);
|
);
|
||||||
|
|
||||||
zone = await ZoneRepository.getById(data.zoneId);
|
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 {
|
try {
|
||||||
return await prisma.zone.create({
|
return await prisma.zone.create({
|
||||||
data: {
|
data: {
|
||||||
name: name,
|
name: name,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
tiles: tiles
|
tiles: tiles,
|
||||||
|
walls: walls,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error: any) {
|
} 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 {
|
try {
|
||||||
return await prisma.zone.update({
|
return await prisma.zone.update({
|
||||||
where: {
|
where: {
|
||||||
@ -59,7 +60,8 @@ class ZoneRepository {
|
|||||||
name: name,
|
name: name,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
tiles: tiles
|
tiles: tiles,
|
||||||
|
walls: walls,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error: any) {
|
} 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, 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, 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.");
|
console.log("Demo zone created.");
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user