Skip to content

Commit

Permalink
Fix code smells in remaining task tests + BombshipFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
lenhatminh451 committed Oct 16, 2023
1 parent da22a69 commit bf99946
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.csse3200.game.entities.configs.*;
import com.csse3200.game.files.FileLoader;
import com.csse3200.game.physics.PhysicsLayer;
import com.csse3200.game.physics.PhysicsUtils;
import com.csse3200.game.physics.components.ColliderComponent;
import com.csse3200.game.physics.components.HitboxComponent;
import com.csse3200.game.physics.components.PhysicsComponent;
Expand All @@ -20,7 +19,6 @@

/**
* Factory to create non-playable human character (NPC) entities with predefined components.
*
* These may be modified to become controllable characters in future sprints.
*
* <p>Each NPC entity type should have a creation method that returns a corresponding entity.
Expand All @@ -31,19 +29,16 @@
* similar characteristics.
*/
public class BombshipFactory {

private static final int COMBAT_TASK_PRIORITY = 2;
private static final int BOMBSHIP_RANGE = 30;
private static final BombshipConfigs configs =
FileLoader.readClass(BombshipConfigs.class, "configs/Bombship.json");

private static final float HUMAN_SCALE_X = 1f;
private static final float HUMAN_SCALE_Y = 0.8f;

/**
* Creates an Engineer entity, based on a base Human entity, with the appropriate components and animations
*
*
* @return entity
*/
public static Entity createBombship() {
Expand Down Expand Up @@ -75,17 +70,12 @@ public static Entity createBombship() {
* @return entity
*/
public static Entity createBaseshipNPC() {


Entity ship =
new Entity()
.addComponent(new PhysicsComponent())
.addComponent(new PhysicsMovementComponent())
.addComponent(new ColliderComponent())
.addComponent(new HitboxComponent().setLayer(PhysicsLayer.BOMBSHIP))
.addComponent(new TouchAttackComponent(PhysicsLayer.NPC, 1.5f));

return ship;
return new Entity()
.addComponent(new PhysicsComponent())
.addComponent(new PhysicsMovementComponent())
.addComponent(new ColliderComponent())
.addComponent(new HitboxComponent().setLayer(PhysicsLayer.BOMBSHIP))
.addComponent(new TouchAttackComponent(PhysicsLayer.NPC, 1.5f));
}

private BombshipFactory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
public class FireTowerCombatTaskTest {
class FireTowerCombatTaskTest {
FireTowerCombatTask fireTowerCombatTask;

@BeforeEach
Expand All @@ -39,7 +39,7 @@ void setUp() {
* in DroidCombatTaskTest by Mohamad Dabboussi
*/
@Test
public void testStartTriggersIdleEvent() {
void testStartTriggersIdleEvent() {
Entity entity = createFireTower();
EventListener0 idleListener = mock(EventListener0.class);
// Deploy Droid in the walking state
Expand All @@ -53,7 +53,7 @@ public void testStartTriggersIdleEvent() {
* in DroidCombatTaskTest by Mohamad Dabboussi
*/
@Test
public void testUpdateTowerStateWithTargetInRange() {
void testUpdateTowerStateWithTargetInRange() {
Entity entity = createFireTower();
entity.setPosition(10, 10);

Expand Down Expand Up @@ -91,7 +91,7 @@ public void testUpdateTowerStateWithTargetInRange() {
* in DroidCombatTaskTest by Mohamad Dabboussi
*/
@Test
public void testUpdateTowerStateWithTargetNotInRange() {
void testUpdateTowerStateWithTargetNotInRange() {
Entity entity = createFireTower();
entity.setPosition(10, 10);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
public class FireworksTowerCombatTaskTest {
class FireworksTowerCombatTaskTest {
FireworksTowerCombatTask fireworksTowerCombatTask;

@BeforeEach
Expand All @@ -39,7 +39,7 @@ void setUp() {
* in DroidCombatTaskTest by Mohamad Dabboussi
*/
@Test
public void testStartTriggersIdleEvent() {
void testStartTriggersIdleEvent() {
Entity entity = createFireworksTower();
EventListener0 idleListener = mock(EventListener0.class);
// Deploy Droid in the walking state
Expand All @@ -53,7 +53,7 @@ public void testStartTriggersIdleEvent() {
* in DroidCombatTaskTest by Mohamad Dabboussi
*/
@Test
public void testUpdateTowerStateWithTargetInRange() {
void testUpdateTowerStateWithTargetInRange() {
Entity entity = createFireworksTower();
entity.setPosition(10, 10);

Expand All @@ -80,7 +80,7 @@ public void testUpdateTowerStateWithTargetInRange() {
* in DroidCombatTaskTest by Mohamad Dabboussi
*/
@Test
public void testUpdateTowerStateWithTargetNotInRange() {
void testUpdateTowerStateWithTargetNotInRange() {
Entity entity = createFireworksTower();
entity.setPosition(10, 10);

Expand Down

0 comments on commit bf99946

Please sign in to comment.