diff --git a/source/core/src/main/com/csse3200/game/components/EffectComponent.java b/source/core/src/main/com/csse3200/game/components/EffectComponent.java index 6d3df3bdc..32b32e3d3 100644 --- a/source/core/src/main/com/csse3200/game/components/EffectComponent.java +++ b/source/core/src/main/com/csse3200/game/components/EffectComponent.java @@ -125,6 +125,7 @@ public void applyEffect(ProjectileEffects effect, Entity host, Entity target) { stunFlag = true; stunTime = gameTime.getTime() + EFFECT_DURATION; } + case FIREBALL -> {} } } diff --git a/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java b/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java index 21b38475d..5ad20684e 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java @@ -163,6 +163,7 @@ public void update() { runFlag = true; } } + case DEATH, DEFAULT -> {} } } diff --git a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossTask.java b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossTask.java index 8930efde0..38896b2b4 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossTask.java @@ -12,11 +12,9 @@ import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.factories.MobBossFactory; import com.csse3200.game.entities.factories.ProjectileFactory; -import com.csse3200.game.physics.PhysicsEngine; import com.csse3200.game.physics.PhysicsLayer; import com.csse3200.game.physics.components.PhysicsMovementComponent; import com.csse3200.game.rendering.AnimationRenderComponent; -import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,7 +29,6 @@ public class DemonBossTask extends DefaultTask implements PriorityTask { // Constants private static final int PRIORITY = 3; private static final Vector2 DEMON_SPEED = new Vector2(1f, 1f); - private static final float STOP_DISTANCE = 0.1f; private static final float JUMP_DISTANCE = 3.0f; private static final double Y_TOP_BOUNDARY = 5.5; private static final double Y_BOT_BOUNDARY = 0.5; @@ -50,9 +47,6 @@ public class DemonBossTask extends DefaultTask implements PriorityTask { // Private variables private static final Logger logger = LoggerFactory.getLogger(DemonBossTask.class); private Vector2 currentPos; - private final PhysicsEngine physics; - private final GameTime gameTime; - private Vector2 jumpPos; private MovementTask jumpTask; private DemonState state = DemonState.IDLE; private DemonState prevState; @@ -79,14 +73,6 @@ private enum DemonState { TRANSFORM, IDLE, CAST, CLEAVE, DEATH, BREATH, SMASH, TAKE_HIT, WALK } - /** - * The demon boss task constructor. Initialises the physics and time. - */ - public DemonBossTask() { - physics = ServiceLocator.getPhysicsService().getPhysics(); - gameTime = ServiceLocator.getTimeSource(); - } - /** * Starts transform animation, triggers idle animation which starts * sequence, and dynamically shifts the demons boundary to the left. @@ -187,10 +173,8 @@ public void update() { } } case TRANSFORM -> { - if (health <= 0) { - if (animation.isFinished()) { - changeState(DemonState.DEATH); - } + if (health <= 0 && animation.isFinished()) { + changeState(DemonState.DEATH); } } case TAKE_HIT -> { @@ -199,6 +183,7 @@ public void update() { halfHealthFlag = true; } } + case DEATH, WALK -> {} } } @@ -308,6 +293,7 @@ public void run() { */ private Vector2 getJumpPos() { // check if boundary has shifted causing demon to be out of bounds + Vector2 jumpPos; if (currentPos.x > xRightBoundary) { jumpPos = new Vector2(currentPos.x - JUMP_DISTANCE, currentPos.y); //jump back into boundary return jumpPos; @@ -317,6 +303,7 @@ private Vector2 getJumpPos() { if (currentPos.dst(ServiceLocator.getEntityService().getClosestEntityOfLayer( demon, PhysicsLayer.HUMANS).getPosition()) < 2f) { jumpPos = new Vector2(currentPos.x + JUMP_DISTANCE, currentPos.y); + //TODO: Check whether jumpPos needs to be returned } float randomAngle = MathUtils.random(0, 2 * MathUtils.PI); diff --git a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/FinalBossMovementTask.java b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/FinalBossMovementTask.java index 34ebf7bae..fdd6e6aeb 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/FinalBossMovementTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/FinalBossMovementTask.java @@ -79,7 +79,7 @@ public void update() { if (towerAhead()) { Entity newProjectile = ProjectileFactory.createEffectProjectile(PhysicsLayer.TOWER, new Vector2(0,currentPos.y + 0.75f), new Vector2(2f,2f), ProjectileEffects.BURN, false); newProjectile.scaleHeight(-0.4f); - newProjectile.setPosition((float) (currentPos.x), (float) (currentPos.y+0.75f)); + newProjectile.setPosition(currentPos.x, currentPos.y + 0.75f); ServiceLocator.getEntityService().register(newProjectile); } startWaiting(); diff --git a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/IceBabyTask.java b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/IceBabyTask.java index 143a8888c..80e703ebf 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/IceBabyTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/IceBabyTask.java @@ -10,12 +10,10 @@ import com.csse3200.game.components.tasks.MovementTask; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.factories.NPCFactory; -import com.csse3200.game.physics.PhysicsEngine; import com.csse3200.game.physics.PhysicsLayer; import com.csse3200.game.physics.components.HitboxComponent; import com.csse3200.game.physics.components.PhysicsMovementComponent; import com.csse3200.game.rendering.AnimationRenderComponent; -import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,8 +32,6 @@ public class IceBabyTask extends DefaultTask implements PriorityTask { private static final int Y_BOT_BOUNDARY = 1; private static final Logger logger = LoggerFactory.getLogger(IceBabyTask.class); /** Variable names */ - private PhysicsEngine physics; - private GameTime gameTime; private STATE prevState; private AnimationRenderComponent animation; private Entity iceBaby; @@ -44,7 +40,6 @@ public class IceBabyTask extends DefaultTask implements PriorityTask { private MovementTask walkTask; private static int xRightBoundary = 17; private static int xLeftBoundary = 12; - private boolean aoe = true; private boolean startFlag = false; private boolean isWalking; /** Animation constants */ @@ -62,14 +57,6 @@ private enum STATE { } private STATE iceBabyState = STATE.IDLE; - /** - * Constructor for IceBabyTask - */ - public IceBabyTask() { - physics = ServiceLocator.getPhysicsService().getPhysics(); - gameTime = ServiceLocator.getTimeSource(); - } - //ice baby should be able to poop out little mobs - spawn new //ice baby can also do aoe attack based on the animation //ice baby does punches to towers once it is close @@ -141,7 +128,7 @@ public void update() { } case ATK1, ATK2 -> { if (animation.isFinished()) { - ATK3(); + atk3(); } } case ATK3 -> { @@ -149,6 +136,7 @@ public void update() { changeState(STATE.IDLE); } } + case DEATH, INTRO, STAGGER, TAKEHIT -> {} } } @@ -253,7 +241,7 @@ private boolean walkComplete() { /** * Changes the state of the animation and deals damage to nearby humans */ - private void ATK3() { + private void atk3() { changeState(STATE.ATK3); animate(); Entity target = ServiceLocator.getEntityService().getClosestEntityOfLayer(iceBaby, @@ -309,16 +297,11 @@ private Array getNearbyHumans(int radius) { for (int i = 0; i < nearbyEntities.size; i++) { Entity targetEntity = nearbyEntities.get(i); HitboxComponent targetHitbox = targetEntity.getComponent(HitboxComponent.class); - if (targetHitbox == null) { + // check target hitbox and layer + if (targetHitbox == null || (!PhysicsLayer.contains(PhysicsLayer.HUMANS, targetHitbox. + getLayer()))) { break; } - - // check target layer - if (!PhysicsLayer.contains(PhysicsLayer.HUMANS, targetHitbox. - getLayer())) { - break; - } - nearbyHumans.add(targetEntity); } return nearbyHumans; diff --git a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/MobBossDeathTask.java b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/MobBossDeathTask.java index 3d02358f2..719c2436a 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/MobBossDeathTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/MobBossDeathTask.java @@ -6,12 +6,8 @@ import com.csse3200.game.components.CombatStatsComponent; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.factories.DropFactory; -import com.csse3200.game.physics.PhysicsEngine; -import com.csse3200.game.physics.raycast.RaycastHit; import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; -//import com.csse3200.game.rendering.DebugRenderer; - /** * Task that prints a message to the terminal whenever it is called. @@ -21,10 +17,8 @@ public class MobBossDeathTask extends DefaultTask implements PriorityTask { private final int priority; private Vector2 bossPosition = new Vector2(10f,10f); - private final PhysicsEngine physics; private GameTime timeSource; private long endTime; - private final RaycastHit hit = new RaycastHit(); private int bossHealth; @@ -33,9 +27,6 @@ public class MobBossDeathTask extends DefaultTask implements PriorityTask { */ public MobBossDeathTask(int priority) { this.priority = priority; - - physics = ServiceLocator.getPhysicsService().getPhysics(); - timeSource = ServiceLocator.getTimeSource(); } @@ -70,11 +61,6 @@ public void updateMobBossState() { } - @Override - public void stop() { - super.stop(); - } - @Override public int getPriority() { if (status == Status.ACTIVE) { @@ -98,11 +84,7 @@ private int getInactivePriority() { return -1; } private boolean bossIsDead(int bosshealth) { - - if (bosshealth <= 0) { - return true; - } - return false; + return bosshealth <= 0; } private void killboss() { diff --git a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/PatrickTask.java b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/PatrickTask.java index ee06a9d44..bf5e6c30c 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/PatrickTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/PatrickTask.java @@ -10,11 +10,9 @@ import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.factories.MobBossFactory; import com.csse3200.game.entities.factories.ProjectileFactory; -import com.csse3200.game.physics.PhysicsEngine; import com.csse3200.game.physics.PhysicsLayer; import com.csse3200.game.physics.components.PhysicsMovementComponent; import com.csse3200.game.rendering.AnimationRenderComponent; -import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,7 +26,6 @@ public class PatrickTask extends DefaultTask implements PriorityTask { // Constants private static final int PRIORITY = 3; private static final Vector2 PATRICK_SPEED = new Vector2(1f, 1f); - private static final float MAX_RADIUS = 20f; private static final int ATTACK_DAMAGE = 100; private static final float RANGE_MIN_X = 10f; private static final float RANGE_MAX_X = 18f; @@ -38,9 +35,6 @@ public class PatrickTask extends DefaultTask implements PriorityTask { // Private variables private static final Logger logger = LoggerFactory.getLogger(PatrickTask.class); - private Vector2 currentPos; - private PhysicsEngine physics; - private GameTime gameTime; private PatrickState state = PatrickState.IDLE; private PatrickState prevState; private AnimationRenderComponent animation; @@ -61,14 +55,6 @@ private enum PatrickState { IDLE, WALK, ATTACK, HURT, DEATH, SPELL, APPEAR } - /** - * Constructor for PatrickTask - */ - public PatrickTask() { - physics = ServiceLocator.getPhysicsService().getPhysics(); - gameTime = ServiceLocator.getTimeSource(); - } - /** * What is called when the patrick task is assigned */ @@ -77,7 +63,6 @@ public void start() { super.start(); patrick = owner.getEntity(); animation = owner.getEntity().getComponent(AnimationRenderComponent.class); // get animation - currentPos = owner.getEntity().getPosition(); // get current position patrick.getComponent(PhysicsMovementComponent.class).setSpeed(PATRICK_SPEED); // set speed // give game time to load @@ -101,10 +86,7 @@ public void update() { // give game time to load if (!startFlag) { return; - } - - // update teleport task while teleporting - if (teleportFlag) { + } else if (teleportFlag) { // update teleport task while teleporting teleportTask.update(); if (teleportTask.getStatus().equals(Status.FINISHED)) { teleportFlag = false; @@ -151,15 +133,12 @@ public void run() { }, 1f); changeState(PatrickState.ATTACK); meleeFlag = false; + } else if (rangeFlag && shotsFired > 2) { + rangeFlag = false; + meleeAttack(); + shotsFired = 0; // reset shots fired } else if (rangeFlag) { - // shoot 3 projectiles - if (shotsFired > 2) { - rangeFlag = false; - meleeAttack(); - shotsFired = 0; // reset shots fired - } else { - changeState(PatrickState.IDLE); - } + changeState(PatrickState.IDLE); } } case IDLE -> { @@ -174,6 +153,7 @@ public void run() { rangeFlag = true; } } + case WALK, HURT, DEATH, SPELL -> {} } } diff --git a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/PatrickTeleportTask.java b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/PatrickTeleportTask.java index 621b0bf9d..fbb2a0c23 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/PatrickTeleportTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/PatrickTeleportTask.java @@ -4,20 +4,18 @@ import com.badlogic.gdx.utils.Timer; import com.csse3200.game.ai.tasks.DefaultTask; import com.csse3200.game.components.CombatStatsComponent; -import com.csse3200.game.components.tasks.MovementTask; import com.csse3200.game.entities.Entity; import com.csse3200.game.rendering.AnimationRenderComponent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class PatrickTeleportTask extends DefaultTask { - private static final Logger logger = LoggerFactory.getLogger(MovementTask.class); + private static final Logger logger = LoggerFactory.getLogger(PatrickTeleportTask.class); private Entity patrick; private final Vector2 location; private PatrickState state = PatrickState.IDLE; private PatrickState prevState; private AnimationRenderComponent animation; - private Status status = Status.INACTIVE; private CombatStatsComponent combatStats; private int health; private enum PatrickState { @@ -32,6 +30,7 @@ public PatrickTeleportTask(Entity patrick, Vector2 location) { @Override public void start() { super.start(); + status = Status.INACTIVE; animation = owner.getEntity().getComponent(AnimationRenderComponent.class); combatStats = owner.getEntity().getComponent(CombatStatsComponent.class); health = combatStats.getHealth(); @@ -70,6 +69,7 @@ public void update() { status = Status.FINISHED; } } + case IDLE -> {} } } diff --git a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/RangeBossTask.java b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/RangeBossTask.java index ec7486a8e..1cd260d3d 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/RangeBossTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/RangeBossTask.java @@ -69,10 +69,9 @@ public void start() { } public void switchMobBossBallState() { - switch (bossBallState) { - case START: - owner.getEntity().getEvents().trigger(FINAL); - bossBallState = STATE.FINAL; + if (bossBallState == STATE.START) { + owner.getEntity().getEvents().trigger(FINAL); + bossBallState = STATE.FINAL; } } diff --git a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/SlimeyBoyTask.java b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/SlimeyBoyTask.java index bef8386d8..fe8cefae4 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/SlimeyBoyTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/SlimeyBoyTask.java @@ -101,6 +101,7 @@ public void update() { slimey.getEvents().trigger("slimey_splat_sound"); slimey.setFlagForDelete(true); } + case IDLE, PROJECTILE_EXPLOSION, PROJECTILE_IDLE -> {} } } @@ -171,10 +172,7 @@ private boolean targetFound() { */ private void applyAoeDamage(Array targets, int damage) { for (int i = 0; i < targets.size; i++) { - Entity targetEntity = targets.get(i); - - CombatStatsComponent targetCombatStats = targetEntity. - getComponent(CombatStatsComponent.class); + CombatStatsComponent targetCombatStats = targets.get(i).getComponent(CombatStatsComponent.class); if (targetCombatStats != null) { targetCombatStats.hit(damage); } diff --git a/source/core/src/main/com/csse3200/game/entities/Entity.java b/source/core/src/main/com/csse3200/game/entities/Entity.java index 4373da4a9..c0bfb1acc 100644 --- a/source/core/src/main/com/csse3200/game/entities/Entity.java +++ b/source/core/src/main/com/csse3200/game/entities/Entity.java @@ -208,10 +208,10 @@ public Entity addComponent(Component component) { public void removeComponent(Class componentClass) { ComponentType componentType = ComponentType.getFrom(componentClass); - int id = componentType.getId(); + int componentID = componentType.getId(); - if (components.containsKey(id)) { - Component removedComponent = components.remove(id); + if (components.containsKey(componentID)) { + Component removedComponent = components.remove(componentID); removedComponent.dispose(); } } @@ -311,7 +311,7 @@ public void setFlagForDelete(boolean condition) { @Override public boolean equals(Object obj) { - return (obj instanceof Entity && ((Entity) obj).getId() == this.getId()); + return (obj instanceof Entity entity && entity.getId() == this.getId()); } @Override diff --git a/source/core/src/main/com/csse3200/game/entities/EntityService.java b/source/core/src/main/com/csse3200/game/entities/EntityService.java index d9f0c2806..35e7a9ee5 100644 --- a/source/core/src/main/com/csse3200/game/entities/EntityService.java +++ b/source/core/src/main/com/csse3200/game/entities/EntityService.java @@ -98,7 +98,7 @@ public Array getEntities() { * @return An array containing entities within the given radius. */ public Array getNearbyEntities(Entity source, float radius) { - Array nearbyEntities = new Array(); + Array nearbyEntities = new Array<>(); Array allEntities = ServiceLocator.getEntityService().getEntities(); for (int i = 0; i < allEntities.size; i++) { Entity otherEntity = allEntities.get(i); @@ -124,7 +124,7 @@ public Array getNearbyEntities(Entity source, float radius) { * @return An array containing entities within the given radius. */ public Array getEntitiesInLayer(Entity source, float radius, short layer) { - Array entities = new Array(); + Array entitiesInLayer = new Array<>(); Array allEntities = getNearbyEntities(source, radius); for (int i = 0; i < allEntities.size; i++) { @@ -132,15 +132,12 @@ public Array getEntitiesInLayer(Entity source, float radius, short layer // check targets layer HitboxComponent targetHitbox = targetEntity.getComponent(HitboxComponent.class); - if (targetHitbox == null) { + if (targetHitbox == null || (!PhysicsLayer.contains(layer, targetHitbox.getLayer()))) { continue; } - if (!PhysicsLayer.contains(layer, targetHitbox.getLayer())) { - continue; - } - entities.add(targetEntity); + entitiesInLayer.add(targetEntity); } - return entities; + return entitiesInLayer; } /** @@ -208,11 +205,11 @@ private boolean entityContainsPosition(Entity entity, float x, float y) { /** * Determine whether there are any entities within the given tile position (x and y range). Checks for out of bounds * click location - * @param x_coord the top right x coordinate of the tile - * @param y_coord the top right y coordinate of the tile + * @param xCoord the top right x coordinate of the tile + * @param yCoord the top right y coordinate of the tile * @return true if the tile is occupied, false otherwise */ - public boolean entitiesInTile(int x_coord, int y_coord) { + public boolean entitiesInTile(int xCoord, int yCoord) { TiledMapTileLayer mp; try { mp = (TiledMapTileLayer)ServiceLocator.getMapService().getComponent().getMap().getLayers().get(0); @@ -220,8 +217,8 @@ public boolean entitiesInTile(int x_coord, int y_coord) { // MapService is not running - consider this occupied (invalid tile) return true; } - if (mp.getCell(x_coord, y_coord) != null) { - Entity entity = checkEntityAtPosition(x_coord, y_coord); + if (mp.getCell(xCoord, yCoord) != null) { + Entity entity = checkEntityAtPosition(xCoord, yCoord); return entity != null; } return true; diff --git a/source/core/src/main/com/csse3200/game/entities/Melee.java b/source/core/src/main/com/csse3200/game/entities/Melee.java index 520aebf09..76289481f 100644 --- a/source/core/src/main/com/csse3200/game/entities/Melee.java +++ b/source/core/src/main/com/csse3200/game/entities/Melee.java @@ -21,10 +21,10 @@ public class Melee implements Weapon { private final int cooldown; - public Melee(int damage, int attackRange, String Element, int castTime, int cooldown) { + public Melee(int damage, int attackRange, String element, int castTime, int cooldown) { this.damage = damage; this.attackRange = attackRange; - this.element = Element; + this.element = element; this.castTime = castTime; this.cooldown = cooldown; } diff --git a/source/core/src/main/com/csse3200/game/entities/PredefinedWeapons.java b/source/core/src/main/com/csse3200/game/entities/PredefinedWeapons.java index d0a2afd2c..53e7e1af7 100644 --- a/source/core/src/main/com/csse3200/game/entities/PredefinedWeapons.java +++ b/source/core/src/main/com/csse3200/game/entities/PredefinedWeapons.java @@ -3,14 +3,19 @@ import com.csse3200.game.entities.configs.ProjectileConfig; public class PredefinedWeapons { + + private PredefinedWeapons() { + throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); + } + // Melee attacks - public static Melee sword = new Melee(10, 4, "fire", 1, 1); - public static Melee punch = new Melee(3, 1, "air", 1, 1); - public static Melee axe = new Melee(9, 3, "fire", 1, 1); - public static Melee kick = new Melee(2, 1, "earth", 1, 1); + public static final Melee SWORD = new Melee(10, 4, "fire", 1, 1); + public static final Melee PUNCH = new Melee(3, 1, "air", 1, 1); + public static final Melee AXE = new Melee(9, 3, "fire", 1, 1); + public static final Melee KICK = new Melee(2, 1, "earth", 1, 1); //TODO import defined projectiles for mobs - public static ProjectileConfig fireBall = new ProjectileConfig(); - public static ProjectileConfig frostBall = new ProjectileConfig(); + public static final ProjectileConfig FIREBALL = new ProjectileConfig(); + public static final ProjectileConfig FROSTBALL = new ProjectileConfig(); } diff --git a/source/core/src/main/com/csse3200/game/entities/configs/BaseEnemyConfig.java b/source/core/src/main/com/csse3200/game/entities/configs/BaseEnemyConfig.java index 1af74ddb7..3b13b70d8 100644 --- a/source/core/src/main/com/csse3200/game/entities/configs/BaseEnemyConfig.java +++ b/source/core/src/main/com/csse3200/game/entities/configs/BaseEnemyConfig.java @@ -25,7 +25,7 @@ */ public class BaseEnemyConfig extends BaseEntityConfig { - private static int idCounter = 0; + private int idCounter = 0; public final int speed; @@ -34,16 +34,16 @@ public class BaseEnemyConfig extends BaseEntityConfig { private final int id; //TODO: change to item class - private final ArrayList drops; - private ArrayList closeRangeAbilities; - private ArrayList longRangeAbilities; + private final List drops; + private List closeRangeAbilities; + private List longRangeAbilities; /** * Creates a new enemy config with default values. */ - public BaseEnemyConfig(ArrayList drops, - ArrayList closeRangeAbilities, - ArrayList longRangeAbilities) { + public BaseEnemyConfig(List drops, + List closeRangeAbilities, + List longRangeAbilities) { this.speed = 1; this.drops = drops; this.fullHeath = this.health; @@ -62,8 +62,8 @@ public BaseEnemyConfig(ArrayList drops, * @param drops the drops of the enemy * @param baseAttack the base damage to the target */ - public BaseEnemyConfig(int speed, int health, ArrayList drops, - ArrayList closeRangeAbilities, ArrayList longRangeAbilities, int baseAttack) { + public BaseEnemyConfig(int speed, int health, List drops, + List closeRangeAbilities, List longRangeAbilities, int baseAttack) { this.speed = speed; this.health = health; this.fullHeath = health; @@ -97,13 +97,13 @@ public String getDrops() { } /*** return the close range (Melee) attacks of the enemy */ - public ArrayList getCloseRangeAbilities() { + public List getCloseRangeAbilities() { return this.closeRangeAbilities; } /** return the long range (Projectile) attacks of the enemy */ //TODO change to projectile - public ArrayList getLongRangeAbilities() { + public List getLongRangeAbilities() { return this.longRangeAbilities; } diff --git a/source/core/src/main/com/csse3200/game/entities/configs/MobBossConfigs.java b/source/core/src/main/com/csse3200/game/entities/configs/MobBossConfigs.java index 54bd8201f..1ae0fc4af 100644 --- a/source/core/src/main/com/csse3200/game/entities/configs/MobBossConfigs.java +++ b/source/core/src/main/com/csse3200/game/entities/configs/MobBossConfigs.java @@ -1,7 +1,7 @@ package com.csse3200.game.entities.configs; /** - * Defines the properties stored in ghost king config files to be loaded by the NPC Factory. + * Defines the properties stored in mob boss config files to be loaded by the Mob Boss Factory. */ public class MobBossConfigs extends BaseEntityConfig { public int baseAttack = 0; diff --git a/source/core/src/main/com/csse3200/game/entities/configs/NPCConfigs.java b/source/core/src/main/com/csse3200/game/entities/configs/NPCConfigs.java index 8faed4421..19914f13c 100644 --- a/source/core/src/main/com/csse3200/game/entities/configs/NPCConfigs.java +++ b/source/core/src/main/com/csse3200/game/entities/configs/NPCConfigs.java @@ -1,10 +1,6 @@ package com.csse3200.game.entities.configs; -import com.csse3200.game.entities.Melee; -import com.csse3200.game.entities.Weapon; - import java.util.ArrayList; -import java.util.Currency; /** * Defines all NPC configs to be loaded by the NPC Factory. @@ -12,15 +8,14 @@ public class NPCConfigs { public BaseEntityConfig ghost = new BaseEntityConfig(); public BaseEntityConfig fireBall = new ProjectileConfig(); - // public GhostKingConfig ghostKing = new GhostKingConfig(); public BaseEntityConfig projectile = new ProjectileConfig(); public GhostKingConfig ghostKing = new GhostKingConfig(); public BaseEnemyConfig xenoGrunt = new BaseEnemyConfig( 10, 100, - new ArrayList(), - new ArrayList(), - new ArrayList(), + new ArrayList<>(), + new ArrayList<>(), + new ArrayList<>(), 10); public MobBossConfigs mobBoss = new MobBossConfigs(); diff --git a/source/core/src/main/com/csse3200/game/entities/factories/MobBossFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/MobBossFactory.java index 20480b0b8..f42babb8a 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/MobBossFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/MobBossFactory.java @@ -216,7 +216,7 @@ public static Entity createIceBoss(int health) { * @return a base mob boss entity */ public static Entity createBaseBoss() { - Entity boss = new Entity() + return new Entity() .addComponent(new PhysicsComponent()) // .addComponent(new ColliderComponent()) .addComponent(new EffectComponent(false)) @@ -225,8 +225,6 @@ public static Entity createBaseBoss() { .addComponent(new TouchAttackComponent(PhysicsLayer.HUMANS, 1.5f)); // PhysicsUtils.setScaledCollider(boss, 0.9f, 0.4f); - - return boss; } /** diff --git a/source/core/src/main/com/csse3200/game/entities/factories/NPCFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/NPCFactory.java index 97ea42dc1..1ceb66b31 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/NPCFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/NPCFactory.java @@ -45,6 +45,7 @@ public class NPCFactory { private static final NPCConfigs configs = FileLoader.readClass(NPCConfigs.class, "configs/NPCs.json"); + private static final String DEFAULT = "default"; /** * Creates a ghost entity. @@ -114,7 +115,7 @@ public static Entity createSkeleton(int health) { animator.addAnimation("skeleton_walk", 0.1f, Animation.PlayMode.LOOP); animator.addAnimation("skeleton_attack", 0.1f); animator.addAnimation("skeleton_death", 0.1f); - animator.addAnimation("default", 0.1f); + animator.addAnimation(DEFAULT, 0.1f); AITaskComponent aiTaskComponent = new AITaskComponent() .addTask(new MobTask(MobType.SKELETON)); @@ -146,7 +147,7 @@ public static Entity createWizard(int health) { animator.addAnimation("wizard_run", 0.1f, Animation.PlayMode.LOOP); animator.addAnimation("wizard_attack", 0.1f); animator.addAnimation("wizard_death", 0.1f); - animator.addAnimation("default", 0.1f); + animator.addAnimation(DEFAULT, 0.1f); AITaskComponent aiTaskComponent = new AITaskComponent() .addTask(new MobTask(MobType.WIZARD)); @@ -176,7 +177,7 @@ public static Entity createWaterQueen(int health) { animator.addAnimation("water_queen_walk", 0.1f, Animation.PlayMode.LOOP); animator.addAnimation("water_queen_attack", 0.1f); animator.addAnimation("water_queen_death", 0.1f); - animator.addAnimation("default", 0.1f); + animator.addAnimation(DEFAULT, 0.1f); AITaskComponent aiTaskComponent = new AITaskComponent() .addTask(new MobTask(MobType.WATER_QUEEN)); @@ -207,7 +208,7 @@ public static Entity createBaseWaterSlime(int health) { animator.addAnimation("water_slime_walk", 0.1f, Animation.PlayMode.LOOP); animator.addAnimation("water_slime_attack", 0.1f); animator.addAnimation("water_slime_death", 0.2f); - animator.addAnimation("default", 0.1f); + animator.addAnimation(DEFAULT, 0.1f); AITaskComponent aiTaskComponent = new AITaskComponent() .addTask(new MobTask(MobType.WATER_SLIME)); @@ -238,7 +239,7 @@ public static Entity createFireWorm(int health) { animator.addAnimation("fire_worm_walk", 0.1f, Animation.PlayMode.LOOP); animator.addAnimation("fire_worm_attack", 0.1f); animator.addAnimation("fire_worm_death", 0.1f); - animator.addAnimation("default", 0.1f); + animator.addAnimation(DEFAULT, 0.1f); AITaskComponent aiTaskComponent = new AITaskComponent() .addTask(new MobTask(MobType.FIRE_WORM)); @@ -269,7 +270,7 @@ public static Entity createDragonKnight(int health) { animator.addAnimation("dragon_knight_run", 0.1f, Animation.PlayMode.LOOP); animator.addAnimation("dragon_knight_attack", 0.1f); animator.addAnimation("dragon_knight_death", 0.1f); - animator.addAnimation("default", 0.1f); + animator.addAnimation(DEFAULT, 0.1f); AITaskComponent aiTaskComponent = new AITaskComponent() .addTask(new MobTask(MobType.DRAGON_KNIGHT)); @@ -296,7 +297,7 @@ public static Entity createCoat(int health) { animator.addAnimation("coat_run", 0.1f, Animation.PlayMode.LOOP); animator.addAnimation("coat_attack", 0.1f); animator.addAnimation("coat_death", 0.1f); - animator.addAnimation("default", 0.1f); + animator.addAnimation(DEFAULT, 0.1f); AITaskComponent aiTaskComponent = new AITaskComponent() .addTask(new MobTask(MobType.COAT)); @@ -323,7 +324,7 @@ public static Entity createNightBorne(int health) { animator.addAnimation("night_borne_run", 0.1f, Animation.PlayMode.LOOP); animator.addAnimation("night_borne_attack", 0.1f); animator.addAnimation("night_borne_death", 0.1f); - animator.addAnimation("default", 0.1f); + animator.addAnimation(DEFAULT, 0.1f); AITaskComponent aiTaskComponent = new AITaskComponent() .addTask(new MobTask(MobType.NIGHT_BORNE)); @@ -350,7 +351,7 @@ public static Entity createRocky(int health) { animator.addAnimation("rocky_move", 0.1f, Animation.PlayMode.LOOP); animator.addAnimation("rocky_attack", 0.1f); animator.addAnimation("night_borne_death", 0.1f); - animator.addAnimation("default", 0.1f); + animator.addAnimation(DEFAULT, 0.1f); AITaskComponent aiTaskComponent = new AITaskComponent() .addTask(new MobTask(MobType.NIGHT_BORNE)); @@ -377,7 +378,7 @@ public static Entity createNecromancer(int health) { animator.addAnimation("necromancer_walk", 0.1f, Animation.PlayMode.LOOP); animator.addAnimation("necromancer_attack", 0.1f); animator.addAnimation("necromancer_death", 0.1f); - animator.addAnimation("default", 0.1f); + animator.addAnimation(DEFAULT, 0.1f); AITaskComponent aiTaskComponent = new AITaskComponent() .addTask(new MobTask(MobType.NECROMANCER)); @@ -404,7 +405,7 @@ public static Entity createFirewizard(int health) { animator.addAnimation("firewizard_move", 0.1f, Animation.PlayMode.LOOP); animator.addAnimation("firewizard_attack", 0.1f); animator.addAnimation("firewizard_death", 0.1f); - animator.addAnimation("default", 0.1f); + animator.addAnimation(DEFAULT, 0.1f); AITaskComponent aiTaskComponent = new AITaskComponent() .addTask(new MobTask(MobType.FIREWIZARD)); @@ -432,7 +433,7 @@ public static Entity createArcaneArcher(int health) { animator.addAnimation("arcane_archer_attack", 0.1f); animator.addAnimation("arcane_archer_death", 0.1f); animator.addAnimation("arcane_archer_dodge", 0.1f); - animator.addAnimation("default", 0.1f); + animator.addAnimation(DEFAULT, 0.1f); AITaskComponent aiTaskComponent = new AITaskComponent() .addTask(new MobTask(MobType.ARCANE_ARCHER)); @@ -459,7 +460,7 @@ public static Entity createGregRangeMob(int health) { animator.addAnimation("fire_worm_walk", 0.1f, Animation.PlayMode.LOOP); animator.addAnimation("fire_worm_attack", 0.1f); animator.addAnimation("fire_worm_death", 0.1f); - animator.addAnimation("default", 0.1f); + animator.addAnimation(DEFAULT, 0.1f); AITaskComponent aiTaskComponent = new AITaskComponent() .addTask(new MobTask(MobType.FIRE_WORM)); @@ -485,9 +486,9 @@ public static Entity createGregRangeMob(int health) { public static Entity createXenoGrunt(int health) { Entity xenoGrunt = createMeleeBaseNPC(); BaseEnemyConfig config = configs.xenoGrunt; - ArrayList melee = new ArrayList<>(Arrays.asList(PredefinedWeapons.sword, PredefinedWeapons.kick)); + ArrayList melee = new ArrayList<>(Arrays.asList(PredefinedWeapons.SWORD, PredefinedWeapons.KICK)); // tester projectiles - ArrayList projectiles = new ArrayList<>(Arrays.asList(PredefinedWeapons.fireBall, PredefinedWeapons.frostBall)); + ArrayList projectiles = new ArrayList<>(Arrays.asList(PredefinedWeapons.FIREBALL, PredefinedWeapons.FROSTBALL)); ArrayList drops = new ArrayList<>(); AnimationRenderComponent animator = @@ -499,7 +500,7 @@ public static Entity createXenoGrunt(int health) { animator.addAnimation("xeno_melee_1", 0.1f); animator.addAnimation("xeno_melee_2", 0.1f); animator.addAnimation("xeno_die", 0.1f); - animator.addAnimation("default", 0.1f); + animator.addAnimation(DEFAULT, 0.1f); xenoGrunt .addComponent(new CombatStatsComponent(health, config.baseAttack, drops, melee, projectiles)) // .addComponent(new CombatStatsComponent(config.fullHeath, config.baseAttack, drops, melee, projectiles)) @@ -601,11 +602,7 @@ public static Entity createSplittingXenoGrunt(int health) { * @return Splitting water slime */ public static Entity createSplittingWaterSlime(int health) { - Entity splitWaterSlime = createBaseWaterSlime(health) - - .addComponent(new SplitMoblings(MobType.WATER_SLIME, 7, 0.5f)); - - return splitWaterSlime; + return createBaseWaterSlime(health).addComponent(new SplitMoblings(MobType.WATER_SLIME, 7, 0.5f)); } /** @@ -615,11 +612,7 @@ public static Entity createSplittingWaterSlime(int health) { * @return Splitting Rocky */ public static Entity createSplittingRocky(int health) { - Entity splitRocky = createRocky(health) - - .addComponent(new SplitMoblings(MobType.ROCKY, 7, 0.5f)); - - return splitRocky; + return createRocky(health).addComponent(new SplitMoblings(MobType.ROCKY, 7, 0.5f)); } /** @@ -629,11 +622,7 @@ public static Entity createSplittingRocky(int health) { * @return Splitting Night Borne */ public static Entity createSplittingNightBorne(int health) { - Entity splitWaterSlime = createNightBorne(health) - - .addComponent(new SplitMoblings(MobType.NIGHT_BORNE, 7, 0.5f)); - - return splitWaterSlime; + return createNightBorne(health).addComponent(new SplitMoblings(MobType.NIGHT_BORNE, 7, 0.5f)); } /** @@ -682,11 +671,8 @@ public static Entity createDodgingArcaneArcher(int health) { * @return Deflecting wizard */ public static Entity createDeflectWizard(int health) { - Entity deflectWizard = createWizard(health); - deflectWizard.addComponent(new DeflectingComponent( + return createWizard(health).addComponent(new DeflectingComponent( PhysicsLayer.PROJECTILE, PhysicsLayer.TOWER, 10)); - - return deflectWizard; } /** @@ -694,11 +680,8 @@ public static Entity createDeflectWizard(int health) { * @return Deflecting firewizard */ public static Entity createDeflectFireWizard(int health) { - Entity deflectWizard = createFirewizard(health); - deflectWizard.addComponent(new DeflectingComponent( + return createFirewizard(health).addComponent(new DeflectingComponent( PhysicsLayer.PROJECTILE, PhysicsLayer.TOWER, 10)); - - return deflectWizard; } } diff --git a/source/core/src/test/com/csse3200/game/components/DeflectingComponentTest.java b/source/core/src/test/com/csse3200/game/components/DeflectingComponentTest.java index 735af2f17..ae532d91c 100644 --- a/source/core/src/test/com/csse3200/game/components/DeflectingComponentTest.java +++ b/source/core/src/test/com/csse3200/game/components/DeflectingComponentTest.java @@ -35,7 +35,7 @@ import com.csse3200.game.services.ServiceLocator; @ExtendWith(GameExtension.class) -public class DeflectingComponentTest { +class DeflectingComponentTest { Entity baseMob; private static final int DEFAULT_ATTACK = 10; private static final int DEFAULT_DEFENSE = 10; @@ -73,13 +73,13 @@ public void setUp() { } @Test - public void shouldNotBeNull() { + void shouldNotBeNull() { assertNotNull("Deflecting component does not exist", baseMob.getComponent(DeflectingComponent.class)); } @Test - public void shouldNotBeDisposed() { + void shouldNotBeDisposed() { Entity projectile = createProjectile(VALID_POSITION_X, VALID_POSITION_Y); triggerCollisionStart(baseMob, projectile); @@ -91,7 +91,7 @@ public void shouldNotBeDisposed() { } @Test - public void shouldBeDisposedWhenDisabled() { + void shouldBeDisposedWhenDisabled() { Entity projectile = createProjectile(VALID_POSITION_X, VALID_POSITION_Y); baseMob.getComponent(DeflectingComponent.class).setEnabled(false); @@ -104,7 +104,7 @@ public void shouldBeDisposedWhenDisabled() { } @Test - public void shouldInvokeDeflectProjEvent() { + void shouldInvokeDeflectProjEvent() { EventListener2 deflectProj = mock(EventListener2.class); Entity projectile = createProjectile(VALID_POSITION_X, VALID_POSITION_Y); @@ -119,7 +119,7 @@ public void shouldInvokeDeflectProjEvent() { } @Test - public void shouldInvokeXAmtTimes() { + void shouldInvokeXAmtTimes() { EventListener2 deflectProj = mock(EventListener2.class); Entity mob = createDeflectMob(3, VALID_POSITION_Y, VALID_POSITION_X); Entity projectile = createProjectile(VALID_POSITION_X, VALID_POSITION_Y); @@ -155,7 +155,7 @@ public void shouldInvokeXAmtTimes() { } @Test - public void shouldInvokeAtMostOnce() { + void shouldInvokeAtMostOnce() { EventListener2 deflectProj = mock(EventListener2.class); Entity mob = createDeflectMob(1, VALID_POSITION_Y, VALID_POSITION_X); Entity projectile = createProjectile(VALID_POSITION_X, VALID_POSITION_Y); @@ -177,7 +177,7 @@ public void shouldInvokeAtMostOnce() { } @Test - public void shouldReverseProjScaleX() { + void shouldReverseProjScaleX() { Entity projectile = createProjectile(VALID_POSITION_X, VALID_POSITION_Y); float initialX = projectile.getScale().x; @@ -191,7 +191,7 @@ public void shouldReverseProjScaleX() { } @Test - public void shouldRemainSameHealth() { + void shouldRemainSameHealth() { Entity projectile = createProjectile(VALID_POSITION_X, VALID_POSITION_Y); int health = baseMob.getComponent(CombatStatsComponent.class) .getHealth(); @@ -205,7 +205,7 @@ public void shouldRemainSameHealth() { } @Test - public void shouldNotChangeHealthWhenDisabled() { + void shouldNotChangeHealthWhenDisabled() { Entity projectile = createProjectile(VALID_POSITION_X, VALID_POSITION_Y); baseMob.getComponent(CombatStatsComponent.class).setHealth(100); int health = baseMob.getComponent(CombatStatsComponent.class).getHealth(); diff --git a/source/core/src/test/com/csse3200/game/components/DodgingComponentTest.java b/source/core/src/test/com/csse3200/game/components/DodgingComponentTest.java index 58bf0c9f1..05369c3a5 100644 --- a/source/core/src/test/com/csse3200/game/components/DodgingComponentTest.java +++ b/source/core/src/test/com/csse3200/game/components/DodgingComponentTest.java @@ -32,7 +32,7 @@ import com.csse3200.game.services.ServiceLocator; @ExtendWith(GameExtension.class) -public class DodgingComponentTest { +class DodgingComponentTest { Entity baseMob, baseProjectile; private static final float VALID_POSITION_Y = 4; private static final float VALID_POSITION_X = 7; @@ -65,19 +65,19 @@ public void setUp() { } @Test - public void shouldNotBeNullComponent() { + void shouldNotBeNullComponent() { assertNotNull("Dodging combat component should not be null", baseMob.getComponent(DodgingComponent.class)); } @Test - public void shouldNotBeNullTask() { + void shouldNotBeNullTask() { assertNotNull("Mob dodging tasks should not be null", baseMob.getComponent(AITaskComponent.class)); } @Test - public void shouldInvokeDodgeEvent() { + void shouldInvokeDodgeEvent() { EventListener1 dodgeProj = mock(EventListener1.class); baseMob.getComponent(AITaskComponent.class).addTask(task); baseMob.getEvents().addListener(DodgingComponent.DODGE_EVENT, dodgeProj); diff --git a/source/core/src/test/com/csse3200/game/components/RicochetComponentTest.java b/source/core/src/test/com/csse3200/game/components/RicochetComponentTest.java index 00a16daa3..49d1295ca 100644 --- a/source/core/src/test/com/csse3200/game/components/RicochetComponentTest.java +++ b/source/core/src/test/com/csse3200/game/components/RicochetComponentTest.java @@ -26,7 +26,7 @@ import com.csse3200.game.services.ServiceLocator; @ExtendWith(GameExtension.class) -public class RicochetComponentTest { +class RicochetComponentTest { Entity projectile; Entity mob; @@ -60,18 +60,18 @@ public void setUp() { } @Test - public void shouldNotBeNull() { + void shouldNotBeNull() { assertNotNull(projectile, "Ricochet projectile does not exist"); } @Test - public void shouldHaveRicochetComponent() { + void shouldHaveRicochetComponent() { assertNotNull(projectile.getComponent(RicochetComponent.class), "Projectile does not contain RicochetComponent"); } @Test - public void shouldDisposeAferCollision() { + void shouldDisposeAferCollision() { int currentEntities = ServiceLocator.getEntityService().getEntities().size; triggerCollisionEnd(projectile, mob); @@ -88,7 +88,7 @@ public void shouldDisposeAferCollision() { // @Ignore @Test - public void shouldSpawnAnotherProjWithinMapBounds() { + void shouldSpawnAnotherProjWithinMapBounds() { projectile.setPosition(3, 3); int currentEntities = ServiceLocator.getEntityService().getEntities().size; @@ -102,7 +102,7 @@ public void shouldSpawnAnotherProjWithinMapBounds() { } @Test - public void shouldNotSpawnAnotherProjOutOfMapBounds() { + void shouldNotSpawnAnotherProjOutOfMapBounds() { projectile.setPosition(-1, -1); int currentEntities = ServiceLocator.getEntityService().getEntities().size; @@ -117,7 +117,7 @@ public void shouldNotSpawnAnotherProjOutOfMapBounds() { } @Test - public void testWithinRangeSpawnedProjectile() { + void testWithinRangeSpawnedProjectile() { projectile.setPosition(3, 3); mob.setPosition(3, 3); @@ -133,7 +133,7 @@ public void testWithinRangeSpawnedProjectile() { } @Test - public void testNotWithinRangeShouldNotSpawnProjectile() { + void testNotWithinRangeShouldNotSpawnProjectile() { projectile.setPosition(3, 3); mob.setPosition(3, 3); triggerCollisionEnd(projectile, mob); @@ -146,7 +146,7 @@ public void testNotWithinRangeShouldNotSpawnProjectile() { } @Test - public void shouldNotSpawnAnotherProjWithMaxBounceCount() { + void shouldNotSpawnAnotherProjWithMaxBounceCount() { Entity newProjectile = createProjectile(PhysicsLayer.NPC, 3); ServiceLocator.getEntityService().register(newProjectile); int currentEntities = ServiceLocator.getEntityService().getEntities().size; diff --git a/source/core/src/test/com/csse3200/game/components/SplitFireworksComponentTest.java b/source/core/src/test/com/csse3200/game/components/SplitFireworksComponentTest.java index 55e5decc2..06425c8d0 100644 --- a/source/core/src/test/com/csse3200/game/components/SplitFireworksComponentTest.java +++ b/source/core/src/test/com/csse3200/game/components/SplitFireworksComponentTest.java @@ -27,7 +27,7 @@ import com.csse3200.game.services.ServiceLocator; @ExtendWith(GameExtension.class) -public class SplitFireworksComponentTest { +class SplitFireworksComponentTest { Entity projectile; Entity mob; static double OFFSET_X = 1.75; @@ -63,18 +63,18 @@ public void setUp() { } @Test - public void shouldNotBeNull() { + void shouldNotBeNull() { assertNotNull(projectile, "Ricochet projectile does not exist"); } @Test - public void shouldHaveSplitFireworksComponent() { + void shouldHaveSplitFireworksComponent() { assertNotNull(projectile.getComponent(SplitFireworksComponent.class), "Projectile does not contain SplitFireworksComponent"); } @Test - public void shouldDisposeAferCollision() { + void shouldDisposeAferCollision() { triggerCollisionEnd(projectile, mob); assertTrue("original projectile entity flag should be true after collision", @@ -98,7 +98,7 @@ void shouldSpawnCorrectNumberOfProjs() { } @Test - public void shouldSpawnMultProjWithinMapBounds() { + void shouldSpawnMultProjWithinMapBounds() { projectile.setPosition(3, 3); mob.setPosition(3, 3); @@ -114,7 +114,7 @@ public void shouldSpawnMultProjWithinMapBounds() { } @Test - public void shouldNotSpawnMultProjOutOfMapBounds() { + void shouldNotSpawnMultProjOutOfMapBounds() { projectile.setPosition(22, 22); mob.setPosition(22, 22); @@ -130,7 +130,7 @@ public void shouldNotSpawnMultProjOutOfMapBounds() { } @Test - public void testWithinRangeSpawnedProjectiles() { + void testWithinRangeSpawnedProjectiles() { projectile.setPosition(3, 3); mob.setPosition(3, 3); @@ -144,7 +144,7 @@ public void testWithinRangeSpawnedProjectiles() { } @Test - public void testTooCloseRangeSpawnedProjectiles() { + void testTooCloseRangeSpawnedProjectiles() { projectile.setPosition(3, 3); mob.setPosition(3, 3); @@ -159,7 +159,7 @@ public void testTooCloseRangeSpawnedProjectiles() { } @Test - public void shouldSpawnAtSpecifiedLocation() { + void shouldSpawnAtSpecifiedLocation() { projectile.setPosition(3, 3); mob.setPosition(3, 3); float currPosition = projectile.getPosition().x; diff --git a/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java b/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java index 9b854eee1..a28f836a1 100644 --- a/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java +++ b/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java @@ -37,7 +37,7 @@ import com.csse3200.game.services.WaveService; @ExtendWith(GameExtension.class) -public class SplitMoblingsTest { +class SplitMoblingsTest { private static final int BASE_Y_COORD = 3; private static final int BASE_AMOUNT = 5; private final String[] atlas = { @@ -73,14 +73,14 @@ public void setUp() { } @Test - public void shouldNotBeNull() { + void shouldNotBeNull() { Entity mob = createSplitMob(5); assertNotNull("Mobling components does not exists", mob.getComponent(SplitMoblings.class)); } @Test - public void shouldHaveAsset() { + void shouldHaveAsset() { Entity projectile = createDummyProjectile(); baseMob.setPosition(SplitMoblings.MIN_X_BOUNDS + 2, SplitMoblings.MIN_Y_BOUNDS + 2); @@ -97,7 +97,7 @@ public void shouldHaveAsset() { } @Test - public void shouldBeDisposedAfterDeath() { + void shouldBeDisposedAfterDeath() { Entity projectile = createDummyProjectile(); projectile.getComponent(CombatStatsComponent.class).setBaseAttack(20); @@ -119,7 +119,7 @@ public void shouldBeDisposedAfterDeath() { } @Test - public void shouldInvokeDieStartEventAfterDeath() { + void shouldInvokeDieStartEventAfterDeath() { EventListener0 dieStart = mock(EventListener0.class); baseMob.getComponent(CombatStatsComponent.class).setHealth(0); @@ -135,7 +135,7 @@ public void shouldInvokeDieStartEventAfterDeath() { } @Test - public void shouldNotInvokeDieStartEventNoDeath() { + void shouldNotInvokeDieStartEventNoDeath() { EventListener0 dieStart = mock(EventListener0.class); assertFalse("mob is dead when health is not 0", @@ -147,7 +147,7 @@ public void shouldNotInvokeDieStartEventNoDeath() { } @Test - public void shouldSplitCorrectAmount() { + void shouldSplitCorrectAmount() { Entity projectile = createDummyProjectile(); int allEntities = ServiceLocator.getEntityService().getEntities().size; @@ -169,7 +169,7 @@ public void shouldSplitCorrectAmount() { } @Test - public void shouldNotSplitCorrectAmountOutOfBounds() { + void shouldNotSplitCorrectAmountOutOfBounds() { Entity projectile = createDummyProjectile(); int allEntities = ServiceLocator.getEntityService().getEntities().size; @@ -191,7 +191,7 @@ public void shouldNotSplitCorrectAmountOutOfBounds() { } @Test - public void shouldSpawnWithinRangeAmountOne() { + void shouldSpawnWithinRangeAmountOne() { Entity mob = createSplitMob(1); Entity projectile = createDummyProjectile(); @@ -213,7 +213,7 @@ public void shouldSpawnWithinRangeAmountOne() { } @Test - public void shouldSpawnWithinRangeMultipleAmount() { + void shouldSpawnWithinRangeMultipleAmount() { Entity projectile = createDummyProjectile(); Entity mobThree = createSplitMob(3); Entity mobSeven = createSplitMob(7); @@ -251,7 +251,7 @@ public void shouldSpawnWithinRangeMultipleAmount() { } @Test - public void shouldScaleBasedOnParamsSingleAmt() { + void shouldScaleBasedOnParamsSingleAmt() { float scale = 1.5f; Entity mob = createSplitMob(1, scale); Entity projectile = createDummyProjectile(); @@ -277,7 +277,7 @@ public void shouldScaleBasedOnParamsSingleAmt() { } @Test - public void shouldScaleXAndYbasedOnParamsMultiAmt() { + void shouldScaleXAndYbasedOnParamsMultiAmt() { float scaleX = 0.5f; float scaleY = 1.75f; Entity mob = createSplitMob(5, scaleX, scaleY); diff --git a/source/core/src/test/com/csse3200/game/components/tasks/MobAttackTaskTest.java b/source/core/src/test/com/csse3200/game/components/tasks/MobAttackTaskTest.java index e30c0e30d..243c1101f 100644 --- a/source/core/src/test/com/csse3200/game/components/tasks/MobAttackTaskTest.java +++ b/source/core/src/test/com/csse3200/game/components/tasks/MobAttackTaskTest.java @@ -12,6 +12,8 @@ class MobAttackTaskTest { @Mock GameTime gameTime; + //TODO: Add some tests to this class. + // @BeforeEach // void beforeEach() { // ServiceLocator.registerTimeSource(gameTime); diff --git a/source/core/src/test/com/csse3200/game/components/tasks/MobWanderTaskTest.java b/source/core/src/test/com/csse3200/game/components/tasks/MobWanderTaskTest.java index 56a4d8bed..102bd2673 100644 --- a/source/core/src/test/com/csse3200/game/components/tasks/MobWanderTaskTest.java +++ b/source/core/src/test/com/csse3200/game/components/tasks/MobWanderTaskTest.java @@ -18,6 +18,7 @@ class MobWanderTaskTest { void beforeEach() { ServiceLocator.registerTimeSource(gameTime); } + //TODO: Add some tests to this class. // @Test // void shouldTriggerEvent() { diff --git a/source/core/src/test/com/csse3200/game/components/xenos/XenoAnimationControllerTest.java b/source/core/src/test/com/csse3200/game/components/xenos/XenoAnimationControllerTest.java index 278e08ee7..aa0249b30 100644 --- a/source/core/src/test/com/csse3200/game/components/xenos/XenoAnimationControllerTest.java +++ b/source/core/src/test/com/csse3200/game/components/xenos/XenoAnimationControllerTest.java @@ -21,7 +21,7 @@ @ExtendWith(GameExtension.class) -public class XenoAnimationControllerTest { +class XenoAnimationControllerTest { private Entity xenoGrunt; private final String[] atlas = {"images/mobs/xenoGrunt.atlas"}; @@ -42,26 +42,27 @@ public void setUp() { } @Test - public void testAnimateWander() { + void testAnimateWander() { xenoGrunt.getEvents().trigger("wanderStart"); assertEquals("xeno_run", xenoGrunt.getComponent(AnimationRenderComponent.class).getCurrentAnimation()); } @Test - public void testAnimateHurt() { + void testAnimateHurt() { xenoGrunt.getEvents().trigger("runHurt"); assertEquals("xeno_hurt", xenoGrunt.getComponent(AnimationRenderComponent.class).getCurrentAnimation()); } @Test - public void testAnimateMelee1() { + void testAnimateMelee1() { + //TODO: Add at least one assertion to this test case. xenoGrunt.getEvents().trigger("meleeStart"); assert(Objects.equals(xenoGrunt.getComponent(AnimationRenderComponent.class).getCurrentAnimation(), "xeno_melee_1") || Objects.equals(xenoGrunt.getComponent(AnimationRenderComponent.class).getCurrentAnimation(), "xeno_melee_2")); } @Test - public void testAnimateDie() { + void testAnimateDie() { xenoGrunt.getEvents().trigger("dieStart"); assertEquals("xeno_die", xenoGrunt.getComponent(AnimationRenderComponent.class).getCurrentAnimation()); } diff --git a/source/core/src/test/com/csse3200/game/entities/EnemyTest.java b/source/core/src/test/com/csse3200/game/entities/EnemyTest.java index d79eb4987..ea11925a8 100644 --- a/source/core/src/test/com/csse3200/game/entities/EnemyTest.java +++ b/source/core/src/test/com/csse3200/game/entities/EnemyTest.java @@ -13,7 +13,7 @@ @ExtendWith(GameExtension.class) -public class EnemyTest { +class EnemyTest { private ArrayList drops = new ArrayList<>(); // private ArrayList drops = new ArrayList<>(Arrays.asList(1,2)); diff --git a/source/core/src/test/com/csse3200/game/entities/factories/MobBossFactoryTest.java b/source/core/src/test/com/csse3200/game/entities/factories/MobBossFactoryTest.java index 23413699d..8dcc791f2 100644 --- a/source/core/src/test/com/csse3200/game/entities/factories/MobBossFactoryTest.java +++ b/source/core/src/test/com/csse3200/game/entities/factories/MobBossFactoryTest.java @@ -136,7 +136,7 @@ public void setUp() { } @Test - public void testCreateMobBossNotNull() { + void testCreateMobBossNotNull() { assertNotNull(baseBoss, "Base Boss should not be null."); assertNotNull(demon, "Demon Boss should not be null."); assertNotNull(slimeyBoy, "Slimey Boy should not be null."); @@ -146,7 +146,7 @@ public void testCreateMobBossNotNull() { } @Test - public void testMobBossPhysicsComponent() { + void testMobBossPhysicsComponent() { assertNotNull(baseBoss.getComponent(PhysicsComponent.class), "Base Boss does not have physics component."); assertNotNull(demon.getComponent(PhysicsComponent.class), @@ -162,7 +162,7 @@ public void testMobBossPhysicsComponent() { } // @Test -// public void testMobBossColliderComponent() { +// void testMobBossColliderComponent() { // assertNotNull(baseBoss.getComponent(ColliderComponent.class), // "Base Boss does not have collider component."); // assertNotNull(demon.getComponent(ColliderComponent.class), @@ -178,7 +178,7 @@ public void testMobBossPhysicsComponent() { // } @Test - public void testMobBossPhysicsMovementComponent() { + void testMobBossPhysicsMovementComponent() { assertNotNull(baseBoss.getComponent(PhysicsMovementComponent.class), "Base Boss does not have physics movement component."); assertNotNull(demon.getComponent(PhysicsMovementComponent.class), @@ -194,7 +194,7 @@ public void testMobBossPhysicsMovementComponent() { } @Test - public void testMobBossHitboxComponent() { + void testMobBossHitboxComponent() { assertNotNull(baseBoss.getComponent(HitboxComponent.class), "Base Boss does not have hitbox component."); assertNotNull(demon.getComponent(HitboxComponent.class), @@ -209,7 +209,7 @@ public void testMobBossHitboxComponent() { "Ice Baby Boss does not have hitbox component."); } @Test - public void testMobBossTouchAttackComponent() { + void testMobBossTouchAttackComponent() { assertNotNull(baseBoss.getComponent(TouchAttackComponent.class), "Base Boss does not have touch attack component."); assertNotNull(demon.getComponent(TouchAttackComponent.class), @@ -225,7 +225,7 @@ public void testMobBossTouchAttackComponent() { } @Test - public void testMobBossCombatStats(){ + void testMobBossCombatStats(){ assertEquals(80, demon.getComponent(CombatStatsComponent.class).getHealth(), "Demon Boss health should be 5000."); assertEquals(0, demon.getComponent(CombatStatsComponent.class).getBaseAttack(), @@ -249,7 +249,7 @@ public void testMobBossCombatStats(){ } @Test - public void testMobBossAnimationRenderComponent() { + void testMobBossAnimationRenderComponent() { assertNotNull(demon.getComponent(AnimationRenderComponent.class), "Demon Boss does not have an animation render component."); assertNotNull(slimeyBoy.getComponent(AnimationRenderComponent.class), @@ -263,7 +263,7 @@ public void testMobBossAnimationRenderComponent() { } @Test - public void testMobBossAnimationController() { + void testMobBossAnimationController() { assertNotNull(demon.getComponent(DemonAnimationController.class), "Demon Boss does not have an animation controller."); assertNotNull(slimeyBoy.getComponent(DemonAnimationController.class), diff --git a/source/core/src/test/com/csse3200/game/entities/factories/NPCFactoryTest.java b/source/core/src/test/com/csse3200/game/entities/factories/NPCFactoryTest.java index a83e3c568..cbb0090d7 100644 --- a/source/core/src/test/com/csse3200/game/entities/factories/NPCFactoryTest.java +++ b/source/core/src/test/com/csse3200/game/entities/factories/NPCFactoryTest.java @@ -33,7 +33,7 @@ import static org.mockito.Mockito.when; @ExtendWith(GameExtension.class) -public class NPCFactoryTest { +class NPCFactoryTest { private Entity rangedBaseNpc; private Entity meleeBaseNpc; @@ -119,81 +119,81 @@ public void setUp() { } @Test - public void testCreateRangedBaseNpcNotNull() { + void testCreateRangedBaseNpcNotNull() { assertNotNull(rangedBaseNpc, "base Ranged NPC should not be null"); } @Test - public void testCreateRangedBaseNpcHasColliderComponent() { + void testCreateRangedBaseNpcHasColliderComponent() { assertNotNull(rangedBaseNpc.getComponent(ColliderComponent.class), "Fire Worm should have ColliderComponent"); } @Test - public void testCreateRangedBaseNpcHasHitboxComponent() { + void testCreateRangedBaseNpcHasHitboxComponent() { assertNotNull(rangedBaseNpc.getComponent(HitboxComponent.class), "Fire Worm should have HitboxComponent"); } @Test - public void testCreateRangedBaseNpcHasPhysicsComponent() { + void testCreateRangedBaseNpcHasPhysicsComponent() { assertNotNull(rangedBaseNpc.getComponent(PhysicsComponent.class), "Fire Worm should have PhysicsComponent"); } @Test - public void testCreateRangedBaseNpcHasPhysicsMovementComponent() { + void testCreateRangedBaseNpcHasPhysicsMovementComponent() { assertNotNull(rangedBaseNpc.getComponent(PhysicsMovementComponent.class), "Fire Worm should have PhysicsMovementComponent"); } @Test - public void testCreateRangedBaseNpcHasAIComponent() { + void testCreateRangedBaseNpcHasAIComponent() { assertNotNull(rangedBaseNpc.getComponent(AITaskComponent.class), "Fire Worm should have PhysicsMovementComponent"); } @Test - public void testCreateMeleeBaseNpcNotNull() { + void testCreateMeleeBaseNpcNotNull() { assertNotNull(meleeBaseNpc, "base Ranged NPC should not be null"); } @Test - public void testCreateMeleeBaseNpcHasColliderComponent() { + void testCreateMeleeBaseNpcHasColliderComponent() { assertNotNull(meleeBaseNpc.getComponent(ColliderComponent.class), "Fire Worm should have ColliderComponent"); } @Test - public void testCreateMeleeBaseNpcHasHitboxComponent() { + void testCreateMeleeBaseNpcHasHitboxComponent() { assertNotNull(meleeBaseNpc.getComponent(HitboxComponent.class), "Fire Worm should have HitboxComponent"); } @Test - public void testCreateMeleeBaseNpcHasPhysicsComponent() { + void testCreateMeleeBaseNpcHasPhysicsComponent() { assertNotNull(meleeBaseNpc.getComponent(PhysicsComponent.class), "Fire Worm should have PhysicsComponent"); } @Test - public void testCreateMeleeBaseNpcHasPhysicsMovementComponent() { + void testCreateMeleeBaseNpcHasPhysicsMovementComponent() { assertNotNull(meleeBaseNpc.getComponent(PhysicsMovementComponent.class), "Fire Worm should have PhysicsMovementComponent"); } @Test - public void testCreateMeleeBaseNpcHasAIComponent() { + void testCreateMeleeBaseNpcHasAIComponent() { assertNotNull(rangedBaseNpc.getComponent(AITaskComponent.class), "Fire Worm should have PhysicsMovementComponent"); } @Test - public void testCreateWaterSlime() { + void testCreateWaterSlime() { assertNotNull(waterSlime, "Water Slime should not be null"); } @Test - public void testWaterSlimeCombatStatsComponent() { + void testWaterSlimeCombatStatsComponent() { assertEquals(60, waterSlime.getComponent(CombatStatsComponent.class).getHealth(), "Health should be 100"); assertEquals(0, waterSlime.getComponent(CombatStatsComponent.class).getBaseAttack(), @@ -201,36 +201,36 @@ public void testWaterSlimeCombatStatsComponent() { } @Test - public void waterSlimeHasAnimationComponent() { + void waterSlimeHasAnimationComponent() { assertNotNull(waterSlime.getComponent(AnimationRenderComponent.class), "Water Slime should have AnimationRenderComponent"); } @Test - public void testCreateWaterSlimeHasAnimationController() { + void testCreateWaterSlimeHasAnimationController() { assertNotNull(waterSlime.getComponent(WaterSlimeAnimationController.class), "Water Slime should have an Animation Controller"); } @Test - public void testSplitWaterSlime() { + void testSplitWaterSlime() { assertNotNull(splitWaterSlime, "Water Slime should not be Null"); } @Test - public void testSplitWaterSlimeHasSplittingComponent() { + void testSplitWaterSlimeHasSplittingComponent() { Entity splitWaterSlime = NPCFactory.createSplittingWaterSlime(60); assertNotNull(splitWaterSlime.getComponent(SplitMoblings.class), "Split water slimes should have a splitting component"); } @Test - public void testCreateWaterQueenNotNull() { + void testCreateWaterQueenNotNull() { assertNotNull(waterQueen, "Water Queen should not be null"); } @Test - public void testWaterQueenCombatStatsComponent() { + void testWaterQueenCombatStatsComponent() { assertEquals(60, waterQueen.getComponent(CombatStatsComponent.class).getHealth(), "Health should be 100"); assertEquals(0, waterQueen.getComponent(CombatStatsComponent.class).getBaseAttack(), @@ -238,24 +238,24 @@ public void testWaterQueenCombatStatsComponent() { } @Test - public void waterQueenHasAnimationComponent() { + void waterQueenHasAnimationComponent() { assertNotNull(waterQueen.getComponent(AnimationRenderComponent.class), "Water Queen should have AnimationRenderComponent"); } @Test - public void testCreateWaterQueenHasAnimationController() { + void testCreateWaterQueenHasAnimationController() { assertNotNull(waterQueen.getComponent(WaterQueenAnimationController.class), "Water Queen should have an Animation controller"); } @Test - public void testCreateFireWormNotNull() { + void testCreateFireWormNotNull() { assertNotNull(fireWorm, "Fire Worm should not be null"); } @Test - public void testFireWormCombatStatsComponent() { + void testFireWormCombatStatsComponent() { assertEquals(60, fireWorm.getComponent(CombatStatsComponent.class).getHealth(), "Health should be 100"); assertEquals(0, fireWorm.getComponent(CombatStatsComponent.class).getBaseAttack(), @@ -263,23 +263,23 @@ public void testFireWormCombatStatsComponent() { } @Test - public void fireWormHasAnimationComponent() { + void fireWormHasAnimationComponent() { assertNotNull(fireWorm.getComponent(AnimationRenderComponent.class), "Fire Worm should have AnimationRenderComponent"); } @Test - public void fireWormHasAnimationController() { + void fireWormHasAnimationController() { assertNotNull(fireWorm.getComponent(FireWormAnimationController.class), "Fire Worm should have AnimationRenderComponent"); } @Test - public void testCreateDragonKnightNotNull() { + void testCreateDragonKnightNotNull() { assertNotNull(dragonKnight, "Dragon Knight should not be null"); } @Test - public void testDragonKnightCombatStatsComponent() { + void testDragonKnightCombatStatsComponent() { assertEquals(60, dragonKnight.getComponent(CombatStatsComponent.class).getHealth(), "Health should be 100"); assertEquals(0, dragonKnight.getComponent(CombatStatsComponent.class).getBaseAttack(), @@ -287,30 +287,30 @@ public void testDragonKnightCombatStatsComponent() { } @Test - public void dragonKnightHasAnimationComponent() { + void dragonKnightHasAnimationComponent() { assertNotNull(dragonKnight.getComponent(AnimationRenderComponent.class), "Dragon Knight should have AnimationRenderComponent"); } @Test - public void dragonKnightHasAnimationController() { + void dragonKnightHasAnimationController() { assertNotNull(dragonKnight.getComponent(DragonKnightAnimationController.class), "Dragon Knight should have Animation Controller"); } @Test - public void dodgingDragonKnightHasDodgingComponent() { + void dodgingDragonKnightHasDodgingComponent() { assertNotNull(dodgingDragonKnight.getComponent(DodgingComponent.class), "Dragon Knight should have AnimationRenderComponent"); } @Test - public void testCreateWizardNotNull() { + void testCreateWizardNotNull() { assertNotNull(wizard, "Wizard should not be null"); } @Test - public void testWizardCombatStatsComponent() { + void testWizardCombatStatsComponent() { assertEquals(60, wizard.getComponent(CombatStatsComponent.class).getHealth(), "Health should be 100"); assertEquals(0, wizard.getComponent(CombatStatsComponent.class).getBaseAttack(), @@ -318,30 +318,30 @@ public void testWizardCombatStatsComponent() { } @Test - public void wizardHasAnimationComponent() { + void wizardHasAnimationComponent() { assertNotNull(wizard.getComponent(AnimationRenderComponent.class), "Wizard should have AnimationRenderComponent"); } @Test - public void wizardHasAnimationController() { + void wizardHasAnimationController() { assertNotNull(wizard.getComponent(WizardAnimationController.class), "Wizard should have Animation Controller"); } @Test - public void dodgingWizardHasDeflectingComponent() { + void dodgingWizardHasDeflectingComponent() { assertNotNull(deflectWizard.getComponent(DeflectingComponent.class), "Deflecting Wizard should have Deflecting component"); } @Test - public void testCreateSkeletonNotNull() { + void testCreateSkeletonNotNull() { assertNotNull(skeleton, "skeleton should not be null"); } @Test - public void testSkeletonCombatStatsComponent() { + void testSkeletonCombatStatsComponent() { assertEquals(60, skeleton.getComponent(CombatStatsComponent.class).getHealth(), "Health should be 100"); assertEquals(0, skeleton.getComponent(CombatStatsComponent.class).getBaseAttack(), @@ -349,13 +349,13 @@ public void testSkeletonCombatStatsComponent() { } @Test - public void skeletonHasAnimationComponent() { + void skeletonHasAnimationComponent() { assertNotNull(skeleton.getComponent(AnimationRenderComponent.class), "skeleton should have AnimationRenderComponent"); } @Test - public void skeletonHasAnimationController() { + void skeletonHasAnimationController() { assertNotNull(skeleton.getComponent(SkeletonAnimationController.class), "skeleton should have an Animation Controller"); } diff --git a/source/core/src/test/com/csse3200/game/entities/factories/ProjectileFactoryTest.java b/source/core/src/test/com/csse3200/game/entities/factories/ProjectileFactoryTest.java index 74d0c4836..d8b8a371c 100644 --- a/source/core/src/test/com/csse3200/game/entities/factories/ProjectileFactoryTest.java +++ b/source/core/src/test/com/csse3200/game/entities/factories/ProjectileFactoryTest.java @@ -63,34 +63,34 @@ public void setUp() { } @Test - public void createBaseProjectile() { + void createBaseProjectile() { Entity projectile = ProjectileFactory.createBaseProjectile(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(projectile); } @Test - public void testBaseProjectileColliderComponent() { + void testBaseProjectileColliderComponent() { Entity projectile = ProjectileFactory.createBaseProjectile(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(projectile.getComponent(ColliderComponent.class), "Projectile does not have a ColliderComponent"); } @Test - public void testBaseProjectileTouchAttackComponent() { + void testBaseProjectileTouchAttackComponent() { Entity projectile = ProjectileFactory.createBaseProjectile(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(projectile.getComponent(TouchAttackComponent.class), "Projectile does not have a TouchAttackComponent"); } @Test - public void testBaseProjectileDeleteOnMapEdgeComponent() { + void testBaseProjectileDeleteOnMapEdgeComponent() { Entity projectile = ProjectileFactory.createBaseProjectile(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(projectile.getComponent(DeleteOnMapEdgeComponent.class), "Projectile does not have a DeleteOnMapEdgeComponent"); } @Test - public void testBaseProjectileSpeed() { + void testBaseProjectileSpeed() { Vector2 testSpeed = new Vector2(1f, 1f); Entity projectile = ProjectileFactory.createBaseProjectile(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), testSpeed); assertEquals(testSpeed, projectile.getComponent(PhysicsMovementComponent.class).getSpeed(), @@ -98,114 +98,114 @@ public void testBaseProjectileSpeed() { } @Test - public void testBaseProjectileHitbox() { + void testBaseProjectileHitbox() { Entity projectile = ProjectileFactory.createBaseProjectile(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(projectile.getComponent(HitboxComponent.class), "Projectile does not contain Hotbox component"); } @Test - public void testBaseProjectilePhysics() { + void testBaseProjectilePhysics() { Entity projectile = ProjectileFactory.createBaseProjectile(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(projectile.getComponent(PhysicsComponent.class), "Projectile does not have Physics component"); } @Test - public void testBaseProjectilePhysicsMovement() { + void testBaseProjectilePhysicsMovement() { Entity projectile = ProjectileFactory.createBaseProjectile(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(projectile.getComponent(PhysicsMovementComponent.class), "Projectile does not have PhysicsMovement component"); } @Test - public void testFireBallProjectileCreation() { + void testFireBallProjectileCreation() { Entity fireBall = ProjectileFactory.createFireBall(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(fireBall); } @Test - public void testFireBallAnimationRenderComponent() { + void testFireBallAnimationRenderComponent() { Entity fireBall = ProjectileFactory.createFireBall(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(fireBall.getComponent(AnimationRenderComponent.class), "Fire Ball does not have an AnimationRenderComponent"); } @Test - public void testFireBallAnimationController() { + void testFireBallAnimationController() { Entity fireBall = ProjectileFactory.createFireBall(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(fireBall.getComponent(ProjectileAnimationController.class), "Fire Ball does not have an Animation Controller"); } @Test - public void createMobBallProjectile() { + void createMobBallProjectile() { Entity mobBallProjectile = ProjectileFactory.createMobBall(PhysicsLayer.HUMANS, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(mobBallProjectile, "Mob King Ball is Null"); } @Test - public void testMobBallProjectileAnimationRenderComponent() { + void testMobBallProjectileAnimationRenderComponent() { Entity mobBallProjectile = ProjectileFactory.createMobBall(PhysicsLayer.HUMANS, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(mobBallProjectile.getComponent(AnimationRenderComponent.class), "Mob Ball Projectile does not have an AnimationRenderComponent"); } // @Test -// public void testMobBallProjectileAnimationController() { +// void testMobBallProjectileAnimationController() { // Entity mobBallProjectile = ProjectileFactory.createMobBall(PhysicsLayer.HUMANS, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); // assertNotNull(mobBallProjectile.getComponent(MobProjectileAnimationController.class), // "Mob Ball Projectile does not have an AnimationController"); // } @Test - public void testMobBossBallCreation() { + void testMobBossBallCreation() { Entity mobBossBall = ProjectileFactory.createMobBossBall(PhysicsLayer.TOWER, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(mobBossBall, "Mob King Ball is null"); } @Test - public void testMobBossBallAnimationRenderComponent() { + void testMobBossBallAnimationRenderComponent() { Entity mobBossBall = ProjectileFactory.createMobBossBall(PhysicsLayer.TOWER, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(mobBossBall.getComponent(AnimationRenderComponent.class), "Mob King Ball does not have AnimationRenderComponent"); } @Test - public void testMobBossBallAnimationController() { + void testMobBossBallAnimationController() { Entity mobBossBall = ProjectileFactory.createMobBossBall(PhysicsLayer.TOWER, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(mobBossBall.getComponent(MobBossProjectAnimController.class), "Mob King Ball does not have Animation Controller"); } @Test - public void testEngineerBulletCreation() { + void testEngineerBulletCreation() { Entity engineerBullet = ProjectileFactory.createEngineerBullet(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(engineerBullet, "engineerBullet is null"); } @Test - public void testEngineerBulletAnimationRenderComponent() { + void testEngineerBulletAnimationRenderComponent() { Entity engineerBulllet = ProjectileFactory.createEngineerBullet(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(engineerBulllet.getComponent(AnimationRenderComponent.class), "Engineer Bullet does not have AnimationRenderComponent"); } @Test - public void testEngineerAnimationController() { + void testEngineerAnimationController() { Entity engineerBullet = ProjectileFactory.createEngineerBullet(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(engineerBullet.getComponent(EngineerBulletsAnimationController.class), "Engineer Bullet does not have Animation Controller"); } @Test - public void testStunProjectileCreation() { + void testStunProjectileCreation() { Entity stunProjectile = ProjectileFactory.createEffectProjectile(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), new Vector2(2,2), ProjectileEffects.STUN, false); assertNotNull(stunProjectile, "stunProjectile is null"); } @Test - public void testStunProjectileAnimationRenderComponent() { + void testStunProjectileAnimationRenderComponent() { Entity stunProjectile = ProjectileFactory.createEffectProjectile(PhysicsLayer.NPC, new Vector2(0.1f,01f), new Vector2(2,2), ProjectileEffects.STUN, false); assertNotNull(stunProjectile.getComponent(AnimationRenderComponent.class), @@ -213,7 +213,7 @@ public void testStunProjectileAnimationRenderComponent() { } @Test - public void testStunProjectileAnimationController() { + void testStunProjectileAnimationController() { Entity stunProjectile = ProjectileFactory.createEffectProjectile(PhysicsLayer.TOWER, new Vector2(0.1f, 0.1f) , new Vector2(2,2), ProjectileEffects.STUN, false); assertNotNull(stunProjectile.getComponent(StunEffectProjectileAnimationController.class), @@ -221,21 +221,21 @@ public void testStunProjectileAnimationController() { } @Test - public void testBurnProjectileCreation() { + void testBurnProjectileCreation() { Entity burnProjectile = ProjectileFactory.createEffectProjectile(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), new Vector2(2,2), ProjectileEffects.BURN, false); assertNotNull(burnProjectile, "burnProjectile is null"); } @Test - public void testBurnProjectileAnimationRenderComponent() { + void testBurnProjectileAnimationRenderComponent() { Entity burnProjectile = ProjectileFactory.createEffectProjectile(PhysicsLayer.NPC, new Vector2(0.1f,01f), new Vector2(2,2), ProjectileEffects.BURN, false); assertNotNull(burnProjectile.getComponent(AnimationRenderComponent.class), "Burn Projectile does not have AnimationRenderComponent"); } @Test - public void testBurnProjectileAnimationController() { + void testBurnProjectileAnimationController() { Entity burnProjectile = ProjectileFactory.createEffectProjectile(PhysicsLayer.TOWER, new Vector2(0.1f, 0.1f) , new Vector2(2,2), ProjectileEffects.BURN, false); assertNotNull(burnProjectile.getComponent(BurnEffectProjectileAnimationController.class), @@ -243,21 +243,21 @@ public void testBurnProjectileAnimationController() { } @Test - public void testSlowProjectileCreation() { + void testSlowProjectileCreation() { Entity slowProjectile = ProjectileFactory.createEffectProjectile(PhysicsLayer.NPC, new Vector2(0.1f, 0.1f), new Vector2(2,2), ProjectileEffects.SLOW, false); assertNotNull(slowProjectile, "slowProjectile is null"); } @Test - public void testSlowProjectileAnimationRenderComponent() { + void testSlowProjectileAnimationRenderComponent() { Entity slowProjectile = ProjectileFactory.createEffectProjectile(PhysicsLayer.NPC, new Vector2(0.1f,01f), new Vector2(2,2), ProjectileEffects.SLOW, false); assertNotNull(slowProjectile.getComponent(AnimationRenderComponent.class), "Slow Projectile does not have AnimationRenderComponent"); } @Test - public void testSlowProjectileAnimationController() { + void testSlowProjectileAnimationController() { Entity slowProjectile = ProjectileFactory.createEffectProjectile(PhysicsLayer.TOWER, new Vector2(0.1f, 0.1f) , new Vector2(2,2), ProjectileEffects.SLOW, false); assertNotNull(slowProjectile.getComponent(SnowBallProjectileAnimationController.class), @@ -265,21 +265,21 @@ public void testSlowProjectileAnimationController() { } @Test - public void testFireworkProjectileCreation() { + void testFireworkProjectileCreation() { Entity fireworkProjectile = ProjectileFactory.createFireworks( PhysicsLayer.TOWER, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(fireworkProjectile, "fireworkProjectile is null"); } @Test - public void testFireworkProjectileAnimationRenderComponent() { + void testFireworkProjectileAnimationRenderComponent() { Entity fireworkProjectile = ProjectileFactory.createFireworks( PhysicsLayer.TOWER, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(fireworkProjectile.getComponent(AnimationRenderComponent.class), "Fire Projectile does not have AnimationRenderComponent"); } @Test - public void testFireworkProjectileAnimationController() { + void testFireworkProjectileAnimationController() { Entity fireworkProjectile = ProjectileFactory.createFireworks( PhysicsLayer.TOWER, new Vector2(0.1f, 0.1f), new Vector2(1f, 1f)); assertNotNull(fireworkProjectile.getComponent(FireworkAnimationController.class),