Browse Source

Mine Changes

lakebane-master
FatBoy-DOTC 9 months ago
parent
commit
6e93e40454
  1. 49
      src/engine/objects/Mine.java
  2. 4
      src/engine/workthreads/HourlyJobThread.java

49
src/engine/objects/Mine.java

@ -23,6 +23,7 @@ import java.sql.SQLException; @@ -23,6 +23,7 @@ import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom;
import static engine.gameManager.DbManager.MineQueries;
import static engine.gameManager.DbManager.getObject;
@ -55,6 +56,7 @@ public class Mine extends AbstractGameObject { @@ -55,6 +56,7 @@ public class Mine extends AbstractGameObject {
HashMap<Guild,ArrayList<Integer>> dividedPlayers;
public Integer totalPlayers;
public boolean hasProduced = false;
/**
* ResultSet Constructor
*/
@ -95,16 +97,16 @@ public class Mine extends AbstractGameObject { @@ -95,16 +97,16 @@ public class Mine extends AbstractGameObject {
this.production = Resource.valueOf(rs.getString("mine_resource"));
this.lastClaimer = null;
//int capRoll = ThreadLocalRandom.current().nextInt(0,100);
//if(capRoll >= 0 && capRoll <= 33){
int capRoll = ThreadLocalRandom.current().nextInt(0,101);
if(capRoll >= 0 && capRoll <= 33){
this.capSize = 5;
//}
//if(capRoll >= 34 && capRoll <= 66){
// this.capSize = 10;
//}
//if(capRoll >= 67 && capRoll <= 100){
// this.capSize = 20;
//}
}
if(capRoll >= 34 && capRoll <= 66){
this.capSize = 10;
}
if(capRoll >= 67 && capRoll <= 100){
this.capSize = 20;
}
Building mineTower = BuildingManager.getBuilding(this.buildingID);
mineTower.setMaxHitPoints(5000 * this.capSize);
mineTower.setCurrentHitPoints((float)5000 * this.capSize);
@ -328,14 +330,33 @@ public class Mine extends AbstractGameObject { @@ -328,14 +330,33 @@ public class Mine extends AbstractGameObject {
}
public boolean changeProductionType(Resource resource) {
if (!this.validForMine(resource))
return false;
//if (!this.validForMine(resource))
// return false;
//update resource in database;
if (!MineQueries.CHANGE_RESOURCE(this, resource))
return false;
if(this.isActive)
return false;
this.production = resource;
return true;
this.hasProduced = true;
ItemBase resourceIB = ItemBase.getItemBase(this.production.UUID);
int value = Warehouse.getCostForResource(this.production.UUID);
int amount = 0;
switch(this.capSize){
case 5:
amount = (int)(3000000/value);
break;
case 10:
amount = (int)(6000000/value);
break;
case 20:
amount = (int)(9000000/value);
break;
}
return this.owningGuild.getOwnedCity().getWarehouse().depositFromMine(this, resourceIB, amount);
}
public MineProduction getMineType() {
@ -442,7 +463,7 @@ public class Mine extends AbstractGameObject { @@ -442,7 +463,7 @@ public class Mine extends AbstractGameObject {
this.owningGuild = Guild.getErrantGuild();
this.lastClaimer = null;
this.wasClaimed = false;
this.hasProduced = false;
// Update database
DbManager.MineQueries.CHANGE_OWNER(this, 0);
@ -551,7 +572,7 @@ public class Mine extends AbstractGameObject { @@ -551,7 +572,7 @@ public class Mine extends AbstractGameObject {
}
public boolean isExpansion() {
return (this.flags & 2) != 0;
return true;
}
public int getModifiedProductionAmount() {

4
src/engine/workthreads/HourlyJobThread.java

@ -221,7 +221,9 @@ public class HourlyJobThread implements Runnable { @@ -221,7 +221,9 @@ public class HourlyJobThread implements Runnable {
for (Mine mine : Mine.getMines()) {
try {
mine.depositMineResources();
if (mine.hasProduced == false) {
mine.depositMineResources();
}
} catch (Exception e) {
Logger.info(e.getMessage() + " for Mine " + mine.getObjectUUID());
}

Loading…
Cancel
Save