From 6fd9e593ae0b182a76a08f01720f460553e4da2f Mon Sep 17 00:00:00 2001 From: bojyyy <140468434+bojyyy@users.noreply.github.com> Date: Sun, 15 Oct 2023 13:01:53 +1000 Subject: [PATCH 01/11] Removes outdated SpawnWaveTask --- .../game/components/tasks/SpawnWaveTask.java | 37 ------------------ .../components/tasks/SpawnWaveTaskTest.java | 39 ------------------- 2 files changed, 76 deletions(-) delete mode 100644 source/core/src/main/com/csse3200/game/components/tasks/SpawnWaveTask.java delete mode 100644 source/core/src/test/com/csse3200/game/components/tasks/SpawnWaveTaskTest.java diff --git a/source/core/src/main/com/csse3200/game/components/tasks/SpawnWaveTask.java b/source/core/src/main/com/csse3200/game/components/tasks/SpawnWaveTask.java deleted file mode 100644 index d6c4a3d85..000000000 --- a/source/core/src/main/com/csse3200/game/components/tasks/SpawnWaveTask.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.csse3200.game.components.tasks; - -import com.csse3200.game.ai.tasks.DefaultTask; -import com.csse3200.game.ai.tasks.PriorityTask; -import com.csse3200.game.services.GameTime; -import com.csse3200.game.services.ServiceLocator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SpawnWaveTask extends DefaultTask implements PriorityTask { - private static final Logger logger = LoggerFactory.getLogger(SpawnWaveTask.class); - private final GameTime globalTime; - private long endTime = 0; - private final int SPAWNING_INTERVAL = 10; - public SpawnWaveTask() { - this.globalTime = ServiceLocator.getTimeSource(); - } - - @Override - public int getPriority() { - return 10; // High priority task - } - - @Override - public void start() { - super.start(); - endTime = globalTime.getTime() + (SPAWNING_INTERVAL * 1000); - } - - @Override - public void update() { - if (globalTime.getTime() >= endTime) { - this.owner.getEntity().getEvents().trigger("spawnWave"); - endTime = globalTime.getTime() + (SPAWNING_INTERVAL * 1000L); // reset end time - } - } -} diff --git a/source/core/src/test/com/csse3200/game/components/tasks/SpawnWaveTaskTest.java b/source/core/src/test/com/csse3200/game/components/tasks/SpawnWaveTaskTest.java deleted file mode 100644 index 58fb2ae9b..000000000 --- a/source/core/src/test/com/csse3200/game/components/tasks/SpawnWaveTaskTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.csse3200.game.components.tasks; - -import com.csse3200.game.ai.tasks.AITaskComponent; -import com.csse3200.game.entities.Entity; -import com.csse3200.game.events.listeners.EventListener0; -import com.csse3200.game.extensions.GameExtension; -import com.csse3200.game.physics.components.PhysicsMovementComponent; -import com.csse3200.game.services.GameTime; -import com.csse3200.game.services.ServiceLocator; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.mockito.Mockito.*; - -@ExtendWith(GameExtension.class) -@ExtendWith(MockitoExtension.class) -class SpawnWaveTaskTest { - - @Test - void shouldTriggerSpawning() { - GameTime time = mock(GameTime.class); - when(time.getTime()).thenReturn(11000L); - ServiceLocator.registerTimeSource(time); - SpawnWaveTask waveTask = new SpawnWaveTask(); - - AITaskComponent aiTaskComponent = new AITaskComponent().addTask(waveTask); - Entity entity = new Entity().addComponent(aiTaskComponent).addComponent(new PhysicsMovementComponent()); - entity.create(); - - // Register callbacks - EventListener0 callback = mock(EventListener0.class); - entity.getEvents().addListener("spawnWave", callback); - - waveTask.update(); - - verify(callback).handle(); - } -} \ No newline at end of file From fced5a7f2ff033874031224125aff6780b22eb65 Mon Sep 17 00:00:00 2001 From: bojyyy <140468434+bojyyy@users.noreply.github.com> Date: Mon, 16 Oct 2023 11:48:00 +1000 Subject: [PATCH 02/11] Fixes a bug with the mob counter going negative due to splitting mobs --- .../game/components/npc/SplitMoblings.java | 3 +-- .../game/entities/factories/NPCFactory.java | 25 ------------------- .../game/entities/factories/WaveFactory.java | 4 +-- .../game/components/SplitMoblingsTest.java | 2 +- 4 files changed, 4 insertions(+), 30 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java b/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java index 5896c2f10..90a390e8d 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java +++ b/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java @@ -167,8 +167,7 @@ public void spawnAdditionalMob(float positionX, float positionY, ServiceLocator.getEntityService().register(entityType); - // ServiceLocator.getWaveService().setEnemyCount(ServiceLocator.getWaveService().getEnemyCount() + 1); - //ServiceLocator.getWaveService().setEnemyCount(ServiceLocator.getWaveService().getEnemyCount() + 1); + ServiceLocator.getWaveService().setEnemyCount(ServiceLocator.getWaveService().getEnemyCount() + 1); } /** 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 1ceb66b31..4d9f0d554 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 @@ -73,31 +73,6 @@ public static Entity createGhost() { return ghost; } - /** - * Creates a ghost king entity. - * - * @return entity - */ - public static Entity createGhostKing() { - Entity ghostKing = createMeleeBaseNPC(); - GhostKingConfig config = configs.ghostKing; - - AnimationRenderComponent animator = - new AnimationRenderComponent( - ServiceLocator.getResourceService() - .getAsset("images/ghostKing.atlas", TextureAtlas.class)); - animator.addAnimation("float", 0.2f, Animation.PlayMode.LOOP); - animator.addAnimation("angry_float", 0.2f, Animation.PlayMode.LOOP); - - ghostKing - .addComponent(new CombatStatsComponent(config.health, config.baseAttack)) - .addComponent(animator) - .addComponent(new GhostAnimationController()); - - ghostKing.getComponent(AnimationRenderComponent.class).scaleEntity(); - return ghostKing; - } - /** * Creates a fire worm entity. * diff --git a/source/core/src/main/com/csse3200/game/entities/factories/WaveFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/WaveFactory.java index c0526e42b..112926f93 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/WaveFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/WaveFactory.java @@ -55,7 +55,7 @@ public class WaveFactory { )); private static final ArrayList> lvl3Structure = new ArrayList<>(Arrays.asList( - new ArrayList<>(Arrays.asList("Necromancer" + new ArrayList<>(Arrays.asList("SplittingRocky" )), new ArrayList<>(Arrays.asList("Necromancer", "DodgingDragon" )), new ArrayList<>(Arrays.asList("Necromancer", "FireWorm" )), new ArrayList<>(Arrays.asList("Necromancer", "FireWorm" @@ -63,7 +63,7 @@ public class WaveFactory { )), new ArrayList<>(Arrays.asList("DodgingDragon", "FireWorm" )), new ArrayList<>(Arrays.asList("DodgingDragon", "Necromancer" )), new ArrayList<>(Arrays.asList("FireWorm", "Necromancer" - )), new ArrayList<>(Arrays.asList("DeflectFireWiza","SplittingRocky", "Necromancer" + )), new ArrayList<>(Arrays.asList("DeflectFireWizard","SplittingRocky", "Necromancer" )), new ArrayList<>(Arrays.asList("DodgingDragon", "DeflectFireWizard", "SplittingRocky", "Necromancer" )), new ArrayList<>(Arrays.asList("FireWorm", "DeflectWizard", "DodgingDragon" )), new ArrayList<>(Arrays.asList("FireWorm", "DeflectWizard", "Necromancer" 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 a28f836a1..ec985954d 100644 --- a/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java +++ b/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java @@ -66,7 +66,7 @@ public void setUp() { resourceService.loadTextureAtlases(atlas); resourceService.loadAll(); - WaveService waveService = new WaveService(); + WaveService waveService = mock(WaveService.class); ServiceLocator.registerWaveService(waveService); baseMob = createSplitMob(BASE_AMOUNT); From 5458c3db52106afebc645c6f00d57ae4eb9747e9 Mon Sep 17 00:00:00 2001 From: bojyyy <140468434+bojyyy@users.noreply.github.com> Date: Mon, 16 Oct 2023 11:56:28 +1000 Subject: [PATCH 03/11] Reverts change to wave structure done for testing purposes --- .../main/com/csse3200/game/entities/factories/WaveFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/src/main/com/csse3200/game/entities/factories/WaveFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/WaveFactory.java index 112926f93..9fb9b16e1 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/WaveFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/WaveFactory.java @@ -55,7 +55,7 @@ public class WaveFactory { )); private static final ArrayList> lvl3Structure = new ArrayList<>(Arrays.asList( - new ArrayList<>(Arrays.asList("SplittingRocky" + new ArrayList<>(Arrays.asList("Necromancer" )), new ArrayList<>(Arrays.asList("Necromancer", "DodgingDragon" )), new ArrayList<>(Arrays.asList("Necromancer", "FireWorm" )), new ArrayList<>(Arrays.asList("Necromancer", "FireWorm" From ab5ea49a82145f525b557b2c74d0729b5f668c5c Mon Sep 17 00:00:00 2001 From: bojyyy <140468434+bojyyy@users.noreply.github.com> Date: Mon, 16 Oct 2023 12:05:51 +1000 Subject: [PATCH 04/11] Fixes a bug with the IceBaby boss where the mob counter was not updating when it spawned WaterSlimes --- .../com/csse3200/game/components/tasks/bosstask/IceBabyTask.java | 1 + 1 file changed, 1 insertion(+) 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 80e703ebf..4b298c059 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 @@ -264,6 +264,7 @@ private void spawnMob() { Entity newMob = NPCFactory.createSplittingWaterSlime(80); newMob.setPosition((float) (iceBaby.getPosition().x + 0.5), (float) (iceBaby.getPosition().y + 0.5)); ServiceLocator.getEntityService().register(newMob); + ServiceLocator.getWaveService().setEnemyCount(ServiceLocator.getWaveService().getEnemyCount() + 1); } /** From a1545aff54030d0189bf3c4106823afa39d1539e Mon Sep 17 00:00:00 2001 From: max9753 Date: Mon, 16 Oct 2023 22:15:46 +1000 Subject: [PATCH 05/11] Removed logger imports in SpawnWaveTask and used String builder in LevelWaves as instructed by SonarCloud. --- .../csse3200/game/components/tasks/SpawnWaveTask.java | 2 -- .../game/components/tasks/waves/LevelWaves.java | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/tasks/SpawnWaveTask.java b/source/core/src/main/com/csse3200/game/components/tasks/SpawnWaveTask.java index 912a2451b..201e3823f 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/SpawnWaveTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/SpawnWaveTask.java @@ -4,8 +4,6 @@ import com.csse3200.game.ai.tasks.PriorityTask; import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class SpawnWaveTask extends DefaultTask implements PriorityTask { diff --git a/source/core/src/main/com/csse3200/game/components/tasks/waves/LevelWaves.java b/source/core/src/main/com/csse3200/game/components/tasks/waves/LevelWaves.java index 7d9e0e731..cca65b2e5 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/waves/LevelWaves.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/waves/LevelWaves.java @@ -124,11 +124,11 @@ public List getWaves() { @Override public String toString() { - String result = ""; - for (WaveClass wave : waves) { - result += wave.toString() + "\n"; - } - return result; + StringBuilder result = new StringBuilder(); + for (WaveClass wave : waves) { + result.append(wave.toString()).append("\n"); + } + return result.toString(); } } From f2c1398992f9794ebf4ec9541f062eb79fc2def2 Mon Sep 17 00:00:00 2001 From: max9753 Date: Mon, 16 Oct 2023 22:21:24 +1000 Subject: [PATCH 06/11] Removed unused mobIndex private variable. --- .../com/csse3200/game/components/tasks/waves/WaveClass.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/tasks/waves/WaveClass.java b/source/core/src/main/com/csse3200/game/components/tasks/waves/WaveClass.java index 3e197601e..635834811 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/waves/WaveClass.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/waves/WaveClass.java @@ -1,15 +1,10 @@ package com.csse3200.game.components.tasks.waves; - -import com.csse3200.game.services.GameTime; - - import java.util.*; public class WaveClass { private HashMap entities; private List wave; - private int mobIndex; /** * Constructor for the WaveClass @@ -18,7 +13,6 @@ public class WaveClass { public WaveClass(HashMap entities) { this.entities = entities; this.wave = entitiesToWave(); - this.mobIndex = 0; } /** From c2b555592279a2567e23db89b7625a581bad70ff Mon Sep 17 00:00:00 2001 From: max9753 Date: Mon, 16 Oct 2023 22:27:09 +1000 Subject: [PATCH 07/11] Removed commented out code and bad comments etc in WaveTask. --- .../game/components/tasks/waves/WaveTask.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/tasks/waves/WaveTask.java b/source/core/src/main/com/csse3200/game/components/tasks/waves/WaveTask.java index d49816692..04353f589 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/waves/WaveTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/waves/WaveTask.java @@ -1,18 +1,14 @@ package com.csse3200.game.components.tasks.waves; -import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.audio.Sound; import com.csse3200.game.ai.tasks.DefaultTask; import com.csse3200.game.ai.tasks.PriorityTask; -import com.csse3200.game.ai.tasks.Task; import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.List; - public class WaveTask extends DefaultTask implements PriorityTask { private static final Logger logger = LoggerFactory.getLogger(WaveTask.class); private LevelWaves level; @@ -21,10 +17,6 @@ public class WaveTask extends DefaultTask implements PriorityTask { private long nextWaveAt = 0; private int currentWaveIndex = 0; private boolean waveInProgress; - private float startTime = 0; - private float endTime = 0; - private final float INITIAL_WAIT_INTERVAL = 10; - private final int SPAWNING_INTERVAL = 10; private static final String[] waveSounds = { "sounds/waves/wave-start/Wave_Start_Alarm.ogg", @@ -83,7 +75,6 @@ public void start() { this.currentWave = level.getWave(currentWaveIndex); ServiceLocator.getWaveService().setEnemyCount(currentWave.getSize()); logger.info("Wave {} starting with {} enemies", currentWaveIndex, ServiceLocator.getWaveService().getEnemyCount()); - // endTime = globalTime.getTime() + (SPAWNING_INTERVAL * 1000); } /** @@ -101,7 +92,6 @@ public void update() { } else { // Spawn the next wave -// logger.info("No enemies remaining, begin next wave"); if (nextWaveAt == 0) { logger.info("Next wave in 10 seconds"); this.waveEnd.play(); @@ -121,16 +111,11 @@ public void update() { this.currentWave = this.level.getWave(currentWaveIndex); ServiceLocator.getWaveService().setEnemyCount(currentWave.getSize()); logger.info("Next wave {} starting with {} enemies", currentWaveIndex, ServiceLocator.getWaveService().getEnemyCount()); - //endTime = globalTime.getTime() + (SPAWNING_INTERVAL * 1000L); // reset end time } } } } else { - //logger.info("{} enemies remaining in wave {}", ServiceLocator.getWaveService().getEnemyCount(), currentWaveIndex); - //logger.info("WAVE SERVICE NUMBER: Wave Number {}",ServiceLocator.getWaveService().getWaveCount()); - //logger.info("NEXT WAVE AT {}", ServiceLocator.getWaveService().getNextWaveTime()); - //logger.info("TIME IS {}", ServiceLocator.getTimeSource().getTime()); if (waveInProgress) { this.level.spawnWave(); } From 9fb461453001f2e375bf0dff14f448f8888e1f9d Mon Sep 17 00:00:00 2001 From: max9753 Date: Mon, 16 Oct 2023 22:35:20 +1000 Subject: [PATCH 08/11] Cleaned up several sections of NPCFactory.java and left COW's testing area alone. Hopefully none of NPC factory was messed with :) --- .../game/entities/factories/NPCFactory.java | 30 ++++--------------- 1 file changed, 5 insertions(+), 25 deletions(-) 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 65185b27e..e8038c978 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 @@ -64,9 +64,7 @@ public static Entity createGhost() { **/ ghost .addComponent(new CombatStatsComponent(config.health, config.baseAttack)) - // .addComponent(animator) .addComponent(new TextureRenderComponent("images/mobs/satyr.png")); - // .addComponent(new GhostAnimationController()); ghost.getComponent(TextureRenderComponent.class).scaleEntity(); @@ -103,8 +101,6 @@ public static Entity createGhostKing() { * * @return entity */ -// public static Entity createSkeleton(int health) { -// Entity skeleton = createBaseNPC(int health); public static Entity createSkeleton(int health) { Entity skeleton = createBaseNPC(); ArrayList drops = new ArrayList<>(); @@ -396,7 +392,7 @@ public static Entity createNecromancer(int health) { } public static Entity createFirewizard(int health) { - Entity Firewizard = createBaseNPC(); + Entity fireWizard = createBaseNPC(); ArrayList drops = new ArrayList<>(); AnimationRenderComponent animator = @@ -410,16 +406,16 @@ public static Entity createFirewizard(int health) { AITaskComponent aiTaskComponent = new AITaskComponent() .addTask(new MobTask(MobType.FIREWIZARD)); - Firewizard + fireWizard .addComponent(new CombatStatsComponent(health, 0, drops)) .addComponent(animator) .addComponent(new FirewizardAnimationController()) .addComponent(aiTaskComponent); - Firewizard.getComponent(HitboxComponent.class).setAsBoxAligned(new Vector2(.3f, .5f), PhysicsComponent.AlignX.RIGHT, PhysicsComponent.AlignY.BOTTOM); - Firewizard.getComponent(AnimationRenderComponent.class).scaleEntity(); + fireWizard.getComponent(HitboxComponent.class).setAsBoxAligned(new Vector2(.3f, .5f), PhysicsComponent.AlignX.RIGHT, PhysicsComponent.AlignY.BOTTOM); + fireWizard.getComponent(AnimationRenderComponent.class).scaleEntity(); - return Firewizard; + return fireWizard; } public static Entity createArcaneArcher(int health) { @@ -503,7 +499,6 @@ public static Entity createXenoGrunt(int health) { 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)) .addComponent(animator) .addComponent(new XenoAnimationController()); @@ -536,10 +531,7 @@ public static Entity createMeleeBaseNPC() { new AITaskComponent() .addTask(new MobWanderTask(2f)) .addTask(new MobMeleeAttackTask(2)); - // .addTask(new MobAttackTask(2, 2f)); - // .addTask(new MeleeMobTask(new Vector2(2f, 2f), 2f)); - // .addTask(new MobAttackTask(2, 40)); Entity npc = new Entity() .addComponent(new PhysicsComponent()) @@ -560,11 +552,8 @@ public static Entity createRangedBaseNPC() { AITaskComponent aiComponent = new AITaskComponent() .addTask(new MobWanderTask(2f)) - // .addTask(new MobAttackTask(2, 2f)); .addTask(new MobRangedAttackTask(2)); - // .addTask(new MeleeMobTask(new Vector2(2f, 2f), 2f)); - // .addTask(new MobAttackTask(2, 40)); Entity npc = new Entity() .addComponent(new PhysicsComponent()) @@ -634,9 +623,6 @@ public static Entity createDodgingDragonKnight(int health) { Entity dodgeKnight = createDragonKnight(health); dodgeKnight.addComponent(new DodgingComponent(PhysicsLayer.PROJECTILE, 0.25f)); - // dodgeKnight.getComponent(AITaskComponent.class).addTask(new MobDodgeTask(new Vector2(2f, 2f), 2f, 5)); - // dodgeKnight.getComponent(AITaskComponent.class). - // addTask(new MobDodgeTask(MobType.DRAGON_KNIGHT, 5)); dodgeKnight.getComponent(AITaskComponent.class).getTask(MobTask.class).setDodge(true); PhysicsUtils.setScaledCollider(dodgeKnight, 0.3f, 0.7f); dodgeKnight.setScale(0.3f, 0.7f); @@ -653,9 +639,6 @@ public static Entity createDodgingArcaneArcher(int health) { Entity dodgeKnight = createArcaneArcher(health); dodgeKnight.addComponent(new DodgingComponent(PhysicsLayer.PROJECTILE, 0.25f)); - // dodgeKnight.getComponent(AITaskComponent.class).addTask(new MobDodgeTask(new Vector2(2f, 2f), 2f, 5)); - // dodgeKnight.getComponent(AITaskComponent.class). - // addTask(new MobDodgeTask(MobType.DRAGON_KNIGHT, 5)); dodgeKnight.getComponent(AITaskComponent.class).getTask(MobTask.class).setDodge(true); PhysicsUtils.setScaledCollider(dodgeKnight, 0.3f, 0.7f); dodgeKnight.setScale(0.3f, 0.7f); @@ -663,9 +646,6 @@ public static Entity createDodgingArcaneArcher(int health) { return dodgeKnight; } -// public static Entity createDeflectXenoGrunt(int health) { -// Entity deflectXenoGrunt = createXenoGrunt(health); -// deflectXenoGrunt.addComponent(new DeflectingComponent( /** * Creates a wizard that can deflect bullets * @return Deflecting wizard From 12c852f206c9d1eba57d32d8e63922a6d6f658ec Mon Sep 17 00:00:00 2001 From: max9753 Date: Mon, 16 Oct 2023 22:50:52 +1000 Subject: [PATCH 09/11] Fixed several code smells in WaveFactoryTest about assertTrue should be assertEquals etc. --- .../entities/factories/WaveFactoryTest.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/core/src/test/com/csse3200/game/entities/factories/WaveFactoryTest.java b/source/core/src/test/com/csse3200/game/entities/factories/WaveFactoryTest.java index eca488c8f..6db312e94 100644 --- a/source/core/src/test/com/csse3200/game/entities/factories/WaveFactoryTest.java +++ b/source/core/src/test/com/csse3200/game/entities/factories/WaveFactoryTest.java @@ -155,7 +155,7 @@ void testLevel1Creation() { if (waveNum != 5) { Set mobNames = new HashSet<>(wave.getEntities().keySet()); Set expectedMobNames = new HashSet<>(LVL1_WAVES_STRUC.get(waveNum - 1)); - assertTrue(mobNames.equals(expectedMobNames), "The mobs in the wave should be " + expectedMobNames + " ."); + assertEquals(mobNames, expectedMobNames, "The mobs in the wave should be " + expectedMobNames + " ."); for (String key: wave.getEntities().keySet()) { int[] values = wave.getEntities().get(key); @@ -164,16 +164,16 @@ void testLevel1Creation() { mobsRemaining --; if (MELEE_MOBS.contains(key)) { - assertTrue(values[1] == MIN_MELEE_HEALTH + waveNum, "The health of the mob should be " + MIN_MELEE_HEALTH + waveNum + " ."); + assertEquals(values[1], MIN_MELEE_HEALTH + waveNum, "The health of the mob should be " + MIN_MELEE_HEALTH + waveNum + " ."); } else { - assertTrue(values[1] == MIN_RANGE_HEALTH + waveNum, "The health of the mob should be " + MIN_RANGE_HEALTH + waveNum + " ."); + assertEquals(values[1], MIN_RANGE_HEALTH + waveNum, "The health of the mob should be " + MIN_RANGE_HEALTH + waveNum + " ."); } } } else { - assertTrue(wave.getEntities().keySet().size() == 1); + assertEquals(wave.getEntities().keySet().size(), 1); for (String key: wave.getEntities().keySet()) { int[] values = wave.getEntities().get(key); - assertTrue(values[1] == bossHealth, "The health of the boss should be " + MIN_BOSS_HEALTH); + assertEquals(values[1], bossHealth, "The health of the boss should be " + MIN_BOSS_HEALTH); } } mobCount ++; @@ -207,7 +207,7 @@ void testLevel2Creation() { if (waveNum != 10) { Set mobNames = new HashSet<>(wave.getEntities().keySet()); Set expectedMobNames = new HashSet<>(LVL2_WAVES_STRUC.get(waveNum - 1)); - assertTrue(mobNames.equals(expectedMobNames), "The mobs in the wave should be " + expectedMobNames + " ."); + assertEquals(mobNames, expectedMobNames, "The mobs in the wave should be " + expectedMobNames + " ."); for (String key: wave.getEntities().keySet()) { int[] values = wave.getEntities().get(key); @@ -231,7 +231,7 @@ void testLevel2Creation() { assertTrue(wave.getEntities().keySet().size() == 1); for (String key: wave.getEntities().keySet()) { int[] values = wave.getEntities().get(key); - assertTrue(values[1] == bossHealth, "The health of the boss should be " + MIN_BOSS_HEALTH); + assertEquals(values[1], bossHealth, "The health of the boss should be " + MIN_BOSS_HEALTH); } } mobCount ++; @@ -266,7 +266,7 @@ void testLevel3Creation() { if (waveNum != 15) { Set mobNames = new HashSet<>(wave.getEntities().keySet()); Set expectedMobNames = new HashSet<>(LVL3_WAVES_STRUC.get(waveNum - 1)); - assertTrue(mobNames.equals(expectedMobNames), "The mobs in the wave should be " + expectedMobNames + " ."); + assertEquals(mobNames, expectedMobNames, "The mobs in the wave should be " + expectedMobNames + " ."); for (String key: wave.getEntities().keySet()) { int[] values = wave.getEntities().get(key); @@ -283,10 +283,10 @@ void testLevel3Creation() { } } else { - assertTrue(wave.getEntities().keySet().size() == 1); + assertEquals(wave.getEntities().keySet().size(), 1); for (String key: wave.getEntities().keySet()) { int[] values = wave.getEntities().get(key); - assertTrue(values[1] == bossHealth, "The health of the boss should be " + MIN_BOSS_HEALTH); + assertEquals(values[1], bossHealth, "The health of the boss should be " + MIN_BOSS_HEALTH); } } mobCount ++; From 289adffe5b883b283b4ce3c3871ba72c63b9aa10 Mon Sep 17 00:00:00 2001 From: max9753 Date: Mon, 16 Oct 2023 23:06:54 +1000 Subject: [PATCH 10/11] Rolled back some stuff because I merged poorly --- .../game/components/npc/SplitMoblings.java | 3 ++- .../game/entities/factories/NPCFactory.java | 25 +++++++++++++++++++ .../game/entities/factories/WaveFactory.java | 5 ---- .../game/components/SplitMoblingsTest.java | 2 +- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java b/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java index 3fd20bb9d..1127cd4ad 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java +++ b/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java @@ -167,7 +167,8 @@ public void spawnAdditionalMob(float positionX, float positionY, ServiceLocator.getEntityService().register(entityType); - ServiceLocator.getWaveService().setEnemyCount(ServiceLocator.getWaveService().getEnemyCount() + 1); + // ServiceLocator.getWaveService().setEnemyCount(ServiceLocator.getWaveService().getEnemyCount() + 1); + //ServiceLocator.getWaveService().setEnemyCount(ServiceLocator.getWaveService().getEnemyCount() + 1); } /** 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 224bb8f8b..e8038c978 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 @@ -71,6 +71,31 @@ public static Entity createGhost() { return ghost; } + /** + * Creates a ghost king entity. + * + * @return entity + */ + public static Entity createGhostKing() { + Entity ghostKing = createMeleeBaseNPC(); + GhostKingConfig config = configs.ghostKing; + + AnimationRenderComponent animator = + new AnimationRenderComponent( + ServiceLocator.getResourceService() + .getAsset("images/ghostKing.atlas", TextureAtlas.class)); + animator.addAnimation("float", 0.2f, Animation.PlayMode.LOOP); + animator.addAnimation("angry_float", 0.2f, Animation.PlayMode.LOOP); + + ghostKing + .addComponent(new CombatStatsComponent(config.health, config.baseAttack)) + .addComponent(animator) + .addComponent(new GhostAnimationController()); + + ghostKing.getComponent(AnimationRenderComponent.class).scaleEntity(); + return ghostKing; + } + /** * Creates a fire worm entity. * diff --git a/source/core/src/main/com/csse3200/game/entities/factories/WaveFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/WaveFactory.java index 76dbecc94..53ea2007a 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/WaveFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/WaveFactory.java @@ -67,11 +67,6 @@ public class WaveFactory { )), new ArrayList<>(Arrays.asList("FireWorm", "SplittingRocky", "Necromancer" )), new ArrayList<>(Arrays.asList("SplittingRocky", "DeflectFireWizard", "FireWorm" )), new ArrayList<>(Arrays.asList("DeflectFireWizard", "SplittingRocky", "Necromancer", "DodgingDragon", "FireWorm" - )), new ArrayList<>(Arrays.asList("DeflectFireWizard","SplittingRocky", "Necromancer" - )), new ArrayList<>(Arrays.asList("DodgingDragon", "DeflectFireWizard", "SplittingRocky", "Necromancer" - )), new ArrayList<>(Arrays.asList("FireWorm", "DeflectWizard", "DodgingDragon" - )), new ArrayList<>(Arrays.asList("FireWorm", "DeflectWizard", "Necromancer" - )), new ArrayList<>(Arrays.asList("Necromancer", "DeflectFireWizard", "SplittingRocky", "DodgingDragon", "FireWorm" )) )); 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 49fdeeee0..d21af300c 100644 --- a/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java +++ b/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java @@ -66,7 +66,7 @@ public void setUp() { resourceService.loadTextureAtlases(atlas); resourceService.loadAll(); - WaveService waveService = mock(WaveService.class); + WaveService waveService = new WaveService(); ServiceLocator.registerWaveService(waveService); baseMob = createSplitMob(BASE_AMOUNT); From 006bfd64e45309c934f8bdda65ee92776891bfa7 Mon Sep 17 00:00:00 2001 From: bojyyy <140468434+bojyyy@users.noreply.github.com> Date: Mon, 16 Oct 2023 23:10:30 +1000 Subject: [PATCH 11/11] Fixing merge conflicts --- .../main/com/csse3200/game/components/npc/SplitMoblings.java | 3 +-- .../test/com/csse3200/game/components/SplitMoblingsTest.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java b/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java index 1127cd4ad..3fd20bb9d 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java +++ b/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java @@ -167,8 +167,7 @@ public void spawnAdditionalMob(float positionX, float positionY, ServiceLocator.getEntityService().register(entityType); - // ServiceLocator.getWaveService().setEnemyCount(ServiceLocator.getWaveService().getEnemyCount() + 1); - //ServiceLocator.getWaveService().setEnemyCount(ServiceLocator.getWaveService().getEnemyCount() + 1); + ServiceLocator.getWaveService().setEnemyCount(ServiceLocator.getWaveService().getEnemyCount() + 1); } /** 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 d21af300c..49fdeeee0 100644 --- a/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java +++ b/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java @@ -66,7 +66,7 @@ public void setUp() { resourceService.loadTextureAtlases(atlas); resourceService.loadAll(); - WaveService waveService = new WaveService(); + WaveService waveService = mock(WaveService.class); ServiceLocator.registerWaveService(waveService); baseMob = createSplitMob(BASE_AMOUNT);