diff --git a/OGP1718-Worms/src/worms/facade/Facade.java b/OGP1718-Worms/src/worms/facade/Facade.java index 2404151..09e1d55 100644 --- a/OGP1718-Worms/src/worms/facade/Facade.java +++ b/OGP1718-Worms/src/worms/facade/Facade.java @@ -384,7 +384,6 @@ public class Facade implements IFacade { } /** - * <<<<<<< HEAD * Create and return a new worm that is positioned at the given location, looks * in the given direction, has the given radius and the given name. * diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index 6a2c8d0..56b3971 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -595,7 +595,7 @@ public class Worm { public void collision(Worm smallestWorm, Worm largestWorm) { long total = 1 + (new Random().nextLong() * (10 - 1)); - long loseSmallest = total/(largestWorm.getOrientation()/(smallestWorm.getOrientation()+largestWorm.getOrientation())); + long loseSmallest = (long) (total / (largestWorm.getOrientation() / (smallestWorm.getOrientation() + largestWorm.getOrientation()))); long loseLargest = total - loseSmallest; smallestWorm.decreaseHitPoints(loseSmallest); largestWorm.decreaseHitPoints(loseLargest); diff --git a/OGP1718-Worms/tests/worms/model/WormTest.java b/OGP1718-Worms/tests/worms/model/WormTest.java index d4fb8ca..1ec9ae9 100644 --- a/OGP1718-Worms/tests/worms/model/WormTest.java +++ b/OGP1718-Worms/tests/worms/model/WormTest.java @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.RepeatedTest; import static org.junit.jupiter.api.Assertions.*; -import worms.util.Tuple; +import worms.util.Coordinate; import java.util.Random; @@ -15,12 +15,12 @@ class WormTest { @BeforeAll static void setUp() { - worm = new Worm(Tuple.create(0.0, 0.0), 0, "Test", 1); + worm = new Worm(Coordinate.create(0.0, 0.0), 0, "Test", 1); } @RepeatedTest(5000) void move() { - worm = new Worm(Tuple.create(0.0, 0.0), 0, "Test", 1); + worm = new Worm(Coordinate.create(0.0, 0.0), 0, "Test", 1); int steps = r.nextInt(5101) - 100; double maxAngle = Math.abs(2 * Math.PI - worm.getOrientation()); double minAngle = worm.getOrientation(); @@ -36,7 +36,7 @@ class WormTest { double newLocX = worm.getLocation().item1 + steps * worm.getRadius() * Math.cos(worm.getOrientation()); double newLocY = worm.getLocation().item2 + steps * worm.getRadius() * Math.sin(worm.getOrientation()); worm.move(steps); - assertEquals(Tuple.create(newLocX, newLocY), worm.getLocation()); + assertEquals(Coordinate.create(newLocX, newLocY), worm.getLocation()); } } @@ -47,7 +47,7 @@ class WormTest { if (!Worm.isValidOrientation(oldAngle + angle) || worm.getActionPoints() - (long) Math.ceil(Math.toDegrees(angle) / 6) < 0) { assertThrows(AssertionError.class, () -> worm.turn(angle)); - worm = new Worm(Tuple.create(0.0, 0.0), 0, "Test", 1); + worm = new Worm(Coordinate.create(0.0, 0.0), 0, "Test", 1); } else { worm.turn(angle); @@ -64,7 +64,7 @@ class WormTest { @RepeatedTest(5000) void jump() { - worm = new Worm(Tuple.create(0.0, 0.0), 0, "Test", 1); + worm = new Worm(Coordinate.create(0.0, 0.0), 0, "Test", 1); double maxAngle = Math.abs(2 * Math.PI - worm.getOrientation()); double minAngle = worm.getOrientation(); double combAngle = maxAngle + minAngle; @@ -82,12 +82,12 @@ class WormTest { double v = force / worm.getMass() * Worm.FORCE_TIME; double newLocX = worm.getLocation().item1 + Math.pow(v, 2) * Math.sin(2 * orient) / Worm.G; worm.jump(); - assertEquals(Tuple.create(newLocX, worm.getLocation().item2), worm.getLocation()); + assertEquals(Coordinate.create(newLocX, worm.getLocation().getCoordinateY()), worm.getLocation()); } } @Test void doubleJump() { - worm = new Worm(Tuple.create(0.0, 0.0), 0, "Test", 1); + worm = new Worm(Coordinate.create(0.0, 0.0), 0, "Test", 1); worm.jump(); assertThrows(IllegalStateException.class, () -> worm.jump()); }