Skip to content

feat(fleets): combat statistics, defense repair, moon chance and plunder - #47

Merged
rolljee merged 2 commits into
masterfrom
feat/combat-statistics
Oct 2, 2026
Merged

rolljee merged 2 commits into
masterfrom
feat/combat-statistics

Conversation

@rolljee

@rolljee rolljee commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Why

First building block of a combat simulator on ogame.rolljee.fr: the site needs averaged outcomes over many battles, not one random run.

What

  • fix: the explosion chance of a unit under 70% hull is now rolled on every hit that gets through, as in the game, instead of once at the end of the round. Shots on a unit already wrecked this round are wasted. A statistical test shows the difference (82% vs 72% on a 2-battleship / 1-cruiser case).
  • feat simulateCombat now also returns:
    • defender.rebuilt: each destroyed defense comes back with a repairFactor chance (0.7 by default)
    • moonChance: 1% per 100 000 debris, capped at 20%
    • plunder: with options.plunder = { resources, ratio = 0.5, hyperspaceLevel, … }, what a winning attacker's survivors can carry (capacity via getCargoCapacity), spread like the resources on the planet
    • defenseDebrisFactor option (maps debrisFactorDef of serverData); defenseDebris: true keeps working
  • feat simulateCombats(attacker, defender, { runs, seed, … }) and getCombatStatistics(results): win shares, average rounds, survivors, losses, rebuilt defenses, lost resources (rebuilt defenses excluded), debris, moon chance, plunder.

Non-breaking: new fields and functions only. Battles replayed with the same seed give different outcomes because of the explosion fix.

Known approximations (to validate against OSimulate)

  • Loot spread proportionally to the planet's resources (the total is right either way).
  • No class / lifeform bonuses on combat stats, no ACS yet.

Checks

npm run lint && npm test && npm run types: 399 tests pass.

🤖 Generated with Claude Code

rolljee and others added 2 commits October 2, 2026 17:17
A unit left under 70% of its hull now gets an explosion roll on each shot
that gets through, as in the game, instead of a single roll at the end of
the round. Shots on a unit already wrecked this round are wasted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and plunder

simulateCombat now reports, for each battle, the destroyed defenses that come
back (repairFactor, 0.7 by default), the moon chance given by the debris
field, and what a winning attacker carries away when `plunder` says what lies
on the planet. Defenses can leave debris at their own defenseDebrisFactor.

simulateCombats runs the same battle many times, and getCombatStatistics
averages a set of results: share of wins, average losses, survivors, rebuilt
defenses, lost resources, debris, moon chance and plunder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rolljee
rolljee merged commit 2466de3 into master Oct 2, 2026
3 checks passed
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 4.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant