Skip to content

Commit

Permalink
#652 Fixed code smells for: Cutscene.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Caleb Murphy committed Oct 17, 2024
1 parent 3e3f0dc commit 54e6250
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class BadEndCutscene extends Cutscene {
*/
public BadEndCutscene() {
super();
this.IsAnimatedScenes = true;
this.isAnimatedScenes = true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public abstract class Cutscene extends Component {
protected String animName;

// Whether the scenes are fully animated
public boolean IsAnimatedScenes = false;
public boolean isAnimatedScenes = false;

// Game time service to keep track of time
protected GameTime gameTime;
Expand All @@ -69,7 +69,7 @@ public abstract class Cutscene extends Component {
/**
* Constructor for the Cutscene class. Initializes the game time and loads assets and scenes.
*/
public Cutscene() {
protected Cutscene() {
this.gameTime = ServiceLocator.getTimeSource();
loadAssets();
setupScenes();
Expand All @@ -94,7 +94,7 @@ public void create() {
public void update() {
float currentTime = gameTime.getTime();
// Check if the current scene has finished
if (!IsAnimatedScenes) {
if (!isAnimatedScenes) {
if ((currentScene != null) && (currentTime - timeStart) > currentScene.getDuration()) {
logger.info("Scene {} finished. Moving to next scene.", currentSceneIndex);
nextCutscene();
Expand All @@ -114,17 +114,17 @@ protected void nextCutscene() {
disposeEntities(); // Dispose of current entities before moving to the next scene

currentSceneIndex++;
if (!IsAnimatedScenes) {
if (!isAnimatedScenes) {
if (currentSceneIndex < scenes.size()) {
logger.info("Loading next scene: {}", currentSceneIndex);
logger.info("Loading next animated scene: {}", currentSceneIndex);
loadScene(currentSceneIndex);
} else {
logger.info("Cutscene finished. Triggering next event.");
ServiceLocator.getCutsceneScreen().getCutsceneScreenDisplay().getEntity().getEvents().trigger("cutsceneEnded");
}
} else {
if (currentSceneIndex < animatedScenes.size()) {
logger.info("Loading next scene: {}", currentSceneIndex);
logger.info("Loading next non animated scene: {}", currentSceneIndex);
loadScene(currentSceneIndex);
} else {
logger.info("Cutscene finished. Triggering next event.");
Expand Down Expand Up @@ -152,7 +152,7 @@ protected void nextCutsceneMoral() {
* @param sceneIndex Index of the scene to load
*/
protected void loadScene(int sceneIndex) {
if (!IsAnimatedScenes) {
if (!isAnimatedScenes) {
if (sceneIndex >= scenes.size()) {
logger.error("No more scenes available.");
nextCutscene();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class GoodEndCutscene extends Cutscene {
*/
public GoodEndCutscene() {
super();
this.IsAnimatedScenes = true;
this.isAnimatedScenes = true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void setUp() {
@Test
public void testConstructor() {
// Verify the initial state of the object
assertTrue(badEndCutscene.IsAnimatedScenes);
assertTrue(badEndCutscene.isAnimatedScenes);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public void testTextForSceneChangesCorrectly() {

@Test
public void testAnimatedSceneLoadsCorrectly() {
cutscene.IsAnimatedScenes = true;
cutscene.isAnimatedScenes = true;
AnimatedScene animatedScene = mock(AnimatedScene.class);
when(animatedScene.getDuration()).thenReturn(5.0f);
when(animatedScene.getAtlasFilePath()).thenReturn("atlas.atlas");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void setUp() {
@Test
public void testConstructor() {
// Verify the initial state of the object
assertTrue(goodEndCutscene.IsAnimatedScenes);
assertTrue(goodEndCutscene.isAnimatedScenes);
}

@Test
Expand Down

0 comments on commit 54e6250

Please sign in to comment.