Some falukant fixes, added undeground ui - no save right now, changed menu (and verification)

This commit is contained in:
Torsten Schulz
2025-07-17 14:28:52 +02:00
parent fceea5b7fb
commit 89cf12a7a8
33 changed files with 1010 additions and 423 deletions

View File

@@ -58,6 +58,8 @@ class FalukantController {
this.renovate = this.renovate.bind(this); this.renovate = this.renovate.bind(this);
this.renovateAll = this.renovateAll.bind(this); this.renovateAll = this.renovateAll.bind(this);
this.createBranch = this.createBranch.bind(this); this.createBranch = this.createBranch.bind(this);
this.getUndergroundTypes = this.getUndergroundTypes.bind(this);
this.getNotifications = this.getNotifications.bind(this);
} }
async getUser(req, res) { async getUser(req, res) {
@@ -806,6 +808,28 @@ class FalukantController {
console.log(error); console.log(error);
} }
} }
async getUndergroundTypes(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const result = await FalukantService.getUndergroundTypes(hashedUserId);
res.status(200).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
console.log(error);
}
}
async getNotifications(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const result = await FalukantService.getNotifications(hashedUserId);
res.status(200).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
console.log(error);
}
}
} }
export default FalukantController; export default FalukantController;

View File

@@ -56,6 +56,19 @@ const menuStructure = {
diary: { diary: {
visible: ["all"], visible: ["all"],
path: "/socialnetwork/diary" path: "/socialnetwork/diary"
},
erotic: {
visible: ["over18"],
children: {
pictures: {
visible: ["over18"],
path: "/socialnetwork/erotic/pictures"
},
videos: {
visible: ["over18"],
path: "/socialnetwork/erotic/videos"
}
}
} }
} }
}, },
@@ -70,6 +83,10 @@ const menuStructure = {
randomChat: { randomChat: {
visible: ["over12"], visible: ["over12"],
action: "openRanomChat" action: "openRanomChat"
},
eroticChat: {
visible: ["over18"],
action: "openEroticChat"
} }
} }
}, },
@@ -248,6 +265,8 @@ class NavigationController {
if (value.visible.includes("all") if (value.visible.includes("all")
|| value.visible.some(v => rights.includes(v) || (value.visible.includes("anyadmin") && rights.length > 0)) || value.visible.some(v => rights.includes(v) || (value.visible.includes("anyadmin") && rights.length > 0))
|| (value.visible.includes("over14") && age >= 14) || (value.visible.includes("over14") && age >= 14)
|| (value.visible.includes("over12") && age >= 12)
|| (value.visible.includes("over18") && age >= 18)
|| (value.visible.includes('nofalukantaccount') && !hasFalukantAccount) || (value.visible.includes('nofalukantaccount') && !hasFalukantAccount)
|| (value.visible.includes('hasfalukantaccount') && hasFalukantAccount)) { || (value.visible.includes('hasfalukantaccount') && hasFalukantAccount)) {
const { visible, ...itemWithoutVisible } = value; const { visible, ...itemWithoutVisible } = value;

View File

@@ -88,6 +88,8 @@ import PoliticalOfficeRequirement from './falukant/predefine/political_office_pr
import PoliticalOfficePrerequisite from './falukant/predefine/political_office_prerequisite.js'; import PoliticalOfficePrerequisite from './falukant/predefine/political_office_prerequisite.js';
import PoliticalOfficeHistory from './falukant/log/political_office_history.js'; import PoliticalOfficeHistory from './falukant/log/political_office_history.js';
import ElectionHistory from './falukant/log/election_history.js'; import ElectionHistory from './falukant/log/election_history.js';
import Underground from './falukant/data/underground.js';
import UndergroundType from './falukant/type/underground.js';
export default function setupAssociations() { export default function setupAssociations() {
// UserParam related associations // UserParam related associations
@@ -675,7 +677,7 @@ export default function setupAssociations() {
PoliticalOfficeType.hasMany(PoliticalOfficeHistory, { PoliticalOfficeType.hasMany(PoliticalOfficeHistory, {
foreignKey: 'officeTypeId', foreignKey: 'officeTypeId',
as: 'history', as: 'history',
}); });
FalukantCharacter.hasMany(PoliticalOfficeHistory, { FalukantCharacter.hasMany(PoliticalOfficeHistory, {
@@ -686,7 +688,7 @@ export default function setupAssociations() {
foreignKey: 'characterId', foreignKey: 'characterId',
as: 'character', as: 'character',
}); });
ElectionHistory.belongsTo(PoliticalOfficeType, { ElectionHistory.belongsTo(PoliticalOfficeType, {
foreignKey: 'officeTypeId', foreignKey: 'officeTypeId',
as: 'officeTypeHistory', as: 'officeTypeHistory',
@@ -696,5 +698,34 @@ export default function setupAssociations() {
foreignKey: 'officeTypeId', foreignKey: 'officeTypeId',
as: 'electionHistory', as: 'electionHistory',
} }
) );
Underground.belongsTo(UndergroundType, {
foreignKey: 'undergroundTypeId',
as: 'undergroundType'
});
UndergroundType.hasMany(Underground, {
foreignKey: 'undergroundTypeId',
as: 'undergrounds'
});
// 2) Täter (performer)
Underground.belongsTo(FalukantCharacter, {
foreignKey: 'performerId',
as: 'performer'
});
FalukantCharacter.hasMany(Underground, {
foreignKey: 'performerId',
as: 'performedUndergrounds'
});
// 3) Opfer (victim)
Underground.belongsTo(FalukantCharacter, {
foreignKey: 'victimId',
as: 'victim'
});
FalukantCharacter.hasMany(Underground, {
foreignKey: 'victimId',
as: 'victimUndergrounds'
});
} }

View File

@@ -0,0 +1,36 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class Underground extends Model { }
Underground.init({
undergroundTypeId: {
type: DataTypes.STRING,
allowNull: false,
},
performerId: {
type: DataTypes.INTEGER,
allowNull: false,
},
victimId: {
type: DataTypes.INTEGER,
allowNull: false,
},
parameters: {
type: DataTypes.JSON,
allowNull: true,
},
result: {
type: DataTypes.JSON,
allowNull: true,
}
}, {
sequelize,
modelName: 'Underground',
tableName: 'underground',
schema: 'falukant_data',
timestamps: true,
underscored: true,
});
export default Underground;

View File

@@ -0,0 +1,25 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class UndergroundType extends Model { }
UndergroundType.init({
tr: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
},
cost: {
type: DataTypes.INTEGER,
allowNull: false,
}
}, {
sequelize,
modelName: 'UndergroundType',
tableName: 'underground',
schema: 'falukant_type',
timestamps: false,
underscored: true,
});
export default UndergroundType;

View File

@@ -96,6 +96,8 @@ import Vote from './falukant/data/vote.js';
import ElectionResult from './falukant/data/election_result.js'; import ElectionResult from './falukant/data/election_result.js';
import PoliticalOfficeHistory from './falukant/log/political_office_history.js'; import PoliticalOfficeHistory from './falukant/log/political_office_history.js';
import ElectionHistory from './falukant/log/election_history.js'; import ElectionHistory from './falukant/log/election_history.js';
import UndergroundType from './falukant/type/underground.js';
import Underground from './falukant/data/underground.js';
const models = { const models = {
SettingsType, SettingsType,
@@ -182,8 +184,6 @@ const models = {
Credit, Credit,
DebtorsPrism, DebtorsPrism,
HealthActivity, HealthActivity,
// Politics
PoliticalOfficeType, PoliticalOfficeType,
PoliticalOfficeRequirement, PoliticalOfficeRequirement,
PoliticalOfficeBenefitType, PoliticalOfficeBenefitType,
@@ -195,6 +195,8 @@ const models = {
ElectionResult, ElectionResult,
PoliticalOfficeHistory, PoliticalOfficeHistory,
ElectionHistory, ElectionHistory,
UndergroundType,
Underground,
}; };
export default models; export default models;

View File

@@ -69,5 +69,7 @@ router.post('/politics/elections', falukantController.vote);
router.get('/politics/open', falukantController.getOpenPolitics); router.get('/politics/open', falukantController.getOpenPolitics);
router.post('/politics/open', falukantController.applyForElections); router.post('/politics/open', falukantController.applyForElections);
router.get('/cities', falukantController.getRegions); router.get('/cities', falukantController.getRegions);
router.get('/underground/types', falukantController.getUndergroundTypes);
router.get('/notifications', falukantController.getNotifications);
export default router; export default router;

View File

@@ -53,6 +53,8 @@ import Candidate from '../models/falukant/data/candidate.js';
import Vote from '../models/falukant/data/vote.js'; import Vote from '../models/falukant/data/vote.js';
import PoliticalOfficePrerequisite from '../models/falukant/predefine/political_office_prerequisite.js'; import PoliticalOfficePrerequisite from '../models/falukant/predefine/political_office_prerequisite.js';
import PoliticalOfficeHistory from '../models/falukant/log/political_office_history.js'; import PoliticalOfficeHistory from '../models/falukant/log/political_office_history.js';
import UndergroundType from '../models/falukant/type/underground.js';
import Notification from '../models/falukant/log/notification.js';
function calcAge(birthdate) { function calcAge(birthdate) {
const b = new Date(birthdate); b.setHours(0, 0); const b = new Date(birthdate); b.setHours(0, 0);
@@ -1063,8 +1065,8 @@ class FalukantService extends BaseService {
] ]
}); });
if (regionUserDirectorProposals.length > 0) { if (regionUserDirectorProposals.length > 0) {
for (const proposal of regionUserDirectorProposals) { for (const p of regionUserDirectorProposals) {
await DirectorProposal.destroy(); await p.destroy();
} }
} }
notifyUser(hashedUserId, 'directorchanged'); notifyUser(hashedUserId, 'directorchanged');
@@ -1772,7 +1774,7 @@ class FalukantService extends BaseService {
} }
const housePrice = this.housePrice(house); const housePrice = this.housePrice(house);
const oldHouse = await UserHouse.findOne({ where: { userId: falukantUser.id } }); const oldHouse = await UserHouse.findOne({ where: { userId: falukantUser.id } });
if (falukantUser.money < housePrice) { if (Number(falukantUser.money) < Number(housePrice)) {
throw new Error('notenoughmoney.'); throw new Error('notenoughmoney.');
} }
if (oldHouse) { if (oldHouse) {
@@ -2779,6 +2781,20 @@ class FalukantService extends BaseService {
return { cost: totalCost }; return { cost: totalCost };
} }
async getUndergroundTypes(hashedUserId) {
const user = await getFalukantUserOrFail(hashedUserId);
const undergroundTypes = await UndergroundType.findAll();
return undergroundTypes;
}
async getNotifications(hashedUserId) {
const user = await getFalukantUserOrFail(hashedUserId);
const notifications = await Notification.findAll({
where: { userId: user.id, shown: false },
order: [['createdAt', 'DESC']]
});
return user.notifications;
}
} }
export default new FalukantService(); export default new FalukantService();

View File

@@ -14,6 +14,7 @@ import BanquetteType from "../../models/falukant/type/banquette.js";
import LearnRecipient from "../../models/falukant/type/learn_recipient.js"; import LearnRecipient from "../../models/falukant/type/learn_recipient.js";
import PoliticalOfficeType from "../../models/falukant/type/political_office_type.js"; import PoliticalOfficeType from "../../models/falukant/type/political_office_type.js";
import PoliticalOfficePrerequisite from "../../models/falukant/predefine/political_office_prerequisite.js"; import PoliticalOfficePrerequisite from "../../models/falukant/predefine/political_office_prerequisite.js";
import UndergroundType from "../../models/falukant/type/underground.js";
export const initializeFalukantTypes = async () => { export const initializeFalukantTypes = async () => {
await initializeFalukantTypeRegions(); await initializeFalukantTypeRegions();
@@ -29,6 +30,7 @@ export const initializeFalukantTypes = async () => {
await initializeLearnerTypes(); await initializeLearnerTypes();
await initializePoliticalOfficeTypes(); await initializePoliticalOfficeTypes();
await initializePoliticalOfficePrerequisites(); await initializePoliticalOfficePrerequisites();
await initializeUndergroundTypes();
}; };
const regionTypes = []; const regionTypes = [];
@@ -48,10 +50,10 @@ const regions = [
{ labelTr: "Siebenbachen", regionType: "shire", parentTr: "Groß-Benbach" }, { labelTr: "Siebenbachen", regionType: "shire", parentTr: "Groß-Benbach" },
{ labelTr: "Bad Homburg", regionType: "county", parentTr: "Siebenbachen" }, { labelTr: "Bad Homburg", regionType: "county", parentTr: "Siebenbachen" },
{ labelTr: "Maintal", regionType: "county", parentTr: "Siebenbachen" }, { labelTr: "Maintal", regionType: "county", parentTr: "Siebenbachen" },
{ labelTr: "Frankfurt", regionType: "city", parentTr: "Bad Homburg", map: {x: 187, y: 117, w: 10, h:11} }, { labelTr: "Frankfurt", regionType: "city", parentTr: "Bad Homburg", map: { x: 187, y: 117, w: 10, h: 11 } },
{ labelTr: "Oberursel", regionType: "city", parentTr: "Bad Homburg", map: {x: 168, y: 121, w: 10, h:11} }, { labelTr: "Oberursel", regionType: "city", parentTr: "Bad Homburg", map: { x: 168, y: 121, w: 10, h: 11 } },
{ labelTr: "Offenbach", regionType: "city", parentTr: "Bad Homburg", map: {x: 171, y: 142, w: 10, h:11} }, { labelTr: "Offenbach", regionType: "city", parentTr: "Bad Homburg", map: { x: 171, y: 142, w: 10, h: 11 } },
{ labelTr: "Königstein", regionType: "city", parentTr: "Maintal", map: {x: 207, y: 124, w: 24, h:18} }, { labelTr: "Königstein", regionType: "city", parentTr: "Maintal", map: { x: 207, y: 124, w: 24, h: 18 } },
]; ];
const relationships = [ const relationships = [
@@ -537,6 +539,29 @@ const politicalOfficePrerequisites = [
} }
]; ];
const undergroundTypes = [
{
"tr": "spyin",
"cost": 3000
},
{
"tr": "assassin",
"cost": 5000
},
{
"tr": "sabotage",
"cost": 10000
},
{
"tr": "corrupt_politician",
"cost": 15000
},
{
"tr": "rob",
"cost": 500
},
];
{ {
const giftNames = promotionalGifts.map(g => g.name); const giftNames = promotionalGifts.map(g => g.name);
const traitNames = characterTraits.map(t => t.name); const traitNames = characterTraits.map(t => t.name);
@@ -777,20 +802,29 @@ export const initializePoliticalOfficeTypes = async () => {
export const initializePoliticalOfficePrerequisites = async () => { export const initializePoliticalOfficePrerequisites = async () => {
for (const prereq of politicalOfficePrerequisites) { for (const prereq of politicalOfficePrerequisites) {
// zunächst den OfficeType anhand seines Namens (tr) ermitteln const office = await PoliticalOfficeType.findOne({
const office = await PoliticalOfficeType.findOne({ where: { name: prereq.officeTr }
where: { name: prereq.officeTr } });
}); if (!office) continue;
if (!office) continue;
await PoliticalOfficePrerequisite.findOrCreate({
// Nun findOrCreate mit dem neuen Spaltennamen: where: { office_type_id: office.id },
await PoliticalOfficePrerequisite.findOrCreate({ defaults: {
where: { office_type_id: office.id }, office_type_id: office.id,
defaults: { prerequisite: prereq.prerequisite
office_type_id: office.id, }
prerequisite: prereq.prerequisite });
}
});
} }
}; };
export const initializeUndergroundTypes = async () => {
for (const underground of undergroundTypes) {
await UndergroundType.findOrCreate({
where: { tr: underground.tr },
defaults: {
tr: underground.tr,
cost: underground.cost
}
});
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

@@ -7,7 +7,7 @@
:columns="branchColumns" :columns="branchColumns"
v-model="localSelectedBranch" v-model="localSelectedBranch"
:placeholder="$t('falukant.branch.selection.placeholder')" :placeholder="$t('falukant.branch.selection.placeholder')"
@input="updateSelectedBranch" @update:modelValue="updateSelectedBranch"
/> />
</div> </div>
<div> <div>
@@ -70,7 +70,6 @@ export default {
}, },
handleCreateBranch() { handleCreateBranch() {
// wird ausgelöst, sobald der Dialog onConfirm erfolgreich abschließt
this.$emit('createBranch'); this.$emit('createBranch');
}, },
}, },

View File

@@ -1,120 +1,141 @@
<template> <template>
<div class="director-info"> <div class="director-info">
<h3>{{ $t('falukant.branch.director.title') }}</h3> <h3>{{ $t('falukant.branch.director.title') }}</h3>
<div v-if="!director || director === null"> <div v-if="!director || director === null">
<button @click="openNewDirectorDialog">{{ $t('falukant.branch.director.actions.new') }}</button> <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>
<div v-else class="director-info-container"> <div>
<div> <table>
<table> <tr>
<tr> <td><button @click="fireDirector">{{ $t('falukant.branch.director.fire') }}</button></td>
<td>{{ $t('falukant.branch.director.name') }}</td> </tr>
<td> <tr>
{{ $t('falukant.titles.' + director.character.gender + '.' + director.character.title) }} <td><button @click="teachDirector">{{ $t('falukant.branch.director.teach') }}</button></td>
{{ director.character.name }} </tr>
</td> <tr>
</tr> <td>
<tr> <label>
<td>{{ $t('falukant.branch.director.salary') }}</td> <input type="checkbox" v-model="director.mayProduce"
<td>{{ director.income }}</td> @change="saveSetting('mayProduce', director.mayProduce)">
</tr> {{ $t('falukant.branch.director.produce') }}
<tr> </label>
<td>{{ $t('falukant.branch.director.satisfaction') }}</td> </td>
<td>{{ director.satisfaction }} %</td> </tr>
</tr> <!-- Ähnliche Checkboxen für maySell und mayStartTransport -->
</table> </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> </div>
</div> </div>
<NewDirectorDialog ref="newDirectorDialog" /> </div>
</template> <NewDirectorDialog ref="newDirectorDialog" />
</template>
<script>
import apiClient from '@/utils/axios.js'; <script>
import NewDirectorDialog from '@/dialogues/falukant/NewDirectorDialog.vue'; import apiClient from '@/utils/axios.js';
import NewDirectorDialog from '@/dialogues/falukant/NewDirectorDialog.vue';
export default {
name: "DirectorInfo", export default {
props: { branchId: { type: Number, required: true } }, name: "DirectorInfo",
components: { props: { branchId: { type: Number, required: true } },
NewDirectorDialog components: {
}, NewDirectorDialog
data() { },
return { data() {
director: null, return {
showNewDirectorDialog: false, director: null,
}; showNewDirectorDialog: false,
}, };
async mounted() { },
async mounted() {
await this.loadDirector();
},
methods: {
async refresh() {
await this.loadDirector(); await this.loadDirector();
}, },
methods: {
async loadDirector() { async loadDirector() {
try { try {
const response = await apiClient.get(`/api/falukant/director/${this.branchId}`); 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; const data = response.data;
} catch (error) { if (
console.error('Error loading director:', error); !data ||
(Array.isArray(data) && data.length === 0) ||
typeof data.director === 'undefined' ||
data.director === null
) {
this.director = null;
} else {
this.director = data.director;
} }
}, } catch (error) {
async saveSetting(settingKey, value) { console.error('Error loading director:', error);
if (!this.director) return; this.director = null;
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> async saveSetting(settingKey, value) {
if (!this.director) return;
<style scoped> try {
.director-info { await apiClient.post(`/api/falukant/director/settings`, {
border: 1px solid #ccc; branchId: this.branchId,
margin: 10px 0; directorId: this.director.id,
border-radius: 4px; settingKey,
padding: 10px; value,
} });
.director-info-container { } catch (error) {
display: flex; console.error(`Error saving setting ${settingKey}:`, error);
} }
.director-info-container > div { },
width: 100%;
} openNewDirectorDialog() {
</style> 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>

View File

@@ -10,7 +10,7 @@
</template> </template>
<span v-if="statusItems.length > 0"> <span v-if="statusItems.length > 0">
<template v-for="(menuItem, key) in menu.falukant.children" :key="menuItem.id" > <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> </template>
</span> </span>
</div> </div>

View File

@@ -334,7 +334,8 @@
"salary": "Gehalt", "salary": "Gehalt",
"skills": "Wissen", "skills": "Wissen",
"product": "Produkt", "product": "Produkt",
"knowledge": "Produktwissen" "knowledge": "Produktwissen",
"hire": "Einstellen"
}, },
"skillKnowledges": { "skillKnowledges": {
"excelent": "Exzellent", "excelent": "Exzellent",
@@ -434,7 +435,8 @@
"type": { "type": {
"backyard_room": "Hinterhofzimmer", "backyard_room": "Hinterhofzimmer",
"wooden_house": "Holzhütte", "wooden_house": "Holzhütte",
"straw_hut": "Strohhütte" "straw_hut": "Strohhütte",
"family_house": "Familienhaus"
} }
}, },
"nobility": { "nobility": {
@@ -675,6 +677,46 @@
"councillor": "Stadtrat", "councillor": "Stadtrat",
"assessor": "Schätzer" "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"
}
} }
} }
} }

View File

@@ -11,7 +11,8 @@
"administration": "Verwaltung", "administration": "Verwaltung",
"m-chats": { "m-chats": {
"multiChat": "Multiuser-Chat", "multiChat": "Multiuser-Chat",
"randomChat": "Zufalls-Singlechat" "randomChat": "Zufalls-Singlechat",
"eroticChat": "Erotikchat"
}, },
"m-socialnetwork": { "m-socialnetwork": {
"guestbook": "Gästebuch", "guestbook": "Gästebuch",
@@ -20,7 +21,12 @@
"gallery": "Galerie", "gallery": "Galerie",
"blockedUsers": "Blockierte Benutzer", "blockedUsers": "Blockierte Benutzer",
"oneTimeInvitation": "Einmal-Einladungen", "oneTimeInvitation": "Einmal-Einladungen",
"diary": "Tagebuch" "diary": "Tagebuch",
"erotic": "Erotik",
"m-erotic": {
"pictures": "Bilder",
"videos": "Videos"
}
}, },
"m-settings": { "m-settings": {
"homepage": "Startseite", "homepage": "Startseite",

View File

@@ -12,6 +12,7 @@ import BankView from '../views/falukant/BankView.vue';
import DirectorView from '../views/falukant/DirectorView.vue'; import DirectorView from '../views/falukant/DirectorView.vue';
import HealthView from '../views/falukant/HealthView.vue'; import HealthView from '../views/falukant/HealthView.vue';
import PoliticsView from '../views/falukant/PoliticsView.vue'; import PoliticsView from '../views/falukant/PoliticsView.vue';
import UndergroundView from '../views/falukant/UndergroundView.vue';
const falukantRoutes = [ const falukantRoutes = [
{ {
@@ -98,6 +99,12 @@ const falukantRoutes = [
component: PoliticsView, component: PoliticsView,
meta: { requiresAuth: true } meta: { requiresAuth: true }
}, },
{
path: '/falukant/darknet',
name: 'UndergroundView',
component: UndergroundView,
meta: { requiresAuth: true }
},
]; ];
export default falukantRoutes; export default falukantRoutes;

View File

@@ -1,291 +1,271 @@
<template> <template>
<div class="contenthidden"> <div class="contenthidden">
<StatusBar ref="statusBar" /> <StatusBar ref="statusBar" />
<div class="contentscroll"> <div class="contentscroll">
<h2>{{ $t('falukant.branch.title') }}</h2> <h2>{{ $t('falukant.branch.title') }}</h2>
<BranchSelection <BranchSelection :branches="branches" :selectedBranch="selectedBranch" @branchSelected="onBranchSelected"
:branches="branches" @createBranch="createBranch" @upgradeBranch="upgradeBranch" ref="branchSelection" />
:selectedBranch="selectedBranch"
@branchSelected="onBranchSelected" <DirectorInfo v-if="selectedBranch" :branchId="selectedBranch.id" ref="directorInfo" />
@createBranch="createBranch"
@upgradeBranch="upgradeBranch" <SaleSection v-if="selectedBranch" :branchId="selectedBranch.id" ref="saleSection" />
ref="branchSelection"
/> <ProductionSection v-if="selectedBranch" :branchId="selectedBranch.id" :products="products"
ref="productionSection" />
<DirectorInfo
v-if="selectedBranch" <StorageSection v-if="selectedBranch" :branchId="selectedBranch.id" ref="storageSection" />
:branchId="selectedBranch.id"
ref="directorInfo" <RevenueSection v-if="selectedBranch" :products="products"
/> :calculateProductRevenue="calculateProductRevenue" :calculateProductProfit="calculateProductProfit"
ref="revenueSection" />
<SaleSection </div>
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> </div>
</template> </template>
<script> <script>
import StatusBar from '@/components/falukant/StatusBar.vue'; import StatusBar from '@/components/falukant/StatusBar.vue';
import BranchSelection from '@/components/falukant/BranchSelection.vue'; import BranchSelection from '@/components/falukant/BranchSelection.vue';
import DirectorInfo from '@/components/falukant/DirectorInfo.vue'; import DirectorInfo from '@/components/falukant/DirectorInfo.vue';
import SaleSection from '@/components/falukant/SaleSection.vue'; import SaleSection from '@/components/falukant/SaleSection.vue';
import ProductionSection from '@/components/falukant/ProductionSection.vue'; import ProductionSection from '@/components/falukant/ProductionSection.vue';
import StorageSection from '@/components/falukant/StorageSection.vue'; import StorageSection from '@/components/falukant/StorageSection.vue';
import RevenueSection from '@/components/falukant/RevenueSection.vue'; import RevenueSection from '@/components/falukant/RevenueSection.vue';
import apiClient from '@/utils/axios.js'; import apiClient from '@/utils/axios.js';
import { mapState } from 'vuex'; import { mapState } from 'vuex';
export default { export default {
name: "BranchView", name: "BranchView",
components: { components: {
StatusBar, StatusBar,
BranchSelection, BranchSelection,
DirectorInfo, DirectorInfo,
SaleSection, SaleSection,
ProductionSection, ProductionSection,
StorageSection, StorageSection,
RevenueSection, RevenueSection,
}, },
data() { data() {
return { return {
branches: [], branches: [],
selectedBranch: null, selectedBranch: null,
products: [], products: [],
}; };
}, },
computed: { computed: {
...mapState(['socket', 'daemonSocket']), ...mapState(['socket', 'daemonSocket']),
}, },
async mounted() { 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(); await this.loadBranches();
},
const branchId = this.$route.params.branchId;
upgradeBranch() { await this.loadProducts();
if (this.selectedBranch) {
alert( if (branchId) {
this.$t( this.selectedBranch = this.branches.find(
'falukant.branch.actions.upgradeAlert', b => b.id === parseInt(branchId, 10)
{ branchId: this.selectedBranch.id } ) || null;
) } else {
); this.selectMainBranch();
} }
},
// Daemon-Socket
selectMainBranch() { if (this.daemonSocket) {
const main = this.branches.find(b => b.isMainBranch) || null; this.daemonSocket.addEventListener('message', this.handleDaemonMessage);
if (main && main !== this.selectedBranch) {
this.selectedBranch = main;
} }
},
// Live-Socket-Events
calculateProductRevenue(product) { [
if (!product.knowledges || product.knowledges.length === 0) { "production_ready",
return { absolute: 0, perMinute: 0 }; "stock_change",
} "price_update",
const knowledgeFactor = product.knowledges[0].knowledge || 0; "director_death",
const maxPrice = product.sellCost; "production_started",
const minPrice = maxPrice * 0.6; "selled_items",
const revenuePerUnit = minPrice + (maxPrice - minPrice) * (knowledgeFactor / 100); "falukantUpdateStatus",
const perMinute = product.productionTime > 0 "falukantBranchUpdate",
? revenuePerUnit / product.productionTime "knowledge_update"
: 0; ].forEach(eventName => {
return { if (this.socket) {
absolute: revenuePerUnit.toFixed(2), this.socket.on(eventName, data => this.handleEvent({ event: eventName, ...data }));
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> beforeUnmount() {
[
<style scoped lang="scss"> "production_ready",
h2 { "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; padding-top: 20px;
} }
</style> </style>

View File

@@ -101,7 +101,7 @@ export default {
try { try {
const { data } = await apiClient.get('/api/falukant/health'); const { data } = await apiClient.get('/api/falukant/health');
this.age = data.age; this.age = data.age;
this.healthStatus = data.status; this.healthStatus = data.health;
this.measuresTaken = data.history; this.measuresTaken = data.history;
this.availableMeasures = data.healthActivities; this.availableMeasures = data.healthActivities;
} catch (err) { } catch (err) {

View 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>