build config changes
All checks were successful
Galvanic Corrosion Cross-Compile / build (push) Successful in 1m50s
All checks were successful
Galvanic Corrosion Cross-Compile / build (push) Successful in 1m50s
* Commit hash shipped with builds
* Post & pre-build events
* Objective fixes
* Orientation challenge filler
* Custom Rooms base
- Currently cannot save rooms (CDN not set up)
* Moved root path to path.ts
* Room cloning
* Rewrote instances - the whole thing
* Relationships are still untested
* Charades Words
* AG Room fetch
* Private room matchmaking
* Socket fixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* Galvanic Corrosion - Rec Room custom server for communities.
|
||||
<https://gitea.proxnet.dev/zombieb/galvanic-corrosion>
|
||||
Copyright (C) 2025 @zombieb (Discord / proxnet Gitea)
|
||||
Copyright (C) 2025 @zombieb (Discord / proxnet Gitea)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
@@ -15,11 +15,13 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
import { APIUtils } from "../../apiutils.ts";
|
||||
import { z } from "zod";
|
||||
import { APIUtils, NoBody } from "../../apiutils.ts";
|
||||
import Rooms from "../../data/content/rooms.ts";
|
||||
import { RoomDataTypes } from "../../data/content/rooms/DataTypes.ts";
|
||||
import { AuthType } from "../../data/users.ts";
|
||||
import express from "express";
|
||||
import { RoomFactory } from "../../data/content/rooms/RoomFactory.ts";
|
||||
|
||||
export const route = APIUtils.createRouter("/rooms");
|
||||
|
||||
@@ -54,7 +56,19 @@ route.router.get('/v2/myrooms',
|
||||
APIUtils.Authentication,
|
||||
APIUtils.AuthenticationType(AuthType.Game),
|
||||
|
||||
APIUtils.emptyArrayResponse
|
||||
async (_rq, rs) => {
|
||||
const ids = await rs.locals.profile.Rooms.getOwnedRoomIds();
|
||||
if (ids.length == 0) {
|
||||
rs.json([]);
|
||||
return;
|
||||
}
|
||||
|
||||
const roomFactoriesPreInit = ids.map(id => new RoomFactory({ id: id }));
|
||||
const roomFactories = (await Promise.all(roomFactoriesPreInit.map(factory => factory.init()))).filter(val => val !== null);
|
||||
const detailsPromises = (await Promise.all(roomFactories.map(factory => factory.export())));
|
||||
|
||||
rs.json(detailsPromises.map(roomDetails => roomDetails.Room));
|
||||
},
|
||||
|
||||
);
|
||||
|
||||
@@ -119,8 +133,58 @@ route.router.post('/v1/roomRolePermissions',
|
||||
APIUtils.Authentication,
|
||||
APIUtils.AuthenticationType(AuthType.Game),
|
||||
|
||||
(rq, rs) => {
|
||||
(_rq, rs) => {
|
||||
rs.sendStatus(200);
|
||||
},
|
||||
|
||||
);
|
||||
|
||||
route.router.get('/v1/agRoomIds',
|
||||
|
||||
APIUtils.Authentication,
|
||||
APIUtils.AuthenticationType(AuthType.Game),
|
||||
|
||||
async (_rq, rs) => {
|
||||
|
||||
const rooms = await Rooms.getAllBuiltinRoomGenerations();
|
||||
rs.json(rooms.map(det => det.Room.RoomId));
|
||||
|
||||
},
|
||||
|
||||
);
|
||||
|
||||
const CloneRoomSchema = z.object({
|
||||
Name: z.string(),
|
||||
RoomId: z.number()
|
||||
});
|
||||
interface CloneRoomBody {
|
||||
Name: string,
|
||||
RoomId: number
|
||||
}
|
||||
|
||||
route.router.post('/v1/clone',
|
||||
|
||||
APIUtils.Authentication,
|
||||
APIUtils.AuthenticationType(AuthType.Game),
|
||||
express.json(),
|
||||
APIUtils.validateRequestBody(CloneRoomSchema),
|
||||
|
||||
async (rq: express.Request<NoBody, NoBody, CloneRoomBody>, rs: express.Response) => {
|
||||
|
||||
const room = await Rooms.cloneRoom(rq.body.RoomId, rq.body.Name, rs.locals.profile);
|
||||
|
||||
const masterRoomFactory = await new RoomFactory({ id: rq.body.RoomId }).init();
|
||||
|
||||
rs.json({
|
||||
Result: room.result,
|
||||
RoomDetails: room.result == RoomDataTypes.CreateModifyRoomStatus.Success ? await room.factory?.export() : await masterRoomFactory?.export()
|
||||
});
|
||||
|
||||
if (
|
||||
room.result == RoomDataTypes.CreateModifyRoomStatus.Success
|
||||
&& room.factory
|
||||
) rs.locals.profile.Rooms.addOwnedRoomId(room.factory.RoomId);
|
||||
|
||||
},
|
||||
|
||||
);
|
||||
Reference in New Issue
Block a user