Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team 7 tower stat alterations #263

Merged
merged 4 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 34 additions & 19 deletions source/core/assets/configs/tower.json
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as with my other comment, could this be modified to fetch the scrap increment value from the config file?

private static final String IDLE = "idleStartEco";
private static final String MOVE = "moveStartEco";
private static final String DEATH = "deathStartEco";
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
14 changes: 7 additions & 7 deletions source/core/src/main/com/csse3200/game/screens/TowerType.java
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion for maintainability, could this fetch values from the config files you defined?

Original file line number Diff line number Diff line change
Expand Up @@ -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");
6, "10", "images/turret-select/mine-tower-default.png", "images/turret-select/mine-tower-clicked.png");

private final String towerName;
private final String description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

}
Expand All @@ -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());

}

Expand Down
Loading