server: missions — type configs, level gate, loot, fine on failure, abandon

Each mission type now has a typeConfig (moneyFactor, xpFactor, repFactor,
riskShift, requiredItemChance, lootChance). startMission checks minLevel.
claimMission awards loot items on success; applies a police-scaled fine
on failure. New abandonMission endpoint (POST /:id/abandon, −1 rep).
computeSuccessChance extracted for reuse between listAvailable and claim.
Narrative template pool expanded (4 templates × 4 types).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 00:11:33 +02:00
parent 8804dfeb22
commit 1568520533
4 changed files with 368 additions and 55 deletions
+58 -2
View File
@@ -97,9 +97,65 @@ export const balance = {
/** Ricompensa XP: base + difficulty * perDifficulty */
rewardXpBase: 20,
rewardXpPerDifficulty: 30,
/** probabilità che una missione DELIVERY/SMUGGLING richieda oggetti */
requiredItemChance: 0.4,
requiredItemQuantityMax: 3,
/**
* Carattere meccanico di ogni tipo di missione:
* - moneyFactor/xpFactor/repFactor: moltiplicatori delle ricompense
* - riskShift: spostamento del rischio base
* - requiredItemChance: probabilità che serva merce dall'inventario
* - lootChance/lootQuantityMax: probabilità e quantità del bottino in merce
*/
typeConfig: {
DELIVERY: {
moneyFactor: 1.0,
xpFactor: 1.0,
repFactor: 1,
riskShift: -0.05,
requiredItemChance: 0.6,
lootChance: 0,
lootQuantityMax: 0,
},
THEFT: {
moneyFactor: 0.6,
xpFactor: 1.0,
repFactor: 1,
riskShift: 0.05,
requiredItemChance: 0,
lootChance: 0.8,
lootQuantityMax: 2,
},
SMUGGLING: {
moneyFactor: 1.6,
xpFactor: 0.9,
repFactor: 1,
riskShift: 0.1,
requiredItemChance: 0.5,
lootChance: 0.25,
lootQuantityMax: 1,
},
INTEL: {
moneyFactor: 0.5,
xpFactor: 1.8,
repFactor: 2,
riskShift: -0.1,
requiredItemChance: 0,
lootChance: 0,
lootQuantityMax: 0,
},
},
/** livello minimo richiesto, indicizzato per difficoltà (1-5) */
minLevelByDifficulty: [1, 1, 1, 2, 4, 6],
/**
* Multa sul fallimento: rewardMoney * rewardFactor * pressione polizia,
* mai oltre il denaro posseduto dal giocatore.
*/
failFine: {
rewardFactor: 0.3,
},
/** abbandono volontario di una missione attiva */
abandon: {
reputationLoss: 1,
},
/**
* Probabilità di successo al claim:
* chance = baseChance