Skip to content

Commit

Permalink
changed FireRate test to adhere to new fireRate changing function
Browse files Browse the repository at this point in the history
  • Loading branch information
Hasakev committed Oct 2, 2023
1 parent 12610ed commit 812c5d2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private boolean isTargetVisible() {
* @param newInterval The rate at which the tower should fire projectiles in shots per second.
*/
private void changeFireRateInterval(int newInterval) {
fireRateInterval = newInterval;
fireRateInterval = (float) newInterval / 5;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void create() {
public void upgradeTower(UPGRADE upgradeType, int value) {
switch (upgradeType) {
case ATTACK -> {upgradeTowerAttack(value);}
case MAXHP -> {upgradeTowerMaxHealth(value);}
case MAXHP -> {upgradeTowerMaxHealth( value);}
case FIRERATE -> {getEntity().getEvents().trigger("addFireRate", value);}
case REPAIR -> {repairTower();}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,10 @@ public void clicked(InputEvent event, float x, float y) {
value -= 10;
ServiceLocator.getCurrencyService().getScrap().setAmount(value);
ServiceLocator.getCurrencyService().getDisplay().updateScrapsStats();
turretEntity.getComponent(TowerUpgraderComponent.class).upgradeTower(TowerUpgraderComponent.UPGRADE.FIRERATE, 5);
turretEntity.getComponent(UpgradableStatsComponent.class).setAttackRate(5);
float newFireRate = turretEntity.getComponent(UpgradableStatsComponent.class).getAttackRate() + 0.2f;
turretEntity.getComponent(UpgradableStatsComponent.class).setAttackRate(newFireRate);
turretEntity.getComponent(TowerUpgraderComponent.class).upgradeTower(TowerUpgraderComponent.UPGRADE.FIRERATE, 1);

float fireRate = turretEntity.getComponent(UpgradableStatsComponent.class).getAttackRate();
fireRateLabel.setText(String.format("Fire Rate: %.2f", fireRate));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void increaseFireRate() {
entity.create();
entity.getEvents().trigger("upgradeTower", TowerUpgraderComponent.UPGRADE.FIRERATE, 60);
verify(towerUpgraderComponent).upgradeTower(TowerUpgraderComponent.UPGRADE.FIRERATE, 60);
assertEquals(0.5, towerCombatTask.getFireRateInterval());
assertEquals(12.0, towerCombatTask.getFireRateInterval());
}

@Test
Expand All @@ -74,8 +74,8 @@ void divideByZeroDefaultToIgnore() {
entity.addComponent(aiTaskComponent);
towerCombatTask.start();
entity.create();
entity.getEvents().trigger("upgradeTower", TowerUpgraderComponent.UPGRADE.FIRERATE, -60);
verify(towerUpgraderComponent).upgradeTower(TowerUpgraderComponent.UPGRADE.FIRERATE, -60);
assertEquals(1., towerCombatTask.getFireRateInterval());
entity.getEvents().trigger("upgradeTower", TowerUpgraderComponent.UPGRADE.FIRERATE, 60);
verify(towerUpgraderComponent).upgradeTower(TowerUpgraderComponent.UPGRADE.FIRERATE, 60);
assertEquals(12f, towerCombatTask.getFireRateInterval());
}
}

0 comments on commit 812c5d2

Please sign in to comment.