Some falukant fixes, added undeground ui - no save right now, changed menu (and verification)
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
:columns="branchColumns"
|
||||
v-model="localSelectedBranch"
|
||||
:placeholder="$t('falukant.branch.selection.placeholder')"
|
||||
@input="updateSelectedBranch"
|
||||
@update:modelValue="updateSelectedBranch"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
@@ -70,7 +70,6 @@ export default {
|
||||
},
|
||||
|
||||
handleCreateBranch() {
|
||||
// wird ausgelöst, sobald der Dialog onConfirm erfolgreich abschließt
|
||||
this.$emit('createBranch');
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,120 +1,141 @@
|
||||
<template>
|
||||
<div class="director-info">
|
||||
<h3>{{ $t('falukant.branch.director.title') }}</h3>
|
||||
<div v-if="!director || director === null">
|
||||
<button @click="openNewDirectorDialog">{{ $t('falukant.branch.director.actions.new') }}</button>
|
||||
<div class="director-info">
|
||||
<h3>{{ $t('falukant.branch.director.title') }}</h3>
|
||||
<div v-if="!director || director === null">
|
||||
<button @click="openNewDirectorDialog">{{ $t('falukant.branch.director.actions.new') }}</button>
|
||||
</div>
|
||||
<div v-else class="director-info-container">
|
||||
<div>
|
||||
<table>
|
||||
<tr>
|
||||
<td>{{ $t('falukant.branch.director.name') }}</td>
|
||||
<td>
|
||||
{{ $t('falukant.titles.' + director.character.gender + '.' + director.character.title) }}
|
||||
{{ director.character.name }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ $t('falukant.branch.director.salary') }}</td>
|
||||
<td>{{ director.income }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ $t('falukant.branch.director.satisfaction') }}</td>
|
||||
<td>{{ director.satisfaction }} %</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div v-else class="director-info-container">
|
||||
<div>
|
||||
<table>
|
||||
<tr>
|
||||
<td>{{ $t('falukant.branch.director.name') }}</td>
|
||||
<td>
|
||||
{{ $t('falukant.titles.' + director.character.gender + '.' + director.character.title) }}
|
||||
{{ director.character.name }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ $t('falukant.branch.director.salary') }}</td>
|
||||
<td>{{ director.income }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ $t('falukant.branch.director.satisfaction') }}</td>
|
||||
<td>{{ director.satisfaction }} %</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<table>
|
||||
<tr>
|
||||
<td><button @click="fireDirector">{{ $t('falukant.branch.director.fire') }}</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><button @click="teachDirector">{{ $t('falukant.branch.director.teach') }}</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" v-model="director.mayProduce" @change="saveSetting('mayProduce', director.mayProduce)">
|
||||
{{ $t('falukant.branch.director.produce') }}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- Ähnliche Checkboxen für maySell und mayStartTransport -->
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<table>
|
||||
<tr>
|
||||
<td><button @click="fireDirector">{{ $t('falukant.branch.director.fire') }}</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><button @click="teachDirector">{{ $t('falukant.branch.director.teach') }}</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" v-model="director.mayProduce"
|
||||
@change="saveSetting('mayProduce', director.mayProduce)">
|
||||
{{ $t('falukant.branch.director.produce') }}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- Ähnliche Checkboxen für maySell und mayStartTransport -->
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<NewDirectorDialog ref="newDirectorDialog" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import apiClient from '@/utils/axios.js';
|
||||
import NewDirectorDialog from '@/dialogues/falukant/NewDirectorDialog.vue';
|
||||
|
||||
export default {
|
||||
name: "DirectorInfo",
|
||||
props: { branchId: { type: Number, required: true } },
|
||||
components: {
|
||||
NewDirectorDialog
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
director: null,
|
||||
showNewDirectorDialog: false,
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
</div>
|
||||
<NewDirectorDialog ref="newDirectorDialog" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import apiClient from '@/utils/axios.js';
|
||||
import NewDirectorDialog from '@/dialogues/falukant/NewDirectorDialog.vue';
|
||||
|
||||
export default {
|
||||
name: "DirectorInfo",
|
||||
props: { branchId: { type: Number, required: true } },
|
||||
components: {
|
||||
NewDirectorDialog
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
director: null,
|
||||
showNewDirectorDialog: false,
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
await this.loadDirector();
|
||||
},
|
||||
methods: {
|
||||
async refresh() {
|
||||
await this.loadDirector();
|
||||
},
|
||||
methods: {
|
||||
async loadDirector() {
|
||||
try {
|
||||
const response = await apiClient.get(`/api/falukant/director/${this.branchId}`);
|
||||
this.director = Object.keys(response.data).length === 0 || !response.data.director ? null : response.data.director;
|
||||
} catch (error) {
|
||||
console.error('Error loading director:', error);
|
||||
|
||||
async loadDirector() {
|
||||
try {
|
||||
const response = await apiClient.get(`/api/falukant/director/${this.branchId}`);
|
||||
const data = response.data;
|
||||
if (
|
||||
!data ||
|
||||
(Array.isArray(data) && data.length === 0) ||
|
||||
typeof data.director === 'undefined' ||
|
||||
data.director === null
|
||||
) {
|
||||
this.director = null;
|
||||
} else {
|
||||
this.director = data.director;
|
||||
}
|
||||
},
|
||||
async saveSetting(settingKey, value) {
|
||||
if (!this.director) return;
|
||||
try {
|
||||
await apiClient.post(`/api/falukant/director/settings`, {
|
||||
branchId: this.branchId,
|
||||
directorId: this.director.id,
|
||||
settingKey,
|
||||
value,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Error saving setting ${settingKey}:`, error);
|
||||
}
|
||||
},
|
||||
openNewDirectorDialog() {
|
||||
console.log('openNewDirectorDialog');
|
||||
this.$refs.newDirectorDialog.open(this.branchId);
|
||||
},
|
||||
fireDirector() {
|
||||
alert(this.$t('falukant.branch.director.fireAlert'));
|
||||
},
|
||||
teachDirector() {
|
||||
alert(this.$t('falukant.branch.director.teachAlert'));
|
||||
},
|
||||
} catch (error) {
|
||||
console.error('Error loading director:', error);
|
||||
this.director = null;
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.director-info {
|
||||
border: 1px solid #ccc;
|
||||
margin: 10px 0;
|
||||
border-radius: 4px;
|
||||
padding: 10px;
|
||||
}
|
||||
.director-info-container {
|
||||
display: flex;
|
||||
}
|
||||
.director-info-container > div {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
async saveSetting(settingKey, value) {
|
||||
if (!this.director) return;
|
||||
try {
|
||||
await apiClient.post(`/api/falukant/director/settings`, {
|
||||
branchId: this.branchId,
|
||||
directorId: this.director.id,
|
||||
settingKey,
|
||||
value,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Error saving setting ${settingKey}:`, error);
|
||||
}
|
||||
},
|
||||
|
||||
openNewDirectorDialog() {
|
||||
console.log('openNewDirectorDialog');
|
||||
this.$refs.newDirectorDialog.open(this.branchId);
|
||||
},
|
||||
|
||||
fireDirector() {
|
||||
alert(this.$t('falukant.branch.director.fireAlert'));
|
||||
},
|
||||
|
||||
teachDirector() {
|
||||
alert(this.$t('falukant.branch.director.teachAlert'));
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.director-info {
|
||||
border: 1px solid #ccc;
|
||||
margin: 10px 0;
|
||||
border-radius: 4px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.director-info-container {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.director-info-container>div {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -10,7 +10,7 @@
|
||||
</template>
|
||||
<span v-if="statusItems.length > 0">
|
||||
<template v-for="(menuItem, key) in menu.falukant.children" :key="menuItem.id" >
|
||||
<img :src="'/images/icons/falukant/' + key + '.jpg'" class="menu-icon" @click="openPage(menuItem)" :title="$t(`navigation.m-falukant.${key}`)" />
|
||||
<img :src="'/images/icons/falukant/shortmap/' + key + '.png'" class="menu-icon" @click="openPage(menuItem)" :title="$t(`navigation.m-falukant.${key}`)" />
|
||||
</template>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -334,7 +334,8 @@
|
||||
"salary": "Gehalt",
|
||||
"skills": "Wissen",
|
||||
"product": "Produkt",
|
||||
"knowledge": "Produktwissen"
|
||||
"knowledge": "Produktwissen",
|
||||
"hire": "Einstellen"
|
||||
},
|
||||
"skillKnowledges": {
|
||||
"excelent": "Exzellent",
|
||||
@@ -434,7 +435,8 @@
|
||||
"type": {
|
||||
"backyard_room": "Hinterhofzimmer",
|
||||
"wooden_house": "Holzhütte",
|
||||
"straw_hut": "Strohhütte"
|
||||
"straw_hut": "Strohhütte",
|
||||
"family_house": "Familienhaus"
|
||||
}
|
||||
},
|
||||
"nobility": {
|
||||
@@ -675,6 +677,46 @@
|
||||
"councillor": "Stadtrat",
|
||||
"assessor": "Schätzer"
|
||||
}
|
||||
},
|
||||
"underground": {
|
||||
"title": "Untergrund",
|
||||
"tabs": {
|
||||
"activities": "Aktivitäten",
|
||||
"attacks": "Angriffe"
|
||||
},
|
||||
"activities": {
|
||||
"none": "Keine Aktivitäten vorhanden.",
|
||||
"create": "Neue Aktivität erstellen",
|
||||
"type": "Aktivitätstyp",
|
||||
"victim": "Zielperson",
|
||||
"cost": "Kosten",
|
||||
"additionalInfo": "Zusätzliche Informationen",
|
||||
"victimPlaceholder": "Benutzername eingeben",
|
||||
"sabotageTarget": "Sabotageziel",
|
||||
"corruptGoal": "Ziel der Korruption"
|
||||
},
|
||||
"attacks": {
|
||||
"target": "Angreifer",
|
||||
"date": "Datum",
|
||||
"success": "Erfolg",
|
||||
"none": "Keine Angriffe aufgezeichnet."
|
||||
},
|
||||
"types": {
|
||||
"spyin": "Spionage",
|
||||
"assassin": "Attentat",
|
||||
"sabotage": "Sabotage",
|
||||
"corrupt_politician": "Korruption",
|
||||
"rob": "Raub"
|
||||
},
|
||||
"targets": {
|
||||
"house": "Wohnhaus",
|
||||
"storage": "Lager"
|
||||
},
|
||||
"goals": {
|
||||
"elect": "Amtseinsetzung",
|
||||
"taxIncrease": "Steuern erhöhen",
|
||||
"taxDecrease": "Steuern senken"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,8 @@
|
||||
"administration": "Verwaltung",
|
||||
"m-chats": {
|
||||
"multiChat": "Multiuser-Chat",
|
||||
"randomChat": "Zufalls-Singlechat"
|
||||
"randomChat": "Zufalls-Singlechat",
|
||||
"eroticChat": "Erotikchat"
|
||||
},
|
||||
"m-socialnetwork": {
|
||||
"guestbook": "Gästebuch",
|
||||
@@ -20,7 +21,12 @@
|
||||
"gallery": "Galerie",
|
||||
"blockedUsers": "Blockierte Benutzer",
|
||||
"oneTimeInvitation": "Einmal-Einladungen",
|
||||
"diary": "Tagebuch"
|
||||
"diary": "Tagebuch",
|
||||
"erotic": "Erotik",
|
||||
"m-erotic": {
|
||||
"pictures": "Bilder",
|
||||
"videos": "Videos"
|
||||
}
|
||||
},
|
||||
"m-settings": {
|
||||
"homepage": "Startseite",
|
||||
|
||||
@@ -12,6 +12,7 @@ import BankView from '../views/falukant/BankView.vue';
|
||||
import DirectorView from '../views/falukant/DirectorView.vue';
|
||||
import HealthView from '../views/falukant/HealthView.vue';
|
||||
import PoliticsView from '../views/falukant/PoliticsView.vue';
|
||||
import UndergroundView from '../views/falukant/UndergroundView.vue';
|
||||
|
||||
const falukantRoutes = [
|
||||
{
|
||||
@@ -98,6 +99,12 @@ const falukantRoutes = [
|
||||
component: PoliticsView,
|
||||
meta: { requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/falukant/darknet',
|
||||
name: 'UndergroundView',
|
||||
component: UndergroundView,
|
||||
meta: { requiresAuth: true }
|
||||
},
|
||||
];
|
||||
|
||||
export default falukantRoutes;
|
||||
|
||||
@@ -1,291 +1,271 @@
|
||||
<template>
|
||||
<div class="contenthidden">
|
||||
<StatusBar ref="statusBar" />
|
||||
<div class="contentscroll">
|
||||
<h2>{{ $t('falukant.branch.title') }}</h2>
|
||||
|
||||
<BranchSelection
|
||||
:branches="branches"
|
||||
:selectedBranch="selectedBranch"
|
||||
@branchSelected="onBranchSelected"
|
||||
@createBranch="createBranch"
|
||||
@upgradeBranch="upgradeBranch"
|
||||
ref="branchSelection"
|
||||
/>
|
||||
|
||||
<DirectorInfo
|
||||
v-if="selectedBranch"
|
||||
:branchId="selectedBranch.id"
|
||||
ref="directorInfo"
|
||||
/>
|
||||
|
||||
<SaleSection
|
||||
v-if="selectedBranch"
|
||||
:branchId="selectedBranch.id"
|
||||
ref="saleSection"
|
||||
/>
|
||||
|
||||
<ProductionSection
|
||||
v-if="selectedBranch"
|
||||
:branchId="selectedBranch.id"
|
||||
:products="products"
|
||||
ref="productionSection"
|
||||
/>
|
||||
|
||||
<StorageSection
|
||||
v-if="selectedBranch"
|
||||
:branchId="selectedBranch.id"
|
||||
ref="storageSection"
|
||||
/>
|
||||
|
||||
<RevenueSection
|
||||
v-if="selectedBranch"
|
||||
:products="products"
|
||||
:calculateProductRevenue="calculateProductRevenue"
|
||||
:calculateProductProfit="calculateProductProfit"
|
||||
ref="revenueSection"
|
||||
/>
|
||||
</div>
|
||||
<StatusBar ref="statusBar" />
|
||||
<div class="contentscroll">
|
||||
<h2>{{ $t('falukant.branch.title') }}</h2>
|
||||
|
||||
<BranchSelection :branches="branches" :selectedBranch="selectedBranch" @branchSelected="onBranchSelected"
|
||||
@createBranch="createBranch" @upgradeBranch="upgradeBranch" ref="branchSelection" />
|
||||
|
||||
<DirectorInfo v-if="selectedBranch" :branchId="selectedBranch.id" ref="directorInfo" />
|
||||
|
||||
<SaleSection v-if="selectedBranch" :branchId="selectedBranch.id" ref="saleSection" />
|
||||
|
||||
<ProductionSection v-if="selectedBranch" :branchId="selectedBranch.id" :products="products"
|
||||
ref="productionSection" />
|
||||
|
||||
<StorageSection v-if="selectedBranch" :branchId="selectedBranch.id" ref="storageSection" />
|
||||
|
||||
<RevenueSection v-if="selectedBranch" :products="products"
|
||||
:calculateProductRevenue="calculateProductRevenue" :calculateProductProfit="calculateProductProfit"
|
||||
ref="revenueSection" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import StatusBar from '@/components/falukant/StatusBar.vue';
|
||||
import BranchSelection from '@/components/falukant/BranchSelection.vue';
|
||||
import DirectorInfo from '@/components/falukant/DirectorInfo.vue';
|
||||
import SaleSection from '@/components/falukant/SaleSection.vue';
|
||||
import ProductionSection from '@/components/falukant/ProductionSection.vue';
|
||||
import StorageSection from '@/components/falukant/StorageSection.vue';
|
||||
import RevenueSection from '@/components/falukant/RevenueSection.vue';
|
||||
import apiClient from '@/utils/axios.js';
|
||||
import { mapState } from 'vuex';
|
||||
|
||||
export default {
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import StatusBar from '@/components/falukant/StatusBar.vue';
|
||||
import BranchSelection from '@/components/falukant/BranchSelection.vue';
|
||||
import DirectorInfo from '@/components/falukant/DirectorInfo.vue';
|
||||
import SaleSection from '@/components/falukant/SaleSection.vue';
|
||||
import ProductionSection from '@/components/falukant/ProductionSection.vue';
|
||||
import StorageSection from '@/components/falukant/StorageSection.vue';
|
||||
import RevenueSection from '@/components/falukant/RevenueSection.vue';
|
||||
import apiClient from '@/utils/axios.js';
|
||||
import { mapState } from 'vuex';
|
||||
|
||||
export default {
|
||||
name: "BranchView",
|
||||
components: {
|
||||
StatusBar,
|
||||
BranchSelection,
|
||||
DirectorInfo,
|
||||
SaleSection,
|
||||
ProductionSection,
|
||||
StorageSection,
|
||||
RevenueSection,
|
||||
StatusBar,
|
||||
BranchSelection,
|
||||
DirectorInfo,
|
||||
SaleSection,
|
||||
ProductionSection,
|
||||
StorageSection,
|
||||
RevenueSection,
|
||||
},
|
||||
|
||||
|
||||
data() {
|
||||
return {
|
||||
branches: [],
|
||||
selectedBranch: null,
|
||||
products: [],
|
||||
};
|
||||
return {
|
||||
branches: [],
|
||||
selectedBranch: null,
|
||||
products: [],
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
computed: {
|
||||
...mapState(['socket', 'daemonSocket']),
|
||||
...mapState(['socket', 'daemonSocket']),
|
||||
},
|
||||
|
||||
|
||||
async mounted() {
|
||||
await this.loadBranches();
|
||||
|
||||
const branchId = this.$route.params.branchId;
|
||||
await this.loadProducts();
|
||||
|
||||
if (branchId) {
|
||||
this.selectedBranch = this.branches.find(
|
||||
b => b.id === parseInt(branchId, 10)
|
||||
) || null;
|
||||
} else {
|
||||
this.selectMainBranch();
|
||||
}
|
||||
|
||||
// Daemon-Socket
|
||||
if (this.daemonSocket) {
|
||||
this.daemonSocket.addEventListener('message', this.handleDaemonMessage);
|
||||
}
|
||||
|
||||
// Live-Socket-Events
|
||||
[
|
||||
"production_ready",
|
||||
"stock_change",
|
||||
"price_update",
|
||||
"director_death",
|
||||
"production_started",
|
||||
"selled_items",
|
||||
"falukantUpdateStatus",
|
||||
"falukantBranchUpdate",
|
||||
"knowledge_update"
|
||||
].forEach(eventName => {
|
||||
if (this.socket) {
|
||||
this.socket.on(eventName, data => this.handleEvent({ event: eventName, ...data }));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
beforeUnmount() {
|
||||
[
|
||||
"production_ready",
|
||||
"stock_change",
|
||||
"price_update",
|
||||
"director_death",
|
||||
"production_started",
|
||||
"selled_items",
|
||||
"falukantUpdateStatus",
|
||||
"falukantBranchUpdate",
|
||||
"knowledge_update"
|
||||
].forEach(eventName => {
|
||||
if (this.socket) {
|
||||
this.socket.off(eventName, this.handleEvent);
|
||||
}
|
||||
});
|
||||
|
||||
if (this.daemonSocket) {
|
||||
this.daemonSocket.removeEventListener('message', this.handleDaemonMessage);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async loadBranches() {
|
||||
try {
|
||||
const result = await apiClient.get('/api/falukant/branches');
|
||||
this.branches = result.data.map(branch => ({
|
||||
id: branch.id,
|
||||
cityName: branch.region.name,
|
||||
type: this.$t(`falukant.branch.types.${branch.branchType.labelTr}`),
|
||||
isMainBranch: branch.isMainBranch,
|
||||
}));
|
||||
if (!this.selectedBranch) {
|
||||
this.selectMainBranch();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading branches:', error);
|
||||
}
|
||||
},
|
||||
|
||||
async loadProducts() {
|
||||
try {
|
||||
const productsResult = await apiClient.get('/api/falukant/products');
|
||||
this.products = productsResult.data;
|
||||
} catch (error) {
|
||||
console.error('Error loading products:', error);
|
||||
}
|
||||
},
|
||||
|
||||
onBranchSelected(newBranch) {
|
||||
this.selectedBranch = newBranch;
|
||||
},
|
||||
|
||||
async createBranch() {
|
||||
// Nach erfolgreichem Dialog-Event: neu laden
|
||||
await this.loadBranches();
|
||||
},
|
||||
|
||||
upgradeBranch() {
|
||||
if (this.selectedBranch) {
|
||||
alert(
|
||||
this.$t(
|
||||
'falukant.branch.actions.upgradeAlert',
|
||||
{ branchId: this.selectedBranch.id }
|
||||
)
|
||||
);
|
||||
|
||||
const branchId = this.$route.params.branchId;
|
||||
await this.loadProducts();
|
||||
|
||||
if (branchId) {
|
||||
this.selectedBranch = this.branches.find(
|
||||
b => b.id === parseInt(branchId, 10)
|
||||
) || null;
|
||||
} else {
|
||||
this.selectMainBranch();
|
||||
}
|
||||
},
|
||||
|
||||
selectMainBranch() {
|
||||
const main = this.branches.find(b => b.isMainBranch) || null;
|
||||
if (main && main !== this.selectedBranch) {
|
||||
this.selectedBranch = main;
|
||||
|
||||
// Daemon-Socket
|
||||
if (this.daemonSocket) {
|
||||
this.daemonSocket.addEventListener('message', this.handleDaemonMessage);
|
||||
}
|
||||
},
|
||||
|
||||
calculateProductRevenue(product) {
|
||||
if (!product.knowledges || product.knowledges.length === 0) {
|
||||
return { absolute: 0, perMinute: 0 };
|
||||
}
|
||||
const knowledgeFactor = product.knowledges[0].knowledge || 0;
|
||||
const maxPrice = product.sellCost;
|
||||
const minPrice = maxPrice * 0.6;
|
||||
const revenuePerUnit = minPrice + (maxPrice - minPrice) * (knowledgeFactor / 100);
|
||||
const perMinute = product.productionTime > 0
|
||||
? revenuePerUnit / product.productionTime
|
||||
: 0;
|
||||
return {
|
||||
absolute: revenuePerUnit.toFixed(2),
|
||||
perMinute: perMinute.toFixed(2),
|
||||
};
|
||||
},
|
||||
|
||||
calculateProductProfit(product) {
|
||||
const { absolute: revenueAbsoluteStr, perMinute: revenuePerMinuteStr }
|
||||
= this.calculateProductRevenue(product);
|
||||
const revenueAbsolute = parseFloat(revenueAbsoluteStr);
|
||||
const costPerUnit = 6 * product.category;
|
||||
const profitAbsolute = revenueAbsolute - costPerUnit;
|
||||
const costPerMinute = product.productionTime > 0
|
||||
? costPerUnit / product.productionTime
|
||||
: 0;
|
||||
const profitPerMinute = parseFloat(revenuePerMinuteStr) - costPerMinute;
|
||||
return {
|
||||
absolute: profitAbsolute.toFixed(2),
|
||||
perMinute: profitPerMinute.toFixed(2),
|
||||
};
|
||||
},
|
||||
|
||||
handleEvent(eventData) {
|
||||
switch (eventData.event) {
|
||||
case 'production_ready':
|
||||
this.$refs.productionSection?.loadProductions();
|
||||
this.$refs.storageSection ?.loadStorageData();
|
||||
this.$refs.saleSection ?.loadInventory();
|
||||
break;
|
||||
case 'stock_change':
|
||||
this.$refs.storageSection ?.loadStorageData();
|
||||
this.$refs.saleSection ?.loadInventory();
|
||||
break;
|
||||
case 'price_update':
|
||||
this.$refs.revenueSection?.refresh();
|
||||
break;
|
||||
case 'director_death':
|
||||
this.$refs.directorInfo?.loadDirector();
|
||||
break;
|
||||
case 'production_started':
|
||||
this.$refs.productionSection?.loadProductions();
|
||||
break;
|
||||
case 'selled_items':
|
||||
this.$refs.saleSection ?.loadInventory();
|
||||
this.$refs.storageSection?.loadStorageData();
|
||||
break;
|
||||
case 'falukantUpdateStatus':
|
||||
case 'falukantBranchUpdate':
|
||||
this.$refs.statusBar?.fetchStatus();
|
||||
this.$refs.productionSection?.loadProductions();
|
||||
this.$refs.storageSection ?.loadStorageData();
|
||||
this.$refs.saleSection ?.loadInventory();
|
||||
break;
|
||||
case 'knowledge_update':
|
||||
this.loadProducts();
|
||||
this.$refs.revenueSection.products = this.products;
|
||||
break;
|
||||
default:
|
||||
console.log('Unhandled event:', eventData);
|
||||
}
|
||||
},
|
||||
|
||||
handleDaemonMessage(event) {
|
||||
if (event.data === 'ping') return;
|
||||
try {
|
||||
const message = JSON.parse(event.data);
|
||||
this.handleEvent(message);
|
||||
} catch (error) {
|
||||
console.error('Error processing daemon message:', error);
|
||||
}
|
||||
},
|
||||
|
||||
// Live-Socket-Events
|
||||
[
|
||||
"production_ready",
|
||||
"stock_change",
|
||||
"price_update",
|
||||
"director_death",
|
||||
"production_started",
|
||||
"selled_items",
|
||||
"falukantUpdateStatus",
|
||||
"falukantBranchUpdate",
|
||||
"knowledge_update"
|
||||
].forEach(eventName => {
|
||||
if (this.socket) {
|
||||
this.socket.on(eventName, data => this.handleEvent({ event: eventName, ...data }));
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
h2 {
|
||||
|
||||
beforeUnmount() {
|
||||
[
|
||||
"production_ready",
|
||||
"stock_change",
|
||||
"price_update",
|
||||
"director_death",
|
||||
"production_started",
|
||||
"selled_items",
|
||||
"falukantUpdateStatus",
|
||||
"falukantBranchUpdate",
|
||||
"knowledge_update"
|
||||
].forEach(eventName => {
|
||||
if (this.socket) {
|
||||
this.socket.off(eventName, this.handleEvent);
|
||||
}
|
||||
});
|
||||
|
||||
if (this.daemonSocket) {
|
||||
this.daemonSocket.removeEventListener('message', this.handleDaemonMessage);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async loadBranches() {
|
||||
try {
|
||||
const result = await apiClient.get('/api/falukant/branches');
|
||||
this.branches = result.data.map(branch => ({
|
||||
id: branch.id,
|
||||
cityName: branch.region.name,
|
||||
type: this.$t(`falukant.branch.types.${branch.branchType.labelTr}`),
|
||||
isMainBranch: branch.isMainBranch,
|
||||
}));
|
||||
if (!this.selectedBranch) {
|
||||
this.selectMainBranch();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading branches:', error);
|
||||
}
|
||||
},
|
||||
|
||||
async loadProducts() {
|
||||
try {
|
||||
const productsResult = await apiClient.get('/api/falukant/products');
|
||||
this.products = productsResult.data;
|
||||
} catch (error) {
|
||||
console.error('Error loading products:', error);
|
||||
}
|
||||
},
|
||||
|
||||
async onBranchSelected(newBranch) {
|
||||
this.selectedBranch = newBranch;
|
||||
await this.loadProducts();
|
||||
this.$nextTick(() => {
|
||||
this.$refs.directorInfo?.refresh();
|
||||
this.$refs.saleSection?.loadInventory();
|
||||
this.$refs.productionSection?.loadProductions();
|
||||
this.$refs.storageSection?.loadStorageData();
|
||||
this.$refs.revenueSection?.refresh && this.$refs.revenueSection.refresh();
|
||||
});
|
||||
},
|
||||
|
||||
async createBranch() {
|
||||
await this.loadBranches();
|
||||
},
|
||||
|
||||
upgradeBranch() {
|
||||
if (this.selectedBranch) {
|
||||
alert(
|
||||
this.$t(
|
||||
'falukant.branch.actions.upgradeAlert',
|
||||
{ branchId: this.selectedBranch.id }
|
||||
)
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
selectMainBranch() {
|
||||
const main = this.branches.find(b => b.isMainBranch) || null;
|
||||
if (main && main !== this.selectedBranch) {
|
||||
this.selectedBranch = main;
|
||||
}
|
||||
},
|
||||
|
||||
calculateProductRevenue(product) {
|
||||
if (!product.knowledges || product.knowledges.length === 0) {
|
||||
return { absolute: 0, perMinute: 0 };
|
||||
}
|
||||
const knowledgeFactor = product.knowledges[0].knowledge || 0;
|
||||
const maxPrice = product.sellCost;
|
||||
const minPrice = maxPrice * 0.6;
|
||||
const revenuePerUnit = minPrice + (maxPrice - minPrice) * (knowledgeFactor / 100);
|
||||
const perMinute = product.productionTime > 0
|
||||
? revenuePerUnit / product.productionTime
|
||||
: 0;
|
||||
return {
|
||||
absolute: revenuePerUnit.toFixed(2),
|
||||
perMinute: perMinute.toFixed(2),
|
||||
};
|
||||
},
|
||||
|
||||
calculateProductProfit(product) {
|
||||
const { absolute: revenueAbsoluteStr, perMinute: revenuePerMinuteStr }
|
||||
= this.calculateProductRevenue(product);
|
||||
const revenueAbsolute = parseFloat(revenueAbsoluteStr);
|
||||
const costPerUnit = 6 * product.category;
|
||||
const profitAbsolute = revenueAbsolute - costPerUnit;
|
||||
const costPerMinute = product.productionTime > 0
|
||||
? costPerUnit / product.productionTime
|
||||
: 0;
|
||||
const profitPerMinute = parseFloat(revenuePerMinuteStr) - costPerMinute;
|
||||
return {
|
||||
absolute: profitAbsolute.toFixed(2),
|
||||
perMinute: profitPerMinute.toFixed(2),
|
||||
};
|
||||
},
|
||||
|
||||
handleEvent(eventData) {
|
||||
switch (eventData.event) {
|
||||
case 'production_ready':
|
||||
this.$refs.productionSection?.loadProductions();
|
||||
this.$refs.storageSection?.loadStorageData();
|
||||
this.$refs.saleSection?.loadInventory();
|
||||
break;
|
||||
case 'stock_change':
|
||||
this.$refs.storageSection?.loadStorageData();
|
||||
this.$refs.saleSection?.loadInventory();
|
||||
break;
|
||||
case 'price_update':
|
||||
this.$refs.revenueSection?.refresh();
|
||||
break;
|
||||
case 'director_death':
|
||||
this.$refs.directorInfo?.loadDirector();
|
||||
break;
|
||||
case 'production_started':
|
||||
this.$refs.productionSection?.loadProductions();
|
||||
break;
|
||||
case 'selled_items':
|
||||
this.$refs.saleSection?.loadInventory();
|
||||
this.$refs.storageSection?.loadStorageData();
|
||||
break;
|
||||
case 'falukantUpdateStatus':
|
||||
case 'falukantBranchUpdate':
|
||||
this.$refs.statusBar?.fetchStatus();
|
||||
this.$refs.productionSection?.loadProductions();
|
||||
this.$refs.storageSection?.loadStorageData();
|
||||
this.$refs.saleSection?.loadInventory();
|
||||
break;
|
||||
case 'knowledge_update':
|
||||
this.loadProducts();
|
||||
this.$refs.revenueSection.products = this.products;
|
||||
break;
|
||||
default:
|
||||
console.log('Unhandled event:', eventData);
|
||||
}
|
||||
},
|
||||
|
||||
handleDaemonMessage(event) {
|
||||
if (event.data === 'ping') return;
|
||||
try {
|
||||
const message = JSON.parse(event.data);
|
||||
this.handleEvent(message);
|
||||
} catch (error) {
|
||||
console.error('Error processing daemon message:', error);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
h2 {
|
||||
padding-top: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
}
|
||||
</style>
|
||||
@@ -101,7 +101,7 @@ export default {
|
||||
try {
|
||||
const { data } = await apiClient.get('/api/falukant/health');
|
||||
this.age = data.age;
|
||||
this.healthStatus = data.status;
|
||||
this.healthStatus = data.health;
|
||||
this.measuresTaken = data.history;
|
||||
this.availableMeasures = data.healthActivities;
|
||||
} catch (err) {
|
||||
|
||||
343
frontend/src/views/falukant/UndergroundView.vue
Normal file
343
frontend/src/views/falukant/UndergroundView.vue
Normal file
@@ -0,0 +1,343 @@
|
||||
<template>
|
||||
<div class="underground-view">
|
||||
<StatusBar />
|
||||
|
||||
<h2>{{ $t('falukant.underground.title') }}</h2>
|
||||
|
||||
<SimpleTabs v-model="activeTab" :tabs="tabs" @change="onTabChange" />
|
||||
|
||||
<div class="tab-content">
|
||||
<!-- Aktivitäten -->
|
||||
<div v-if="activeTab === 'activities'" class="tab-pane">
|
||||
<!-- Neues Activity-Formular -->
|
||||
<div class="create-activity">
|
||||
<h3>{{ $t('falukant.underground.activities.create') }}</h3>
|
||||
|
||||
<label class="form-label">
|
||||
{{ $t('falukant.underground.activities.type') }}
|
||||
<select v-model="newActivityTypeId" class="form-control">
|
||||
<option v-for="type in undergroundTypes" :key="type.id" :value="type.id">
|
||||
{{ $t(`falukant.underground.types.${type.tr}`) }}
|
||||
({{ formatCost(type.cost) }})
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label class="form-label">
|
||||
{{ $t('falukant.underground.activities.victim') }}
|
||||
<input v-model="newVictimUsername" type="text" class="form-control"
|
||||
:placeholder="$t('falukant.underground.activities.victimPlaceholder')" />
|
||||
</label>
|
||||
|
||||
<!-- Bei sabotage: Ziel auswählen -->
|
||||
<label v-if="selectedType && selectedType.tr === 'sabotage'" class="form-label">
|
||||
{{ $t('falukant.underground.activities.sabotageTarget') }}
|
||||
<select v-model="newSabotageTarget" class="form-control">
|
||||
<option value="house">{{ $t('falukant.underground.targets.house') }}</option>
|
||||
<option value="storage">{{ $t('falukant.underground.targets.storage') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<!-- Bei corrupt_politician: Ziel erreichen -->
|
||||
<label v-if="selectedType && selectedType.tr === 'corrupt_politician'" class="form-label">
|
||||
{{ $t('falukant.underground.activities.corruptGoal') }}
|
||||
<select v-model="newCorruptGoal" class="form-control">
|
||||
<option value="elect">{{ $t('falukant.underground.goals.elect') }}</option>
|
||||
<option value="tax_increase">{{ $t('falukant.underground.goals.taxIncrease') }}</option>
|
||||
<option value="tax_decrease">{{ $t('falukant.underground.goals.taxDecrease') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<button class="btn-create-activity" :disabled="!canCreate" @click="createActivity">
|
||||
{{ $t('falukant.underground.activities.create') }}
|
||||
</button>
|
||||
</div>
|
||||
<!-- /Neues Activity-Formular -->
|
||||
|
||||
<div v-if="loading.activities" class="loading">
|
||||
{{ $t('loading') }}
|
||||
</div>
|
||||
<div v-else class="activities-table">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ $t('falukant.underground.activities.type') }}</th>
|
||||
<th>{{ $t('falukant.underground.activities.victim') }}</th>
|
||||
<th>{{ $t('falukant.underground.activities.cost') }}</th>
|
||||
<th>{{ $t('falukant.underground.activities.additionalInfo') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="act in activities" :key="act.id">
|
||||
<!-- Typ -->
|
||||
<td>{{ $t(`falukant.underground.types.${act.type}`) }}</td>
|
||||
<!-- Victim -->
|
||||
<td>{{ act.victimName }}</td>
|
||||
<!-- Cost -->
|
||||
<td>{{ formatCost(act.cost) }}</td>
|
||||
<!-- Zusätzliche Informationen -->
|
||||
<td>
|
||||
<template v-if="act.type === 'sabotage'">
|
||||
{{ $t(`falukant.underground.targets.${act.target}`) }}
|
||||
</template>
|
||||
<template v-else-if="act.type === 'corrupt_politician'">
|
||||
{{ $t(`falukant.underground.goals.${act.goal}`) }}
|
||||
</template>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!activities.length">
|
||||
<td colspan="4">{{ $t('falukant.underground.activities.none') }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Angriffe -->
|
||||
<div v-else-if="activeTab === 'attacks'" class="tab-pane">
|
||||
<div v-if="loading.attacks" class="loading">
|
||||
{{ $t('loading') }}
|
||||
</div>
|
||||
<div v-else class="attacks-list">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ $t('falukant.underground.attacks.source') }}</th>
|
||||
<th>{{ $t('falukant.underground.attacks.date') }}</th>
|
||||
<th>{{ $t('falukant.underground.attacks.success') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="atk in attacks" :key="atk.id">
|
||||
<td>{{ atk.targetName }}</td>
|
||||
<td>{{ formatDate(atk.date) }}</td>
|
||||
<td>{{ atk.success ? $t('yes') : $t('no') }}</td>
|
||||
</tr>
|
||||
<tr v-if="!attacks.length">
|
||||
<td colspan="3">
|
||||
{{ $t('falukant.underground.attacks.none') }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import StatusBar from '@/components/falukant/StatusBar.vue';
|
||||
import SimpleTabs from '@/components/SimpleTabs.vue';
|
||||
import apiClient from '@/utils/axios.js';
|
||||
|
||||
export default {
|
||||
name: 'UndergroundView',
|
||||
components: { StatusBar, SimpleTabs },
|
||||
data() {
|
||||
return {
|
||||
activeTab: 'activities',
|
||||
tabs: [
|
||||
{ value: 'activities', label: 'falukant.underground.tabs.activities' },
|
||||
{ value: 'attacks', label: 'falukant.underground.tabs.attacks' }
|
||||
],
|
||||
undergroundTypes: [],
|
||||
activities: [],
|
||||
attacks: [],
|
||||
loading: { activities: false, attacks: false },
|
||||
|
||||
// Neue Activity-Formfelder
|
||||
newActivityTypeId: null,
|
||||
newVictimUsername: '',
|
||||
newSabotageTarget: 'house',
|
||||
newCorruptGoal: 'elect'
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
selectedType() {
|
||||
return this.undergroundTypes.find(t => t.id === this.newActivityTypeId) || null;
|
||||
},
|
||||
canCreate() {
|
||||
if (!this.newActivityTypeId || !this.newVictimUsername.trim()) return false;
|
||||
if (this.selectedType.tr === 'sabotage' && !this.newSabotageTarget) return false;
|
||||
if (this.selectedType.tr === 'corrupt_politician' && !this.newCorruptGoal) return false;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
await this.loadUndergroundTypes();
|
||||
if (this.undergroundTypes.length) {
|
||||
this.newActivityTypeId = this.undergroundTypes[0].id;
|
||||
}
|
||||
await this.loadActivities();
|
||||
},
|
||||
methods: {
|
||||
onTabChange(tab) {
|
||||
if (tab === 'activities' && !this.activities.length) {
|
||||
this.loadActivities();
|
||||
}
|
||||
if (tab === 'attacks' && !this.attacks.length) {
|
||||
this.loadAttacks();
|
||||
}
|
||||
},
|
||||
|
||||
async loadUndergroundTypes() {
|
||||
const { data } = await apiClient.get('/api/falukant/underground/types');
|
||||
this.undergroundTypes = data;
|
||||
},
|
||||
|
||||
async loadActivities() {
|
||||
this.loading.activities = true;
|
||||
try {
|
||||
const { data } = await apiClient.get('/api/falukant/underground/activities');
|
||||
this.activities = data;
|
||||
} catch (err) {
|
||||
console.error('Error loading activities', err);
|
||||
} finally {
|
||||
this.loading.activities = false;
|
||||
}
|
||||
},
|
||||
|
||||
async loadAttacks() {
|
||||
this.loading.attacks = true;
|
||||
try {
|
||||
const { data } = await apiClient.get('/api/falukant/underground/attacks');
|
||||
this.attacks = data;
|
||||
} catch (err) {
|
||||
console.error('Error loading attacks', err);
|
||||
} finally {
|
||||
this.loading.attacks = false;
|
||||
}
|
||||
},
|
||||
|
||||
async createActivity() {
|
||||
if (!this.canCreate) return;
|
||||
const payload = {
|
||||
typeId: this.newActivityTypeId,
|
||||
victimUsername: this.newVictimUsername.trim()
|
||||
};
|
||||
// je nach Typ noch ergänzen:
|
||||
if (this.selectedType.tr === 'sabotage') {
|
||||
payload.target = this.newSabotageTarget;
|
||||
}
|
||||
if (this.selectedType.tr === 'corrupt_politician') {
|
||||
payload.goal = this.newCorruptGoal;
|
||||
}
|
||||
try {
|
||||
await apiClient.post('/api/falukant/underground/activities', payload);
|
||||
// zurücksetzen & neu laden
|
||||
this.newVictimUsername = '';
|
||||
this.newSabotageTarget = 'house';
|
||||
this.newCorruptGoal = 'elect';
|
||||
await this.loadActivities();
|
||||
} catch (err) {
|
||||
console.error('Error creating activity', err);
|
||||
}
|
||||
},
|
||||
|
||||
formatDate(ts) {
|
||||
return new Date(ts).toLocaleDateString(this.$i18n.locale, {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
});
|
||||
},
|
||||
|
||||
formatCost(value) {
|
||||
return new Intl.NumberFormat(navigator.language, {
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 0
|
||||
}).format(value);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.underground-view {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
h2 {
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.tab-content {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.tab-pane {
|
||||
min-height: 200px;
|
||||
}
|
||||
|
||||
.loading {
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
/* --- Create Activity --- */
|
||||
.create-activity {
|
||||
border: 1px solid #ccc;
|
||||
padding: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
border-radius: 4px;
|
||||
background: #fafafa;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.create-activity h3 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
margin-bottom: 0.5rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.form-control {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 0.4rem;
|
||||
margin-bottom: 1rem;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.btn-create-activity {
|
||||
padding: 0.5rem 1rem;
|
||||
cursor: pointer;
|
||||
background: #4caf50;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.btn-create-activity:disabled {
|
||||
background: #ccc;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* --- Activities List --- */
|
||||
.activities-list ul {
|
||||
list-style: disc;
|
||||
margin-left: 1.5em;
|
||||
}
|
||||
|
||||
/* --- Attacks Table --- */
|
||||
.attacks-list table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.attacks-list th,
|
||||
.attacks-list td {
|
||||
padding: 8px;
|
||||
border: 1px solid #ddd;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user