Skip to content

Commit

Permalink
fix: System attack
Browse files Browse the repository at this point in the history
- Wrong variable
- If ship.experience = 0, damage was always 0
- Add damage to ship.experience
  • Loading branch information
Clashsoft committed Aug 9, 2024
1 parent 0a646b0 commit 17b9bfb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/game-logic/game-logic.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,10 @@ export class GameLogicService {
variables: Partial<Record<Variable, number>>,
jobs: JobDocument[],
) {
const attack = variables[`ships.${ship.type}.damage.system` as Variable] ?? variables[`ships.${ship.type}.damage.default` as Variable] ?? 0;
const attack = variables[`ships.${ship.type}.attack.system` as Variable] ?? variables[`ships.${ship.type}.attack.default` as Variable] ?? 0;
// The damage is calculated using A.attack.system / system.defense + log(A.experience)
const damage = Math.max(attack / defense + Math.log(ship.experience), 0);
const damage = Math.max(attack / defense + Math.log1p(ship.experience), 0);
ship.experience += damage;
system.health -= damage;
if (system.health > 0) {
return;
Expand Down

0 comments on commit 17b9bfb

Please sign in to comment.