Skip to content

Commit

Permalink
bugfix in damage. < instead of >
Browse files Browse the repository at this point in the history
  • Loading branch information
mklemmingen committed Dec 5, 2023
1 parent 7ef0ce9 commit d6b9e1d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions core/src/com/boomchess/game/backend/Damage.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public static void dealBigBoom(int positionAttX, int positionAttY, int positionD
for (int i = startX; i <= endX; i++) {
for (int j = startY; j <= endY; j++) {
if (i == positionAttX && j == positionAttY) continue; // Skip on checking the original piece
if (!(gameBoard[i][j] instanceof Empty)){
if (!(gameBoard[i][j] instanceof Hill)){
if (!(gameBoard[i][j] instanceof Empty)) {
if (!(gameBoard[i][j] instanceof Hill)) {
String hurtColor = gameBoard[i][j].getTeamColor();
if (!hurtColor.equals(soldierAttack.getTeamColor())) {
enemyCount++;
Expand All @@ -122,13 +122,15 @@ public static void dealBigBoom(int positionAttX, int positionAttY, int positionD
}

// lower the damage by the amount of enemies surrounding the attacking piece
if(enemyCount == 0){enemyCount = 1;} // impossible theoretically, but might occur
damage = damage / enemyCount;
if (enemyCount == 0) {
enemyCount = 1;
} // impossible theoretically, but might occur
damage = damage / enemyCount ;

// increase the damage by the amount of friends surrounding the attacking piece
if(friendCount != 0) {
damage = damage * friendCount;
}

} else {
System.out.println("The attacking piece is not a calculateDamageInterface\n");
}
Expand All @@ -153,7 +155,7 @@ public static void damagePiece(int damage, int positionAttX, int positionAttY,
int calculatedDamage = ((defendAndBleedInterface) gameBoard[positionDefX][positionDefY])
.defendAndBleed(damage, gameBoard[positionAttX][positionAttY]);
// check to make sure no negative integer is used for damage, as this would heal the piece
if(calculatedDamage > 0){calculatedDamage = 0;}
if(calculatedDamage < 0){calculatedDamage = 0;}
currentHealth = currentHealth - calculatedDamage;
} else {
System.out.println("The defending piece is not a defendAndBleedInterface\n");
Expand Down

0 comments on commit d6b9e1d

Please sign in to comment.