forked from OpenWF/SpaceNinjaServer
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
b15ca46541 | |||
508440e0a6 | |||
41623807e1 |
@ -15,6 +15,12 @@ export const changeDojoRootController: RequestHandler = async (req, res) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Example POST body: {"pivot":[0, 0, -64],"components":"{\"670429301ca0a63848ccc467\":{\"R\":[0,0,0],\"P\":[0,3,32]},\"6704254a1ca0a63848ccb33c\":{\"R\":[0,0,0],\"P\":[0,9.25,-32]},\"670429461ca0a63848ccc731\":{\"R\":[-90,0,0],\"P\":[-47.999992370605,3,16]}}"}
|
||||||
|
if (req.body) {
|
||||||
|
logger.debug(`data provided to ${req.path}: ${String(req.body)}`);
|
||||||
|
throw new Error("dojo reparent operation should not need deco repositioning"); // because we always provide SortId
|
||||||
|
}
|
||||||
|
|
||||||
const idToNode: Record<string, INode> = {};
|
const idToNode: Record<string, INode> = {};
|
||||||
guild.DojoComponents.forEach(x => {
|
guild.DojoComponents.forEach(x => {
|
||||||
idToNode[x._id.toString()] = {
|
idToNode[x._id.toString()] = {
|
||||||
@ -43,23 +49,13 @@ export const changeDojoRootController: RequestHandler = async (req, res) => {
|
|||||||
newRoot.component.pp = undefined;
|
newRoot.component.pp = undefined;
|
||||||
newRoot.parent = undefined;
|
newRoot.parent = undefined;
|
||||||
|
|
||||||
// Don't even ask me why this is needed because I don't know either
|
// Set/update SortId in top-to-bottom order
|
||||||
const stack: INode[] = [newRoot];
|
const stack: INode[] = [newRoot];
|
||||||
let i = 0;
|
|
||||||
const idMap: Record<string, Types.ObjectId> = {};
|
|
||||||
while (stack.length != 0) {
|
while (stack.length != 0) {
|
||||||
const top = stack.shift()!;
|
const top = stack.shift()!;
|
||||||
idMap[top.component._id.toString()] = new Types.ObjectId(
|
top.component.SortId = new Types.ObjectId();
|
||||||
(++i).toString(16).padStart(8, "0") + top.component._id.toString().substr(8)
|
|
||||||
);
|
|
||||||
top.children.forEach(x => stack.push(x));
|
top.children.forEach(x => stack.push(x));
|
||||||
}
|
}
|
||||||
guild.DojoComponents.forEach(x => {
|
|
||||||
x._id = idMap[x._id.toString()];
|
|
||||||
if (x.pi) {
|
|
||||||
x.pi = idMap[x.pi.toString()];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
logger.debug("New tree:\n" + treeToString(newRoot));
|
logger.debug("New tree:\n" + treeToString(newRoot));
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ const dojoLeaderboardEntrySchema = new Schema<IDojoLeaderboardEntry>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const dojoComponentSchema = new Schema<IDojoComponentDatabase>({
|
const dojoComponentSchema = new Schema<IDojoComponentDatabase>({
|
||||||
|
SortId: Schema.Types.ObjectId,
|
||||||
pf: { type: String, required: true },
|
pf: { type: String, required: true },
|
||||||
ppf: String,
|
ppf: String,
|
||||||
pi: Schema.Types.ObjectId,
|
pi: Schema.Types.ObjectId,
|
||||||
|
@ -145,6 +145,7 @@ const apiRouter = express.Router();
|
|||||||
apiRouter.get("/abandonLibraryDailyTask.php", abandonLibraryDailyTaskController);
|
apiRouter.get("/abandonLibraryDailyTask.php", abandonLibraryDailyTaskController);
|
||||||
apiRouter.get("/abortDojoComponentDestruction.php", abortDojoComponentDestructionController);
|
apiRouter.get("/abortDojoComponentDestruction.php", abortDojoComponentDestructionController);
|
||||||
apiRouter.get("/cancelGuildAdvertisement.php", cancelGuildAdvertisementController);
|
apiRouter.get("/cancelGuildAdvertisement.php", cancelGuildAdvertisementController);
|
||||||
|
apiRouter.get("/changeDojoRoot.php", changeDojoRootController);
|
||||||
apiRouter.get("/changeGuildRank.php", changeGuildRankController);
|
apiRouter.get("/changeGuildRank.php", changeGuildRankController);
|
||||||
apiRouter.get("/checkDailyMissionBonus.php", checkDailyMissionBonusController);
|
apiRouter.get("/checkDailyMissionBonus.php", checkDailyMissionBonusController);
|
||||||
apiRouter.get("/claimLibraryDailyTaskReward.php", claimLibraryDailyTaskRewardController);
|
apiRouter.get("/claimLibraryDailyTaskReward.php", claimLibraryDailyTaskRewardController);
|
||||||
|
@ -147,6 +147,7 @@ export const getDojoClient = async (
|
|||||||
if (!componentId || dojoComponent._id.equals(componentId)) {
|
if (!componentId || dojoComponent._id.equals(componentId)) {
|
||||||
const clientComponent: IDojoComponentClient = {
|
const clientComponent: IDojoComponentClient = {
|
||||||
id: toOid(dojoComponent._id),
|
id: toOid(dojoComponent._id),
|
||||||
|
SortId: toOid(dojoComponent.SortId ?? dojoComponent._id), // always providing a SortId so decos don't need repositioning to reparent
|
||||||
pf: dojoComponent.pf,
|
pf: dojoComponent.pf,
|
||||||
ppf: dojoComponent.ppf,
|
ppf: dojoComponent.ppf,
|
||||||
Name: dojoComponent.Name,
|
Name: dojoComponent.Name,
|
||||||
|
@ -190,6 +190,7 @@ export interface IDojoComponentDatabase
|
|||||||
"id" | "SortId" | "pi" | "CompletionTime" | "DestructionTime" | "Decos" | "PaintBot"
|
"id" | "SortId" | "pi" | "CompletionTime" | "DestructionTime" | "Decos" | "PaintBot"
|
||||||
> {
|
> {
|
||||||
_id: Types.ObjectId;
|
_id: Types.ObjectId;
|
||||||
|
SortId?: Types.ObjectId;
|
||||||
pi?: Types.ObjectId;
|
pi?: Types.ObjectId;
|
||||||
CompletionTime?: Date;
|
CompletionTime?: Date;
|
||||||
CompletionLogPending?: boolean;
|
CompletionLogPending?: boolean;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user