diff --git a/README.md b/README.md index 6e5ebec..5fc2673 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A small Java based game where creating the A.I. is the fun part. About ----- -Using the API (coming soon) and the [SampleDrone](https://github.com/tgrosinger/Nomads-Sample-Drone) create a drone of your own that can destroy all the other drones. +Using the [API](https://github.com/tgrosinger/Nomads/downloads) and the [SampleDrone](https://github.com/tgrosinger/Nomads-Sample-Drone) create a drone of your own that can destroy all the other drones. A sucessful drone will be able to gather resources, avoid the law and other malicious drones, and even reproduce to increase it's forces. Wiki diff --git a/bin/net/grosinger/nomads/Building$Structure.class b/bin/net/grosinger/nomads/Building$Structure.class index f8e0131..867b1c9 100644 Binary files a/bin/net/grosinger/nomads/Building$Structure.class and b/bin/net/grosinger/nomads/Building$Structure.class differ diff --git a/bin/net/grosinger/nomads/Building.class b/bin/net/grosinger/nomads/Building.class index 1d7da41..4753945 100644 Binary files a/bin/net/grosinger/nomads/Building.class and b/bin/net/grosinger/nomads/Building.class differ diff --git a/bin/net/grosinger/nomads/DroneTools.class b/bin/net/grosinger/nomads/DroneTools.class index 47ad856..2b73330 100644 Binary files a/bin/net/grosinger/nomads/DroneTools.class and b/bin/net/grosinger/nomads/DroneTools.class differ diff --git a/bin/net/grosinger/nomads/House.class b/bin/net/grosinger/nomads/House.class index 521d1bd..dc4d6b7 100644 Binary files a/bin/net/grosinger/nomads/House.class and b/bin/net/grosinger/nomads/House.class differ diff --git a/bin/net/grosinger/nomads/InitializeGame.class b/bin/net/grosinger/nomads/InitializeGame.class index 9f232c3..4c2177c 100644 Binary files a/bin/net/grosinger/nomads/InitializeGame.class and b/bin/net/grosinger/nomads/InitializeGame.class differ diff --git a/bin/net/grosinger/nomads/NeighborBuilding.class b/bin/net/grosinger/nomads/NeighborBuilding.class index 014ff27..ba10c9d 100644 Binary files a/bin/net/grosinger/nomads/NeighborBuilding.class and b/bin/net/grosinger/nomads/NeighborBuilding.class differ diff --git a/bin/net/grosinger/nomads/PoliceStation.class b/bin/net/grosinger/nomads/PoliceStation.class new file mode 100644 index 0000000..0ed2b42 Binary files /dev/null and b/bin/net/grosinger/nomads/PoliceStation.class differ diff --git a/bin/net/grosinger/nomads/RepairShop.class b/bin/net/grosinger/nomads/RepairShop.class new file mode 100644 index 0000000..f402588 Binary files /dev/null and b/bin/net/grosinger/nomads/RepairShop.class differ diff --git a/bin/net/grosinger/nomads/TownHall.class b/bin/net/grosinger/nomads/TownHall.class index b066d56..f276cbc 100644 Binary files a/bin/net/grosinger/nomads/TownHall.class and b/bin/net/grosinger/nomads/TownHall.class differ diff --git a/bin/net/grosinger/nomads/UpgradeShop.class b/bin/net/grosinger/nomads/UpgradeShop.class new file mode 100644 index 0000000..b4580ad Binary files /dev/null and b/bin/net/grosinger/nomads/UpgradeShop.class differ diff --git a/src/net/grosinger/nomads/Building.java b/src/net/grosinger/nomads/Building.java index 86c934e..3413350 100644 --- a/src/net/grosinger/nomads/Building.java +++ b/src/net/grosinger/nomads/Building.java @@ -9,9 +9,6 @@ package net.grosinger.nomads; * UpgradeShop - 2 * PoliceStation - 3 * Home - 1 - * - * - * */ public class Building implements GameObject { Structure structure; diff --git a/src/net/grosinger/nomads/DroneTools.java b/src/net/grosinger/nomads/DroneTools.java index ee0121e..09c7f37 100644 --- a/src/net/grosinger/nomads/DroneTools.java +++ b/src/net/grosinger/nomads/DroneTools.java @@ -155,9 +155,30 @@ public class DroneTools { + i, getY() + j); if (objectHere instanceof Building) { Building buildingHere = (Building) objectHere; - NeighborBuilding aWildNeighbor = new NeighborBuilding( - buildingHere.getX(), buildingHere.getY(), - buildingHere.getName(), buildingHere); + NeighborBuilding aWildNeighbor; + + if (buildingHere.getType() == Structure.TOWNHALL) { + aWildNeighbor = new TownHall(buildingHere.getX(), + buildingHere.getY(), + buildingHere.getName(), buildingHere); + } else if (buildingHere.getType() == Structure.REPAIRSHOP) { + aWildNeighbor = new RepairShop(buildingHere.getX(), + buildingHere.getY(), + buildingHere.getName(), buildingHere); + } else if (buildingHere.getType() == Structure.UPGRADESHOP) { + aWildNeighbor = new UpgradeShop( + buildingHere.getX(), buildingHere.getY(), + buildingHere.getName(), buildingHere); + } else if (buildingHere.getType() == Structure.POLICESTATION) { + aWildNeighbor = new PoliceStation( + buildingHere.getX(), buildingHere.getY(), + buildingHere.getName(), buildingHere); + } else { + aWildNeighbor = new NeighborBuilding( + buildingHere.getX(), buildingHere.getY(), + buildingHere.getName(), buildingHere); + } + neighbors.add(aWildNeighbor); } } @@ -212,7 +233,7 @@ public class DroneTools { findEmptyPoint(intendedPoint); House newHouse = new House(Structure.HOUSE, intendedPoint.getX(), - intendedPoint.getY(), referredDrone.getName()); + intendedPoint.getY(), currentTeam); worldReference.placeNewBuilding(newHouse); currentTeam.deductFromBalance(Nomads.HOUSEPRICE); listItem.setWaiting(Nomads.CREATIONTIME); diff --git a/src/net/grosinger/nomads/House.java b/src/net/grosinger/nomads/House.java index 2001dbb..9a031b4 100644 --- a/src/net/grosinger/nomads/House.java +++ b/src/net/grosinger/nomads/House.java @@ -5,30 +5,13 @@ package net.grosinger.nomads; * team */ public class House extends Building { - - private String team; private int turnCreated; - public House(Structure thisBuilding, int newX, int newY) { - super(thisBuilding, newX, newY); + public House(Structure thisBuilding, int newX, int newY, DroneTeam team) { + super(thisBuilding, newX, newY, team); turnCreated = Nomads.turn; } - public House(Structure thisBuilding, int newX, int newY, String teamName) { - super(thisBuilding, newX, newY); - team = teamName; - turnCreated = Nomads.turn; - } - - /** - * Retrieve the name of team that owns this house - * - * @return String - */ - public String getTeam() { - return team; - } - /** * Calculates the age of the house * @@ -37,14 +20,4 @@ public class House extends Building { public int getAge() { return Nomads.turn - turnCreated; } - - /** - * Sets the name of the team that owns this house - * - * @param newTeam - * String House owner - */ - public void setTeam(String newTeam) { - team = newTeam; - } } diff --git a/src/net/grosinger/nomads/InitializeGame.java b/src/net/grosinger/nomads/InitializeGame.java index 7f59baf..5444f2e 100644 --- a/src/net/grosinger/nomads/InitializeGame.java +++ b/src/net/grosinger/nomads/InitializeGame.java @@ -29,7 +29,8 @@ public class InitializeGame { * @throws IOException * @throws ClassNotFoundException */ - public static void initializeDrones() throws ClassNotFoundException, IOException { + public static void initializeDrones() throws ClassNotFoundException, + IOException { if (Nomads.DEBUGSTATUS) System.out.println("Loading the drones into world..."); /* @@ -52,9 +53,11 @@ public class InitializeGame { if (Nomads.DEBUGSTATUS) System.out.println("Loading " + filename); - File file = new File(System.getProperty("user.dir") + "/drones/" + filename); + File file = new File(System.getProperty("user.dir") + "/drones/" + + filename); - URLClassLoader clazzLoader = URLClassLoader.newInstance(new URL[] { file.toURI().toURL() }); + URLClassLoader clazzLoader = URLClassLoader + .newInstance(new URL[] { file.toURI().toURL() }); // System.class.getClassLoader() JarFile jarFile = new JarFile(file); @@ -65,7 +68,8 @@ public class InitializeGame { if (element.getName().endsWith(className + ".class")) { try { @SuppressWarnings("rawtypes") - Class c = clazzLoader.loadClass(element.getName().replaceAll(".class", "").replaceAll("/", ".")); + Class c = clazzLoader.loadClass(element.getName() + .replaceAll(".class", "").replaceAll("/", ".")); // Create new GameObject GameObject newGameObject = (GameObject) c.newInstance(); @@ -145,10 +149,11 @@ public class InitializeGame { if (Nomads.DEBUGSTATUS) System.out.println("Generating and placing required buildings..."); - Building townHall = new Building(Structure.TOWNHALL, 30, 40); - Building upgradeShop = new Building(Structure.UPGRADESHOP, 30, 60); - Building policeStation = new Building(Structure.POLICESTATION, 50, 40); - Building RepairShop = new Building(Structure.REPAIRSHOP, 50, 60); + Building townHall = new Building(Structure.TOWNHALL, 30, 40, null); + Building upgradeShop = new Building(Structure.UPGRADESHOP, 30, 60, null); + Building policeStation = new Building(Structure.POLICESTATION, 50, 40, + null); + Building RepairShop = new Building(Structure.REPAIRSHOP, 50, 60, null); if (Nomads.DEBUGSTATUS) System.out.println("Building generation complete"); diff --git a/src/net/grosinger/nomads/NeighborBuilding.java b/src/net/grosinger/nomads/NeighborBuilding.java index 046907d..f5a14cd 100644 --- a/src/net/grosinger/nomads/NeighborBuilding.java +++ b/src/net/grosinger/nomads/NeighborBuilding.java @@ -1,7 +1,5 @@ package net.grosinger.nomads; -import net.grosinger.nomads.Building.Structure; - /** * An array of NeigborBuildings will be given to a drone that is searching for * the buildings it is near. This is typically done from the town center. @@ -53,15 +51,6 @@ public class NeighborBuilding implements GameObject { return y; } - /** - * Retrieve type of building that this is - * - * @return Structure - */ - public Structure getType() { - return building.getType(); - } - /** * Retrieve the name of the team that owns the current building. If the * building is a public building, the string will be "Public". diff --git a/src/net/grosinger/nomads/PoliceStation.java b/src/net/grosinger/nomads/PoliceStation.java new file mode 100644 index 0000000..ef01478 --- /dev/null +++ b/src/net/grosinger/nomads/PoliceStation.java @@ -0,0 +1,13 @@ +package net.grosinger.nomads; + +/** + * A representation of a PoliceStation. Allows Drones to interact with this + * building. + */ +public class PoliceStation extends NeighborBuilding { + + public PoliceStation(int x, int y, String name, Building building) { + super(x, y, name, building); + } + +} diff --git a/src/net/grosinger/nomads/RepairShop.java b/src/net/grosinger/nomads/RepairShop.java new file mode 100644 index 0000000..790fc89 --- /dev/null +++ b/src/net/grosinger/nomads/RepairShop.java @@ -0,0 +1,13 @@ +package net.grosinger.nomads; + +/** + * A representation of a RepairShop. Allows Drones to interact with this + * building. + */ +public class RepairShop extends NeighborBuilding { + + public RepairShop(int x, int y, String name, Building building) { + super(x, y, name, building); + } + +} diff --git a/src/net/grosinger/nomads/TownHall.java b/src/net/grosinger/nomads/TownHall.java index 36645b3..fff8340 100644 --- a/src/net/grosinger/nomads/TownHall.java +++ b/src/net/grosinger/nomads/TownHall.java @@ -2,10 +2,13 @@ package net.grosinger.nomads; import java.util.ArrayList; -public class TownHall extends Building { +/** + * A representation of a TownHall. Allows Drones to interact with this building. + */ +public class TownHall extends NeighborBuilding { - public TownHall(int newX, int newY) { - super(Structure.TOWNHALL, newX, newY); + public TownHall(int x, int y, String name, Building building) { + super(x, y, name, building); } public void cashInventory(ArrayList inventory, DroneTeam team) { @@ -21,8 +24,8 @@ public class TownHall extends Building { inventory.remove(currentObject); } } - - public Point requestNewObjective(String UID){ + + public Point requestNewObjective(String UID) { return Nomads.awesomeWorld.generateObjective(UID); } } diff --git a/src/net/grosinger/nomads/UpgradeShop.java b/src/net/grosinger/nomads/UpgradeShop.java new file mode 100644 index 0000000..54331d0 --- /dev/null +++ b/src/net/grosinger/nomads/UpgradeShop.java @@ -0,0 +1,13 @@ +package net.grosinger.nomads; + +/** + * A representation of an UpgradeShop. Allows Drones to interact with this + * building. + */ +public class UpgradeShop extends NeighborBuilding { + + public UpgradeShop(int x, int y, String name, Building building) { + super(x, y, name, building); + } + +}