Browse Source

Mine limits based upon nation tree rank.

master
MagicBot 2 years ago
parent
commit
20dba75602
  1. 39
      src/engine/objects/Mine.java
  2. 2
      src/engine/powers/poweractions/ClaimMinePowerAction.java

39
src/engine/objects/Mine.java

@ -28,7 +28,6 @@ import engine.net.DispatchMessage;
import engine.net.client.msg.ErrorPopupMsg; import engine.net.client.msg.ErrorPopupMsg;
import engine.net.client.msg.chat.ChatSystemMsg; import engine.net.client.msg.chat.ChatSystemMsg;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import engine.session.SessionID;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.net.UnknownHostException; import java.net.UnknownHostException;
@ -47,13 +46,12 @@ public class Mine extends AbstractGameObject {
private Resource production; private Resource production;
private boolean isActive = false; private boolean isActive = false;
public boolean wasClaimed = false;
private float latitude; private float latitude;
private float longitude; private float longitude;
private float altitude; private float altitude;
private Guild owningGuild; private Guild owningGuild;
public PlayerCharacter lastClaimer; public PlayerCharacter lastClaimer;
public boolean wasClaimed = false;
private int flags; private int flags;
private int buildingID; private int buildingID;
private Zone parentZone; private Zone parentZone;
@ -287,15 +285,11 @@ public class Mine extends AbstractGameObject {
int guildWOO = mineOwnerGuild.getNation().getMineTime(); int guildWOO = mineOwnerGuild.getNation().getMineTime();
LocalDateTime guildMineTime = mineOpenTime.withHour(guildWOO); LocalDateTime guildMineTime = mineOpenTime.withHour(guildWOO);
if (mineOpenTime.isAfter(guildMineTime)) if (mineOpenTime.isAfter(guildMineTime) || mine.wasClaimed == true)
mineOpenTime = guildMineTime.plusDays(1); mineOpenTime = guildMineTime.plusDays(1);
else else
mineOpenTime = guildMineTime; mineOpenTime = guildMineTime;
// Mines can only open once per cycle
if (mine.wasClaimed == true)
mineOpenTime = guildMineTime.plusDays(1);
} }
writer.putLocalDateTime(mineOpenTime); writer.putLocalDateTime(mineOpenTime);
@ -395,31 +389,38 @@ public class Mine extends AbstractGameObject {
if (playerGuild.getNation().isErrant()) if (playerGuild.getNation().isErrant())
return false; return false;
if (SessionManager.getPlayerCharacterByID(playerCharacter.getObjectUUID()) == null)
return false;
//Get a count of nation mines, can't go over capital tol rank. //Get a count of nation mines, can't go over capital tol rank.
City capital = playerGuild.getOwnedCity(); City nationCapitol = playerGuild.getNation().getOwnedCity();
City guildCity = playerGuild.getOwnedCity(); City guildCity = playerGuild.getOwnedCity();
if (guildCity == null) if (nationCapitol == null)
return false; return false;
if (capital == null) if (guildCity == null)
return false; return false;
if (guildCity.getWarehouse() == null) if (guildCity.getWarehouse() == null)
return false; return false;
Building tol = capital.getTOL(); Building nationCapitolTOL = nationCapitol.getTOL();
if (tol == null) if (nationCapitolTOL == null)
return false; return false;
int rank = tol.getRank(); int treeRank = nationCapitolTOL.getRank();
if (treeRank < 1)
return false;
if (rank < 1) if (guildUnderMineLimit(playerGuild.getNation(), treeRank) == false){
ErrorPopupMsg.sendErrorMsg(playerCharacter, "Your nation cannot support another mine.");
return false; return false;
}
return true;
}
private static boolean guildUnderMineLimit(Guild playerGuild, int tolRank) {
int mineCnt = 0; int mineCnt = 0;
@ -428,7 +429,7 @@ public class Mine extends AbstractGameObject {
for (Guild guild : playerGuild.getSubGuildList()) for (Guild guild : playerGuild.getSubGuildList())
mineCnt += Mine.getMinesForGuild(guild.getObjectUUID()).size(); mineCnt += Mine.getMinesForGuild(guild.getObjectUUID()).size();
if (mineCnt > rank) if (mineCnt > tolRank)
return false; return false;
return true; return true;

2
src/engine/powers/poweractions/ClaimMinePowerAction.java

@ -52,8 +52,6 @@ public class ClaimMinePowerAction extends AbstractPowerAction {
if (mine.claimMine(playerCharacter) == true) if (mine.claimMine(playerCharacter) == true)
ChatManager.sendSystemMessage( (PlayerCharacter) source, "You successfully claimed this mine.."); ChatManager.sendSystemMessage( (PlayerCharacter) source, "You successfully claimed this mine..");
else
ChatManager.sendSystemMessage( (PlayerCharacter) source, "Your attempt for to claim this mine failed.");
} }
@Override @Override

Loading…
Cancel
Save