Skip to content

Commit e4bbb07

Browse files
base attack reduces health of all ants in a cell
1 parent c1aed9d commit e4bbb07

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/main/java/ir/sharif/aichallenge/server/logic/handlers/AttackHandler.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ private void runAttack(int fromXPosition, int fromYPosition, int damage, int att
102102
}
103103
}
104104
Ant defender = ants.get(index);
105+
if (attackerId < 0) {
106+
// base attack to all ants of a cell
107+
for (Ant defAnt : map.getCell(defender.getXPosition(), defender.getYPosition()).getAnts()) {
108+
defAnt.decreaseHealth(damage);
109+
AttackSummary attackSummary = new AttackSummary(attackerId, defAnt.getId(), fromYPosition,
110+
fromXPosition, defAnt.getYPosition(), defAnt.getXPosition());
111+
attackSummaries.add(attackSummary);
112+
}
113+
return;
114+
}
105115
defender.decreaseHealth(damage);
106116
AttackSummary attackSummary = new AttackSummary(attackerId, defender.getId(), fromYPosition, fromXPosition,
107117
defender.getYPosition(), defender.getXPosition());

0 commit comments

Comments
 (0)