From 608e62c2bd67271181dbbb7100cb7463c518ea50 Mon Sep 17 00:00:00 2001
From: "Torsten Schulz (local)"
Date: Wed, 26 Nov 2025 17:23:54 +0100
Subject: [PATCH] Implement cooldown feature for nobility advancement
- Added logic in FalukantService to calculate the next available advancement date based on the user's last advancement.
- Updated the frontend to display a cooldown message indicating when the user can next advance in nobility.
- Enhanced the NobilityView component to handle and format the next advancement date appropriately.
---
backend/services/falukantService.js | 10 +++++++++-
frontend/src/i18n/locales/de/falukant.json | 3 ++-
frontend/src/i18n/locales/en/falukant.json | 3 +++
frontend/src/views/falukant/NobilityView.vue | 16 ++++++++++++++--
4 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js
index 45e7b55..6671cd6 100644
--- a/backend/services/falukantService.js
+++ b/backend/services/falukantService.js
@@ -2907,6 +2907,13 @@ class FalukantService extends BaseService {
],
attributes: ['labelTr', 'level']
});
+ let nextAdvanceAt = null;
+ if (falukantUser.lastNobilityAdvanceAt) {
+ const last = new Date(falukantUser.lastNobilityAdvanceAt);
+ const next = new Date(last.getTime());
+ next.setDate(next.getDate() + 7);
+ nextAdvanceAt = next.toISOString();
+ }
const currentTitleLevel = nobility.level;
const nextTitle = await TitleOfNobility.findOne({
where: {
@@ -2922,7 +2929,8 @@ class FalukantService extends BaseService {
});
return {
current: nobility,
- next: nextTitle
+ next: nextTitle,
+ nextAdvanceAt
};
}
diff --git a/frontend/src/i18n/locales/de/falukant.json b/frontend/src/i18n/locales/de/falukant.json
index 8e9eed6..bae94e5 100644
--- a/frontend/src/i18n/locales/de/falukant.json
+++ b/frontend/src/i18n/locales/de/falukant.json
@@ -538,7 +538,8 @@
},
"advance": {
"confirm": "Aufsteigen beantragen"
- }
+ },
+ "cooldown": "Du kannst frühestens wieder am {date} aufsteigen."
},
"reputation": {
"title": "Reputation",
diff --git a/frontend/src/i18n/locales/en/falukant.json b/frontend/src/i18n/locales/en/falukant.json
index b4f1f22..a142aae 100644
--- a/frontend/src/i18n/locales/en/falukant.json
+++ b/frontend/src/i18n/locales/en/falukant.json
@@ -41,6 +41,9 @@
"raft": "Raft",
"sailing_ship": "Sailing ship"
}
+ },
+ "nobility": {
+ "cooldown": "You can only advance again on {date}."
}
}
}
\ No newline at end of file
diff --git a/frontend/src/views/falukant/NobilityView.vue b/frontend/src/views/falukant/NobilityView.vue
index 7137443..b7d96af 100644
--- a/frontend/src/views/falukant/NobilityView.vue
+++ b/frontend/src/views/falukant/NobilityView.vue
@@ -23,6 +23,9 @@
{{ $t('falukant.nobility.nextTitle') }}:
{{ $t(`falukant.titles.${gender}.${next.labelTr}`) }}
+
+ {{ $t('falukant.nobility.cooldown', { date: formatDate(nextAdvanceAt) }) }}
+
-
{{ $t(`falukant.nobility.requirement.${req.requirementType}`, { amount: formatCost(req.requirementValue) }) }}
@@ -32,7 +35,6 @@
{{ $t('falukant.nobility.advance.confirm') }}
{{ $t('falukant.nobility.advance.processing') }}
-
@@ -58,6 +60,7 @@
],
current: { labelTr: '', requirements: [], charactersWithNobleTitle: [] },
next: { labelTr: '', requirements: [] },
+ nextAdvanceAt: null,
isAdvancing: false
};
},
@@ -67,7 +70,11 @@
return this.current.charactersWithNobleTitle[0]?.gender || 'male';
},
canAdvance() {
- return true;
+ if (!this.next) return false;
+ if (!this.nextAdvanceAt) return true;
+ const now = new Date();
+ const nextDate = new Date(this.nextAdvanceAt);
+ return nextDate <= now;
}
},
async mounted() {
@@ -101,6 +108,7 @@
const { data } = await apiClient.get('/api/falukant/nobility');
this.current = data.current;
this.next = data.next;
+ this.nextAdvanceAt = data.nextAdvanceAt || null;
} catch (err) {
console.error('Error loading nobility:', err);
}
@@ -124,6 +132,10 @@
},
formatCost(val) {
return new Intl.NumberFormat(navigator.language, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(val);
+ },
+ formatDate(isoString) {
+ const d = new Date(isoString);
+ return d.toLocaleDateString();
}
}
};