Release v2.0

GUI updates for part 2 of the project
This commit is contained in:
Koen Yskout
2018-03-13 10:27:15 +01:00
parent 6aa12c7a1e
commit 5f5948795f
41 changed files with 1827 additions and 353 deletions

View File

@@ -1,51 +0,0 @@
package worms.model;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import worms.facade.Facade;
import worms.facade.IFacade;
import worms.model.Worm;
import worms.util.ModelException;
public class PartialFacadeTest {
private static final double EPS = 1e-4;
private IFacade facade;
@Before
public void setup() {
facade = new Facade();
}
@Test
public void testMaximumActionPoints() {
Worm worm = facade.createWorm(new double[] {0.0,0.0}, 0, 1, "Test");
assertEquals(4448, facade.getMaxNbActionPoints(worm));
}
@Test
public void testMoveHorizontal() {
Worm worm = facade.createWorm(new double[] {0.0,0.0}, 0, 1, "Test");
facade.move(worm, 5);
assertEquals(5, facade.getX(worm), EPS);
assertEquals(0, facade.getY(worm), EPS);
}
@Test
public void testMoveVertical() {
Worm worm = facade.createWorm(new double[] {0.0,0.0}, Math.PI / 2, 1, "Test");
facade.move(worm, 5);
assertEquals(0, facade.getX(worm), EPS);
assertEquals(5, facade.getY(worm), EPS);
}
@Test(expected = ModelException.class)
public void testJumpException() {
Worm worm = facade.createWorm(new double[] {0.0,0.0}, 3 * Math.PI / 2, 1, "Test");
facade.jump(worm);
}
}

View File

@@ -0,0 +1,81 @@
package worms.model;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import worms.facade.Facade;
import worms.facade.IFacade;
import worms.model.Worm;
public class PartialPart2FacadeTest {
private static final double EPS = 1e-4;
private IFacade facade;
// X X X X //
// . . . . //
// . . . . //
// X X X X //
private boolean[][] passableMap = new boolean[][] { //
{ false, false, false, false }, //
{ true, true, true, true }, //
{ true, true, true, true }, //
{ false, false, false, false } };
private World world;
@Before
public void setup() {
facade = new Facade();
world = facade.createWorld(4.0, 4.0, passableMap);
}
@Test
public void testMaximumActionPoints() {
Worm worm = facade.createWorm(world, new double[] { 1, 2 }, 0, 1, "Test", null);
assertEquals(4448, facade.getMaxNbActionPoints(worm));
}
@Test
public void testMoveHorizontal() {
Worm worm = facade.createWorm(world, new double[] { 1, 2 }, 0, 1, "Test", null);
facade.move(worm);
double[] xy = facade.getLocation(worm);
assertEquals(2, xy[0], EPS);
assertEquals(2, xy[1], EPS);
}
@Test
public void testMoveVertical() {
Worm worm = facade.createWorm(world, new double[] { 1, 1.5 }, Math.PI / 2, 0.5, "Test", null);
facade.move(worm);
double[] xy = facade.getLocation(worm);
assertEquals(1, xy[0], EPS);
assertEquals(2.0, xy[1], EPS);
}
@Test
public void testFall() {
// . X .
// . w .
// . . .
// X X X
World world = facade.createWorld(3.0, 4.0, new boolean[][] { //
{ true, false, true }, //
{ true, true, true }, //
{ true, true, true }, //
{ false, false, false } });
Worm worm = facade.createWorm(world, new double[] { 1.5, 2.5 }, 3*Math.PI/2, 0.5, "Test", null);
assertFalse(facade.canFall(worm));
facade.move(worm);
assertTrue(facade.canFall(worm));
facade.fall(worm);
double[] xy = facade.getLocation(worm);
assertEquals(1.5, xy[0], EPS);
assertEquals(1.5, xy[1], EPS);
}
}