Create win/lose outcome logic. An event must resolve with consequences.

Every event needs a resolution — did you win or lose? And what happens as a result? The resolution engine takes inputs (player power, enemy power) and produces consequences (XP gained, XP lost). Without resolution, events are meaningless. Today we make them matter.

Ami — Combat Risk Engine

Battle Resolution:

  • Player Power = 10 + (riskLevel * 2)
  • Enemy Power = random between 5 and 20
  • If Player Power > Enemy Power → Win (+XP based on riskLevel)
  • If Enemy Power >= Player Power → Lose (lose all unbanked XP, respawn to Camp)
Ida — Economic Growth Engine

Build Resolution:

  • Build Cost = deduct materials (karma or debt)
  • Completion = add payout to karma
  • If karma drops below -50 → forced bankruptcy reset

The decision: take on debt for bigger builds, or stay safe with small jobs?

Ami's battle resolution function:

function resolveEncounter() { if (!gameState.activeEvent) return; const playerPower = 10 + (gameState.riskLevel * 2); const enemyPower = gameState.activeEvent.enemyPower; if (playerPower > enemyPower) { // Win — gain XP based on risk const xpGain = gameState.riskLevel * 5; gameState.unbankedXP += xpGain; console.log(`Victory! +${xpGain} XP (Power: ${playerPower} vs ${enemyPower})`); } else { // Lose — lose all unbanked XP, respawn console.log(`Defeat! Lost ${gameState.unbankedXP} unbanked XP (Power: ${playerPower} vs ${enemyPower})`); gameState.unbankedXP = 0; gameState.zone = "safe"; // Respawn to Camp } gameState.activeEvent = null; // Clear the event }

Ida's build resolution function:

function resolveBuild() { if (!gameState.activeEvent) return; const job = gameState.activeEvent; // Deduct cost gameState.karma -= job.cost; console.log(`Building... Cost: -${job.cost} karma`); // Add payout gameState.karma += job.payout; console.log(`Complete! Payout: +${job.payout} karma. Net: ${job.payout - job.cost}`); // Check bankruptcy if (gameState.karma < -50) { console.log("BANKRUPTCY! Karma below -50. Resetting all progress."); gameState.karma = 0; gameState.debt = 0; // Reset other progress as needed } gameState.activeEvent = null; // Clear the event }
  • Implement resolveEncounter() for Ami
  • Implement resolveBuild() for Ida
  • Update gameState after resolution
  • Test winning scenario
  • Test losing scenario
  • Verify consequences feel meaningful
  • Checkpoint

    You can win and gain XP/karma. You can lose and feel real consequences. State updates correctly after each resolution.

    No complex stats. Single variable power only. No inventory. No special abilities.

    Not resetting state after loss — unbanked XP must go to zero, zone must reset to safe.

    Making wins too easy — if the player always wins, there is no challenge and no tension.

    Making losses too harsh — if the player loses everything every time, they quit. Balance matters.

    Not testing both outcomes — you must verify both winning and losing paths work correctly.

    This is applied math. The combat formula is simple but powerful. Ask them to calculate: "With riskLevel 3, what's your power? What's the chance of winning?" Player Power would be 10 + (3 * 2) = 16. Enemy range is 5-20. So the player wins against enemies with power 5-15 (11 out of 16 possibilities). Make them reason about probability.