diff --git a/Assignment 2/src/ca/cosc3p91/a2/Main.java b/Assignment 2/src/ca/cosc3p91/a2/Main.java index e65efa7..1747fdb 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/Main.java +++ b/Assignment 2/src/ca/cosc3p91/a2/Main.java @@ -7,7 +7,7 @@ public class Main { public static void main(String[] args) { GameEngine engine = new GameEngine(); - engine.printMap(); + engine.printState(); 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 e48016f..1ba887e 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/game/GameEngine.java +++ b/Assignment 2/src/ca/cosc3p91/a2/game/GameEngine.java @@ -1,9 +1,7 @@ package ca.cosc3p91.a2.game; -import ca.cosc3p91.a2.gameobjects.Building; -import ca.cosc3p91.a2.gameobjects.VillageStage; -import ca.cosc3p91.a2.gameobjects.Village_Hall; -import ca.cosc3p91.a2.player.Player; +import ca.cosc3p91.a2.gameobjects.*; +import ca.cosc3p91.a2.player.*; public class GameEngine implements Runnable { @@ -22,11 +20,17 @@ public class GameEngine implements Runnable { map = new Map(new Village_Hall(1,vInitialStage),30); } - public void printMap() { - System.out.println("~ Current Map State ~\n\n"); + public void printState() { + // Print toPrint = new Print("~ Current Village Buildings ~",2); + System.out.println("In Map:\n"); + System.out.println("\t~ Current Village Buildings ~\n"); for (Building b : map.contains) { - System.out.println("|> "+b.getClass().getSimpleName()+" lvl: "+b.getLevel()+" health: "+b.getHealth()); + System.out.println("\t|> "+b.getClass().getSimpleName()+" lvl: "+b.getLevel()+" health: "+b.getHealth()); + } + System.out.println("\n\t~ Current Village Inhabitants ~\n\n"); + for (Inhabitant i : map.inhabitants) { + System.out.println("\t|> "+i.getClass().getSimpleName()+" lvl: "+i.getLevel()); } } diff --git a/Assignment 2/src/ca/cosc3p91/a2/game/Map.java b/Assignment 2/src/ca/cosc3p91/a2/game/Map.java index 8564a36..bd7cc4b 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/game/Map.java +++ b/Assignment 2/src/ca/cosc3p91/a2/game/Map.java @@ -33,7 +33,7 @@ public class Map { } - public void build(Village_Hall hall, Tile t, Building b) { + public void build(Tile t, Building b) { contains.add(b); } diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Archer.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Archer.java index 02701ad..e11f54d 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Archer.java +++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Archer.java @@ -1,4 +1,28 @@ package ca.cosc3p91.a2.gameobjects; public class Archer extends Infantry { + + public Archer() { + super(90, 2, 10); + } + + @Override + public void move(Tile t) { + + } + + @Override + public void getPosition() { + + } + + @Override + public int getLevel() { + return super.getLevel(); + } + + @Override + public int setLevel(int level) { + return super.setLevel(level); + } } \ No newline at end of file diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Catapult.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Catapult.java index fc0071c..4bc871e 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Catapult.java +++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Catapult.java @@ -1,4 +1,28 @@ package ca.cosc3p91.a2.gameobjects; public class Catapult extends Infantry { + + public Catapult() { + super(80, 12, 12); + } + + @Override + public void move(Tile t) { + + } + + @Override + public void getPosition() { + + } + + @Override + public int getLevel() { + return super.getLevel(); + } + + @Override + public int setLevel(int level) { + return super.setLevel(level); + } } \ No newline at end of file diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Infantry.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Infantry.java index a9c4f7c..450d50c 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Infantry.java +++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Infantry.java @@ -1,6 +1,6 @@ package ca.cosc3p91.a2.gameobjects; -public abstract class Infantry { +public abstract class Infantry implements Inhabitant { private int health; @@ -8,16 +8,36 @@ public abstract class Infantry { private int range; + public Infantry(int hitPoints, int damage, int range) { + this.health = hitPoints; + this.damage = damage; + this.range = range; + } + public void attack(Building b) { } - public void getHealth() { + public int getHealth() { + return health; } - public void getDamage() { + public int getDamage() { + return damage; } - public void getRange() { + public int getRange() { + return range; } + public void setHealth(int health) { + this.health = health; + } + + public void setDamage(int damage) { + this.damage = damage; + } + + public void setRange(int range) { + this.range = range; + } } diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Inhabitant.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Inhabitant.java index 3a10a28..a4053c1 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Inhabitant.java +++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Inhabitant.java @@ -1,14 +1,19 @@ package ca.cosc3p91.a2.gameobjects; - import ca.cosc3p91.a2.game.Map; public interface Inhabitant { Map map = null; Building building = null; + int lvl = 1; void move(Tile t); - void getPosition(); + default int getLevel() { + return lvl; + } + default int setLevel(int level) { + return lvl; + } } diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Knight.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Knight.java index 8e78d73..e8b91e1 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Knight.java +++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Knight.java @@ -1,4 +1,28 @@ package ca.cosc3p91.a2.gameobjects; public class Knight extends Infantry { + + public Knight() { + super(150, 6, 6); + } + + @Override + public void move(Tile t) { + + } + + @Override + public void getPosition() { + + } + + @Override + public int getLevel() { + return super.getLevel(); + } + + @Override + public int setLevel(int level) { + return super.setLevel(level); + } } \ No newline at end of file diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Soldier.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Soldier.java index 7cbbe32..4656c78 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Soldier.java +++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Soldier.java @@ -1,4 +1,28 @@ package ca.cosc3p91.a2.gameobjects; public class Soldier extends Infantry { + + public Soldier() { + super(100, 4, 4); + } + + @Override + public void move(Tile t) { + + } + + @Override + public void getPosition() { + + } + + @Override + public int getLevel() { + return super.getLevel(); + } + + @Override + public int setLevel(int level) { + return super.setLevel(level); + } } \ No newline at end of file diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Worker.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Worker.java index 90255c0..c0ac8a0 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Worker.java +++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/Worker.java @@ -1,11 +1,33 @@ package ca.cosc3p91.a2.gameobjects; -public class Worker { +public class Worker implements Inhabitant { private boolean currentlyBuilding; + public void set_IsBuilding(boolean state) { + currentlyBuilding = state; + } public boolean isCurrentlyBuilding() { return currentlyBuilding; } + @Override + public void move(Tile t) { + + } + + @Override + public void getPosition() { + + } + + @Override + public int getLevel() { + return Inhabitant.super.getLevel(); + } + + @Override + public int setLevel(int level) { + return Inhabitant.super.setLevel(level); + } }