Update product definitions and revenue calculations in Falukant: Adjust product sell costs and production times for better balance. Refactor revenue calculations to focus on profit per minute instead of revenue per minute. Enhance localization files to include new terms related to product unlocks and certificate levels in English, German, and Spanish, improving user experience across languages.

This commit is contained in:
Torsten Schulz (local)
2026-03-26 20:19:49 +01:00
parent 01849c8ffe
commit e0c3b472db
10 changed files with 303 additions and 43 deletions

View File

@@ -15,6 +15,28 @@
</div>
</section>
<section class="branch-certificate surface-card">
<div class="branch-certificate__header">
<div>
<h3>{{ $t('falukant.branch.certificate.title') }}</h3>
<p>{{ $t('falukant.branch.certificate.description') }}</p>
</div>
<span class="branch-hero__badge">
{{ $t('falukant.branch.currentCertificate') }}: {{ currentCertificate ?? 1 }}
</span>
</div>
<div class="branch-certificate__grid">
<article class="branch-certificate__block">
<h4>{{ $t('falukant.branch.certificate.currentUnlocks') }}</h4>
<p>{{ currentCertificateProducts.join(', ') }}</p>
</article>
<article v-if="nextCertificateProducts.length" class="branch-certificate__block">
<h4>{{ $t('falukant.branch.certificate.nextUnlocks', { level: nextCertificateLevel }) }}</h4>
<p>{{ nextCertificateProducts.join(', ') }}</p>
</article>
</div>
</section>
<section
v-if="debtorsPrison.active"
class="branch-debt-warning surface-card"
@@ -84,6 +106,7 @@
<ProductionSection
:branchId="selectedBranch.id"
:products="products"
:current-certificate="currentCertificate"
ref="productionSection"
/>
<!-- Tax summary for production -->
@@ -363,6 +386,19 @@ import apiClient from '@/utils/axios.js';
import { mapState } from 'vuex';
import { showError, showSuccess, showApiError } from '@/utils/feedback.js';
const CERTIFICATE_PRODUCT_LEVELS = [
{ level: 1, products: ['fish', 'meat', 'leather', 'wood', 'stone', 'milk', 'cheese', 'bread', 'wheat', 'grain', 'carrot'] },
{ level: 2, products: ['beer', 'iron', 'copper', 'spices', 'salt', 'sugar', 'vinegar', 'cotton', 'wine'] },
{ level: 3, products: ['gold', 'diamond', 'furniture', 'clothing'] },
{ level: 4, products: ['jewelry', 'painting', 'book', 'weapon', 'armor', 'shield'] },
{ level: 5, products: ['horse', 'ox'] },
];
const PRODUCTION_COST_BASE = 6.0;
const PRODUCTION_COST_PER_PRODUCT_CATEGORY = 1.0;
const PRODUCTION_HEADROOM_DISCOUNT_PER_STEP = 0.035;
const PRODUCTION_HEADROOM_DISCOUNT_CAP = 0.14;
export default {
name: "BranchView",
components: {
@@ -468,6 +504,23 @@ export default {
// 10% Rabatt für Reparatur aller Fahrzeuge
return Math.round(totalCost * 0.9);
},
currentCertificateProducts() {
const certificate = Number(this.currentCertificate || 1);
return CERTIFICATE_PRODUCT_LEVELS
.filter((entry) => entry.level <= certificate)
.flatMap((entry) => entry.products)
.map((productKey) => this.$t(`falukant.product.${productKey}`));
},
nextCertificateLevel() {
const current = Number(this.currentCertificate || 1);
return current < CERTIFICATE_PRODUCT_LEVELS.length ? current + 1 : null;
},
nextCertificateProducts() {
const nextEntry = CERTIFICATE_PRODUCT_LEVELS.find((entry) => entry.level === this.nextCertificateLevel);
return nextEntry
? nextEntry.products.map((productKey) => this.$t(`falukant.product.${productKey}`))
: [];
},
},
async mounted() {
@@ -540,6 +593,17 @@ export default {
},
methods: {
calculateProductionPieceCost(productCategory) {
const category = Math.max(1, Number(productCategory) || 1);
const certificate = Math.max(1, Number(this.currentCertificate) || 1);
const raw = PRODUCTION_COST_BASE + (category * PRODUCTION_COST_PER_PRODUCT_CATEGORY);
const headroom = Math.max(0, certificate - category);
const discount = Math.min(
headroom * PRODUCTION_HEADROOM_DISCOUNT_PER_STEP,
PRODUCTION_HEADROOM_DISCOUNT_CAP
);
return raw * (1 - discount);
},
matchesCurrentUser(eventData) {
if (eventData?.user_id == null) {
return true;
@@ -798,7 +862,7 @@ export default {
const { absolute: revenueAbsoluteStr, perMinute: revenuePerMinuteStr }
= this.calculateProductRevenue(product);
const revenueAbsolute = parseFloat(revenueAbsoluteStr);
const costPerUnit = 6 * product.category;
const costPerUnit = this.calculateProductionPieceCost(product.category);
const profitAbsolute = revenueAbsolute - costPerUnit;
const costPerMinute = product.productionTime > 0
? costPerUnit / product.productionTime
@@ -1267,6 +1331,45 @@ export default {
font-weight: 600;
}
.branch-certificate {
margin-bottom: 16px;
padding: 18px;
}
.branch-certificate__header {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 16px;
margin-bottom: 14px;
}
.branch-certificate__header p {
margin: 6px 0 0;
color: var(--color-text-secondary);
}
.branch-certificate__grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 14px;
}
.branch-certificate__block {
padding: 14px 16px;
border-radius: var(--radius-lg);
background: rgba(138, 84, 17, 0.06);
}
.branch-certificate__block h4 {
margin: 0 0 8px;
}
.branch-certificate__block p {
margin: 0;
color: var(--color-text-secondary);
}
.branch-tab-content {
margin-top: 16px;
padding: 18px;