From 7080221f4e56fcbeb21c26c79c362e106827b672 Mon Sep 17 00:00:00 2001 From: Thivan W Date: Sun, 15 Oct 2023 16:03:42 +1000 Subject: [PATCH 1/3] Altered Tower Stats and fixed a bug with the towers' health --- source/core/assets/configs/tower.json | 53 ++++++++++------ .../game/input/UpgradeUIComponent.java | 1 - .../com/csse3200/game/screens/TowerType.java | 14 ++--- .../entities/factories/TowerFactoryTest.java | 62 +++++++++---------- 4 files changed, 72 insertions(+), 58 deletions(-) diff --git a/source/core/assets/configs/tower.json b/source/core/assets/configs/tower.json index df72c561c..4d1daa23c 100644 --- a/source/core/assets/configs/tower.json +++ b/source/core/assets/configs/tower.json @@ -1,37 +1,52 @@ { - "weapon": { + "income": { "health": 10, - "baseAttack": 10, + "baseAttack": 0, "cost": 10 }, "wall": { - "health": 20, - "baseAttack": 0, - "cost": 5 - }, - "income": { - "health": 20, + "health": 300, "baseAttack": 0, - "cost": 1 + "cost": 45 }, "TNTTower": { "health": 10, "baseAttack": 5, - "cost": 1 + "cost": 30 + }, + "weapon": { + "health": 75, + "baseAttack": 15, + "cost": 15 }, "DroidTower": { - "health": 50, - "baseAttack": 5, - "cost": 1 + "health": 100, + "baseAttack": 25, + "cost": 45 }, "fireTower": { - "health": 10, - "baseAttack": 10, - "cost": 10 + "health": 100, + "baseAttack": 25, + "cost": 45 }, "stunTower": { - "health": 10, - "baseAttack": 10, - "cost": 10 + "health": 100, + "baseAttack": 25, + "cost": 45 + }, + "fireworksTower": { + "health": 125, + "baseAttack": 45, + "cost": 70 + }, + "pierceTower": { + "health": 125, + "baseAttack": 45, + "cost": 70 + }, + "ricochetTower": { + "health": 125, + "baseAttack": 45, + "cost": 70 } } \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/input/UpgradeUIComponent.java b/source/core/src/main/com/csse3200/game/input/UpgradeUIComponent.java index b06134cb6..f21db90fb 100644 --- a/source/core/src/main/com/csse3200/game/input/UpgradeUIComponent.java +++ b/source/core/src/main/com/csse3200/game/input/UpgradeUIComponent.java @@ -171,7 +171,6 @@ private Table createUpgradeTable(Entity turretEntity) { // Default values for the stats int maxHealth = turretEntity.getComponent(CombatStatsComponent.class).getMaxHealth(); int currentHealth = turretEntity.getComponent(CombatStatsComponent.class).getHealth(); - turretEntity.getComponent(CombatStatsComponent.class).setHealth(5); // for testing int attack = turretEntity.getComponent(CombatStatsComponent.class).getBaseAttack(); float fireRate = turretEntity.getComponent(UpgradableStatsComponent.class).getAttackRate(); Label healthLabel = new Label(String.format("%d/%d", currentHealth, maxHealth), createLabelStyle()); diff --git a/source/core/src/main/com/csse3200/game/screens/TowerType.java b/source/core/src/main/com/csse3200/game/screens/TowerType.java index a6f79dbdf..71b49feae 100644 --- a/source/core/src/main/com/csse3200/game/screens/TowerType.java +++ b/source/core/src/main/com/csse3200/game/screens/TowerType.java @@ -2,19 +2,19 @@ public enum TowerType { WEAPON("Weapon Tower", "The Weapon Tower is a simple and basic turret that fires rapid shots at enemies dealing damage over time.", - 0, "0", "images/turret-select/Weapon-Tower-Default.png", "images/turret-select/Weapon-Tower-Clicked.png"), + 0, "15", "images/turret-select/Weapon-Tower-Default.png", "images/turret-select/Weapon-Tower-Clicked.png"), TNT("TNT Tower", "The TNT Tower launches explosive projectiles, dealing area damage to groups of enemies.", - 1, "0", "images/turret-select/tnt-tower-default.png", "images/turret-select/tnt-tower-clicked.png"), + 1, "30", "images/turret-select/tnt-tower-default.png", "images/turret-select/tnt-tower-clicked.png"), DROID("Droid Tower", "Droid Towers deploy robotic helpers that assist in combat and provide support to nearby turrets.", - 2, "0", "images/turret-select/droid-tower-default.png", "images/turret-select/droid-tower-clicked.png"), + 2, "45", "images/turret-select/droid-tower-default.png", "images/turret-select/droid-tower-clicked.png"), WALL("Wall Tower", "The Wall Tower creates barriers to block enemy paths, slowing down their progress.", - 3, "100", "images/turret-select/wall-tower-default.png", "images/turret-select/wall-tower-clicked.png"), + 3, "45", "images/turret-select/wall-tower-default.png", "images/turret-select/wall-tower-clicked.png"), FIRE("Fire Tower", "The Fire Tower emits flames, causing damage over time to enemies caught in its fiery radius.", - 4, "0", "images/turret-select/fire-tower-default.png", "images/turret-select/fire-tower-clicked.png"), + 4, "45", "images/turret-select/fire-tower-default.png", "images/turret-select/fire-tower-clicked.png"), STUN("Stun Tower", "The Stun Tower releases electric shocks that temporarily immobilize and damage enemies.", - 5, "1000", "images/turret-select/stun-tower-default.png", "images/turret-select/stun-tower-clicked.png"), + 5, "45", "images/turret-select/stun-tower-default.png", "images/turret-select/stun-tower-clicked.png"), INCOME("Income Tower", "The Income Tower generates additional in-game currency over time.", - 5, "0", "images/turret-select/mine-tower-default.png", "images/turret-select/mine-tower-clicked.png"); + 5, "10", "images/turret-select/mine-tower-default.png", "images/turret-select/mine-tower-clicked.png"); private final String towerName; private final String description; diff --git a/source/core/src/test/com/csse3200/game/entities/factories/TowerFactoryTest.java b/source/core/src/test/com/csse3200/game/entities/factories/TowerFactoryTest.java index 3b72c699a..2b5aa28b7 100644 --- a/source/core/src/test/com/csse3200/game/entities/factories/TowerFactoryTest.java +++ b/source/core/src/test/com/csse3200/game/entities/factories/TowerFactoryTest.java @@ -179,46 +179,46 @@ public void testCreateBaseTowerPhysicsComponentStaticBody() { @Test public void testWeaponTowerCombatStatsComponentAndCostComponent() { - assertEquals(10, weaponTower.getComponent(CombatStatsComponent.class).getHealth(), - "Health should be 10"); - assertEquals(10, weaponTower.getComponent(CombatStatsComponent.class).getBaseAttack(), - "BaseAttack should be 10"); - assertEquals(10, weaponTower.getComponent(CostComponent.class).getCost(), - "Cost should be 10"); - assertEquals(10, fireTower.getComponent(CombatStatsComponent.class).getHealth(), - "Fire Tower health must be 10"); - assertEquals(10, fireTower.getComponent(CombatStatsComponent.class).getBaseAttack(), - "Fire Tower base attack must be 10"); - assertEquals(10, fireTower.getComponent(CostComponent.class).getCost(), - "Fire Tower cost must 10"); - assertEquals(10, stunTower.getComponent(CombatStatsComponent.class).getHealth(), - "Stun Tower health must be 10"); - assertEquals(10, stunTower.getComponent(CombatStatsComponent.class).getBaseAttack(), - "Stun Tower base attack must be 10"); - assertEquals(10, stunTower.getComponent(CostComponent.class).getCost(), - "Stun Tower cost must 10"); + assertEquals(75, weaponTower.getComponent(CombatStatsComponent.class).getHealth(), + "Health should be 75"); + assertEquals(15, weaponTower.getComponent(CombatStatsComponent.class).getBaseAttack(), + "BaseAttack should be 15"); + assertEquals(15, weaponTower.getComponent(CostComponent.class).getCost(), + "Cost should be 15"); + assertEquals(100, fireTower.getComponent(CombatStatsComponent.class).getHealth(), + "Fire Tower health must be 100"); + assertEquals(25, fireTower.getComponent(CombatStatsComponent.class).getBaseAttack(), + "Fire Tower base attack must be 25"); + assertEquals(45, fireTower.getComponent(CostComponent.class).getCost(), + "Fire Tower cost must 45"); + assertEquals(100, stunTower.getComponent(CombatStatsComponent.class).getHealth(), + "Stun Tower health must be 100"); + assertEquals(25, stunTower.getComponent(CombatStatsComponent.class).getBaseAttack(), + "Stun Tower base attack must be 25"); + assertEquals(45, stunTower.getComponent(CostComponent.class).getCost(), + "Stun Tower cost must 45"); assertEquals(10, tntTower.getComponent(CombatStatsComponent.class).getHealth(), "TNT Tower health must be 10"); assertEquals(5, tntTower.getComponent(CombatStatsComponent.class).getBaseAttack(), "TNT Tower base attack must be 5"); - assertEquals(1, tntTower.getComponent(CostComponent.class).getCost(), - "TNT Tower cost must 1"); - assertEquals(50, droidTower.getComponent(CombatStatsComponent.class).getHealth(), - "TNT Tower health must be 50"); - assertEquals(5, droidTower.getComponent(CombatStatsComponent.class).getBaseAttack(), - "Droid Tower base attack must be 5"); - assertEquals(1, droidTower.getComponent(CostComponent.class).getCost(), - "Droid Tower cost must 1"); + assertEquals(30, tntTower.getComponent(CostComponent.class).getCost(), + "TNT Tower cost must 30"); + assertEquals(100, droidTower.getComponent(CombatStatsComponent.class).getHealth(), + "Droid Tower health must be 100"); + assertEquals(25, droidTower.getComponent(CombatStatsComponent.class).getBaseAttack(), + "Droid Tower base attack must be 25"); + assertEquals(45, droidTower.getComponent(CostComponent.class).getCost(), + "Droid Tower cost must 45"); } @Test public void testWallTowerCombatStatsComponentAndCostComponent() { - assertTrue(wallTower.getComponent(CombatStatsComponent.class).getHealth() == 20, - "Health should be 20"); + assertTrue(wallTower.getComponent(CombatStatsComponent.class).getHealth() == 300, + "Health should be 300"); assertTrue(wallTower.getComponent(CombatStatsComponent.class).getBaseAttack() == 0, "BaseAttack should be 0"); - assertTrue(wallTower.getComponent(CostComponent.class).getCost() == 5, + assertTrue(wallTower.getComponent(CostComponent.class).getCost() == 45, "Cost should be 5"); } @@ -240,11 +240,11 @@ public void testAttackerCollisionWithWall() { attacker.setPosition(10f,10f); wallTower.create(); - assertEquals(20, wallTower.getComponent(CombatStatsComponent.class).getHealth()); + assertEquals(300, wallTower.getComponent(CombatStatsComponent.class).getHealth()); ServiceLocator.getPhysicsService().getPhysics().update(); - assertEquals(10, wallTower.getComponent(CombatStatsComponent.class).getHealth()); + assertEquals(290, wallTower.getComponent(CombatStatsComponent.class).getHealth()); } From 5ce75c1744f3535287f656a8d99659d47828f113 Mon Sep 17 00:00:00 2001 From: Thivan W Date: Sun, 15 Oct 2023 16:12:04 +1000 Subject: [PATCH 2/3] changed INCOME tower id to 6 in towertype.java to ensure unqiuness --- source/core/src/main/com/csse3200/game/screens/TowerType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/src/main/com/csse3200/game/screens/TowerType.java b/source/core/src/main/com/csse3200/game/screens/TowerType.java index 71b49feae..1be6c2bc9 100644 --- a/source/core/src/main/com/csse3200/game/screens/TowerType.java +++ b/source/core/src/main/com/csse3200/game/screens/TowerType.java @@ -14,7 +14,7 @@ public enum TowerType { STUN("Stun Tower", "The Stun Tower releases electric shocks that temporarily immobilize and damage enemies.", 5, "45", "images/turret-select/stun-tower-default.png", "images/turret-select/stun-tower-clicked.png"), INCOME("Income Tower", "The Income Tower generates additional in-game currency over time.", - 5, "10", "images/turret-select/mine-tower-default.png", "images/turret-select/mine-tower-clicked.png"); + 6, "10", "images/turret-select/mine-tower-default.png", "images/turret-select/mine-tower-clicked.png"); private final String towerName; private final String description; From 07ca336ca9fd5ff6da1b3cac452f4be1621347f2 Mon Sep 17 00:00:00 2001 From: Thivan W Date: Sun, 15 Oct 2023 16:23:09 +1000 Subject: [PATCH 3/3] Changed the income amount from 50 to 30 --- .../com/csse3200/game/components/tasks/CurrencyTask.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/tasks/CurrencyTask.java b/source/core/src/main/com/csse3200/game/components/tasks/CurrencyTask.java index 8f2ea18cd..a20c7464f 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/CurrencyTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/CurrencyTask.java @@ -21,7 +21,7 @@ public class CurrencyTask extends DefaultTask implements PriorityTask { private long endTime; private int interval; private final Scrap scrap = new Scrap(); // currency to update - private final int currencyAmount = scrap.getAmount(); // amount of currency to update + private final int currencyAmount = 30; // amount of currency to update private static final String IDLE = "idleStartEco"; private static final String MOVE = "moveStartEco"; private static final String DEATH = "deathStartEco"; @@ -49,7 +49,6 @@ public CurrencyTask(int priority, int interval) { public void start() { super.start(); owner.getEntity().getEvents().addListener("addIncome",this::changeInterval); - // TODO: changed 30 TIMES MULTIPLIER to 5 times endTime = timeSource.getTime() + (interval * 1500L); owner.getEntity().getEvents().trigger(IDLE); } @@ -98,11 +97,11 @@ public void updateTowerState() { * Updates the currency based on time intervals. */ public void updateCurrency() { - //logger.info("Updating currency"); - ServiceLocator.getCurrencyService().getScrap().modify(currencyAmount/2); + logger.info("Updating currency"); + ServiceLocator.getCurrencyService().getScrap().modify(currencyAmount); Vector2 coordinates = this.owner.getEntity().getCenterPosition(); - ServiceLocator.getCurrencyService().getDisplay().currencyPopUp(coordinates.x, coordinates.y, currencyAmount/2, 25); + ServiceLocator.getCurrencyService().getDisplay().currencyPopUp(coordinates.x, coordinates.y, currencyAmount, 25); ServiceLocator.getCurrencyService().getDisplay().updateScrapsStats(); // update currency display