diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BigBomb.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BigBomb.java index 19debfc0250626a78605dd8607737e4bf7dae03e..1264904a5f02410faebc32d7e0fdf9533c29c4fe 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BigBomb.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BigBomb.java @@ -7,6 +7,8 @@ import de.hdm_stuttgart.battlearena.Model.Entity.EntityFactory; import de.hdm_stuttgart.battlearena.Model.Entity.IEntity; import de.hdm_stuttgart.battlearena.Model.Map.TileManager; +import de.hdm_stuttgart.battlearena.Model.Sound.SFX; +import de.hdm_stuttgart.battlearena.Model.Sound.SoundEffects; import javafx.geometry.BoundingBox; import javafx.scene.canvas.GraphicsContext; import javafx.scene.image.Image; @@ -21,11 +23,12 @@ public class BigBomb implements IEntity { private static final Logger log = LogManager.getLogger(BigBomb.class); RuntimeInfo runtimeInfo = RuntimeInfo.getInstance(); + private SoundEffects sfx = new SoundEffects(); private final int posX; private final int posY; private int frameIndex = 0; private int frameCounter = 0; - private final Image[] frames = new Image[6]; + private final Image[] frames = new Image[8]; private final GraphicsContext graphicsContext; private BoundingBox boxCollider; private final ObjectType OBJECT_TYPE = ObjectType.BOMB; @@ -49,9 +52,12 @@ public class BigBomb implements IEntity { @Override public void loadEntitySprites() { - frames[0] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/big_bomb/Bigbomb.png"))); - frames[1] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/big_bomb/Bigbomb.png"))); - frames[2] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/bomb/redbomb.png"))); + frames[0] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/big_bomb/bigBomb1.png"))); + frames[1] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/big_bomb/bigBomb2.png"))); + frames[2] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/big_bomb/bigRedBomb3.png"))); + frames[3] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/big_bomb/bigBomb4.png"))); + frames[4] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/big_bomb/bigRedBomb5.png"))); + frames[5] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/big_bomb/bigDarkRedBomb6.png"))); } @Override @@ -87,14 +93,27 @@ public class BigBomb implements IEntity { private void updateAnimation() { //Easily add more frames frameCounter++; - if (frameCounter > 17) { + if (frameCounter > 18) { + if (frameIndex == 0) { frameIndex = 1; } else if (frameIndex == 1) { frameIndex = 2; } else if (frameIndex == 2) { frameIndex = 3; - checkExplosionSpawn(graphicsContext,blastradius); + } else if (frameIndex == 3) { + frameIndex = 4; + } else if (frameIndex == 4) { + frameIndex = 5; + } else if (frameIndex == 5) { + frameIndex = 6; + + + checkExplosionSpawn(graphicsContext, blastradius); + + //soundEffects.playSoundEffectOnce(SFX.BOMB); + + OBJECT_STATUS = ObjectStatus.USED; } frameCounter = 0; @@ -213,6 +232,8 @@ public class BigBomb implements IEntity { final double dropChanceTeleportItemFrame = 0.15; double randomDropChance = Math.random() * 1; + sfx.playSoundEffectOnce(SFX.WOOD_Destruction); + if (randomDropChance < dropChanceBigBombItemFrame) { List<IEntity> gameplayObjects = runtimeInfo.getGameplayObjects(); IEntity heart = EntityFactory.createGameplayObject(ObjectType.BIG_BOMB_ITEMFRAME, x, y, graphicsContext); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Bomb.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Bomb.java index f919ee7c7a3b950ef8e36911448d6235a9bc9c06..9a875a9b8211432ad8491ecce4acd34d8fc55fce 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Bomb.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Bomb.java @@ -25,11 +25,12 @@ import java.util.Objects; public class Bomb implements IEntity { private static final Logger log = LogManager.getLogger(Bomb.class); RuntimeInfo runtimeInfo = RuntimeInfo.getInstance(); + private SoundEffects sfx = new SoundEffects(); private final int posX; private final int posY; private int frameIndex = 0; private int frameCounter = 0; - private final Image[] frames = new Image[6]; + private final Image[] frames = new Image[8]; private final GraphicsContext graphicsContext; private BoundingBox boxCollider; private final ObjectType OBJECT_TYPE = ObjectType.BOMB; @@ -60,6 +61,9 @@ public class Bomb implements IEntity { frames[0] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/bomb/bomb.png"))); frames[1] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/bomb/bomb.png"))); frames[2] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/bomb/redbomb.png"))); + frames[3] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/bomb/bomb.png"))); + frames[4] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/bomb/redbomb.png"))); + frames[5] = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/objects/big_bomb/bigRedBomb5.png"))); } @Override @@ -95,7 +99,7 @@ public class Bomb implements IEntity { private void updateAnimation() { //Easily add more frames frameCounter++; - if (frameCounter > 17) { + if (frameCounter > 18) { if (frameIndex == 0) { frameIndex = 1; @@ -103,6 +107,12 @@ public class Bomb implements IEntity { frameIndex = 2; } else if (frameIndex == 2) { frameIndex = 3; + } else if (frameIndex == 3) { + frameIndex = 4; + } else if (frameIndex == 4) { + frameIndex = 5; + } else if (frameIndex == 5) { + frameIndex = 6; checkExplosionSpawn(graphicsContext, blastradius); @@ -218,14 +228,16 @@ public class Bomb implements IEntity { } public void spawnItems(int x, int y,GraphicsContext graphicsContext){ - final double dropChanceBigBombItemFrame = 0.1; + final double dropChanceBigBombItemFrame = 0.11; final double dropChanceHeart = 0.15; - final double dropChanceBlastUpItemFrame = 0.15; - final double dropChanceBlastDownItemFrame = 0.15; - final double dropChanceBombClock = 0.1; - final double dropChanceTeleportItemFrame = 0.15; + final double dropChanceBlastUpItemFrame = 0.13; + final double dropChanceBlastDownItemFrame = 0.13; + final double dropChanceBombClock = 0.08; + final double dropChanceTeleportItemFrame = 0.13; double randomDropChance = Math.random() * 1; + sfx.playSoundEffectOnce(SFX.WOOD_Destruction); + if (randomDropChance < dropChanceBigBombItemFrame) { List<IEntity> gameplayObjects = runtimeInfo.getGameplayObjects(); IEntity heart = EntityFactory.createGameplayObject(ObjectType.BIG_BOMB_ITEMFRAME, x, y, graphicsContext); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java index 29223dd95d73b1b9120baafd6dc5890a61048606..89287a60d704868065d9af097382e1e7b58a65f3 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java @@ -3,6 +3,7 @@ package de.hdm_stuttgart.battlearena.Model.Entity; import de.hdm_stuttgart.battlearena.Controller.Enum.PlayerMode; import de.hdm_stuttgart.battlearena.Controller.GameSceneController; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo; +import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.Heart; import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.ObjectStatus; import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.ObjectType; import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; @@ -80,7 +81,7 @@ class Player implements IEntity { private int iFrameCounter = 0; private int attackRate = 0; private int bombPlacementRate = 0; - private int bombReducedPlacementRate = 100; + private int bombReducedPlacementRate = 150; private boolean isBigBombItemFrame = false; private boolean isBlastUpItemFrame = false; private boolean isBlastDownItemFrame = false; @@ -88,6 +89,7 @@ class Player implements IEntity { private boolean markerPlacedPlayerOne = false; private boolean markerPlacedPlayerTwo = false; private boolean isTeleportItemFrame = false; + private boolean isDead = false; private int blastradius = 1; private final int pixelpadding = 30; @@ -424,7 +426,7 @@ class Player implements IEntity { return markerSet; } - public boolean checkTilePlacing(int y, int x) { //Change it with a DestructionHandler like CollisionHandler //tileSet[xTile].getDestruction(); + private boolean checkTilePlacing(int y, int x) { //Change it with a DestructionHandler like CollisionHandler //tileSet[xTile].getDestruction(); if (y < 18 && y > 0 && x < 18 && x > 0 && TileManager.tileMap[y][x] < 10) { return true; } @@ -487,6 +489,7 @@ class Player implements IEntity { } else if (gameplayObject.getOBJECT_TYPE() == ObjectType.BIG_BOMB_ITEMFRAME) { if (gameplayObject.getBoxCollider().intersects(boxCollider)) { isBigBombItemFrame = true; + sfx.playSoundEffectOnce(SFX.POWERUP); log.info("Collision with bigBombItemFrame"); gameplayObject.setObjectStatus(ObjectStatus.USED); } @@ -494,6 +497,7 @@ class Player implements IEntity { if (gameplayObject.getBoxCollider().intersects(boxCollider)) { log.info("Collision with blastUpItemFrame"); isBlastUpItemFrame = true; + sfx.playSoundEffectOnce(SFX.POWERUP); blastradius = updateBlastradius(blastradius); gameplayObject.setObjectStatus(ObjectStatus.USED); } @@ -501,6 +505,7 @@ class Player implements IEntity { if (gameplayObject.getBoxCollider().intersects(boxCollider)) { log.info("Collision with blastDownItemFrame"); isBlastDownItemFrame = true; + sfx.playSoundEffectOnce(SFX.POWERUP); blastradius = updateBlastradius(blastradius); gameplayObject.setObjectStatus(ObjectStatus.USED); } @@ -508,12 +513,14 @@ class Player implements IEntity { if (gameplayObject.getBoxCollider().intersects(boxCollider)) { log.info("Collision with bombClockItemFrame"); isBombClockItemFrame = true; + sfx.playSoundEffectOnce(SFX.POWERUP); bombPlacementRate = updateBombPlacementRate(bombPlacementRate); gameplayObject.setObjectStatus(ObjectStatus.USED); } } else if (gameplayObject.getOBJECT_TYPE() == ObjectType.TELEPORT_ITEMFRAME) { if (gameplayObject.getBoxCollider().intersects(boxCollider)) { isTeleportItemFrame = true; + sfx.playSoundEffectOnce(SFX.POWERUP); log.info("Collision with teleportItemFrame"); gameplayObject.setObjectStatus(ObjectStatus.USED); } @@ -731,9 +738,14 @@ class Player implements IEntity { health -= damageDone; iFrameCounter = 100; } else { - + if(!isDead){ + sfx.playSoundEffectOnce(SFX.DEAD); + log.info("Dead"); + } + isDead = true; health = 0; - log.info("Dead"); + iFrameCounter = 100; + } log.info("DamageTaken, current Health: " + health); } @@ -747,7 +759,7 @@ class Player implements IEntity { sfx.playSoundEffectOnce(SFX.POWERUP); if (regeneratedHealth < maxPlayerHealth && regeneratedHealth > 0) { - + sfx.playSoundEffectOnce(SFX.COIN_COLLECTED); health += healthRegenerated; } else { health = maxPlayerHealth; diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SFX.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SFX.java index e4c38057c02294e1dc8e200ea275a6d00bc493fa..9ad2548b6d8f9d4449ce2212792733536d6578a6 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SFX.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SFX.java @@ -2,11 +2,11 @@ package de.hdm_stuttgart.battlearena.Model.Sound; public enum SFX { //Poweup Sounds - POWERUP("src/main/resources/sound/sfx/otSFX/powerup.mp3"), - COIN_COLLECTED("src/main/resources/sound/sfx/otSFX/powerups/drop-coins.mp3"), + POWERUP("src/main/resources/sound/sfx/otSFX/powerup2.wav"), + COIN_COLLECTED("src/main/resources/sound/sfx/otSFX/powerups/drop-coins2.wav"), //Bomb - BOMB("src/main/resources/sound/sfx/otSFX/bomb/BombSound.wav"), + BOMB("src/main/resources/sound/sfx/otSFX/bomb/Bomb3.wav"), //Attack Sounds @@ -17,7 +17,7 @@ public enum SFX { WOOD_Destruction("src/main/resources/sound/sfx/otSFX/destruction/WoodDestruction.wav"), //Die Sounds - DEAD("src/main/resources/sound/sfx/otSFX/dieSounds/body-falling-to-ground.mp3"); + DEAD("src/main/resources/sound/sfx/otSFX/dieSounds/body-falling-to-ground.wav"); private String path; diff --git a/src/main/resources/sound/sfx/otSFX/bomb/Bomb3.wav b/src/main/resources/sound/sfx/otSFX/bomb/Bomb3.wav new file mode 100644 index 0000000000000000000000000000000000000000..ee0ea009bea69e5996dcb8a4e634ff4a698b3e12 Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/bomb/Bomb3.wav differ diff --git a/src/main/resources/sound/sfx/otSFX/destruction/WoodDestruction.wav b/src/main/resources/sound/sfx/otSFX/destruction/WoodDestruction.wav deleted file mode 100644 index e51acbdb37fb2bea31b35251facd10643caa18e7..0000000000000000000000000000000000000000 Binary files a/src/main/resources/sound/sfx/otSFX/destruction/WoodDestruction.wav and /dev/null differ diff --git a/src/main/resources/sound/sfx/otSFX/dieSounds/body-falling-to-ground.mp3 b/src/main/resources/sound/sfx/otSFX/dieSounds/body-falling-to-ground.mp3 deleted file mode 100644 index 701a73f47a8dc8013eabb1e7fc8a4a8d0a2b62f8..0000000000000000000000000000000000000000 Binary files a/src/main/resources/sound/sfx/otSFX/dieSounds/body-falling-to-ground.mp3 and /dev/null differ diff --git a/src/main/resources/sound/sfx/otSFX/dieSounds/body-falling-to-ground.wav b/src/main/resources/sound/sfx/otSFX/dieSounds/body-falling-to-ground.wav new file mode 100644 index 0000000000000000000000000000000000000000..fda045f5ff3b017c78803402eb9ff951bc67f1eb Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/dieSounds/body-falling-to-ground.wav differ diff --git a/src/main/resources/sound/sfx/otSFX/powerups/drop-coins.mp3 b/src/main/resources/sound/sfx/otSFX/powerups/drop-coins.wav similarity index 100% rename from src/main/resources/sound/sfx/otSFX/powerups/drop-coins.mp3 rename to src/main/resources/sound/sfx/otSFX/powerups/drop-coins.wav diff --git a/src/main/resources/sound/sfx/otSFX/powerups/drop-coins2.wav b/src/main/resources/sound/sfx/otSFX/powerups/drop-coins2.wav new file mode 100644 index 0000000000000000000000000000000000000000..6f121cf03114c68efc113999938453daf1236355 Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/powerups/drop-coins2.wav differ diff --git a/src/main/resources/sound/sfx/otSFX/powerups/powerup.mp3 b/src/main/resources/sound/sfx/otSFX/powerups/powerup.wav similarity index 100% rename from src/main/resources/sound/sfx/otSFX/powerups/powerup.mp3 rename to src/main/resources/sound/sfx/otSFX/powerups/powerup.wav diff --git a/src/main/resources/sound/sfx/otSFX/powerups/powerup2.wav b/src/main/resources/sound/sfx/otSFX/powerups/powerup2.wav new file mode 100644 index 0000000000000000000000000000000000000000..512aa4e1eb8ff6239cf73e3a379ca9beb5e4093f Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/powerups/powerup2.wav differ diff --git a/src/main/resources/textures/objects/big_bomb/bigBomb1.png b/src/main/resources/textures/objects/big_bomb/bigBomb1.png new file mode 100644 index 0000000000000000000000000000000000000000..9c41710bcff9be6ad9de5688e02691d4ff9d5296 Binary files /dev/null and b/src/main/resources/textures/objects/big_bomb/bigBomb1.png differ diff --git a/src/main/resources/textures/objects/big_bomb/bigbomb.png b/src/main/resources/textures/objects/big_bomb/bigBomb2.png similarity index 100% rename from src/main/resources/textures/objects/big_bomb/bigbomb.png rename to src/main/resources/textures/objects/big_bomb/bigBomb2.png diff --git a/src/main/resources/textures/objects/big_bomb/bigBomb4.png b/src/main/resources/textures/objects/big_bomb/bigBomb4.png new file mode 100644 index 0000000000000000000000000000000000000000..3dce4f0e0449046ca52cde663fd026dd60e6254b Binary files /dev/null and b/src/main/resources/textures/objects/big_bomb/bigBomb4.png differ diff --git a/src/main/resources/textures/objects/big_bomb/bigDarkRedBomb6.png b/src/main/resources/textures/objects/big_bomb/bigDarkRedBomb6.png new file mode 100644 index 0000000000000000000000000000000000000000..03cc9f6bbb7cda78eeae3483db1894dd1af80565 Binary files /dev/null and b/src/main/resources/textures/objects/big_bomb/bigDarkRedBomb6.png differ diff --git a/src/main/resources/textures/objects/big_bomb/bigRedBomb3.png b/src/main/resources/textures/objects/big_bomb/bigRedBomb3.png new file mode 100644 index 0000000000000000000000000000000000000000..535766fe34590c1053a292e3df3099d1acac7aae Binary files /dev/null and b/src/main/resources/textures/objects/big_bomb/bigRedBomb3.png differ diff --git a/src/main/resources/textures/objects/big_bomb/bigRedBomb5.png b/src/main/resources/textures/objects/big_bomb/bigRedBomb5.png new file mode 100644 index 0000000000000000000000000000000000000000..dcc3e14d15d6b85575dd6579a690a2d7697fa5ad Binary files /dev/null and b/src/main/resources/textures/objects/big_bomb/bigRedBomb5.png differ diff --git a/src/test/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityFactoryTest.java b/src/test/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityFactoryTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8b72d4b536a4b1566d4ce0fff301846412382bf0 --- /dev/null +++ b/src/test/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityFactoryTest.java @@ -0,0 +1,74 @@ +package de.hdm_stuttgart.battlearena.Model.Entity; + +import de.hdm_stuttgart.battlearena.Controller.GameSceneController; +import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.*; +import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; +import javafx.fxml.FXML; +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.layout.BorderPane; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; +import de.hdm_stuttgart.battlearena.Model.Entity.EntityType; +import de.hdm_stuttgart.battlearena.Controller.Enum.PlayerMode; + +public class EntityFactoryTest { + + private GraphicsContext gameScene, graphicsContext; + //InputHandler inputHandler = new InputHandler(); + GameSceneController GameSceneController = new GameSceneController(); + int posX, posY, blastradius = 5; + int player = 1; + /*@Test + public void gameplayObjectCreationWorking(){ + assertEquals(new Heart(posX, posY, graphicsContext), EntityFactory.createGameplayObject(ObjectType.HEART, posX, posY, graphicsContext)); + assertEquals(new BigBombItemFrame(posX, posY, graphicsContext), EntityFactory.createGameplayObject(ObjectType.BIG_BOMB_ITEMFRAME, posX, posY, graphicsContext)); + assertEquals(new BlastUpItemFrame(posX, posY, graphicsContext), EntityFactory.createGameplayObject(ObjectType.BLASTUP_ITEMFRAME, posX, posY, graphicsContext)); + assertEquals(new BlastDownItemFrame(posX, posY, graphicsContext), EntityFactory.createGameplayObject(ObjectType.BLASTDOWN_ITEMFRAME, posX, posY, graphicsContext)); + assertEquals(new Explosion(posX, posY, graphicsContext), EntityFactory.createGameplayObject(ObjectType.EXPLOSION, posX, posY, graphicsContext)); + assertEquals(new TeleportationItemFrame(posX, posY, graphicsContext), EntityFactory.createGameplayObject(ObjectType.TELEPORT_ITEMFRAME, posX, posY, graphicsContext)); + //assertTrue(EntityFactory.createGameplayObject(new Player(gameScene, inputHandler, EntityClass.HUMAN,GameSceneController,PlayerMode.PLAYER_ONE),EntityType.PLAYER, gameScene, inputHandler,EntityClass.HUMAN, GameSceneController, PlayerMode.PLAYER_ONE)); + } + @Test + public void gameplayObjectCreationTestFailing() { + assertNotEquals(new BigBomb(posX, posY, graphicsContext, blastradius), EntityFactory.createGameplayObject(ObjectType.BIG_BOMB, posX, posY, graphicsContext)); + assertNotEquals(new Bomb(posX, posY, graphicsContext, blastradius), EntityFactory.createGameplayObject(ObjectType.BOMB, posX, posY, graphicsContext)); + assertNotEquals(new Explosion(posX, posY, graphicsContext), EntityFactory.createGameplayObject(ObjectType.BOMB, posX, posY, graphicsContext)); + //assertThrows(new IllegalArgumentException(), EntityFactory.createGameplayObject(ObjectType.BOMB, posX, posY, graphicsContext)); + //assertThrows(new IllegalArgumentException(), EntityFactory.createGameplayObject(ObjectType.EXPLOSION, posX, posY, graphicsContext)); + //assertThrows(new IllegalArgumentException(), EntityFactory.createGameplayObject(ObjectType.BOMB, posX, posY, graphicsContext)); + } + @Test + public void bombCreationTestWorking() { + assertEquals(new Bomb(posX, posY, graphicsContext, blastradius), EntityFactory.createBombs(ObjectType.BOMB, posX, posY, graphicsContext, blastradius)); + assertEquals(new BigBomb(posX, posY, graphicsContext, blastradius), EntityFactory.createBombs(ObjectType.BIG_BOMB, posX, posY, graphicsContext, blastradius)); + assertEquals(new Explosion(posX, posY, graphicsContext), EntityFactory.createBombs(ObjectType.BOMB, posX, posY, graphicsContext, blastradius)); + } + @Test + public void bombCreationTestFailing() { + assertNotEquals(new Bomb(posX, posY, graphicsContext, blastradius), EntityFactory.createBombs(ObjectType.BOMB, posX, posY, graphicsContext, blastradius)); + assertNotEquals(new Bomb(posX, posY, graphicsContext, blastradius), EntityFactory.createBombs(ObjectType.EXPLOSION, posX, posY, graphicsContext, blastradius)); + assertNotEquals(new Explosion(posX, posY, graphicsContext), EntityFactory.createBombs(ObjectType.BOMB, posX, posY, graphicsContext, blastradius)); + //assertThrows(new IllegalArgumentException(), EntityFactory.createBombs(ObjectType.BOMB, posX, posY, graphicsContext)); + //assertThrows(new IllegalArgumentException(), EntityFactory.createBombs(ObjectType.BIG_BOMB, posX, posY, graphicsContext)); + //assertThrows(new IllegalArgumentException(), EntityFactory.createBombs(ObjectType.BOMB, posX, posY, graphicsContext)); + } + @Test + public void markerCreationTestWorking() { + assertEquals(new Marker(posX, posY, graphicsContext, player), EntityFactory.createMarker(ObjectType.MARKER, posX, posY, graphicsContext, 1)); + assertEquals(new Marker(posX, posY, graphicsContext, player), EntityFactory.createMarker(ObjectType.MARKER, posX, posY, graphicsContext, 2)); + assertEquals(new Explosion(posX, posY, graphicsContext), EntityFactory.createMarker(ObjectType.BOMB, posX, posY, graphicsContext, player)); + } + @Test + public void markerCreationTestFailing() { + Marker marker = new Marker(posX, posY, graphicsContext, 1); + //assertThrows(new IllegalArgumentException(), marker.loadEntitySprites()); + + IllegalArgumentException test = assertThrows(IllegalArgumentException.class, ()-> + marker.loadEntitySprites()); + + + assertNotEquals(new Explosion(posX, posY, graphicsContext), EntityFactory.createMarker(ObjectType.BOMB, posX, posY, graphicsContext, player)); + }*/ + +} diff --git a/src/test/java/de/hdm_stuttgart/battlearena/Model/Entity/PlayerTest.java b/src/test/java/de/hdm_stuttgart/battlearena/Model/Entity/PlayerTest.java index 7055c8bad92ea6d3136c0b210d0a36579cf52e53..03dc89a93124f71e9a5c61a4d79b05d413a01dc5 100644 --- a/src/test/java/de/hdm_stuttgart/battlearena/Model/Entity/PlayerTest.java +++ b/src/test/java/de/hdm_stuttgart/battlearena/Model/Entity/PlayerTest.java @@ -5,11 +5,14 @@ import de.hdm_stuttgart.battlearena.Controller.GameSceneController; import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; import de.hdm_stuttgart.battlearena.Model.Entity.EntityClass; import de.hdm_stuttgart.battlearena.Model.Entity.EntityDirection; +import de.hdm_stuttgart.battlearena.Model.Map.Biom; import de.hdm_stuttgart.battlearena.Model.Map.TileManager; import javafx.fxml.FXML; +import javafx.scene.canvas.GraphicsContext; import javafx.scene.layout.BorderPane; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.mock; public class PlayerTest { @FXML @@ -17,13 +20,47 @@ public class PlayerTest { GameSceneController GameSceneController = new GameSceneController(); - //TileManager tileManager = new TileManager() Player player = new Player(null, InputHandler.getInstance(), EntityClass.HUMAN, GameSceneController, PlayerMode.PLAYER_ONE); - @Test + /*@Test public void checkTileWalkable(){ + String mapString = "12 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 12 " + + "13 1 1 20 20 20 20 20 20 20 20 20 20 20 20 1 1 14 " + + "13 1 10 20 10 20 10 20 10 10 20 10 20 10 20 10 1 14 " + + "13 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 14 " + + "13 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 14 " + + "13 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 14 " + + "13 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 14 " + + "13 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 14 " + + "13 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 14 " + + "13 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 14 " + + "13 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 14 " + + "13 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 14 " + + "13 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 14 " + + "13 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 14 " + + "13 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 14 " + + "13 1 10 20 10 20 10 20 10 10 20 10 20 10 20 10 1 14 " + + "13 1 1 20 20 20 20 20 20 20 20 20 20 20 20 1 1 14 " + + "12 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 12 "; + + Biom mapBiom = Biom.GRASS; - int x = 1, y =1; - if(TileManager.tileMap[y][x] < 10) - assertTrue(player.checkTilePlacing(x,y)); + GraphicsContext graphicsContext2D; + //TileManager tileManager = mock(TileManager.class); + TileManager tileManager = new TileManager( graphicsContext2D, 30, + 18, 18, mapString,mapBiom) { + + int x = 1, y = 1; + if(TileManager.tileMap[y][x] < 10) + assertTrue(player.checkTilePlacing(x, y)); + } } + @Test + private void updateBlastradiusWorking(){ + Player player = new Player(); + player.updateBlastradius(100); + } + @Test + private void updateBombPlacementRateWorking(){ + + }*/ }