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:
@@ -97,16 +97,26 @@ async function getBranchOrFail(userId, branchId) {
|
||||
return branch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gesamtkosten für eine Produktionscharge (früher: quantity * category * 6 pro Einheit).
|
||||
* Pro Einheit jetzt 2 * Kategorie (z.B. Kat.1 = 2, Kat.2 = 4), damit Nettoerlös und
|
||||
* typischer town_product_worth (oft 40–60 %, siehe Model-Hook) zusammenpassen.
|
||||
*/
|
||||
function productionCostTotal(quantity, category) {
|
||||
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;
|
||||
|
||||
function productionPieceCost(certificate, category) {
|
||||
const c = Math.max(1, Number(category) || 1);
|
||||
const cert = Math.max(1, Number(certificate) || 1);
|
||||
const raw = PRODUCTION_COST_BASE + (c * PRODUCTION_COST_PER_PRODUCT_CATEGORY);
|
||||
const headroom = Math.max(0, cert - c);
|
||||
const discount = Math.min(
|
||||
headroom * PRODUCTION_HEADROOM_DISCOUNT_PER_STEP,
|
||||
PRODUCTION_HEADROOM_DISCOUNT_CAP
|
||||
);
|
||||
return raw * (1 - discount);
|
||||
}
|
||||
|
||||
function productionCostTotal(quantity, category, certificate) {
|
||||
const q = Math.min(100, Math.max(1, Number(quantity) || 1));
|
||||
const perUnit = 2 * c;
|
||||
return q * perUnit;
|
||||
return q * productionPieceCost(certificate, category);
|
||||
}
|
||||
|
||||
/** Regionaler Nachfragewert: sehr niedrige Werte aus der DB sonst unspielbar; Decke nach oben bei 100. */
|
||||
@@ -2053,7 +2063,7 @@ class FalukantService extends BaseService {
|
||||
}
|
||||
if (!p) throw new Error('Product not found');
|
||||
quantity = Math.min(100, quantity);
|
||||
const cost = productionCostTotal(quantity, p.category);
|
||||
const cost = productionCostTotal(quantity, p.category, u.certificate);
|
||||
if (u.money < cost) throw new Error('notenoughmoney');
|
||||
const r = await updateFalukantUserMoney(u.id, -cost, 'Production cost', u.id);
|
||||
if (!r.success) throw new Error('Failed to update money');
|
||||
|
||||
Reference in New Issue
Block a user