Compare commits

...

10 Commits

Author SHA1 Message Date
Brett 0495018430 reformat 2023-03-02 13:19:34 -05:00
Brett 9a7aa7c6b3 reformat 2023-03-02 13:01:41 -05:00
Brett 5b516418ed fix merge 2023-03-02 12:45:28 -05:00
Brett 27b9b240a3 Merge remote-tracking branch 'refs/remotes/origin/main' 2023-03-02 12:43:13 -05:00
Brett 02504e59a6 move current storage to village hall 2023-03-02 12:42:24 -05:00
mike 7e90cd8435 Merge https://github.com/Tri11Paragon/COSC-3P91-Assignments 2023-03-02 12:41:47 -05:00
mike af4788969a Java = Javascript 2023-03-02 12:39:49 -05:00
Brett 55edf6fe54 saul goodmine 2023-03-02 12:38:17 -05:00
mike 84271b265b The second Javascript update 2023-03-02 11:21:52 -05:00
mike a357975440 The javascript update 2023-03-02 11:17:56 -05:00
56 changed files with 396 additions and 400 deletions

View File

@ -1,34 +1,13 @@
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.printState();
engine.run();
}

View File

@ -1,21 +1,18 @@
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 {
private final boolean running = true;
private Player player;
private int pillageFactor;
private int currentTime;
<<<<<<< HEAD
public Map map;
public GameEngine() {
player = new Player();
VillageStage vInitialStage = new VillageStage(100, 0, 2, 30, 0,
@ -23,22 +20,22 @@ 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().toString()+" 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());
}
}
public void attackVillage(Map map) {
}
=======
public Map map;
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
public void attackVIllage(Map map) {
}
public Map generateMap() {
return null;
@ -49,8 +46,6 @@ public class GameEngine implements Runnable {
@Override
public void run() {
while (running) {
}
}
}

View File

@ -5,30 +5,18 @@ 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;
=======
public class Map {
private Village_Hall townHall;
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
private int guardTime;
<<<<<<< HEAD
public List<Building> contains;
=======
private List<Building> contains;
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
public List<Inhabitant> inhabitants;
<<<<<<< HEAD
public Map(Village_Hall villageHall, int gTime) {
contains = new ArrayList<>();
inhabitants = new ArrayList<>();
@ -45,31 +33,16 @@ public class Map {
}
public void build(Village_Hall hall, Tile t, Building b) {
public void build(Tile t, Building b) {
contains.add(b);
}
=======
public void move(Infantry i, Tile t) {
}
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
}

View File

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

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
public abstract class Building {
<<<<<<< HEAD
// members
private int level;
private int health;
@ -14,33 +13,13 @@ public abstract class Building {
private int goldCost;
private int ironCost;
private int woodCost;
=======
private static int level;
private int health;
private static Stage stages;
private int goldCost;
private int ironCost;
private int woodCost;
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
private int buildTime;
<<<<<<< HEAD
public ArrayList<Tile> tiles = new ArrayList<>();
public ArrayList<Inhabitant> inhabitants = new ArrayList<>();
// functions
=======
public List<Stage> stage;
public Tile tile;
public List<Inhabitant> inhabitant;
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
public int getLevel() {
return level;
@ -50,7 +29,6 @@ public abstract class Building {
return health;
}
<<<<<<< HEAD
public int getCost(String type) {
return (type.equals("gold")) ? (goldCost) :
(type.equals("iron")) ? (ironCost) : woodCost;
@ -59,17 +37,11 @@ public abstract class Building {
public Stage getStage() {
return stage;
}
=======
public int getCost(String type) {
return 0;
}
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
public int getUpgradeCost() {
return 0;
}
<<<<<<< HEAD
public void setLevel(int level) {
this.level = level;
}
@ -78,7 +50,9 @@ public abstract class Building {
this.health = health;
}
public void setStage(Stage stage) {this.stage = stage; }
public void setStage(Stage stage) {
this.stage = stage;
}
public void addInhabitant(Inhabitant newMember) {
inhabitants.add(newMember);
@ -94,14 +68,4 @@ public abstract class Building {
public int getBuildTime() {
return buildTime;
}
=======
public void upgrade() {
}
public int getBuildTime() {
return 0;
}
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
}

View File

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

View File

@ -2,7 +2,6 @@ package ca.cosc3p91.a2.gameobjects;
public class DefenseBuilding extends Building {
<<<<<<< HEAD
private int damage;
private int range;
@ -11,11 +10,6 @@ public class DefenseBuilding extends Building {
this.damage += stage.getDamageChange();
this.range += stage.getRangeChange();
}
=======
public int damage;
public int range;
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
public void attack(Infantry attacker) {

View File

@ -2,15 +2,10 @@ package ca.cosc3p91.a2.gameobjects;
class DefenseStage extends Stage {
<<<<<<< HEAD
protected int dDamage;
=======
protected int dDamge;
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
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);
@ -25,12 +20,5 @@ class DefenseStage extends Stage {
public int getRangeChange() {
return dRange;
}
=======
public void getDamageChange() {
}
public void getRangeChange() {
}
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
}

View File

@ -8,11 +8,9 @@ public class Farm extends ResourceBuilding {
}
public int getPopulationContribution() {
return 0;
return getHarvestRate();
}
@Override
public void harvest(Village_Hall hall) {
}
public void harvest(Village_Hall hall) {}
}

View File

@ -1,20 +0,0 @@
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) {
}
}

View File

@ -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;
}
}

View File

@ -6,9 +6,18 @@ 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;
}
}

View File

@ -4,7 +4,6 @@ public class IronMine extends ResourceBuilding {
public static String resource = "iron";
<<<<<<< HEAD
public IronMine(int lvl, ResourceStage baseStage) {
setLevel(lvl);
upgrade(baseStage);
@ -12,10 +11,6 @@ public class IronMine extends ResourceBuilding {
@Override
public void harvest(Village_Hall hall) {
=======
@Override
public void harvest(Village_Hall hall) {
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
hall.addCurrentIron(getHarvestRate());
}
}

View File

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

View File

@ -4,17 +4,13 @@ public class LumberMine extends ResourceBuilding {
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
hall.addCurrentWood(getHarvestRate());
}
}

View File

@ -1,11 +0,0 @@
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);
}

View File

@ -1,15 +1,36 @@
package ca.cosc3p91.a2.gameobjects;
import ca.cosc3p91.a2.util.Time;
public abstract class ResourceBuilding extends Building {
public static String resource;
private final Time harvestMinTime = new Time().offsetSeconds(10);
private int harvest_rate;
private Time nextHarvestTime;
public ResourceBuilding() {
nextHarvestTime = Time.getTime().offsetTime(harvestMinTime);
}
public void upgrade(ResourceStage stage) {
super.upgrade(stage);
this.harvest_rate += stage.getHarvestRateIncrease();
}
public abstract void harvest(Village_Hall hall);
public void update(Village_Hall hall){
if (nextHarvestTime.occurred()){
harvest(hall);
nextHarvestTime = Time.getTime().offsetTime(harvestMinTime);
}
}
protected abstract void harvest(Village_Hall hall);
public int getHarvestRate(){
return harvest_rate;
}
}

View File

@ -4,7 +4,6 @@ public class ResourceStage extends Stage {
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);
@ -14,10 +13,5 @@ public class ResourceStage extends Stage {
public int getHarvestRateIncrease() {
return harvestRateIncrease;
}
=======
public int getHarvestRateIncrease() {
return harvestRateIncrease;
}
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
}

View File

@ -0,0 +1,18 @@
package ca.cosc3p91.a2.gameobjects;
import ca.cosc3p91.a2.util.Time;
public class SaulGoodMine extends ResourceBuilding {
public static String resource = "gold";
public SaulGoodMine(int lvl, ResourceStage baseStage) {
setLevel(lvl);
upgrade(baseStage);
}
@Override
public void harvest(Village_Hall hall) {
hall.addCurrentGold(getHarvestRate());
}
}

View File

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

View File

@ -14,7 +14,6 @@ abstract class Stage {
protected int woodCost;
<<<<<<< HEAD
public Stage(int dHealth, int goldCost, int requiredVillageLevel, int upgradeTime, int ironCost, int woodCost) {
this.dHealth = dHealth;
this.goldCost = goldCost;
@ -32,16 +31,6 @@ abstract class Stage {
return (type.equals("gold")) ? (goldCost) :
(type.equals("iron")) ? (ironCost) : woodCost;
}
=======
public Building building;
public void getHealthChange() {
}
public int getCost(String type) {
return 0;
}
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
public int getRequiredVillageLevel() {
return requiredVillageLevel;

View File

@ -8,9 +8,4 @@ public class Tile {
public int y;
<<<<<<< HEAD
=======
public List<Building> building;
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
}

View File

@ -8,7 +8,6 @@ public class VillageStage extends Stage {
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);
@ -20,11 +19,6 @@ public class VillageStage extends Stage {
public int getGoldCapacityIncrease() {
return goldCapacityIncrease;
}
=======
public int getGoldCapacityIncrease() {
return goldCapacityIncrease;
}
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
public int getIronCapacityIncrease() {
return ironCapacityIncrease;

View File

@ -4,13 +4,14 @@ import java.util.ArrayList;
public class Village_Hall extends Building {
<<<<<<< HEAD
private int goldCapacity = 0;
private int ironCapacity = 0;
private int woodCapacity = 0;
private int currentGold;
private int currentIron;
private int currentWood;
public Village_Hall(int lvl, VillageStage baseStage) {
setLevel(lvl);
upgrade(baseStage);
@ -35,24 +36,28 @@ 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 getCurrentGold() {
return currentGold;
}
public int getIronCapacity() {
return ironCapacity;
public void addCurrentGold(int currentGold) {
this.currentGold += currentGold;
}
public int getWoodCapacity() {
return woodCapacity;
public int getCurrentIron() {
return currentIron;
}
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
public void addCurrentIron(int currentIron) {
this.currentIron += currentIron;
}
public int getCurrentWood() {
return currentWood;
}
public void addCurrentWood(int currentWood) {
this.currentWood += currentWood;
}
}

View File

@ -1,11 +1,34 @@
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);
}
}

View File

@ -2,16 +2,5 @@ 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
}

View File

@ -37,16 +37,8 @@ public class Time {
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;
}
return getTime().timeSeconds >= timeSeconds;
}
public static Time getTime() {