Skip to content

Commit

Permalink
Merge pull request #142 from UQcsse3200/Team-2--Alasdair-Branch
Browse files Browse the repository at this point in the history
Team 2 code smell fixes
  • Loading branch information
The-AhmadAA authored Sep 12, 2023
2 parents d067d15 + 6a6575a commit 6b321e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,7 @@ private boolean isTargetVisible() {
private void changeFireRateInterval(int perMinute) {
float oldFireSpeed = 1/fireRateInterval;
float newFireSpeed = oldFireSpeed + perMinute/60f;
if (newFireSpeed == 0) {
return;
} else {
if (newFireSpeed != 0) {
fireRateInterval = 1 / newFireSpeed;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@

import com.csse3200.game.components.CombatStatsComponent;
import com.csse3200.game.components.Component;
import static java.lang.Math.round;

/**
* Listens for an event from the popup menu to upgrade
* the turret entity this component is attached to.
*/
public class TowerUpgraderComponent extends Component {
/**
* A set of specifiers allowing upgrade event triggers to specify the type of upgrade being requested.
*/
public enum UPGRADE {
ATTACK, MAXHP, FIRERATE, REPAIR
}

/**
* Called when the entity is created and registered.
* Sets up an event listener to detect when an upgrade request is sent to this tower.
*/
@Override
public void create() {
super.create();
Expand All @@ -28,10 +34,10 @@ public void create() {
*/
void upgradeTower(UPGRADE upgradeType, int value) {
switch (upgradeType) {
case ATTACK -> {upgradeTowerAttack(value);}
case MAXHP -> {upgradeTowerMaxHealth(value);}
case FIRERATE -> {getEntity().getEvents().trigger("addFireRate", value);}
case REPAIR -> {repairTower();}
case ATTACK -> upgradeTowerAttack(value);
case MAXHP -> upgradeTowerMaxHealth(value);
case FIRERATE -> getEntity().getEvents().trigger("addFireRate", value);
case REPAIR -> repairTower();
}
}

Expand Down

0 comments on commit 6b321e6

Please sign in to comment.