Implement church career information retrieval and update related components: Add a new method in FalukantService to fetch church career details for characters, including current and approved office levels. Enhance DashboardWidget, StatusBar, and ChurchView components to handle new church-related socket events and display relevant information. Update localization files for church-related terms and error messages in English, German, and Spanish.

This commit is contained in:
Torsten Schulz (local)
2026-03-23 11:05:48 +01:00
parent ce36315b58
commit 57ab85fe10
10 changed files with 749 additions and 24 deletions

View File

@@ -108,7 +108,7 @@ export default {
},
setupSocketListeners() {
this.teardownSocketListeners();
const daemonEvents = ['falukantUpdateStatus', 'falukantUpdateFamily', 'children_update', 'falukantUpdateProductionCertificate', 'stock_change', 'familychanged'];
const daemonEvents = ['falukantUpdateStatus', 'falukantUpdateFamily', 'falukantUpdateChurch', 'children_update', 'falukantUpdateProductionCertificate', 'stock_change', 'familychanged'];
if (this.daemonSocket) {
this._daemonMessageHandler = (event) => {
if (event.data === 'ping') return;
@@ -126,6 +126,9 @@ export default {
this._familySocketHandler = (data) => {
if (this.matchesCurrentUser(data)) this.queueFetchData();
};
this._churchSocketHandler = (data) => {
if (this.matchesCurrentUser(data)) this.queueFetchData();
};
this._childrenSocketHandler = (data) => {
if (this.matchesCurrentUser(data)) this.queueFetchData();
};
@@ -136,6 +139,7 @@ export default {
this.socket.on('falukantUpdateStatus', this._statusSocketHandler);
this.socket.on('falukantUpdateFamily', this._familySocketHandler);
this.socket.on('falukantUpdateChurch', this._churchSocketHandler);
this.socket.on('children_update', this._childrenSocketHandler);
this.socket.on('falukantUpdateProductionCertificate', this._productionCertificateSocketHandler);
this.socket.on('falukantBranchUpdate', this._branchSocketHandler);
@@ -149,6 +153,7 @@ export default {
if (this.socket) {
if (this._statusSocketHandler) this.socket.off('falukantUpdateStatus', this._statusSocketHandler);
if (this._familySocketHandler) this.socket.off('falukantUpdateFamily', this._familySocketHandler);
if (this._churchSocketHandler) this.socket.off('falukantUpdateChurch', this._churchSocketHandler);
if (this._childrenSocketHandler) this.socket.off('children_update', this._childrenSocketHandler);
if (this._productionCertificateSocketHandler) this.socket.off('falukantUpdateProductionCertificate', this._productionCertificateSocketHandler);
if (this._branchSocketHandler) this.socket.off('falukantBranchUpdate', this._branchSocketHandler);

View File

@@ -176,6 +176,7 @@ export default {
if (!this.socket) return;
this._statusSocketHandler = (data) => this.handleEvent({ event: 'falukantUpdateStatus', ...data });
this._familySocketHandler = (data) => this.handleEvent({ event: 'falukantUpdateFamily', ...data });
this._churchSocketHandler = (data) => this.handleEvent({ event: 'falukantUpdateChurch', ...data });
this._childrenSocketHandler = (data) => this.handleEvent({ event: 'children_update', ...data });
this._productionCertificateSocketHandler = (data) => this.handleEvent({ event: 'falukantUpdateProductionCertificate', ...data });
this._stockSocketHandler = (data) => this.handleEvent({ event: 'stock_change', ...data });
@@ -183,6 +184,7 @@ export default {
this.socket.on('falukantUpdateStatus', this._statusSocketHandler);
this.socket.on('falukantUpdateFamily', this._familySocketHandler);
this.socket.on('falukantUpdateChurch', this._churchSocketHandler);
this.socket.on('children_update', this._childrenSocketHandler);
this.socket.on('falukantUpdateProductionCertificate', this._productionCertificateSocketHandler);
this.socket.on('stock_change', this._stockSocketHandler);
@@ -192,6 +194,7 @@ export default {
if (this.socket) {
if (this._statusSocketHandler) this.socket.off('falukantUpdateStatus', this._statusSocketHandler);
if (this._familySocketHandler) this.socket.off('falukantUpdateFamily', this._familySocketHandler);
if (this._churchSocketHandler) this.socket.off('falukantUpdateChurch', this._churchSocketHandler);
if (this._childrenSocketHandler) this.socket.off('children_update', this._childrenSocketHandler);
if (this._productionCertificateSocketHandler) this.socket.off('falukantUpdateProductionCertificate', this._productionCertificateSocketHandler);
if (this._stockSocketHandler) this.socket.off('stock_change', this._stockSocketHandler);
@@ -204,7 +207,7 @@ export default {
this._daemonHandler = (event) => {
try {
const data = JSON.parse(event.data);
if (['falukantUpdateStatus', 'falukantUpdateFamily', 'children_update', 'falukantUpdateProductionCertificate', 'stock_change', 'familychanged'].includes(data.event)) {
if (['falukantUpdateStatus', 'falukantUpdateFamily', 'falukantUpdateChurch', 'children_update', 'falukantUpdateProductionCertificate', 'stock_change', 'familychanged'].includes(data.event)) {
this.handleEvent(data);
}
} catch (_) {}
@@ -243,6 +246,7 @@ export default {
switch (eventData.event) {
case 'falukantUpdateStatus':
case 'falukantUpdateFamily':
case 'falukantUpdateChurch':
case 'children_update':
case 'falukantUpdateProductionCertificate':
case 'stock_change':

View File

@@ -1024,10 +1024,18 @@
"church": {
"title": "Kirche",
"tabs": {
"baptism": "Taufen",
"current": "Aktuelle Positionen",
"available": "Verfügbare Positionen",
"applications": "Bewerbungen"
},
"summary": {
"highestCurrentOffice": "Höchstes aktuelles Amt",
"availableApplications": "Mögliche Bewerbungen",
"supervisedApplications": "Zu entscheidende Bewerbungen",
"guidance": "Kirchenämter steigen stufenweise auf. Über Bewerbungen entscheidet in der Regel das nächsthöhere Amt; falls dort kein Spieler sitzt, kann später ein NPC entscheiden.",
"none": "Noch kein Kirchenamt"
},
"current": {
"office": "Amt",
"region": "Region",
@@ -1039,11 +1047,25 @@
"office": "Amt",
"region": "Region",
"supervisor": "Vorgesetzter",
"decision": "Entscheidung durch",
"decisionType": {
"entry": "Direkter Einstieg",
"player": "Spieler",
"npc": "NPC",
"interim": "Interim"
},
"seats": "Verfügbare Plätze",
"action": "Aktion",
"apply": "Bewerben",
"applySuccess": "Bewerbung erfolgreich eingereicht.",
"applyError": "Fehler beim Einreichen der Bewerbung.",
"errors": {
"characterNotFound": "Dein Charakter konnte nicht gefunden werden.",
"officeTypeNotFound": "Das Kirchenamt wurde nicht gefunden.",
"churchCareerTooLow": "Deine bisherige kirchliche Laufbahn reicht für dieses Amt noch nicht aus.",
"noAvailableSeats": "Für dieses Kirchenamt sind derzeit keine Plätze frei.",
"applicationAlreadyExists": "Für dieses Kirchenamt in dieser Region besteht bereits eine offene Bewerbung."
},
"none": "Keine verfügbaren Positionen."
},
"applications": {

View File

@@ -651,10 +651,18 @@
"church": {
"title": "Church",
"tabs": {
"baptism": "Baptism",
"current": "Current Positions",
"available": "Available Positions",
"applications": "Applications"
},
"summary": {
"highestCurrentOffice": "Highest current office",
"availableApplications": "Possible applications",
"supervisedApplications": "Applications to decide",
"guidance": "Church offices usually progress step by step. Applications are normally decided by the next higher office; if no player holds it, an NPC may later decide.",
"none": "No church office yet"
},
"current": {
"office": "Office",
"region": "Region",
@@ -666,11 +674,25 @@
"office": "Office",
"region": "Region",
"supervisor": "Supervisor",
"decision": "Decision by",
"decisionType": {
"entry": "Direct entry",
"player": "Player",
"npc": "NPC",
"interim": "Interim"
},
"seats": "Available Seats",
"action": "Action",
"apply": "Apply",
"applySuccess": "Application submitted successfully.",
"applyError": "Error submitting application.",
"errors": {
"characterNotFound": "Your character could not be found.",
"officeTypeNotFound": "The church office could not be found.",
"churchCareerTooLow": "Your previous church career is not yet sufficient for this office.",
"noAvailableSeats": "There are currently no free seats for this church office.",
"applicationAlreadyExists": "There is already an open application for this church office in this region."
},
"none": "No available positions."
},
"applications": {

View File

@@ -967,6 +967,64 @@
},
"church": {
"title": "Iglesia",
"tabs": {
"baptism": "Bautizos",
"current": "Cargos actuales",
"available": "Cargos disponibles",
"applications": "Solicitudes"
},
"summary": {
"highestCurrentOffice": "Cargo actual más alto",
"availableApplications": "Solicitudes posibles",
"supervisedApplications": "Solicitudes por decidir",
"guidance": "Los cargos eclesiásticos suelen ascender paso a paso. Las solicitudes normalmente las decide el cargo inmediatamente superior; si no hay jugador en ese puesto, más adelante puede decidir un NPC.",
"none": "Todavía sin cargo eclesiástico"
},
"current": {
"office": "Cargo",
"region": "Región",
"holder": "Titular",
"supervisor": "Superior",
"none": "No hay cargos actuales."
},
"available": {
"office": "Cargo",
"region": "Región",
"supervisor": "Superior",
"decision": "Decide",
"decisionType": {
"entry": "Acceso directo",
"player": "Jugador",
"npc": "NPC",
"interim": "Interino"
},
"seats": "Plazas disponibles",
"action": "Acción",
"apply": "Solicitar",
"applySuccess": "Solicitud enviada correctamente.",
"applyError": "Error al enviar la solicitud.",
"errors": {
"characterNotFound": "No se pudo encontrar tu personaje.",
"officeTypeNotFound": "No se encontró el cargo eclesiástico.",
"churchCareerTooLow": "Tu trayectoria eclesiástica todavía no es suficiente para este cargo.",
"noAvailableSeats": "Actualmente no hay plazas libres para este cargo eclesiástico.",
"applicationAlreadyExists": "Ya existe una solicitud abierta para este cargo eclesiástico en esta región."
},
"none": "No hay cargos disponibles."
},
"applications": {
"office": "Cargo",
"region": "Región",
"applicant": "Solicitante",
"date": "Fecha",
"action": "Acción",
"approve": "Aceptar",
"reject": "Rechazar",
"approveSuccess": "Solicitud aceptada.",
"rejectSuccess": "Solicitud rechazada.",
"decideError": "Error al tomar la decisión.",
"none": "No hay solicitudes."
},
"baptism": {
"title": "Bautizos",
"table": {

View File

@@ -3,6 +3,25 @@
<StatusBar />
<div class="church-content">
<h2>{{ $t('falukant.church.title') }}</h2>
<div class="church-summary">
<div class="church-summary-card">
<div class="church-summary-label">{{ $t('falukant.church.summary.highestCurrentOffice') }}</div>
<div class="church-summary-value">{{ highestCurrentOfficeLabel }}</div>
</div>
<div class="church-summary-card">
<div class="church-summary-label">{{ $t('falukant.church.summary.availableApplications') }}</div>
<div class="church-summary-value">{{ availablePositions.length }}</div>
</div>
<div class="church-summary-card">
<div class="church-summary-label">{{ $t('falukant.church.summary.supervisedApplications') }}</div>
<div class="church-summary-value">{{ supervisedApplications.length }}</div>
</div>
</div>
<div class="church-guidance">
<p>{{ $t('falukant.church.summary.guidance') }}</p>
</div>
<SimpleTabs v-model="activeTab" :tabs="tabs" />
<div class="tab-content">
@@ -87,6 +106,7 @@
<th>{{ $t('falukant.church.available.office') }}</th>
<th>{{ $t('falukant.church.available.region') }}</th>
<th>{{ $t('falukant.church.available.supervisor') }}</th>
<th>{{ $t('falukant.church.available.decision') }}</th>
<th>{{ $t('falukant.church.available.seats') }}</th>
<th>{{ $t('falukant.church.available.action') }}</th>
</tr>
@@ -101,6 +121,7 @@
</span>
<span v-else></span>
</td>
<td>{{ decisionModeLabel(pos.decisionMode) }}</td>
<td>{{ pos.availableSeats }}</td>
<td>
<button @click="applyForPosition(pos)" :disabled="pos.availableSeats === 0">
@@ -109,7 +130,7 @@
</td>
</tr>
<tr v-if="!availablePositions.length">
<td colspan="5">{{ $t('falukant.church.available.none') }}</td>
<td colspan="6">{{ $t('falukant.church.available.none') }}</td>
</tr>
</tbody>
</table>
@@ -166,6 +187,7 @@ import MessageDialog from '@/dialogues/standard/MessageDialog.vue'
import ErrorDialog from '@/dialogues/standard/ErrorDialog.vue'
import apiClient from '@/utils/axios.js'
import SimpleTabs from '@/components/SimpleTabs.vue'
import { mapState } from 'vuex'
export default {
name: 'ChurchView',
@@ -196,9 +218,37 @@ export default {
}
}
},
computed: {
...mapState(['socket', 'daemonSocket', 'user']),
highestCurrentOffice() {
if (!this.currentPositions.length) {
return null;
}
return [...this.currentPositions]
.filter(pos => this.isOwnPosition(pos))
.sort((a, b) => this.officeRank(b.officeType?.name) - this.officeRank(a.officeType?.name))[0] || null;
},
highestCurrentOfficeLabel() {
if (!this.highestCurrentOffice?.officeType?.name) {
return this.$t('falukant.church.summary.none');
}
return this.$t(`falukant.church.offices.${this.highestCurrentOffice.officeType.name}`);
}
},
async mounted() {
await this.loadNotBaptisedChildren();
await this.loadOwnCharacterId();
await Promise.all([
this.loadCurrentPositions(),
this.loadAvailablePositions(),
this.loadSupervisedApplications()
]);
this.setupSocketEvents();
this.setupDaemonListeners();
},
beforeUnmount() {
this.teardownSocketEvents();
this.teardownDaemonListeners();
},
watch: {
activeTab(newTab) {
@@ -212,6 +262,90 @@ export default {
}
},
methods: {
matchesCurrentUser(eventData) {
if (eventData?.user_id == null) {
return true;
}
const currentIds = [this.user?.id, this.user?.hashedId]
.filter(Boolean)
.map((value) => String(value));
return currentIds.includes(String(eventData.user_id));
},
setupSocketEvents() {
this.teardownSocketEvents();
if (!this.socket) {
setTimeout(() => this.setupSocketEvents(), 1000);
return;
}
this._statusSocketHandler = (data) => this.handleEvent({ event: 'falukantUpdateStatus', ...data });
this._churchSocketHandler = (data) => this.handleEvent({ event: 'falukantUpdateChurch', ...data });
this.socket.on('falukantUpdateStatus', this._statusSocketHandler);
this.socket.on('falukantUpdateChurch', this._churchSocketHandler);
},
teardownSocketEvents() {
if (!this.socket) return;
if (this._statusSocketHandler) this.socket.off('falukantUpdateStatus', this._statusSocketHandler);
if (this._churchSocketHandler) this.socket.off('falukantUpdateChurch', this._churchSocketHandler);
},
setupDaemonListeners() {
this.teardownDaemonListeners();
if (!this.daemonSocket) return;
this._daemonChurchHandler = (event) => {
if (event.data === 'ping') return;
try {
const message = JSON.parse(event.data);
if (['falukantUpdateStatus', 'falukantUpdateChurch'].includes(message.event)) {
this.handleEvent(message);
}
} catch (_) {}
};
this.daemonSocket.addEventListener('message', this._daemonChurchHandler);
},
teardownDaemonListeners() {
if (this.daemonSocket && this._daemonChurchHandler) {
this.daemonSocket.removeEventListener('message', this._daemonChurchHandler);
this._daemonChurchHandler = null;
}
},
queueChurchRefresh({ current = true, available = true, applications = true } = {}) {
if (this._pendingChurchRefresh) {
clearTimeout(this._pendingChurchRefresh);
}
this._pendingChurchRefresh = setTimeout(async () => {
this._pendingChurchRefresh = null;
const tasks = [];
if (current) tasks.push(this.loadCurrentPositions());
if (available) tasks.push(this.loadAvailablePositions());
if (applications) tasks.push(this.loadSupervisedApplications());
await Promise.all(tasks);
}, 120);
},
handleEvent(eventData) {
if (!this.matchesCurrentUser(eventData)) {
return;
}
switch (eventData.event) {
case 'falukantUpdateStatus':
this.queueChurchRefresh();
break;
case 'falukantUpdateChurch':
switch (eventData.reason) {
case 'applications':
this.queueChurchRefresh({ current: false, available: false, applications: true });
break;
case 'npc_decision':
this.queueChurchRefresh({ current: true, available: true, applications: true });
break;
case 'appointment':
case 'vacancy_fill':
case 'promotion':
default:
this.queueChurchRefresh({ current: true, available: true, applications: false });
break;
}
break;
}
},
async loadNotBaptisedChildren() {
try {
const { data } = await apiClient.get('/api/falukant/family/notbaptised')
@@ -292,6 +426,24 @@ export default {
}
return pos.character.id === this.ownCharacterId;
},
officeRank(name) {
const ranks = {
'lay-preacher': 0,
'village-priest': 1,
'parish-priest': 2,
dean: 3,
archdeacon: 4,
bishop: 5,
archbishop: 6,
cardinal: 7,
pope: 8
};
return ranks[name] ?? -1;
},
decisionModeLabel(mode) {
const key = `falukant.church.available.decisionType.${mode || 'interim'}`;
return this.$te(key) ? this.$t(key) : mode || '—';
},
async applyForPosition(position) {
try {
const regionId = position.regionId || position.region?.id;
@@ -310,7 +462,7 @@ export default {
} catch (err) {
console.error('Error applying for position', err);
const errorMsg = err.response?.data?.message || 'falukant.church.available.applyError';
this.$root.$refs.errorDialog?.open(`tr:${errorMsg}`);
this.$root.$refs.errorDialog?.open(errorMsg.startsWith('falukant.') ? `tr:${errorMsg}` : `tr:falukant.church.available.applyError`);
}
},
async decideOnApplication(applicationId, decision) {
@@ -370,6 +522,35 @@ h2 {
margin-top: 1rem;
}
.church-summary {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 0.75rem;
margin: 1rem 0 0.75rem;
}
.church-summary-card,
.church-guidance {
border: 1px solid #ddd;
background: #fff;
padding: 0.85rem 1rem;
border-radius: 8px;
}
.church-summary-label {
font-size: 0.85rem;
color: #666;
}
.church-summary-value {
margin-top: 0.25rem;
font-weight: 700;
}
.church-guidance {
margin-bottom: 1rem;
}
input[type="text"] {
width: 140px;
margin-right: 0.5rem;

View File

@@ -455,6 +455,7 @@ export default {
'falukantUpdateStatus',
'falukantUpdateFamily',
'children_update',
'falukantUpdateChurch',
'familychanged',
'falukant_family_scandal_hint'
].includes(message.event)) {
@@ -513,7 +514,7 @@ export default {
} else if (eventData.reason === 'lover_birth') {
showInfo(this, this.$t('falukant.family.notifications.loverBirth'));
}
this.queueFamilyRefresh({ reloadCharacter: eventData.reason === 'monthly' || eventData.reason === 'daily' });
this.queueFamilyRefresh({ reloadCharacter: ['monthly', 'daily', 'lover_installment'].includes(eventData.reason) });
break;
}
},

View File

@@ -356,6 +356,7 @@ export default {
this.socket.off("falukantUserUpdated", this.fetchFalukantUser);
this.socket.off("falukantUpdateStatus");
this.socket.off("falukantUpdateFamily");
this.socket.off("falukantUpdateChurch");
this.socket.off("falukantUpdateProductionCertificate");
this.socket.off("children_update");
this.socket.off("falukantBranchUpdate");
@@ -372,6 +373,9 @@ export default {
this.socket.on("falukantUpdateFamily", (data) => {
this.handleEvent({ event: 'falukantUpdateFamily', ...data });
});
this.socket.on("falukantUpdateChurch", (data) => {
this.handleEvent({ event: 'falukantUpdateChurch', ...data });
});
this.socket.on("falukantUpdateProductionCertificate", (data) => {
this.handleEvent({ event: 'falukantUpdateProductionCertificate', ...data });
});
@@ -441,6 +445,7 @@ export default {
switch (eventData.event) {
case 'falukantUpdateStatus':
case 'falukantUpdateFamily':
case 'falukantUpdateChurch':
case 'falukantUpdateProductionCertificate':
case 'children_update':
case 'falukantBranchUpdate':