Saul Goodmine

main
mike 2023-03-01 16:16:08 -05:00
parent 713be595b8
commit c1c656674f
47 changed files with 300 additions and 53 deletions

124
.idea/uiDesigner.xml Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

View File

@ -7,6 +7,7 @@ public class Main {
public static void main(String[] args) { public static void main(String[] args) {
GameEngine engine = new GameEngine(); GameEngine engine = new GameEngine();
engine.printMap();
engine.run(); engine.run();
} }

View File

@ -1,5 +1,8 @@
package ca.cosc3p91.a2.game; 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.player.Player;
public class GameEngine implements Runnable { public class GameEngine implements Runnable {
@ -12,7 +15,22 @@ public class GameEngine implements Runnable {
public Map map; public Map map;
public void attackVIllage(Map map) { public GameEngine () {
player = new Player();
VillageStage vInitialStage = new VillageStage(100,0,2,30,0,
0, 12,12,12);
map = new Map(new Village_Hall(1,vInitialStage),30);
}
public void printMap() {
System.out.println("~ Current Map State ~\n\n");
System.out.println("In Map:\n");
for (Building b : map.contains) {
System.out.println("|> "+b.getClass().toString()+" lvl: "+b.getLevel()+" health: "+b.getHealth());
}
}
public void attackVillage(Map map) {
} }
public Map generateMap() { public Map generateMap() {

View File

@ -2,34 +2,47 @@ package ca.cosc3p91.a2.game;
import ca.cosc3p91.a2.gameobjects.*; import ca.cosc3p91.a2.gameobjects.*;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class Map { public class Map {
static int MAXSIZE = 400;
private Village_Hall townHall; private Village_Hall townHall;
private int guardTime; private int guardTime;
private List<Building> contains; public List<Building> contains;
public List<Inhabitant> inhabitants; public List<Inhabitant> inhabitants;
public Map (Village_Hall villageHall, int gTime) {
contains = new ArrayList<>();
inhabitants = new ArrayList<>();
this.townHall = villageHall;
this.contains.add(villageHall);
this.guardTime = gTime;
}
public void move(Infantry i, Tile t) { public void move(Infantry i, Tile t) {
} }
public void inRange(Infantry i, Building b) { public void inRange(Infantry i, Building b) {
} }
public void build(Village_Hall hall, Tile t, Building b) { public void build(Village_Hall hall, Tile t, Building b) {
contains.add(b);
} }
public int getGuardTime() { public int getGuardTime() {
return guardTime; return guardTime;
} }
public void setGuardTime() { public void setGuardTime(int gTime) {
this.guardTime = gTime;
} }
} }

View File

@ -1,27 +1,25 @@
package ca.cosc3p91.a2.gameobjects; package ca.cosc3p91.a2.gameobjects;
import java.util.List; import java.util.ArrayList;
public abstract class Building { public abstract class Building {
private static int level; // members
private int level;
private int health; private int health;
private static Stage stages; private Stage stage;
private int goldCost; private int goldCost;
private int ironCost; private int ironCost;
private int woodCost; private int woodCost;
private int buildTime; private int buildTime;
public List<Stage> stage; public ArrayList<Tile> tiles = new ArrayList<>();
public Tile tile; public ArrayList<Inhabitant> inhabitants = new ArrayList<>();
public List<Inhabitant> inhabitant; // functions
public int getLevel() { public int getLevel() {
return level; return level;
@ -32,19 +30,40 @@ public abstract class Building {
} }
public int getCost(String type) { public int getCost(String type) {
return 0; return (type.equals("gold"))?(goldCost):
(type.equals("iron"))?(ironCost):woodCost;
}
public Stage getStage() {
return stage;
} }
public int getUpgradeCost() { public int getUpgradeCost() {
return 0; return 0;
} }
public void upgrade() { public void setLevel(int level) {
this.level = level;
}
public void setHealth(int health) {
this.health = health;
}
public void setStage(Stage stage) {this.stage = stage; }
public void addInhabitant(Inhabitant newMember) {
inhabitants.add(newMember);
// newMember.setBuilding(this);
}
public void upgrade(Stage stage) {
this.stage = stage;
this.health += stage.dHealth;
// interact with the timer regarding Upgrade time
} }
public int getBuildTime() { public int getBuildTime() {
return 0; return buildTime;
} }
} }

View File

@ -2,9 +2,14 @@ package ca.cosc3p91.a2.gameobjects;
public class DefenseBuilding extends Building { public class DefenseBuilding extends Building {
public int damage; private int damage;
private int range;
public int range; public void upgrade(DefenseStage stage) {
super.upgrade(stage);
this.damage += stage.getDamageChange();
this.range += stage.getRangeChange();
}
public void attack(Infantry attacker) { public void attack(Infantry attacker) {

View File

@ -2,14 +2,23 @@ package ca.cosc3p91.a2.gameobjects;
class DefenseStage extends Stage { class DefenseStage extends Stage {
protected int dDamge; protected int dDamage;
protected int dRange; protected int dRange;
public void getDamageChange() { 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);
this.dDamage = damageIncrease;
this.dRange = rangeIncrease;
} }
public void getRangeChange() { public int getDamageChange() {
return dDamage;
}
public int getRangeChange() {
return dRange;
} }
} }

View File

@ -1,6 +1,11 @@
package ca.cosc3p91.a2.gameobjects; package ca.cosc3p91.a2.gameobjects;
public class Farm extends ResourceBuidling { public class Farm extends ResourceBuilding {
public Farm (int lvl, ResourceStage baseStage) {
setLevel(lvl);
upgrade(baseStage);
}
public int getPopulationContribution() { public int getPopulationContribution() {
return 0; return 0;

View File

@ -1,8 +1,13 @@
package ca.cosc3p91.a2.gameobjects; package ca.cosc3p91.a2.gameobjects;
public class GoldMine extends ResourceBuidling { public class GoldMine extends ResourceBuilding {
public static String resource = "good"; public static String resource = "gold";
public GoldMine (int lvl, ResourceStage baseStage) {
setLevel(lvl);
upgrade(baseStage);
}
@Override @Override
public void harvest(Village_Hall hall) { public void harvest(Village_Hall hall) {

View File

@ -1,9 +1,14 @@
package ca.cosc3p91.a2.gameobjects; package ca.cosc3p91.a2.gameobjects;
public class IronMine extends ResourceBuidling { public class IronMine extends ResourceBuilding {
public static String resource = "iron"; public static String resource = "iron";
public IronMine (int lvl, ResourceStage baseStage) {
setLevel(lvl);
upgrade(baseStage);
}
@Override @Override
public void harvest(Village_Hall hall) { public void harvest(Village_Hall hall) {

View File

@ -1,9 +1,14 @@
package ca.cosc3p91.a2.gameobjects; package ca.cosc3p91.a2.gameobjects;
public class LumberMine extends ResourceBuidling { public class LumberMine extends ResourceBuilding {
public static String resource = "wood"; public static String resource = "wood";
public LumberMine (int lvl, ResourceStage baseStage) {
setLevel(lvl);
upgrade(baseStage);
}
public void harvest(Village_Hall hall) { public void harvest(Village_Hall hall) {
} }

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

@ -0,0 +1,15 @@
package ca.cosc3p91.a2.gameobjects;
public abstract class ResourceBuilding extends Building {
public static String resource;
private int harvest_rate;
public void upgrade(ResourceStage stage) {
super.upgrade(stage);
this.harvest_rate += stage.getHarvestRateIncrease();
}
public abstract void harvest(Village_Hall hall);
}

View File

@ -4,6 +4,12 @@ public class ResourceStage extends Stage {
protected int harvestRateIncrease; protected int harvestRateIncrease;
public ResourceStage(int dHealth, int goldCost, int requiredVillageLevel, int upgradeTime, int ironCost, int woodCost,
int harvestRateIncr) {
super(dHealth,goldCost,requiredVillageLevel,upgradeTime,ironCost,woodCost);
this.harvestRateIncrease = harvestRateIncr;
}
public int getHarvestRateIncrease() { public int getHarvestRateIncrease() {
return harvestRateIncrease; return harvestRateIncrease;
} }

View File

@ -14,13 +14,22 @@ abstract class Stage {
protected int woodCost; protected int woodCost;
public Building building; public Stage(int dHealth, int goldCost, int requiredVillageLevel, int upgradeTime, int ironCost, int woodCost) {
this.dHealth = dHealth;
this.goldCost = goldCost;
this.requiredVillageLevel = requiredVillageLevel;
this.upgradeTime = upgradeTime;
this.ironCost = ironCost;
this.woodCost = woodCost;
}
public void getHealthChange() { public int getHealthChange() {
return dHealth;
} }
public int getCost(String type) { public int getCost(String type) {
return 0; return (type.equals("gold"))?(goldCost):
(type.equals("iron"))?(ironCost):woodCost;
} }
public int getRequiredVillageLevel() { public int getRequiredVillageLevel() {

View File

@ -8,6 +8,4 @@ public class Tile {
public int y; public int y;
public List<Building> building;
} }

View File

@ -1,6 +1,6 @@
package ca.cosc3p91.a2.gameobjects; package ca.cosc3p91.a2.gameobjects;
class VillageStage extends Stage { public class VillageStage extends Stage {
protected int goldCapacityIncrease; protected int goldCapacityIncrease;
@ -8,6 +8,14 @@ class VillageStage extends Stage {
protected int woodCapacityIncrease; protected int woodCapacityIncrease;
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);
this.goldCapacityIncrease = goldCapIncrease;
this.ironCapacityIncrease = ironCapIncrease;
this.woodCapacityIncrease = woodCapIncrease;
}
public int getGoldCapacityIncrease() { public int getGoldCapacityIncrease() {
return goldCapacityIncrease; return goldCapacityIncrease;
} }

View File

@ -1,23 +1,38 @@
package ca.cosc3p91.a2.gameobjects; package ca.cosc3p91.a2.gameobjects;
import java.util.ArrayList;
public class Village_Hall extends Building { public class Village_Hall extends Building {
private int goldCapacity; private int goldCapacity = 0;
private int ironCapacity; private int ironCapacity = 0;
private int woodCapacity = 0;
public Village_Hall (int lvl, VillageStage baseStage) {
setLevel(lvl);
upgrade(baseStage);
}
public void upgrade(VillageStage stage) {
super.upgrade(stage);
this.goldCapacity += stage.getGoldCapacityIncrease();
this.ironCapacity += stage.getIronCapacityIncrease();
this.woodCapacity += stage.getWoodCapacityIncrease();
}
private int woodCapacity;
public int getGoldCapacity() { public int getGoldCapacity() {
return goldCapacity; return goldCapacity;
} }
public int getIronCapacity() { public int getIronCapacity() {
return ironCapacity; return ironCapacity;
} }
public int getWoodCapacity() { public int getWoodCapacity() {
return woodCapacity; return woodCapacity;
} }
} }

View File

@ -3,9 +3,7 @@ package ca.cosc3p91.a2.player;
public class Player { public class Player {
public int currentGold; public int currentGold;
public int currentIron; public int currentIron;
public int currentWood; public int currentWood;
} }

Binary file not shown.