private GameProfile getTestGameProfileForRoom(Room room, double x, double y, double direction) { UserProfile testProfile = new UserProfile("test", "test"); room.addUser(testProfile); GameProfile profile = testProfile.getGameProfile(); profile.setX(x); profile.setY(y); profile.setDirection(direction); return profile; }
@SuppressWarnings("MagicNumber") @Test public void checkForCollision() { RoomFFA ffa = new RoomFFA("test"); GameProfile enemy = getTestGameProfileForRoom(ffa, 125, 125, 180); GameProfile me = getTestGameProfileForRoom(ffa, 100, 100, 35); moveActionStrategy.checkCollision(me, ffa); assertFalse("enemy was not killed", enemy.isKilled()); assertTrue("me should not be killed", me.isKilled()); enemy.setIsKilled(false); enemy.setDirection(225); moveActionStrategy.checkCollision(me, ffa); boolean directAttack = me.isKilled() || enemy.isKilled(); assertTrue("someone must be killed", directAttack); }