From d23bfed055bbbbe89aabbf9cbd84963c5f2d8186 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Sun, 3 May 2020 14:22:39 +0200 Subject: [PATCH] =?UTF-8?q?Fikser=20en=20bug=20vedr=C3=B8rende=20skade=20f?= =?UTF-8?q?ra=20trippel=20laser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inf112/fiasko/roborally/objects/Board.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/inf112/fiasko/roborally/objects/Board.java b/src/main/java/inf112/fiasko/roborally/objects/Board.java index 9eb8741..df310fe 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/Board.java +++ b/src/main/java/inf112/fiasko/roborally/objects/Board.java @@ -854,7 +854,21 @@ public class Board { * @param robot The robot getting hit by the robot */ private void applyLaserDamage(WallType laserType, Robot robot) { - robot.setDamageTaken(robot.getDamageTaken() + laserType.getWallTypeID() - 2); + int laserDamage; + switch (laserType) { + case WALL_LASER_SINGLE: + laserDamage = 1; + break; + case WALL_LASER_DOUBLE: + laserDamage = 2; + break; + case WALL_LASER_TRIPLE: + laserDamage = 3; + break; + default: + throw new IllegalArgumentException("Invalid laser type encountered."); + } + robot.setDamageTaken(robot.getDamageTaken() + laserDamage - 2); } /**