Browse Source

OwningGuild should be set to errant not null.

master
MagicBot 2 years ago
parent
commit
e78d1f4ac4
  1. 18
      src/engine/objects/Mine.java

18
src/engine/objects/Mine.java

@ -102,7 +102,8 @@ public class Mine extends AbstractGameObject {
this.owningGuild = Guild.getGuild(ownerUID); this.owningGuild = Guild.getGuild(ownerUID);
Guild nation = null; Guild nation = null;
if (this.owningGuild != null && !this.owningGuild.isErrant()) {
if (!this.owningGuild.isErrant()) {
this.guildName = this.owningGuild.getName(); this.guildName = this.owningGuild.getName();
this.guildTag = this.owningGuild.getGuildTag(); this.guildTag = this.owningGuild.getGuildTag();
nation = this.owningGuild.getNation(); nation = this.owningGuild.getNation();
@ -207,6 +208,9 @@ public class Mine extends AbstractGameObject {
} }
public Guild getOwningGuild() { public Guild getOwningGuild() {
if (this.owningGuild == null)
return Guild.getErrantGuild();
else
return this.owningGuild; return this.owningGuild;
} }
@ -323,7 +327,7 @@ public class Mine extends AbstractGameObject {
public static ArrayList<Mine> getMinesForGuild(int guildID) { public static ArrayList<Mine> getMinesForGuild(int guildID) {
ArrayList<Mine> mineList = new ArrayList<>(); ArrayList<Mine> mineList = new ArrayList<>();
for (Mine mine : Mine.mineMap.keySet()) { for (Mine mine : Mine.mineMap.keySet()) {
if (mine.owningGuild != null && mine.owningGuild.getObjectUUID() == guildID) if (mine.owningGuild.getObjectUUID() == guildID)
mineList.add(mine); mineList.add(mine);
} }
return mineList; return mineList;
@ -434,7 +438,7 @@ public class Mine extends AbstractGameObject {
this.guildName = ""; this.guildName = "";
this.nationName = ""; this.nationName = "";
this.owningGuild = null; this.owningGuild = Guild.getErrantGuild();
Mine.setLastChange(System.currentTimeMillis()); Mine.setLastChange(System.currentTimeMillis());
// Update database // Update database
@ -492,7 +496,7 @@ public class Mine extends AbstractGameObject {
return false; return false;
} }
if (this.owningGuild == null || this.owningGuild.isErrant() || this.owningGuild.getNation().isErrant()) if (this.owningGuild.isErrant() || this.owningGuild.getNation().isErrant())
return false; return false;
//Update ownership to map //Update ownership to map
@ -557,7 +561,7 @@ public class Mine extends AbstractGameObject {
public boolean depositMineResources() { public boolean depositMineResources() {
if (this.owningGuild == null) if (this.owningGuild.isErrant())
return false; return false;
if (this.owningGuild.getOwnedCity() == null) if (this.owningGuild.getOwnedCity() == null)
@ -583,7 +587,7 @@ public class Mine extends AbstractGameObject {
} }
if (pc == null) { if (pc == null) {
this.owningGuild = null; this.owningGuild = Guild.getErrantGuild();
this.guildName = "None"; this.guildName = "None";
this.guildTag = GuildTag.ERRANT; this.guildTag = GuildTag.ERRANT;
this.nationName = "None"; this.nationName = "None";
@ -661,7 +665,7 @@ public class Mine extends AbstractGameObject {
if (this.isExpansion()) if (this.isExpansion())
return (int) totalModded; return (int) totalModded;
if (this.owningGuild != null) { if (this.owningGuild.isErrant() == false) {
if (this.owningGuild.getOwnedCity() != null) { if (this.owningGuild.getOwnedCity() != null) {
float distanceSquared = this.owningGuild.getOwnedCity().getLoc().distanceSquared2D(mineBuilding.getLoc()); float distanceSquared = this.owningGuild.getOwnedCity().getLoc().distanceSquared2D(mineBuilding.getLoc());

Loading…
Cancel
Save