Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/war-points #18

Merged
merged 5 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -219,24 +219,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 @@ -264,6 +247,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 @@ -275,6 +264,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 @@ -20,6 +20,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 @@ -264,4 +266,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 @@ -248,7 +248,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