Skip to content

Commit

Permalink
Solves the bug:
Browse files Browse the repository at this point in the history
- Where a revolting Town was paid plunder when they lost a REVOLT siege
and the Nation chose to plunder: the money meant to be paid to soldiers
of the Nation was instead being paid to the soldiers of the Town.

- Renames a few things to make it clearer what they do.
  • Loading branch information
LlmDl committed Apr 24, 2021
1 parent 4bf4fab commit cfc6067
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
26 changes: 11 additions & 15 deletions src/main/java/com/gmail/goosius/siegewar/objects/Siege.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public class Siege {
private int cannonSessionRemainingShortTicks; //Short ticks remaining until standard cannon protections are restored
private int attackerBattlePoints;
private int defenderBattlePoints;
private Set<String> attackerBattleContributors; //UUID's of attackers who contributed during the current battle
private Map<String, Integer> residentTimedPointContributors; //UUID:numContributions map of attackers who contributed during current siege
private Set<String> successfulBattleContributors; //UUID's of residents who contributed during the current battle
private Map<String, Integer> residentTimedPointContributors; //UUID:numContributions map of residents who contributed during current siege

public Siege(Town town) {
this.town = town;
Expand All @@ -80,7 +80,7 @@ public Siege(Town town) {
cannonSessionRemainingShortTicks = 0;
attackerBattlePoints = 0;
defenderBattlePoints = 0;
attackerBattleContributors = new HashSet<>();
successfulBattleContributors = new HashSet<>();
residentTimedPointContributors = new HashMap<>();
}

Expand Down Expand Up @@ -389,16 +389,12 @@ public String getFormattedBattleTimeRemaining() {
}
}

public Set<String> getAttackerBattleContributors() {
return attackerBattleContributors;
public Set<String> getSuccessfulBattleContributors() {
return successfulBattleContributors;
}

public void setAttackerBattleContributors(Set<String> attackerBattleContributors) {
this.attackerBattleContributors = attackerBattleContributors;
}

public void clearAttackerBattleContributors() {
attackerBattleContributors.clear();
public void clearSuccessfulBattleContributors() {
successfulBattleContributors.clear();
}
public Map<String, Integer> getResidentTimedPointContributors() {
return residentTimedPointContributors;
Expand All @@ -408,14 +404,14 @@ public void setResidentTimedPointContributors(Map<String, Integer> residentTimed
this.residentTimedPointContributors = residentTimedPointContributors;
}

public void registerAttackerBattleContributorsFromBannerControl() {
public void registerSuccessfulBattleContributorsFromBannerControl() {
for(Resident resident: bannerControllingResidents) {
attackerBattleContributors.add(resident.getUUID().toString());
successfulBattleContributors.add(resident.getUUID().toString());
}
}

public void propagateAttackerBattleContributorsToResidentTimedPointContributors() {
for(String playerUuid: attackerBattleContributors) {
public void propagateSuccessfulBattleContributorsToResidentTimedPointContributors() {
for(String playerUuid: successfulBattleContributors) {
if(residentTimedPointContributors.containsKey(playerUuid)) {
residentTimedPointContributors.put(playerUuid, residentTimedPointContributors.get(playerUuid) + 1);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.gmail.goosius.siegewar.SiegeWar;
import com.gmail.goosius.siegewar.enums.SiegeSide;
import com.gmail.goosius.siegewar.enums.SiegeStatus;
import com.gmail.goosius.siegewar.enums.SiegeType;
import com.gmail.goosius.siegewar.objects.BannerControlSession;
import com.gmail.goosius.siegewar.objects.BattleSession;
import com.gmail.goosius.siegewar.objects.Siege;
Expand Down Expand Up @@ -35,7 +36,7 @@ public class SiegeWarBannerControlUtil {
public static void evaluateBannerControl(Siege siege) {
try {
if(siege.getStatus() == SiegeStatus.IN_PROGRESS) {
evaluateBannerControlEffects(siege);
evaluateBannerControlPoints(siege);
evaluateExistingBannerControlSessions(siege);
evaluateNewBannerControlSessions(siege);
}
Expand Down Expand Up @@ -290,7 +291,7 @@ public void run() {
}
}

private static void evaluateBannerControlEffects(Siege siege) {
private static void evaluateBannerControlPoints(Siege siege) {
if(!BattleSession.getBattleSession().isActive())
return;

Expand All @@ -305,12 +306,15 @@ private static void evaluateBannerControlEffects(Siege siege) {
battlePoints = siege.getBannerControllingResidents().size() * SiegeWarSettings.getWarBattlePointsForAttackerOccupation();
battlePoints = SiegeWarScoringUtil.applyBattlePointsAdjustmentForPopulationQuotient(true, battlePoints, siege);
siege.adjustAttackerBattlePoints(battlePoints);
siege.registerAttackerBattleContributorsFromBannerControl();
if (!siege.getSiegeType().equals(SiegeType.REVOLT))
siege.registerSuccessfulBattleContributorsFromBannerControl();
break;
case DEFENDERS:
battlePoints = siege.getBannerControllingResidents().size() * SiegeWarSettings.getWarBattlePointsForDefenderOccupation();
battlePoints = SiegeWarScoringUtil.applyBattlePointsAdjustmentForPopulationQuotient(false, battlePoints, siege);
siege.adjustDefenderBattlePoints(battlePoints);
if (siege.getSiegeType().equals(SiegeType.REVOLT))
siege.registerSuccessfulBattleContributorsFromBannerControl();
break;
default:
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void evaluateBattleSessions() {
siege.adjustSiegeBalance(battlePointsOfWinner);

//Propagate attacker battle contributions to siege history
siege.propagateAttackerBattleContributorsToResidentTimedPointContributors();
siege.propagateSuccessfulBattleContributorsToResidentTimedPointContributors();

//Prepare result for messaging
battleResults.put(siege, battlePointsOfWinner);
Expand All @@ -83,7 +83,7 @@ public void run() {
siege.clearBannerControlSessions();
siege.setAttackerBattlePoints(0);
siege.setDefenderBattlePoints(0);
siege.clearAttackerBattleContributors();
siege.clearSuccessfulBattleContributors();

//Save siege
SiegeController.saveSiege(siege);
Expand Down

0 comments on commit cfc6067

Please sign in to comment.