Browse Source

universal mines round 2

lakebane-master
FatBoy-DOTC 7 months ago
parent
commit
0dca6c4662
  1. 18
      src/engine/db/handlers/dbMineHandler.java
  2. 6
      src/engine/objects/Mine.java
  3. 22
      src/engine/objects/MineProduction.java

18
src/engine/db/handlers/dbMineHandler.java

@ -33,8 +33,24 @@ public class dbMineHandler extends dbHandlerBase {
if (id == 0) if (id == 0)
return null; return null;
Mine mine = (Mine) DbManager.getFromCache(Enum.GameObjectType.Mine, id); Mine mine = (Mine) DbManager.getFromCache(Enum.GameObjectType.Mine, id);
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM obj_mine;")) {
//preparedStatement.setInt(1, id);
ResultSet rs = preparedStatement.executeQuery();
while(rs.next()){
if(rs.getInt("UID") == id){
int towerUID = rs.getInt("mine_buildingUID");
mine = Mine.getMineFromTower(towerUID);
}
}
} catch (SQLException e) {
Logger.error(e);
}
if (mine != null) if (mine != null)
return mine; return mine;

6
src/engine/objects/Mine.java

@ -72,8 +72,8 @@ public class Mine extends AbstractGameObject {
public Mine(ResultSet rs) throws SQLException, UnknownHostException { public Mine(ResultSet rs) throws SQLException, UnknownHostException {
super(rs); super(rs);
//this.mineType = MineProduction.getByName(rs.getString("mine_type")); this.mineType = MineProduction.getByName(rs.getString("mine_type"));
this.mineType = MineProduction.LUMBER; //this.mineType = MineProduction.LUMBER;
int ownerUID = rs.getInt("mine_ownerUID"); int ownerUID = rs.getInt("mine_ownerUID");
this.buildingID = rs.getInt("mine_buildingUID"); this.buildingID = rs.getInt("mine_buildingUID");
@ -282,7 +282,7 @@ public class Mine extends AbstractGameObject {
for (Mine mine : serverMines) { for (Mine mine : serverMines) {
Mine.mineMap.put(mine, mine.buildingID); Mine.mineMap.put(mine, mine.buildingID);
Mine.towerMap.put(mine.buildingID, mine); Mine.towerMap.put(mine.buildingID, mine);
mine.mineType = MineProduction.LUMBER; //mine.mineType = MineProduction.LUMBER;
} }
try { try {

22
src/engine/objects/MineProduction.java

@ -36,33 +36,11 @@ public enum MineProduction {
public static void addResources() { public static void addResources() {
if (MineProduction.LUMBER.resources.size() == 0) { if (MineProduction.LUMBER.resources.size() == 0) {
// MineProduction.LUMBER.resources.put(7, Resource.GOLD);
// MineProduction.LUMBER.resources.put(1580004, Resource.LUMBER);
// MineProduction.LUMBER.resources.put(1580005, Resource.OAK);
// MineProduction.LUMBER.resources.put(1580006, Resource.BRONZEWOOD);
// MineProduction.LUMBER.resources.put(1580007, Resource.MANDRAKE);
MineProduction.LUMBER.resources.put(7, Resource.GOLD); MineProduction.LUMBER.resources.put(7, Resource.GOLD);
MineProduction.LUMBER.resources.put(1580004, Resource.LUMBER); MineProduction.LUMBER.resources.put(1580004, Resource.LUMBER);
MineProduction.LUMBER.resources.put(1580005, Resource.OAK); MineProduction.LUMBER.resources.put(1580005, Resource.OAK);
MineProduction.LUMBER.resources.put(1580006, Resource.BRONZEWOOD); MineProduction.LUMBER.resources.put(1580006, Resource.BRONZEWOOD);
MineProduction.LUMBER.resources.put(1580007, Resource.MANDRAKE); MineProduction.LUMBER.resources.put(1580007, Resource.MANDRAKE);
MineProduction.LUMBER.resources.put(1580012, Resource.AZOTH);
MineProduction.LUMBER.resources.put(1580013, Resource.ORICHALK);
MineProduction.LUMBER.resources.put(1580014, Resource.ANTIMONY);
MineProduction.LUMBER.resources.put(1580015, Resource.SULFUR);
MineProduction.LUMBER.resources.put(1580016, Resource.QUICKSILVER);
MineProduction.LUMBER.resources.put(1580000, Resource.STONE);
MineProduction.LUMBER.resources.put(1580008, Resource.COAL);
MineProduction.LUMBER.resources.put(1580009, Resource.AGATE);
MineProduction.LUMBER.resources.put(1580010, Resource.DIAMOND);
MineProduction.LUMBER.resources.put(1580011, Resource.ONYX);
MineProduction.LUMBER.resources.put(1580001, Resource.TRUESTEEL);
MineProduction.LUMBER.resources.put(1580002, Resource.IRON);
MineProduction.LUMBER.resources.put(1580003, Resource.ADAMANT);
MineProduction.LUMBER.resources.put(1580018, Resource.WORMWOOD);
MineProduction.LUMBER.resources.put(1580020, Resource.BLOODSTONE);
MineProduction.LUMBER.resources.put(1580019, Resource.OBSIDIAN);
MineProduction.LUMBER.resources.put(1580017, Resource.GALVOR);
} }
if (MineProduction.ORE.resources.size() == 0) { if (MineProduction.ORE.resources.size() == 0) {
MineProduction.ORE.resources.put(7, Resource.GOLD); MineProduction.ORE.resources.put(7, Resource.GOLD);

Loading…
Cancel
Save