Skip to content

Commit

Permalink
Merge pull request #18 from ShermansWorld/feature/war-points
Browse files Browse the repository at this point in the history
Feature/war-points
  • Loading branch information
AubriTheHuman authored Apr 27, 2023
2 parents 395e374 + fe231e3 commit ba6ebf6
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 181 deletions.
32 changes: 14 additions & 18 deletions src/main/java/me/ShermansWorld/AlathraWar/Siege.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,24 +235,7 @@ public void attackersWin(final OfflinePlayer siegeLeader) {
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The attackers have won the siege of " + this.town.getName() + "!");
try {
nation = resident.getTown().getNation();
} catch (NotRegisteredException e) {
for (final String playerName : this.attackerPlayers) {
try {
Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.Chatlabel()) + "The town of "
+ this.town.getName()
+ " could not be occupied because the player who started the siege is not part of a nation");
} catch (NullPointerException ex) {
}
}
for (final String playerName : this.defenderPlayers) {
try {
Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.Chatlabel()) + "The town of "
+ this.town.getName()
+ " could not be occupied because the player who started the siege is not part of a nation");
} catch (NullPointerException ex2) {
}
}
}
} catch (Exception e) {}
if (nation != null) {
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The town of " + this.town.getName()
+ " has been placed under occupation by " + nation.getName() + "!");
Expand Down Expand Up @@ -280,6 +263,12 @@ public void attackersWin(final OfflinePlayer siegeLeader) {
+ ", valuing $" + String.valueOf(amt));
Main.econ.depositPlayer(siegeLeader, amt);

if (side1AreAttackers) {
war.addSide1Points(50);
} else {
war.addSide2Points(50);
}

stop();
clearBeacon();
}
Expand All @@ -291,6 +280,13 @@ public void defendersWin() {
+ " has recovered the attackers' war chest, valued at $2,500");
Main.warLogger
.log(war.getName() + ": The defenders have won the siege of " + this.town.getName() + "!");

if (side1AreAttackers) {
war.addSide2Points(50);
} else {
war.addSide1Points(50);
}

stop();
clearBeacon();
}
Expand Down
162 changes: 0 additions & 162 deletions src/main/java/me/ShermansWorld/AlathraWar/UUIDFetcher.java

This file was deleted.

18 changes: 18 additions & 0 deletions src/main/java/me/ShermansWorld/AlathraWar/War.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class War {
private ArrayList<String> side1Towns = new ArrayList<String>();
private ArrayList<String> side2Towns = new ArrayList<String>();
private ArrayList<String> surrenderedTowns = new ArrayList<String>();
private int side1Points = 0;
private int side2Points = 0;

// References
private ArrayList<Siege> sieges = new ArrayList<Siege>();
Expand Down Expand Up @@ -268,4 +270,20 @@ public void setLastRaidTimeSide2(int lastRaidTime) {
public int getLastRaidTimeSide2() {
return this.lastRaidTimeSide2;
}

public int getSide1Points() {
return this.side1Points;
}

public int getSide2Points() {
return this.side2Points;
}

public void addSide1Points(int points) {
side1Points += points;
}

public void addSide2Points(int points){
side2Points += points;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private static void warList(Player p, String[] args) {
p.sendMessage("There are no current wars.");
} else {
for (War war : wars) {
p.sendMessage(war.getName() + " - " + war.getSide1() + " vs. " + war.getSide2());
p.sendMessage(war.getName() + " - " + war.getSide1() + "(" + war.getSide1Points() + ") vs. " + war.getSide2() + "(" + war.getSide2Points() + ")");
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/me/ShermansWorld/AlathraWar/data/WarData.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public static War fromMap(HashMap<String, Object> fileData) {
war.setSide2Towns((ArrayList<String>) fileData.get("side2Towns"));
war.setSurrenderedTowns((ArrayList<String>) fileData.get("surrenderedTowns"));

war.addSide1Points((int) fileData.get("side1Points"));
war.addSide2Points((int) fileData.get("side2Points"));

if(fileData.get("lastRaidTimeSide1") != null && fileData.get("lastRaidTimeSide2") != null) {
war.setLastRaidTimeSide1((int) fileData.get("lastRaidTimeSide1"));
war.setLastRaidTimeSide2((int) fileData.get("lastRaidTimeSide2"));
Expand Down Expand Up @@ -144,6 +147,8 @@ public static void saveWar(War war) {
sHashMap.put("side1Towns", (List<String>) war.getSide1Towns());
sHashMap.put("side2Towns", (List<String>) war.getSide2Towns());
sHashMap.put("surrenderedTowns", (List<String>) war.getSurrenderedTowns());
sHashMap.put("side1Points", war.getSide1Points());
sHashMap.put("side2Points", war.getSide2Points());

sHashMap.put("sieges", SiegeData.getSiegeMap(war));
sHashMap.put("raids", RaidData.getRaidMap(war));
Expand Down

0 comments on commit ba6ebf6

Please sign in to comment.