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:
@@ -64,11 +64,18 @@
|
||||
<script>
|
||||
import apiClient from '@/utils/axios.js';
|
||||
import { showApiError } from '@/utils/feedback.js';
|
||||
|
||||
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: "ProductionSection",
|
||||
props: {
|
||||
branchId: { type: Number, required: true },
|
||||
products: { type: Array, required: true },
|
||||
currentCertificate: { type: Number, default: 1 },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -125,7 +132,7 @@
|
||||
calculateProductionCost() {
|
||||
if (!this.products) return 0;
|
||||
const product = this.products.find(p => p.id === this.selectedProduct);
|
||||
return product ? 6 * product.category * this.productionQuantity : 0;
|
||||
return product ? this.calculateProductionPieceCost(product.category) * this.productionQuantity : 0;
|
||||
},
|
||||
calculateProductionDuration(productId) {
|
||||
if (!this.products || !productId) return 0;
|
||||
@@ -152,6 +159,17 @@
|
||||
const secondsLeft = Math.max(Math.floor((end - this.currentTime) / 1000), 0);
|
||||
return secondsLeft;
|
||||
},
|
||||
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);
|
||||
},
|
||||
async startProduction() {
|
||||
if (this.selectedProduct && this.productionQuantity > 0) {
|
||||
this.productionQuantity = Math.min(this.productionQuantity, 200);
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="product in products" :key="product.id" :class="{ highlight: product.id === productWithMaxRevenuePerMinute?.id }">
|
||||
<tr v-for="product in products" :key="product.id" :class="{ highlight: product.id === productWithMaxProfitPerMinute?.id }">
|
||||
<td>{{ $t(`falukant.product.${product.labelTr}`) }}</td>
|
||||
<td>{{ product.knowledges && product.knowledges[0] ? product.knowledges[0].knowledge : 0 }}</td>
|
||||
<td>{{ calculateProductRevenue(product).absolute }}</td>
|
||||
@@ -64,12 +64,12 @@
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
productWithMaxRevenuePerMinute() {
|
||||
productWithMaxProfitPerMinute() {
|
||||
if (!this.products || this.products.length === 0) return null;
|
||||
return this.products.reduce((maxProduct, currentProduct) => {
|
||||
const currentRevenue = parseFloat(this.calculateProductRevenue(currentProduct).perMinute);
|
||||
const maxRevenue = maxProduct ? parseFloat(this.calculateProductRevenue(maxProduct).perMinute) : 0;
|
||||
return currentRevenue > maxRevenue ? currentProduct : maxProduct;
|
||||
const currentProfit = parseFloat(this.calculateProductProfit(currentProduct).perMinute);
|
||||
const maxProfit = maxProduct ? parseFloat(this.calculateProductProfit(maxProduct).perMinute) : Number.NEGATIVE_INFINITY;
|
||||
return currentProfit > maxProfit ? currentProduct : maxProduct;
|
||||
}, null);
|
||||
},
|
||||
},
|
||||
@@ -223,4 +223,4 @@
|
||||
font-style: italic;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user