Compare commits

...

5 Commits

Author SHA1 Message Date
541b8d32a8 feat: LizzieShawzin (#1525)
Reviewed-on: OpenWF/SpaceNinjaServer#1525
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-04-09 15:37:28 -07:00
74f9d1567f feat: handle QueuedDialogues in saveDialogue (#1524)
Reviewed-on: OpenWF/SpaceNinjaServer#1524
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-04-09 15:30:59 -07:00
02a4d2b30a feat: track KIM resets (#1528)
This was added in 38.5.0 for FlareRank1Convo3

Reviewed-on: OpenWF/SpaceNinjaServer#1528
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-04-09 15:28:29 -07:00
a8f174bce1 fix: don't duplicate FlavourItems (#1526)
Reviewed-on: OpenWF/SpaceNinjaServer#1526
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-04-09 15:26:40 -07:00
db1dd21924 ci: improve prettier coverage (#1523)
All prettier violations will now be reported, not just what eslint checks.

Reviewed-on: OpenWF/SpaceNinjaServer#1523
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-04-09 15:25:19 -07:00
7 changed files with 41 additions and 14 deletions

View File

@ -13,4 +13,13 @@ jobs:
- run: npm ci
- run: cp config.json.example config.json
- run: npm run verify
- run: npm run lint
- run: npm run lint:ci
- run: npm run prettier
- name: Fail if there are uncommitted changes
run: |
if [[ -n "$(git status --porcelain)" ]]; then
echo "Uncommitted changes detected:"
git status
git diff
exit 1
fi

View File

@ -9,6 +9,7 @@
"build": "tsc --incremental --sourceMap && ncp static/webui build/static/webui",
"verify": "tsgo --noEmit",
"lint": "eslint --ext .ts .",
"lint:ci": "eslint --ext .ts --rule \"prettier/prettier: off\" .",
"lint:fix": "eslint --fix --ext .ts .",
"prettier": "prettier --write .",
"update-translations": "cd scripts && node update-translations.js"

View File

@ -7,6 +7,8 @@ export const clearDialogueHistoryController: RequestHandler = async (req, res) =
const inventory = await getInventory(accountId);
const request = JSON.parse(String(req.body)) as IClearDialogueRequest;
if (inventory.DialogueHistory && inventory.DialogueHistory.Dialogues) {
inventory.DialogueHistory.Resets ??= 0;
inventory.DialogueHistory.Resets += 1;
for (const dialogueName of request.Dialogues) {
const index = inventory.DialogueHistory.Dialogues.findIndex(x => x.DialogueName == dialogueName);
if (index != -1) {

View File

@ -1,6 +1,7 @@
import { getInventory } from "@/src/services/inventoryService";
import { addEmailItem, getInventory } from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { ICompletedDialogue } from "@/src/types/inventoryTypes/inventoryTypes";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { logger } from "@/src/utils/logger";
import { RequestHandler } from "express";
@ -21,9 +22,10 @@ export const saveDialogueController: RequestHandler = async (req, res) => {
if (!inventory.DialogueHistory) {
throw new Error("bad inventory state");
}
if (request.QueuedDialogues.length != 0 || request.OtherDialogueInfos.length != 0) {
if (request.OtherDialogueInfos.length != 0) {
logger.error(`saveDialogue request not fully handled: ${String(req.body)}`);
}
const inventoryChanges: IInventoryChanges = {};
inventory.DialogueHistory.Dialogues ??= [];
let dialogue = inventory.DialogueHistory.Dialogues.find(x => x.DialogueName == request.DialogueName);
if (!dialogue) {
@ -36,6 +38,7 @@ export const saveDialogueController: RequestHandler = async (req, res) => {
AvailableGiftDate: new Date(0),
RankUpExpiry: new Date(0),
BountyChemExpiry: new Date(0),
QueuedDialogues: [],
Gifts: [],
Booleans: [],
Completed: [],
@ -45,9 +48,16 @@ export const saveDialogueController: RequestHandler = async (req, res) => {
}
dialogue.Rank = request.Rank;
dialogue.Chemistry = request.Chemistry;
//dialogue.QueuedDialogues = request.QueuedDialogues;
dialogue.QueuedDialogues = request.QueuedDialogues;
for (const bool of request.Booleans) {
dialogue.Booleans.push(bool);
if (bool == "LizzieShawzin") {
await addEmailItem(
inventory,
"/Lotus/Types/Items/EmailItems/LizzieShawzinSkinEmailItem",
inventoryChanges
);
}
}
for (const bool of request.ResetBooleans) {
const index = dialogue.Booleans.findIndex(x => x == bool);
@ -60,7 +70,7 @@ export const saveDialogueController: RequestHandler = async (req, res) => {
dialogue.AvailableDate = new Date(tomorrowAt0Utc);
await inventory.save();
res.json({
InventoryChanges: [],
InventoryChanges: inventoryChanges,
AvailableDate: { $date: { $numberLong: tomorrowAt0Utc.toString() } }
});
}
@ -77,7 +87,7 @@ interface SaveCompletedDialogueRequest {
Rank: number;
Chemistry: number;
CompletionType: number;
QueuedDialogues: string[]; // unsure
QueuedDialogues: string[];
Booleans: string[];
ResetBooleans: string[];
Data: ICompletedDialogue;

View File

@ -773,7 +773,7 @@ const dialogueSchema = new Schema<IDialogueDatabase>(
AvailableGiftDate: Date,
RankUpExpiry: Date,
BountyChemExpiry: Date,
//QueuedDialogues: ???
QueuedDialogues: { type: [String], default: [] },
Gifts: { type: [dialogueGiftSchema], default: [] },
Booleans: { type: [String], default: [] },
Completed: { type: [completedDialogueSchema], default: [] },
@ -797,6 +797,7 @@ dialogueSchema.set("toJSON", {
const dialogueHistorySchema = new Schema<IDialogueHistoryDatabase>(
{
YearIteration: { type: Number, required: true },
Resets: Number,
Dialogues: { type: [dialogueSchema], required: false }
},
{ _id: false }

View File

@ -1014,12 +1014,14 @@ export const addCustomization = (
customizationName: string,
inventoryChanges: IInventoryChanges = {}
): IInventoryChanges => {
if (!inventory.FlavourItems.find(x => x.ItemType == customizationName)) {
const flavourItemIndex = inventory.FlavourItems.push({ ItemType: customizationName }) - 1;
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
inventoryChanges.FlavourItems ??= [];
(inventoryChanges.FlavourItems as IFlavourItem[]).push(
inventory.FlavourItems[flavourItemIndex].toJSON<IFlavourItem>()
);
}
return inventoryChanges;
};

View File

@ -1074,11 +1074,13 @@ export interface IEndlessXpProgress {
export interface IDialogueHistoryClient {
YearIteration: number;
Resets?: number; // added in 38.5.0
Dialogues?: IDialogueClient[];
}
export interface IDialogueHistoryDatabase {
YearIteration: number;
Resets?: number;
Dialogues?: IDialogueDatabase[];
}
@ -1089,7 +1091,7 @@ export interface IDialogueClient {
AvailableGiftDate: IMongoDate;
RankUpExpiry: IMongoDate;
BountyChemExpiry: IMongoDate;
//QueuedDialogues: any[];
QueuedDialogues: string[];
Gifts: IDialogueGift[];
Booleans: string[];
Completed: ICompletedDialogue[];