diff --git a/.gitignore b/.gitignore
index e69de29..62f45e8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1,2 @@
+Assignment 2/out/
+out/
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000..a55e7a1
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/Assignment 2/src/ca/cosc3p91/a2/Main.java b/Assignment 2/src/ca/cosc3p91/a2/Main.java
index e65efa7..311e498 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/Main.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/Main.java
@@ -1,13 +1,34 @@
package ca.cosc3p91.a2;
import ca.cosc3p91.a2.game.GameEngine;
+import ca.cosc3p91.a2.util.Print;
public class Main {
public static void main(String[] args) {
GameEngine engine = new GameEngine();
+<<<<<<< HEAD
engine.printMap();
+=======
+ Print test = new Print("Hello There", 2);
+
+ test.addColumn(new Print.Column("I am value 1"));
+ test.addColumn(new Print.Column("Super Value"));
+ test.addColumn(new Print.Column("SOLD!"));
+
+ Print.Row row = new Print.Row();
+ row.add("HelloThere");
+ row.add("Goodbye");
+ row.add("3");
+
+ test.addRow(row);
+ test.addRow(row);
+ test.addRow(row);
+
+ Print.print(test.createTable());
+
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
engine.run();
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/game/GameEngine.java b/Assignment 2/src/ca/cosc3p91/a2/game/GameEngine.java
index 7ff19d4..a5be66c 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/game/GameEngine.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/game/GameEngine.java
@@ -7,14 +7,15 @@ import ca.cosc3p91.a2.player.Player;
public class GameEngine implements Runnable {
- private Player player;
+ private final boolean running = true;
- private int pillageFactor;
+ private Player player;
- private int currentTime;
+ private int pillageFactor;
- public Map map;
+ private int currentTime;
+<<<<<<< HEAD
public GameEngine () {
player = new Player();
VillageStage vInitialStage = new VillageStage(100,0,2,30,0,
@@ -32,16 +33,24 @@ public class GameEngine implements Runnable {
public void attackVillage(Map map) {
}
+=======
+ public Map map;
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
- public Map generateMap() {
- return null;
- }
+ public void attackVIllage(Map map) {
+ }
- public void getScore(Map map) {
- }
+ public Map generateMap() {
+ return null;
+ }
- @Override
- public void run() {
-
- }
+ public void getScore(Map map) {
+ }
+
+ @Override
+ public void run() {
+ while (running) {
+
+ }
+ }
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/game/Map.java b/Assignment 2/src/ca/cosc3p91/a2/game/Map.java
index 8564a36..e8169ac 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/game/Map.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/game/Map.java
@@ -5,18 +5,30 @@ import ca.cosc3p91.a2.gameobjects.*;
import java.util.ArrayList;
import java.util.List;
+<<<<<<< HEAD
public class Map {
static int MAXSIZE = 400;
private Village_Hall townHall;
+=======
- private int guardTime;
+public class Map {
+ private Village_Hall townHall;
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
+
+ private int guardTime;
+
+<<<<<<< HEAD
public List contains;
+=======
+ private List contains;
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
- public List inhabitants;
+ public List inhabitants;
+<<<<<<< HEAD
public Map (Village_Hall villageHall, int gTime) {
contains = new ArrayList<>();
inhabitants = new ArrayList<>();
@@ -36,13 +48,28 @@ public class Map {
public void build(Village_Hall hall, Tile t, Building b) {
contains.add(b);
}
+=======
+ public void move(Infantry i, Tile t) {
+ }
- public int getGuardTime() {
- return guardTime;
- }
+ public void inRange(Infantry i, Building b) {
+ }
+ public void build(Village_Hall hall, Tile t, Building b) {
+ }
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
+
+ public int getGuardTime() {
+ return guardTime;
+ }
+
+<<<<<<< HEAD
public void setGuardTime(int gTime) {
this.guardTime = gTime;
}
+=======
+ public void setGuardTime() {
+ }
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Building.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Building.java
index 91f5a03..80a6990 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Building.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Building.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
public abstract class Building {
+<<<<<<< HEAD
// members
private int level;
private int health;
@@ -13,22 +14,43 @@ public abstract class Building {
private int goldCost;
private int ironCost;
private int woodCost;
+=======
+ private static int level;
- private int buildTime;
+ private int health;
+ private static Stage stages;
+
+ private int goldCost;
+
+ private int ironCost;
+
+ private int woodCost;
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
+
+ private int buildTime;
+
+<<<<<<< HEAD
public ArrayList tiles = new ArrayList<>();
public ArrayList inhabitants = new ArrayList<>();
// functions
+=======
+ public List stage;
+ public Tile tile;
- public int getLevel() {
- return level;
- }
+ public List inhabitant;
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
- public int getHealth() {
- return health;
- }
+ public int getLevel() {
+ return level;
+ }
+ public int getHealth() {
+ return health;
+ }
+
+<<<<<<< HEAD
public int getCost(String type) {
return (type.equals("gold"))?(goldCost):
(type.equals("iron"))?(ironCost):woodCost;
@@ -37,11 +59,17 @@ public abstract class Building {
public Stage getStage() {
return stage;
}
+=======
+ public int getCost(String type) {
+ return 0;
+ }
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
- public int getUpgradeCost() {
- return 0;
- }
+ public int getUpgradeCost() {
+ return 0;
+ }
+<<<<<<< HEAD
public void setLevel(int level) {
this.level = level;
}
@@ -66,4 +94,14 @@ public abstract class Building {
public int getBuildTime() {
return buildTime;
}
+=======
+ public void upgrade() {
+
+ }
+
+ public int getBuildTime() {
+ return 0;
+ }
+
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Collector.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Collector.java
index 7d63c27..dcf9a4f 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Collector.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Collector.java
@@ -2,10 +2,10 @@ package ca.cosc3p91.a2.gameobjects;
public class Collector {
- private int averageCollectionRate;
+ private int averageCollectionRate;
- public int getCollectionRate() {
- return averageCollectionRate;
- }
+ public int getCollectionRate() {
+ return averageCollectionRate;
+ }
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/DefenseBuilding.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/DefenseBuilding.java
index 30b3692..c2fe0bf 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/DefenseBuilding.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/DefenseBuilding.java
@@ -2,6 +2,7 @@ package ca.cosc3p91.a2.gameobjects;
public class DefenseBuilding extends Building {
+<<<<<<< HEAD
private int damage;
private int range;
@@ -10,9 +11,14 @@ public class DefenseBuilding extends Building {
this.damage += stage.getDamageChange();
this.range += stage.getRangeChange();
}
+=======
+ public int damage;
- public void attack(Infantry attacker) {
+ public int range;
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
- }
+ public void attack(Infantry attacker) {
+
+ }
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/DefenseStage.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/DefenseStage.java
index bc0320c..c095aaf 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/DefenseStage.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/DefenseStage.java
@@ -2,10 +2,15 @@ package ca.cosc3p91.a2.gameobjects;
class DefenseStage extends Stage {
+<<<<<<< HEAD
protected int dDamage;
+=======
+ protected int dDamge;
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
- protected int dRange;
+ protected int dRange;
+<<<<<<< HEAD
public DefenseStage(int dHealth, int goldCost, int requiredVillageLevel, int upgradeTime, int ironCost, int woodCost,
int damageIncrease, int rangeIncrease) {
super(dHealth,goldCost,requiredVillageLevel,upgradeTime,ironCost,woodCost);
@@ -20,5 +25,12 @@ class DefenseStage extends Stage {
public int getRangeChange() {
return dRange;
}
+=======
+ public void getDamageChange() {
+ }
+
+ public void getRangeChange() {
+ }
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
}
\ No newline at end of file
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Farm.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Farm.java
index 28b92f5..66ba7a6 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Farm.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Farm.java
@@ -7,12 +7,12 @@ public class Farm extends ResourceBuilding {
upgrade(baseStage);
}
- public int getPopulationContribution() {
- return 0;
- }
+ public int getPopulationContribution() {
+ return 0;
+ }
- @Override
- public void harvest(Village_Hall hall) {
+ @Override
+ public void harvest(Village_Hall hall) {
- }
+ }
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/GoldMine.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/GoldMine.java
index 7aa95f9..a369ee1 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/GoldMine.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/GoldMine.java
@@ -2,15 +2,19 @@ package ca.cosc3p91.a2.gameobjects;
public class GoldMine extends ResourceBuilding {
+<<<<<<< HEAD
public static String resource = "gold";
public GoldMine (int lvl, ResourceStage baseStage) {
setLevel(lvl);
upgrade(baseStage);
}
+=======
+ public static String resource = "good";
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
- @Override
- public void harvest(Village_Hall hall) {
+ @Override
+ public void harvest(Village_Hall hall) {
- }
+ }
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Infantry.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Infantry.java
index 9a3c078..a9c4f7c 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Infantry.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Infantry.java
@@ -2,22 +2,22 @@ package ca.cosc3p91.a2.gameobjects;
public abstract class Infantry {
- private int health;
+ private int health;
- private int damage;
+ private int damage;
- private int range;
+ private int range;
- public void attack(Building b) {
- }
+ public void attack(Building b) {
+ }
- public void getHealth() {
- }
+ public void getHealth() {
+ }
- public void getDamage() {
- }
+ public void getDamage() {
+ }
- public void getRange() {
- }
+ public void getRange() {
+ }
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Inhabitant.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Inhabitant.java
index 96c6da8..3a10a28 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Inhabitant.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Inhabitant.java
@@ -4,11 +4,11 @@ import ca.cosc3p91.a2.game.Map;
public interface Inhabitant {
- public Map map = null;
- public Building building = null;
+ Map map = null;
+ Building building = null;
- public void move(Tile t);
+ void move(Tile t);
- public void getPosition();
+ void getPosition();
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/IronMine.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/IronMine.java
index ec38c21..2d4a98c 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/IronMine.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/IronMine.java
@@ -2,8 +2,9 @@ package ca.cosc3p91.a2.gameobjects;
public class IronMine extends ResourceBuilding {
- public static String resource = "iron";
+ public static String resource = "iron";
+<<<<<<< HEAD
public IronMine (int lvl, ResourceStage baseStage) {
setLevel(lvl);
upgrade(baseStage);
@@ -11,6 +12,10 @@ public class IronMine extends ResourceBuilding {
@Override
public void harvest(Village_Hall hall) {
+=======
+ @Override
+ public void harvest(Village_Hall hall) {
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
- }
+ }
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/LumberMine.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/LumberMine.java
index b5323b5..bcdc494 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/LumberMine.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/LumberMine.java
@@ -2,15 +2,19 @@ package ca.cosc3p91.a2.gameobjects;
public class LumberMine extends ResourceBuilding {
- public static String resource = "wood";
+ public static String resource = "wood";
+<<<<<<< HEAD
public LumberMine (int lvl, ResourceStage baseStage) {
setLevel(lvl);
upgrade(baseStage);
}
public void harvest(Village_Hall hall) {
+=======
+ public void harvest(Village_Hall hall) {
+
+ }
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
- }
-
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/ResourceBuidling.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/ResourceBuidling.java
new file mode 100644
index 0000000..c0c9fbc
--- /dev/null
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/ResourceBuidling.java
@@ -0,0 +1,11 @@
+package ca.cosc3p91.a2.gameobjects;
+
+public abstract class ResourceBuidling extends Building {
+
+ public static String resource;
+
+ private int harvest_rate;
+
+ public abstract void harvest(Village_Hall hall);
+
+}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/ResourceStage.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/ResourceStage.java
index a2092b0..6809500 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/ResourceStage.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/ResourceStage.java
@@ -2,8 +2,9 @@ package ca.cosc3p91.a2.gameobjects;
public class ResourceStage extends Stage {
- protected int harvestRateIncrease;
+ protected int harvestRateIncrease;
+<<<<<<< HEAD
public ResourceStage(int dHealth, int goldCost, int requiredVillageLevel, int upgradeTime, int ironCost, int woodCost,
int harvestRateIncr) {
super(dHealth,goldCost,requiredVillageLevel,upgradeTime,ironCost,woodCost);
@@ -13,5 +14,10 @@ public class ResourceStage extends Stage {
public int getHarvestRateIncrease() {
return harvestRateIncrease;
}
+=======
+ public int getHarvestRateIncrease() {
+ return harvestRateIncrease;
+ }
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Stage.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Stage.java
index 71e10a1..687781a 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Stage.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Stage.java
@@ -2,18 +2,19 @@ package ca.cosc3p91.a2.gameobjects;
abstract class Stage {
- protected int dHealth;
+ protected int dHealth;
- protected int goldCost;
+ protected int goldCost;
- protected int requiredVillageLevel;
+ protected int requiredVillageLevel;
- protected int upgradeTime;
+ protected int upgradeTime;
- protected int ironCost;
+ protected int ironCost;
- protected int woodCost;
+ protected int woodCost;
+<<<<<<< HEAD
public Stage(int dHealth, int goldCost, int requiredVillageLevel, int upgradeTime, int ironCost, int woodCost) {
this.dHealth = dHealth;
this.goldCost = goldCost;
@@ -31,13 +32,23 @@ abstract class Stage {
return (type.equals("gold"))?(goldCost):
(type.equals("iron"))?(ironCost):woodCost;
}
+=======
+ public Building building;
- public int getRequiredVillageLevel() {
- return requiredVillageLevel;
- }
+ public void getHealthChange() {
+ }
- public int getUpgradeTime() {
- return upgradeTime;
- }
+ public int getCost(String type) {
+ return 0;
+ }
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
+
+ public int getRequiredVillageLevel() {
+ return requiredVillageLevel;
+ }
+
+ public int getUpgradeTime() {
+ return upgradeTime;
+ }
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Tile.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Tile.java
index bbc6f6f..ae976cc 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Tile.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Tile.java
@@ -4,8 +4,13 @@ import java.util.List;
public class Tile {
- public int x;
+ public int x;
- public int y;
+ public int y;
+<<<<<<< HEAD
+=======
+ public List building;
+
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/VillageStage.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/VillageStage.java
index 71c7019..f1d1986 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/VillageStage.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/VillageStage.java
@@ -2,12 +2,13 @@ package ca.cosc3p91.a2.gameobjects;
public class VillageStage extends Stage {
- protected int goldCapacityIncrease;
+ protected int goldCapacityIncrease;
- protected int ironCapacityIncrease;
+ protected int ironCapacityIncrease;
- protected int woodCapacityIncrease;
+ protected int woodCapacityIncrease;
+<<<<<<< HEAD
public VillageStage(int dHealth, int goldCost, int requiredVillageLevel, int upgradeTime, int ironCost, int woodCost,
int goldCapIncrease, int ironCapIncrease, int woodCapIncrease) {
super(dHealth,goldCost,requiredVillageLevel,upgradeTime,ironCost,woodCost);
@@ -19,13 +20,18 @@ public class VillageStage extends Stage {
public int getGoldCapacityIncrease() {
return goldCapacityIncrease;
}
+=======
+ public int getGoldCapacityIncrease() {
+ return goldCapacityIncrease;
+ }
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
- public int getIronCapacityIncrease() {
- return ironCapacityIncrease;
- }
+ public int getIronCapacityIncrease() {
+ return ironCapacityIncrease;
+ }
- public int getWoodCapacityIncrease() {
- return woodCapacityIncrease;
- }
+ public int getWoodCapacityIncrease() {
+ return woodCapacityIncrease;
+ }
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Village_Hall.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Village_Hall.java
index 039216a..ebd891e 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Village_Hall.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Village_Hall.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
public class Village_Hall extends Building {
+<<<<<<< HEAD
private int goldCapacity = 0;
private int ironCapacity = 0;
@@ -34,5 +35,24 @@ public class Village_Hall extends Building {
public int getWoodCapacity() {
return woodCapacity;
}
+=======
+ private int goldCapacity;
+
+ private int ironCapacity;
+
+ private int woodCapacity;
+
+ public int getGoldCapacity() {
+ return goldCapacity;
+ }
+
+ public int getIronCapacity() {
+ return ironCapacity;
+ }
+
+ public int getWoodCapacity() {
+ return woodCapacity;
+ }
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Worker.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Worker.java
index ae319b1..90255c0 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Worker.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Worker.java
@@ -2,10 +2,10 @@ package ca.cosc3p91.a2.gameobjects;
public class Worker {
- private boolean currentlyBuilding;
+ private boolean currentlyBuilding;
- public boolean isCurrentlyBuilding() {
- return currentlyBuilding;
- }
+ public boolean isCurrentlyBuilding() {
+ return currentlyBuilding;
+ }
}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/player/Player.java b/Assignment 2/src/ca/cosc3p91/a2/player/Player.java
index 0dcbff3..195cb1e 100644
--- a/Assignment 2/src/ca/cosc3p91/a2/player/Player.java
+++ b/Assignment 2/src/ca/cosc3p91/a2/player/Player.java
@@ -2,8 +2,16 @@ package ca.cosc3p91.a2.player;
public class Player {
+<<<<<<< HEAD
public int currentGold;
public int currentIron;
public int currentWood;
+=======
+ public int currentGold;
+
+ public int currentIron;
+
+ public int currentWood;
+>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
}
\ No newline at end of file
diff --git a/Assignment 2/src/ca/cosc3p91/a2/util/Print.java b/Assignment 2/src/ca/cosc3p91/a2/util/Print.java
new file mode 100644
index 0000000..2d8ef59
--- /dev/null
+++ b/Assignment 2/src/ca/cosc3p91/a2/util/Print.java
@@ -0,0 +1,208 @@
+package ca.cosc3p91.a2.util;
+
+import java.util.ArrayList;
+
+/**
+ * Ported from blt::TableFormatter (C++)
+ * https://github.com/Tri11Paragon/BLT/
+ */
+public class Print {
+
+ public static class Row {
+ private final ArrayList values;
+
+ public Row(ArrayList row) {
+ this.values = row;
+ }
+
+ public Row(){
+ this.values = new ArrayList<>();
+ }
+
+ public void add(String value){
+ values.add(value);
+ }
+ }
+
+ public static class Column {
+ private final String columnName;
+ private long maxColumnLength = 0;
+
+ public Column(String columnName){
+ this.columnName = columnName;
+ }
+ }
+
+ private final ArrayList rows = new ArrayList<>();
+ private final ArrayList columns = new ArrayList<>();
+
+ private final String tableName;
+ private final int columnPadding;
+ private int maxColumnWidth;
+
+ public Print(String tableName, int columnPadding){
+ this.tableName = tableName;
+ this.columnPadding = columnPadding;
+ }
+
+ public Print(){
+ this("", 2);
+ }
+
+ private String createPadding(int amount) {
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < amount; i++){
+ builder.append(' ');
+ }
+ return builder.toString();
+ }
+
+ private String generateTopSelector(long size) {
+ long sizeOfName = tableName.isEmpty() ? 0 : tableName.length() + 4;
+ long sizeNameRemoved = size - sizeOfName;
+
+ StringBuilder halfWidthLeftSeparator = new StringBuilder();
+ StringBuilder halfWidthRightSeparator = new StringBuilder();
+
+ long sizeNameFloor = (long) Math.floor((double)sizeNameRemoved / 2.0);
+ long sizeNameCeil = (long) Math.ceil((double)sizeNameRemoved / 2.0);
+
+ halfWidthLeftSeparator.append('+');
+
+ for (int i = 0; i < sizeNameFloor - 1; i++)
+ halfWidthLeftSeparator.append('-');
+ for (int i = 0; i < sizeNameCeil - 1; i++)
+ halfWidthRightSeparator.append('-');
+
+ halfWidthRightSeparator.append('+');
+
+ StringBuilder separator = new StringBuilder();
+ separator.append(halfWidthLeftSeparator.toString());
+ if (sizeOfName != 0){
+ separator.append("{ ");
+ separator.append(tableName);
+ separator.append(" }");
+ }
+ separator.append(halfWidthRightSeparator);
+ return separator.toString();
+ }
+
+ private String generateColumnHeader(){
+ updateColumnLengths();
+ StringBuilder header = new StringBuilder();
+ header.append('|');
+
+ for (int i = 0; i < columns.size(); i++){
+ Column column = columns.get(i);
+ double columnPaddingLength = ((int)(column.maxColumnLength) - (int)(column.columnName.length()))/2.0;
+ header.append(createPadding((int)(columnPadding + (int)Math.floor(columnPaddingLength))));
+
+ header.append(column.columnName);
+
+ header.append(createPadding((int)(columnPadding + (int)Math.ceil(columnPaddingLength))));
+ if (i < columns.size()-1)
+ header.append('|');
+ }
+ header.append('|');
+
+ return header.toString();
+ }
+
+ private String generateSeparator(long size) {
+ int nextIndex = 0;
+ int currentColumnIndex = 0;
+ StringBuilder wholeWidthSeparator = new StringBuilder();
+ for (int i = 0; i < size; i++) {
+ if (i == nextIndex) {
+ System.out.println(currentColumnIndex + " " + nextIndex + " " + size);
+ int currentColumnSize = (int) (columns.get(currentColumnIndex++).maxColumnLength + columnPadding*2);
+ nextIndex += currentColumnSize + 1;
+ wholeWidthSeparator.append('+');
+ } else
+ wholeWidthSeparator.append('-');
+ }
+ wholeWidthSeparator.append('+');
+ return wholeWidthSeparator.toString();
+ }
+
+ private void updateColumnLengths() {
+ for (int i = 0; i < columns.size(); i++) {
+ Column column = columns.get(i);
+ column.maxColumnLength = column.columnName.length();
+ for (Row row : rows) {
+ column.maxColumnLength = Math.max(column.maxColumnLength, row.values.get(i).length() - 1);
+ }
+ }
+ }
+
+ public long columnSize(Column column) {
+ return column.columnName.length() + columnPadding * 2L;
+ }
+
+ public Print addColumn(Column column){
+ columns.add(column);
+ return this;
+ }
+
+ public Print addRow(Row row) {
+ if (row.values.size() > columns.size())
+ throw new RuntimeException("Unable to create row with more values than columns!");
+ if (row.values.size() < columns.size())
+ for (int i = row.values.size(); i < columns.size(); i++)
+ row.values.add("");
+ rows.add(row);
+ return this;
+ }
+
+ public Print addRow(ArrayList row){
+ return addRow(new Row(row));
+ }
+
+ public ArrayList createTable(boolean top, boolean bottom, boolean separators){
+ ArrayList lines = new ArrayList<>();
+
+ String header = generateColumnHeader();
+ String topSeparator = generateTopSelector(header.length());
+ String lineSeparator = generateSeparator(header.length() - 1);
+
+ if (top)
+ lines.add(topSeparator);
+
+ lines.add(header);
+ lines.add(lineSeparator);
+
+ for (Row row : rows) {
+ StringBuilder rowLine = new StringBuilder();
+ rowLine.append('|');
+ for (int i = 0; i < row.values.size(); i++){
+ String value = row.values.get(i);
+ Column column = columns.get(i);
+ int spaceLeft = (int)(column.maxColumnLength - value.length());
+ rowLine.append(createPadding((int)Math.floor(spaceLeft / 2.0) + columnPadding));
+ rowLine.append(value);
+ rowLine.append(createPadding((int)Math.ceil(spaceLeft / 2.0) + columnPadding));
+ rowLine.append('|');
+ }
+ lines.add(rowLine.toString());
+ }
+
+ if (bottom)
+ lines.add(lineSeparator);
+
+ return lines;
+ }
+
+ public ArrayList createBox(){
+ return new ArrayList<>();
+ }
+
+ public ArrayList createTable() {
+ return createTable(true, true, true);
+ }
+
+ public static void print(ArrayList lines){
+ for (String line : lines)
+ System.out.println(line);
+ }
+
+}
diff --git a/Assignment 2/src/ca/cosc3p91/a2/util/Time.java b/Assignment 2/src/ca/cosc3p91/a2/util/Time.java
new file mode 100644
index 0000000..60d5f93
--- /dev/null
+++ b/Assignment 2/src/ca/cosc3p91/a2/util/Time.java
@@ -0,0 +1,56 @@
+package ca.cosc3p91.a2.util;
+
+public class Time {
+
+ private long timeSeconds;
+
+ public Time() {
+ this.timeSeconds = 0;
+ }
+
+ protected Time(long timeSeconds) {
+ this.timeSeconds = timeSeconds;
+ }
+
+ public Time offsetSeconds(long seconds) {
+ this.timeSeconds += seconds;
+ return this;
+ }
+
+ public Time offsetMinutes(long minutes) {
+ return offsetSeconds(minutes * 60);
+ }
+
+ public Time offsetHours(long hours) {
+ return offsetMinutes(hours * 60);
+ }
+
+ public Time offsetDays(long days) {
+ return offsetHours(days * 24);
+ }
+
+ public Time offsetTime(Time time) {
+ return offsetSeconds(time.timeSeconds);
+ }
+
+ public long get() {
+ return timeSeconds;
+ }
+
+ public static class FutureTime {
+ private final Time futureTime;
+
+ public FutureTime(Time futureTime) {
+ this.futureTime = futureTime;
+ }
+
+ public boolean occurred() {
+ return getTime().timeSeconds >= futureTime.timeSeconds;
+ }
+ }
+
+ public static Time getTime() {
+ return new Time(System.currentTimeMillis() / 1000);
+ }
+
+}