Search in sources :

Example 31 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class CollisionConfigTest method testNoNode.

/**
 * Test no node.
 */
@Test
void testNoNode() {
    final Xml root = new Xml(Constant.XML_PREFIX + FeaturableConfig.NODE_FEATURABLE);
    assertTrue(CollisionConfig.imports(root).getCollisions().isEmpty());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Test(org.junit.jupiter.api.Test)

Example 32 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class UtilActionnable method createAction.

/**
 * Create a default action.
 *
 * @param description The description.
 * @param area The button.
 * @return The temp media.
 */
public static Media createAction(String description, Area area) {
    final Media media = Medias.create("action.xml");
    final String name = "name";
    final ActionConfig action = new ActionConfig(name, description, (int) area.getX(), (int) area.getY(), area.getWidth(), area.getHeight());
    final Xml root = new Xml("test");
    root.add(ActionConfig.exports(action));
    root.save(media);
    return media;
}
Also used : ActionConfig(com.b3dgs.lionengine.game.feature.ActionConfig) Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media)

Example 33 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class AttackerModelTest method testNoConfig.

/**
 * Test without config.
 */
@Test
void testNoConfig() {
    final Media media = UtilTransformable.createMedia(AttackerModelTest.class);
    final Xml xml = new Xml(media);
    xml.save(media);
    final AttackerModel attacker = new AttackerModel(services, new Setup(media));
    assertTrue(attacker.getAttackDamages() == 0);
    assertTrue(media.getFile().delete());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Setup(com.b3dgs.lionengine.game.feature.Setup) UtilSetup(com.b3dgs.lionengine.game.feature.UtilSetup) Test(org.junit.jupiter.api.Test)

Example 34 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class ProducerModelTest method createMedia.

/**
 * Create default media.
 *
 * @return The default media.
 */
private static Media createMedia() {
    final Media media = UtilSetup.createMedia(Featurable.class);
    final Xml root = new Xml("test");
    root.add(ActionsConfig.exports(Collections.emptyList()));
    root.save(media);
    return media;
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media)

Example 35 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class LaunchableConfigTest method testExportsImports.

/**
 * Test exports imports.
 */
@Test
void testExportsImports() {
    final LaunchableConfig launchable = new LaunchableConfig("media", "sfx", 10, 1, 2, new Force(1.0, 2.0));
    final Xml root = new Xml("test");
    root.add(LaunchableConfig.exports(launchable));
    final Media media = Medias.create("launchable.xml");
    root.save(media);
    assertEquals(launchable, LaunchableConfig.imports(new Xml(media).getChild(LaunchableConfig.NODE_LAUNCHABLE)));
    assertTrue(media.getFile().delete());
}
Also used : Force(com.b3dgs.lionengine.game.Force) Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Test(org.junit.jupiter.api.Test)

Aggregations

Xml (com.b3dgs.lionengine.Xml)133 Test (org.junit.jupiter.api.Test)73 Media (com.b3dgs.lionengine.Media)63 Configurer (com.b3dgs.lionengine.game.Configurer)25 Setup (com.b3dgs.lionengine.game.feature.Setup)11 HashMap (java.util.HashMap)9 Collection (java.util.Collection)8 Animation (com.b3dgs.lionengine.Animation)4 Collision (com.b3dgs.lionengine.game.feature.collidable.Collision)4 Feature (com.b3dgs.lionengine.game.Feature)3 Force (com.b3dgs.lionengine.game.Force)3 SizeConfig (com.b3dgs.lionengine.game.SizeConfig)3 Services (com.b3dgs.lionengine.game.feature.Services)3 UtilSetup (com.b3dgs.lionengine.game.feature.UtilSetup)3 Map (java.util.Map)3 ViewerMock (com.b3dgs.lionengine.ViewerMock)2 Origin (com.b3dgs.lionengine.Origin)1 UtilAssert.assertThrows (com.b3dgs.lionengine.UtilAssert.assertThrows)1 XmlReader (com.b3dgs.lionengine.XmlReader)1 Orientation (com.b3dgs.lionengine.game.Orientation)1