forked from OpenWF/SpaceNinjaServer
fix: move getDialogue preconditions into the function itself (#2679)
Closes #2678 Reviewed-on: OpenWF/SpaceNinjaServer#2679 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
parent
9c232bfc1f
commit
5e1ff64cca
@ -20,8 +20,6 @@ export const saveDialogueController: RequestHandler = async (req, res) => {
|
||||
const tomorrowAt0Utc = config.noKimCooldowns
|
||||
? Date.now()
|
||||
: (Math.trunc(Date.now() / 86400_000) + 1) * 86400_000;
|
||||
inventory.DialogueHistory ??= {};
|
||||
inventory.DialogueHistory.Dialogues ??= [];
|
||||
const dialogue = getDialogue(inventory, request.DialogueName);
|
||||
dialogue.Rank = request.Rank;
|
||||
dialogue.Chemistry += request.Chemistry;
|
||||
|
||||
@ -2286,11 +2286,13 @@ export const cleanupInventory = (inventory: TInventoryDatabaseDocument): void =>
|
||||
};
|
||||
|
||||
export const getDialogue = (inventory: TInventoryDatabaseDocument, dialogueName: string): IDialogueDatabase => {
|
||||
let dialogue = inventory.DialogueHistory!.Dialogues!.find(x => x.DialogueName == dialogueName);
|
||||
inventory.DialogueHistory ??= {};
|
||||
inventory.DialogueHistory.Dialogues ??= [];
|
||||
let dialogue = inventory.DialogueHistory.Dialogues.find(x => x.DialogueName == dialogueName);
|
||||
if (!dialogue) {
|
||||
dialogue =
|
||||
inventory.DialogueHistory!.Dialogues![
|
||||
inventory.DialogueHistory!.Dialogues!.push({
|
||||
inventory.DialogueHistory.Dialogues[
|
||||
inventory.DialogueHistory.Dialogues.push({
|
||||
Rank: 0,
|
||||
Chemistry: 0,
|
||||
AvailableDate: new Date(0),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user