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

4
src/engine/workthreads/HourlyJobThread.java

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

Loading…
Cancel
Save