From 989c76ced9a2fe135f55fe455a45357893915f67 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 3 Mar 2023 14:50:28 -0500 Subject: [PATCH] village stages --- .../src/ca/cosc3p91/a2/game/GameEngine.java | 7 ++--- .../cosc3p91/a2/gameobjects/CasaDeNarino.java | 14 +++++----- .../cosc3p91/a2/gameobjects/DefenseStage.java | 4 ++- .../a2/gameobjects/VillageHallStages.java | 26 +++++++++++++++++++ 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/Assignment 2/src/ca/cosc3p91/a2/game/GameEngine.java b/Assignment 2/src/ca/cosc3p91/a2/game/GameEngine.java index 40c7ee8..a323cb5 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/game/GameEngine.java +++ b/Assignment 2/src/ca/cosc3p91/a2/game/GameEngine.java @@ -77,9 +77,7 @@ public class GameEngine implements Runnable { } private Map generateInitialMap(){ - VillageStage villageHallInitialStage = new VillageStage(100, 0, 2, new Time(), 0, - 0, 1000, 2500, 5000); - return new Map(new CasaDeNarino(1, villageHallInitialStage), 30); + return new Map(new CasaDeNarino(1, VillageHallStages.villageStages[0]), 30); } public Map generateMap() { @@ -112,6 +110,9 @@ public class GameEngine implements Runnable { case 'p': printState(); break; + case 'q': + System.exit(0); + break; default: break; } diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/CasaDeNarino.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/CasaDeNarino.java index f49fbea..ae0403e 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/CasaDeNarino.java +++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/CasaDeNarino.java @@ -39,6 +39,12 @@ public class CasaDeNarino extends Building { return currentGold; } + public int getCurrentIron() { + return currentIron; + } + + public int getCurrentWood() {return currentWood;} + public boolean addGold(int amount) { int newGold = this.currentGold + amount; if (newGold <= goldCapacity && this.currentGold + amount >= 0){ @@ -48,10 +54,6 @@ public class CasaDeNarino extends Building { return false; } - public int getCurrentIron() { - return currentIron; - } - public boolean addIron(int amount) { int newIron = this.currentIron + amount; if (newIron <= ironCapacity && newIron >= 0) { @@ -61,10 +63,6 @@ public class CasaDeNarino extends Building { return false; } - public int getCurrentWood() { - return currentWood; - } - public boolean addWood(int amount) { int newWood = this.currentWood + amount; if (newWood <= woodCapacity && newWood >= 0) { diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/DefenseStage.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/DefenseStage.java index 7686dd7..26cd7cf 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/DefenseStage.java +++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/DefenseStage.java @@ -1,12 +1,14 @@ package ca.cosc3p91.a2.gameobjects; +import ca.cosc3p91.a2.util.Time; + class DefenseStage extends Stage { protected int dDamage; protected int dRange; - public DefenseStage(int dHealth, int goldCost, int requiredVillageLevel, int upgradeTime, int ironCost, int woodCost, + public DefenseStage(int dHealth, int goldCost, int requiredVillageLevel, Time upgradeTime, int ironCost, int woodCost, int damageIncrease, int rangeIncrease) { super(dHealth, goldCost, requiredVillageLevel, upgradeTime, ironCost, woodCost); this.dDamage = damageIncrease; diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/VillageHallStages.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/VillageHallStages.java index f222f87..d1f2c3b 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/VillageHallStages.java +++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/VillageHallStages.java @@ -1,4 +1,30 @@ package ca.cosc3p91.a2.gameobjects; +import ca.cosc3p91.a2.util.Time; + public class VillageHallStages { + + public static class VillageStage1 extends VillageStage { + public VillageStage1() { + super(100, 0, 0, new Time(), 0, + 0, 1000, 2500, 5000); + } + } + + public static class VillageStage2 extends VillageStage { + public VillageStage2() { + super(550, 1000, 0, new Time().offsetHours(2), 2500, + 5000, 2500, 5000, 10000); + } + } + + public static class VillageStage3 extends VillageStage { + public VillageStage3() { + super(550, 2500, 0, new Time().offsetHours(2), 5000, + 10000, 5000, 7500, 15000); + } + } + + public static VillageStage[] villageStages = {new VillageStage1(), new VillageStage2(), new VillageStage3()}; + }