Search in sources :

Example 21 with Configurer

use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.

the class CollidableConfigTest method testDefaultGroup.

/**
 * Test with default group.
 */
@Test
void testDefaultGroup() {
    final Media media = Medias.create("Object.xml");
    final Xml root = new Xml("test");
    root.save(media);
    assertEquals(CollidableConfig.DEFAULT_GROUP, CollidableConfig.imports(new Configurer(media)).getGroup());
    assertTrue(media.getFile().delete());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Configurer(com.b3dgs.lionengine.game.Configurer) Test(org.junit.jupiter.api.Test)

Example 22 with Configurer

use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.

the class CollidableConfigTest method testInvalidGroup.

/**
 * Test with invalid group.
 */
@Test
void testInvalidGroup() {
    final Media media = Medias.create("Object.xml");
    final Xml root = new Xml("test");
    final Xml node = root.createChild(CollidableConfig.NODE_COLLIDABLE);
    node.writeString(CollidableConfig.ATT_GROUP, "a");
    root.save(media);
    assertCause(() -> CollidableConfig.imports(new Configurer(media)), NumberFormatException.class);
    assertTrue(media.getFile().delete());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Configurer(com.b3dgs.lionengine.game.Configurer) Test(org.junit.jupiter.api.Test)

Example 23 with Configurer

use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.

the class CollisionConfigTest method testExportsImports.

/**
 * Test exports imports.
 */
@Test
void testExportsImports() {
    final Xml root = new Xml(Constant.XML_PREFIX + FeaturableConfig.NODE_FEATURABLE);
    final Collision collision = new Collision("test", 0, 1, 2, 3, true);
    CollisionConfig.exports(root, collision);
    final Media media = Medias.create("collision.xml");
    root.save(media);
    final CollisionConfig config = CollisionConfig.imports(new Configurer(media));
    final Collision imported = config.getCollision("test");
    assertEquals("test", imported.getName());
    assertEquals(0, imported.getOffsetX());
    assertEquals(1, imported.getOffsetY());
    assertEquals(2, imported.getWidth());
    assertEquals(3, imported.getHeight());
    assertTrue(imported.hasMirror());
    assertFalse(config.getCollisions().isEmpty());
    assertEquals(collision, config.getCollision("test"));
    assertTrue(media.getFile().delete());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Configurer(com.b3dgs.lionengine.game.Configurer) Test(org.junit.jupiter.api.Test)

Example 24 with Configurer

use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.

the class PathfindableConfigTest method testNoMovements.

/**
 * Test without movements.
 */
@Test
void testNoMovements() {
    final Map<String, PathData> map = new HashMap<>();
    final PathData data = new PathData("category", 1.0, true, EnumSet.noneOf(MovementTile.class));
    map.put(data.getName(), data);
    final Xml root = new Xml("test");
    root.add(PathfindableConfig.exports(map));
    final Media media = Medias.create("pathfindable.xml");
    root.save(media);
    final Map<String, PathData> imported = PathfindableConfig.imports(new Configurer(media));
    assertTrue(imported.get(data.getName()).getAllowedMovements().isEmpty());
    assertEquals(map, imported);
    assertTrue(media.getFile().delete());
}
Also used : HashMap(java.util.HashMap) Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Configurer(com.b3dgs.lionengine.game.Configurer) Test(org.junit.jupiter.api.Test)

Example 25 with Configurer

use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.

the class PathfindableConfigTest method testNoNode.

/**
 * Test without node.
 */
@Test
void testNoNode() {
    final Xml root = new Xml("test");
    final Media media = Medias.create("pathfindable.xml");
    root.save(media);
    assertTrue(PathfindableConfig.imports(new Configurer(media)).isEmpty());
    assertTrue(media.getFile().delete());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Configurer(com.b3dgs.lionengine.game.Configurer) Test(org.junit.jupiter.api.Test)

Aggregations

Configurer (com.b3dgs.lionengine.game.Configurer)30 Media (com.b3dgs.lionengine.Media)27 Xml (com.b3dgs.lionengine.Xml)25 Test (org.junit.jupiter.api.Test)25 HashMap (java.util.HashMap)4 LionEngineException (com.b3dgs.lionengine.LionEngineException)3 Setup (com.b3dgs.lionengine.game.feature.Setup)3 Animation (com.b3dgs.lionengine.Animation)2 ViewerMock (com.b3dgs.lionengine.ViewerMock)2 ActionRef (com.b3dgs.lionengine.game.ActionRef)2 Services (com.b3dgs.lionengine.game.feature.Services)2 Collision (com.b3dgs.lionengine.game.feature.collidable.Collision)2 Xml (com.b3dgs.lionengine.io.Xml)2 Collection (java.util.Collection)2 Test (org.junit.Test)2 XmlReader (com.b3dgs.lionengine.XmlReader)1 Force (com.b3dgs.lionengine.game.Force)1 SizeConfig (com.b3dgs.lionengine.game.SizeConfig)1 DeviceAxis (com.b3dgs.lionengine.io.DeviceAxis)1 DeviceMapper (com.b3dgs.lionengine.io.DeviceMapper)1