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

Fix point system and displays. #3

Merged
merged 1 commit into from
Mar 24, 2015
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
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,19 @@ private void monarchDeath(Player attackerPlayer, Player defenderPlayer, Resident
if (warEvent.isWarringNation(defenderNation))
if (defenderResident.isMayor())
if (defenderResident.isKing()) {
TownyMessaging.sendGlobalMessage(defenderNation.getName() + "'s king was killed!");
if (attackerResident != null && attackerResident.hasTown())
warEvent.remove(attackerResident.getTown(), defenderNation);
else
warEvent.remove(defenderNation);
TownyMessaging.sendGlobalMessage(defenderNation.getName() + "'s king was killed. Nation removed from war.");
//TownyMessaging.sendGlobalMessage(defenderNation.getName() + "'s king was killed. Nation removed from war.");
} else {
TownyMessaging.sendGlobalMessage(defenderResident.getTown() + "'s mayor was killed!");
if (attackerResident != null && attackerResident.hasTown())
warEvent.remove(attackerResident.getTown(), defenderResident.getTown());
else
warEvent.remove(defenderResident.getTown());
TownyMessaging.sendGlobalMessage(defenderResident.getTown() + "'s mayor was killed. Town removed from war.");
//TownyMessaging.sendGlobalMessage(defenderResident.getTown() + "'s mayor was killed. Town removed from war.");
}
} catch (NotRegisteredException e) {
}
Expand Down
95 changes: 64 additions & 31 deletions src/com/palmergames/bukkit/towny/war/eventwar/War.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void end() {
for (Player player : BukkitTools.getOnlinePlayers())
if (player != null)
sendStats(player);

double halfWinnings;
try {
// Transactions might leave 1 coin. (OH noez!)
Expand Down Expand Up @@ -260,11 +260,21 @@ public void remove(Town attacker, TownBlock townBlock) throws NotRegisteredExcep
} else
TownyMessaging.sendTownMessage(townBlock.getTown(), "Your town lost " + TownyEconomyHandler.getFormattedBalance(TownySettings.getWartimeTownBlockLossPrice()) + ".");
} catch (EconomyException e) {
}
if (townBlock.getTown().isHomeBlock(townBlock))
remove(townBlock.getTown());
else
}
if (townBlock.getTown().isHomeBlock(townBlock) && townBlock.getTown().isCapital()){
remove(attacker, townBlock.getTown().getNation());
} else if (townBlock.getTown().isHomeBlock(townBlock)){
remove(attacker, townBlock.getTown());
} else{
townScored(attacker, TownySettings.getWarPointsForTownBlock());
try {
Town town = townBlock.getTown();
TownyMessaging.sendGlobalMessage(TownySettings.getWarTimeLoseTownBlockMsg(townBlock.getWorldCoord(), town.getName()));
} catch (NotRegisteredException e) {
TownyMessaging.sendGlobalMessage(TownySettings.getWarTimeLoseTownBlockMsg(townBlock.getWorldCoord()));
}
remove(townBlock.getWorldCoord());
}
TownyUniverse.getDataSource().saveTown(townBlock.getTown());
TownyUniverse.getDataSource().saveTown(attacker);
}
Expand All @@ -279,21 +289,33 @@ public void remove(TownBlock townBlock) throws NotRegisteredException {

public void eliminate(Town town) {

remove(town);
//remove(town);
try {
checkNation(town.getNation());
} catch (NotRegisteredException e) {
TownyMessaging.sendErrorMsg("[War] Error checking " + town.getName() + "'s nation.");
}
TownyMessaging.sendGlobalMessage(TownySettings.getWarTimeEliminatedMsg(town.getName()));
checkEnd();
//checkEnd();
}

public void eliminate(Town town, String townBlocksFallen) {

//remove(town);
try {
checkNation(town.getNation());
} catch (NotRegisteredException e) {
TownyMessaging.sendErrorMsg("[War] Error checking " + town.getName() + "'s nation.");
}
TownyMessaging.sendGlobalMessage(TownySettings.getWarTimeEliminatedMsg(town.getName()) + " (" + townBlocksFallen + " town blocks captured");
//checkEnd();
}

public void eliminate(Nation nation) {

remove(nation);
//remove(nation);
TownyMessaging.sendGlobalMessage(TownySettings.getWarTimeEliminatedMsg(nation.getName()));
checkEnd();
//checkEnd();
}

public void nationLeave(Nation nation) {
Expand All @@ -312,41 +334,52 @@ public void townLeave(Town town) {
checkEnd();
}

public void remove(Town attacker, Nation nation) {
public void remove(Town attacker, Nation nation) throws NotRegisteredException {

townScored(attacker, TownySettings.getWarPointsForNation());
warringNations.remove(nation);
warringNations.remove(nation);
eliminate(nation);
for (Town town : nation.getTowns())
if (warringTowns.contains(town))
remove(attacker, town);
checkEnd();
}

public void remove(Nation nation) {

warringNations.remove(nation);
warringNations.remove(nation);
eliminate(nation);
for (Town town : nation.getTowns())
remove(town);
}

public void remove(Town attacker, Town town) throws NotRegisteredException {

townScored(attacker, TownySettings.getWarPointsForTown());

for (TownBlock townBlock : town.getTownBlocks())
remove(townBlock.getWorldCoord());
warringTowns.remove(town);
try {
if (!townsLeft(town.getNation()))
eliminate(town.getNation());
} catch (NotRegisteredException e) {
}
remove(town);
// try {
// if (!townsLeft(town.getNation()))
// eliminate(town.getNation());
// } catch (NotRegisteredException e) {
// }
}

public void remove(Town town) {

for (TownBlock townBlock : town.getTownBlocks())
remove(townBlock.getWorldCoord());
int fallenTownBlocks = 0;
warringTowns.remove(town);
try {
if (!townsLeft(town.getNation()))
eliminate(town.getNation());
} catch (NotRegisteredException e) {
}
for (TownBlock townBlock : town.getTownBlocks())
if (warZone.contains(townBlock.getWorldCoord())){
fallenTownBlocks++;
remove(townBlock.getWorldCoord());
}
eliminate (town, fallenTownBlocks + "");

// try {
// if (!townsLeft(town.getNation()))
// eliminate(town.getNation());
// } catch (NotRegisteredException e) {
// }
}

public boolean townsLeft(Nation nation) {
Expand All @@ -357,11 +390,11 @@ public boolean townsLeft(Nation nation) {
public void remove(WorldCoord worldCoord) {

try {
Town town = worldCoord.getTownBlock().getTown();
TownyMessaging.sendGlobalMessage(TownySettings.getWarTimeLoseTownBlockMsg(worldCoord, town.getName()));
//Town town = worldCoord.getTownBlock().getTown();
//TownyMessaging.sendGlobalMessage(TownySettings.getWarTimeLoseTownBlockMsg(worldCoord, town.getName()));
warZone.remove(worldCoord);
} catch (NotRegisteredException e) {
TownyMessaging.sendGlobalMessage(TownySettings.getWarTimeLoseTownBlockMsg(worldCoord));
//TownyMessaging.sendGlobalMessage(TownySettings.getWarTimeLoseTownBlockMsg(worldCoord));
warZone.remove(worldCoord);
}

Expand Down