From 4c4d15bcae04797078ddbf809a684dfa53d0c490 Mon Sep 17 00:00:00 2001 From: Jacopo Turchi Date: Fri, 5 Jul 2024 15:19:17 +0200 Subject: [PATCH] Changed name skeleton to skull --- .../cell/powerUp/impl/SkullEffect.java | 2 +- .../unibo/bombardero/character/Character.java | 34 +++++++++---------- .../it/unibo/bombardero/character/Enemy.java | 2 +- .../it/unibo/bombardero/character/Player.java | 2 +- src/test/java/it/bombardero/TestPowerUp.java | 12 +++---- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/main/java/it/unibo/bombardero/cell/powerUp/impl/SkullEffect.java b/src/main/java/it/unibo/bombardero/cell/powerUp/impl/SkullEffect.java index 9a515cff..4ccd8f06 100644 --- a/src/main/java/it/unibo/bombardero/cell/powerUp/impl/SkullEffect.java +++ b/src/main/java/it/unibo/bombardero/cell/powerUp/impl/SkullEffect.java @@ -67,7 +67,7 @@ public Consumer getEffect() { skull.get(new Random().nextInt(skull.size())).accept(character); // Set the effect duration and reset logic - character.setSkeletonEffectDuration(EFFECT_DURATION_IN_SECONDS * SECONDS_TO_MILLISECONDS); + character.setSkullEffectDuration(EFFECT_DURATION_IN_SECONDS * SECONDS_TO_MILLISECONDS); character.setResetEffect(() -> { // Restores all stats modified by the skull character.setSpeed(previousSpeed); character.setFlameRange(previousFlameRange); diff --git a/src/main/java/it/unibo/bombardero/character/Character.java b/src/main/java/it/unibo/bombardero/character/Character.java index f858d40c..ed115cf1 100644 --- a/src/main/java/it/unibo/bombardero/character/Character.java +++ b/src/main/java/it/unibo/bombardero/character/Character.java @@ -108,7 +108,7 @@ public enum CharacterType { private boolean butterfingers; // The character's hand becomes slippery. The character rapidly lays down bombs // Skull manager - private long skeletonEffectDuration; // Indicates the duration of the skull effect + private long skullEffectDuration; // Indicates the duration of the skull effect private Optional resetEffect = Optional.empty(); // Restores all stats modified by the skull /** @@ -134,17 +134,17 @@ public Character(final GenPair coord, final BombFactory bombFactor public abstract void update(GameManager manager, long elapsedTime); /** - * Updates the skeleton's effects. + * Updates the skull's effects. * * @param manager the game manager * @param elapsedTime the time elapsed since the last update * @param type the type of character */ - public void updateSkeleton(final GameManager manager, final long elapsedTime, final CharacterType type) { - if (this.skeletonEffectDuration > 0) { // Continues until the duration reaches zero - this.skeletonEffectDuration -= elapsedTime; - if (this.skeletonEffectDuration <= 0) { // When the effect ends the character's stats get resetted - setSkeletonEffectDuration(0); + public void updateSkull(final GameManager manager, final long elapsedTime, final CharacterType type) { + if (this.skullEffectDuration > 0) { // Continues until the duration reaches zero + this.skullEffectDuration -= elapsedTime; + if (this.skullEffectDuration <= 0) { // When the effect ends the character's stats get resetted + setSkullEffectDuration(0); this.resetEffect.ifPresent(Runnable::run); // If there's a effect to reset, it runs the reset effect this.resetEffect = Optional.empty(); // Clear the reset effect after it has run } @@ -575,26 +575,26 @@ public void setButterfingers(final boolean butterfingers) { } /** - * Gets the duration of the skeleton effect. + * Gets the duration of the skull effect. * - * @return the skeletonEffectDuration + * @return the skullEffectDuration */ - public long getSkeletonEffectDuration() { - return this.skeletonEffectDuration; + public long getSkullEffectDuration() { + return this.skullEffectDuration; } /** - * Sets the skeleton effect's duration. + * Sets the skull effect's duration. * - * @param duration the duration of the skeleton effect + * @param duration the duration of the skull effect */ - public void setSkeletonEffectDuration(final long duration) { - this.skeletonEffectDuration = duration; + public void setSkullEffectDuration(final long duration) { + this.skullEffectDuration = duration; } // TODO: write better javadoc /** - * Gets the reset effect. + * Gets the reset effect used to reset the Character's stats after the skull effect ends. * * @return the reset effect */ @@ -603,7 +603,7 @@ public Optional getResetEffect() { } /** - * Sets the reset effect. + * Sets the reset effect used to reset the Character's stats after the skull effect ends. * * @param resetEffect the reset effect */ diff --git a/src/main/java/it/unibo/bombardero/character/Enemy.java b/src/main/java/it/unibo/bombardero/character/Enemy.java index 320aaec4..895132c3 100644 --- a/src/main/java/it/unibo/bombardero/character/Enemy.java +++ b/src/main/java/it/unibo/bombardero/character/Enemy.java @@ -180,7 +180,7 @@ private void computeNextDir(final GameManager manager) { @Override public void update(final GameManager manager, final long elapsedTime) { updateGraph(manager.getGameMap()); - updateSkeleton(manager, elapsedTime, CharacterType.ENEMY); + updateSkull(manager, elapsedTime, CharacterType.ENEMY); if (nextMove.isEmpty()) { computeNextDir(manager); } else if (canMoveOn(manager.getGameMap(), nextMove.get())) { diff --git a/src/main/java/it/unibo/bombardero/character/Player.java b/src/main/java/it/unibo/bombardero/character/Player.java index 3a8ef670..4afcfa41 100644 --- a/src/main/java/it/unibo/bombardero/character/Player.java +++ b/src/main/java/it/unibo/bombardero/character/Player.java @@ -39,7 +39,7 @@ public Player(final GenPair coord, final BombFactory bombFactory) public void update(final GameManager manager, final long elapsedTime) { // Skeleton effect: if (getResetEffect().isPresent()) { // If there's a Task to reset - updateSkeleton(manager, elapsedTime, CharacterType.PLAYER); + updateSkull(manager, elapsedTime, CharacterType.PLAYER); } // Player movement: if (!isStationary()) { // If he's not stationary, computes the new position diff --git a/src/test/java/it/bombardero/TestPowerUp.java b/src/test/java/it/bombardero/TestPowerUp.java index baf588e3..ca6d5df3 100644 --- a/src/test/java/it/bombardero/TestPowerUp.java +++ b/src/test/java/it/bombardero/TestPowerUp.java @@ -55,8 +55,8 @@ void testCreating100PowerUp() { powerUP.applyEffect(this.manager.getPlayer()); }); if (this.manager.getPlayer().getResetEffect().isPresent()) { - while (this.manager.getPlayer().getSkeletonEffectDuration() > 0) { - this.manager.getPlayer().updateSkeleton(manager, STANDARD_ELAPSED_TIME, CharacterType.PLAYER); + while (this.manager.getPlayer().getSkullEffectDuration() > 0) { + this.manager.getPlayer().updateSkull(manager, STANDARD_ELAPSED_TIME, CharacterType.PLAYER); } } } @@ -72,15 +72,15 @@ void testRandomSkullEffect() { powerUP.applyEffect(this.manager.getPlayer()); assertEquals(SkullEffect.getEffectDurationInSeconds() * SECONDS_TO_MILLISECONDS, - this.manager.getPlayer().getSkeletonEffectDuration()); + this.manager.getPlayer().getSkullEffectDuration()); assertTrue(this.manager.getPlayer().getResetEffect().isPresent()); - while (this.manager.getPlayer().getSkeletonEffectDuration() > 0) { - this.manager.getPlayer().updateSkeleton(manager, STANDARD_ELAPSED_TIME, CharacterType.PLAYER); + while (this.manager.getPlayer().getSkullEffectDuration() > 0) { + this.manager.getPlayer().updateSkull(manager, STANDARD_ELAPSED_TIME, CharacterType.PLAYER); } // Asserts the skull duration is 0 - assertEquals(0L, this.manager.getPlayer().getSkeletonEffectDuration()); + assertEquals(0L, this.manager.getPlayer().getSkullEffectDuration()); // Asserts there is no Reset effect to run assertEquals(Optional.empty(), this.manager.getPlayer().getResetEffect()); // Asserts the initial stats are resetted