Skip to content

Commit

Permalink
saga bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ZinixZay committed Jan 12, 2024
1 parent 2fcdf98 commit 509eb8d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions rpgsaga/saga/src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ export class Game {
const winners: Player[] = []
console.log(`Кон ${count}.`)
for (let i = 0; i < shuffledPlayers.length - 1; i += 2) {
shuffledPlayers[i].health =shuffledPlayers[i].full_health
shuffledPlayers[i + 1].health =shuffledPlayers[i + 1].full_health
shuffledPlayers[i].health = shuffledPlayers[i].full_health
shuffledPlayers[i].abilityAbsense = false
shuffledPlayers[i + 1].health = shuffledPlayers[i + 1].full_health
shuffledPlayers[i + 1].abilityAbsense = false
winners.push(this.fight(shuffledPlayers[i], shuffledPlayers[i + 1]))
console.log()
}
Expand All @@ -61,7 +63,6 @@ export class Game {
if (randomInt(0, 1)){ // если применяется способность
if (attackingPlayer.abilityAbsense){ // если стрелы уже использовались
let damage = attackingPlayer.dealDmg(defendingPlayer)
damage += defendingPlayer.tickDamage
Logger.makeDamage(attackingPlayer, defendingPlayer, damage)
if (defendingPlayer.health <= 0) { // если у защищающегося закончилось хп
Logger.death(defendingPlayer)
Expand All @@ -77,9 +78,6 @@ export class Game {
}
} else { // если способность не применяется
let damage = attackingPlayer.dealDmg(defendingPlayer)
if (defendingPlayer.tickDamage){ // если на защищающемся тик дмг
damage += defendingPlayer.tickDamage
}
Logger.makeDamage(attackingPlayer, defendingPlayer, damage)
if (defendingPlayer.health <= 0) { // если у защищающегося закончилось хп
Logger.death(defendingPlayer)
Expand Down
2 changes: 1 addition & 1 deletion rpgsaga/saga/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Game } from "./game";

const game = new Game(6)
const game = new Game(8)
game.start()

0 comments on commit 509eb8d

Please sign in to comment.