Skip to content

Commit

Permalink
tick damage bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ZinixZay committed Jan 12, 2024
1 parent 509eb8d commit 6b952cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions rpgsaga/saga/src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ export class Game {
for (let i = 0; i < shuffledPlayers.length - 1; i += 2) {
shuffledPlayers[i].health = shuffledPlayers[i].full_health
shuffledPlayers[i].abilityAbsense = false
shuffledPlayers[i].tickDamage = 0

shuffledPlayers[i + 1].health = shuffledPlayers[i + 1].full_health
shuffledPlayers[i + 1].abilityAbsense = false
shuffledPlayers[i + 1].tickDamage = 0

winners.push(this.fight(shuffledPlayers[i], shuffledPlayers[i + 1]))
console.log()
}
Expand Down Expand Up @@ -85,6 +89,14 @@ export class Game {
}
}
}
if (attackingPlayer.tickDamage > 0){
attackingPlayer.health -= attackingPlayer.tickDamage
Logger.ticked(attackingPlayer)
if (attackingPlayer.health <= 0) { // если у защищающегося закончилось хп
Logger.death(attackingPlayer)
return defendingPlayer
}
}
if (turn){ // смена хода
turn = false
} else {
Expand Down
4 changes: 4 additions & 0 deletions rpgsaga/saga/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ export class Logger {
static death(player: Player){
console.log(`(${player.type}) ${player.name} погибает`)
}

static ticked(player: Player){
console.log(`(${player.type}) ${player.name} получает ${player.tickDamage} урона от горения`)
}
}

0 comments on commit 6b952cf

Please sign in to comment.