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

Add Option to force players to either Plunder or Invade a Town #927

Merged
merged 4 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -124,6 +124,9 @@ private static void allowInvasionOrThrow(Player player, Nation residentsNation,
if (siege.isTownInvaded())
throw new TownyException(translator.of("msg_err_town_already_invaded"));

if (SiegeWarSettings.isOnlyOneActionEnabled() && siege.isTownPlundered())
throw new TownyException(translator.of("msg_err_town_already_plundered_only_one_action"));

SiegeWarDistanceUtil.throwIfTownIsTooFarFromNationCapitalByWorld(residentsNation, targetTown);

SiegeWarDistanceUtil.throwIfTownIsTooFarFromNationCapitalByDistance(residentsNation, targetTown);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ private static Nation getPlunderingNationOrThrow(Player player, Siege siege) thr
if(siege.isTownPlundered())
throw new TownyException(translator.of("msg_err_siege_war_town_already_plundered", townToBePlundered.getName()));

if (SiegeWarSettings.isOnlyOneActionEnabled() && siege.isTownInvaded())
throw new TownyException(translator.of("msg_err_town_already_invaded_only_one_action"));

// If the rebels won, plunder is not possible
if(siege.isRevoltSiege() && siege.getStatus().defendersWon())
throw new TownyException(translator.of("msg_err_siege_war_plunder_not_possible_rebels_won"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ public enum ConfigNodes {
"",
"# When true, players will have a glowing effect."),

WAR_SIEGE_ONLY_ONE_ACTION_ENABLED(
"war.siege.switches.only_one_action_enabled",
"false",
"",
"# If true, players can only either invade or plunder a town, not both.",
"# If false, players can perform both actions."
),

WAR_SIEGE_MONEY(
"war.siege.money",
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,11 @@ public static boolean isUnjailingAttackerResidents() {
public static boolean isGlowingEnabled() {
return Settings.getBoolean(ConfigNodes.WAR_SIEGE_GLOWING);
}

public static boolean isOnlyOneActionEnabled() {
return Settings.getBoolean(ConfigNodes.WAR_SIEGE_ONLY_ONE_ACTION_ENABLED);
}

public static double getWarSiegeNationCostRefundPercentageOnDelete() {
return Settings.getDouble(ConfigNodes.WAR_SIEGE_NATION_COST_REFUND_PERCENTAGE_ON_DELETE);
}
Expand Down