Skip to content

Commit

Permalink
adding powerup & life total checks to DMG box result
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Brennan authored and Jon Brennan committed Dec 19, 2023
1 parent 8bea3a1 commit 76283e0
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/components/Game.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,6 @@ export const DungeonThrowdown = {
(die) => die === "def"
).length;

// if (isPlayer1) {
// G.battleDice.p1 = { type: "atk", roll: attackRoll };
// G.battleDice.p2 = { type: "def", roll: defenseRoll };
// } else {
// G.battleDice.p2 = { type: "atk", roll: attackRoll };
// G.battleDice.p1 = { type: "def", roll: defenseRoll };
// }

if (isPlayer1) {
G.battleDice.p1 = attackRoll;
G.battleDice.p2 = defenseRoll;
Expand Down Expand Up @@ -236,14 +228,25 @@ export const DungeonThrowdown = {
currentPlayer.hitPoints += boxRollResult.amount;
G.messages.game = `${currentPlayerName} finds a ${boxRollResult.name} and gains ${boxRollResult.amount} hit point!`;
} else if (boxRollResult.type === "DMG") {
opponent.hitPoints -= boxRollResult.amount;
G.messages.game = `${currentPlayerName} finds a ${boxRollResult.name} -- ${opponent.name} is struck and loses ${boxRollResult.amount} hit point!`;
if (opponent.powerup) {
opponent.powerup = null;
opponent.attackBoost = 0;
opponent.defenseBoost = 0;
G.messages.game = `${currentPlayerName} finds a ${boxRollResult.name} -- ${opponent.name}'s ${opponent.powerup.name} absorbs the damage, but is lost!`;
} else {
opponent.hitPoints -= boxRollResult.amount;
G.messages.game = `${currentPlayerName} finds a ${boxRollResult.name} -- ${opponent.name} is struck and loses ${boxRollResult.amount} hit point!`;
if (opponent.hitPoints <= 0) {
G.tiles[opponent.position] = null;
opponent.position = null;
G.messages.game += ` ${currentPlayerName} WINS!`;
}
}
} else if (boxRollResult.type === "ATK") {
currentPlayer.powerup = boxRollResult;
// reset any boosts from previous powerup
currentPlayer.attackBoost = 0;
currentPlayer.defenseBoost = 0;

currentPlayer.attackBoost += boxRollResult.amount;
G.messages.game = `${currentPlayerName} finds a ${boxRollResult.name} and adds ${boxRollResult.amount} to attack dice!`;
} else if (boxRollResult.type === "DEF") {
Expand Down

0 comments on commit 76283e0

Please sign in to comment.