Skip to content
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
3 changes: 3 additions & 0 deletions src/main/java/net/tfminecraft/simplefactions/Cache.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ public static boolean requireProvinces(org.bukkit.command.CommandSender sender)
public static boolean warBattleVotingPassIfEither;
public static int warBattleVotingDevMinPlayers;
public static boolean warBattleVotingDevMinPlayersEnabled;
public static int warBattleVotingMaxPostponements = 1;
public static double warAutoresolveLuck = 0.15;
public static double warAutoresolveLoserLossFraction = 0.5;
public static int warBattleLivesPerRegiment;
public static int warBattleMinSideLives;
public static int warBattleDeathsPerRegimentLoss;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@ public void loadWar(File warFile) {
} else {
Cache.warBattleVotingDevMinPlayers = Cache.warBattleVotingMinPlayers;
}
Cache.warBattleVotingMaxPostponements = Math.max(
0,
config.getInt("war.battle_voting.max_postponements", 1));
double autoresolveLuck = config.getDouble("war.autoresolve.luck", 0.15);
if (autoresolveLuck < 0) {
autoresolveLuck = 0;
} else if (autoresolveLuck > 1) {
autoresolveLuck = 1;
}
Cache.warAutoresolveLuck = autoresolveLuck;
double loserLossFraction = config.getDouble("war.autoresolve.loser_loss_fraction", 0.5);
Cache.warAutoresolveLoserLossFraction = loserLossFraction < 0 ? 0 : loserLossFraction;
Cache.warDevmodePhantomCount = config.getInt("war.devmode.phantom_count", 10);
validateBattleScheduleConfig();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.tfminecraft.simplefactions.war.campaign.progression.AttackerNavalContestService;
import net.tfminecraft.simplefactions.war.campaign.progression.CampaignCapabilityService;
import net.tfminecraft.simplefactions.war.campaign.progression.postbattle.CampaignOffensiveForfeitService;
import net.tfminecraft.simplefactions.war.campaign.runtime.BattleAutoresolveService;
import net.tfminecraft.simplefactions.war.campaign.runtime.BattleScheduleService;
import net.tfminecraft.simplefactions.war.campaign.runtime.BattleSideMembers;
import net.tfminecraft.simplefactions.war.campaign.runtime.BattleWindowService;
Expand Down Expand Up @@ -69,37 +70,13 @@ public static Battle prepareScheduledBattle(War war) {
return battle;
}

/** Simulated result. Does not create or start a live battle. */
public static Battle launchAutoresolveBattle(War war) {
if (war == null || !war.isActive()) {
return null;
}
Battle existing = BattleManager.getByWarId(war.getId());
Integer provinceId = BattleScheduleService.resolveScheduledProvinceId(war);
if (provinceId != null
&& AttackerNavalContestService.applyIfAttackerHasNoBerthedNavy(war, provinceId)) {
return null;
}

if (existing != null) {
String startError = startPreparedBattle(war, existing);
if (startError != null) {
logWarning("Could not start autoresolve battle: " + startError);
}
return existing;
}

if (provinceId == null) {
return null;
}

Battle battle = createCampaignBattle(war, provinceId, true);
if (battle != null) {
String startError = startPreparedBattle(war, battle);
if (startError != null) {
logWarning("Could not start autoresolve battle: " + startError);
}
}
return battle;
BattleAutoresolveService.resolve(war);
return null;
}

public static boolean tryStartScheduledBattle(War war, Instant now) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public static CampaignBattleApplyResult applyCampaignBattleOutcome(
return new CampaignBattleApplyResult(false, false, Optional.empty());
}

war.setPostponementsThisCycle(0);

CampaignPushTarget preBattlePushTarget = war.getPushTarget();
ObjectiveHolder preBattleObjectiveHeldBy = war.getObjectiveHeldBy();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public static WarScheduleAdminResult closeVote(War war, Instant now) {

case AUTORESOLVE_PENDING -> WarScheduleAdminResult.ok("Vote close set AUTORESOLVE_PENDING.");

case AUTORESOLVED -> WarScheduleAdminResult.ok("Vote close autoresolved the battle.");

case BLOCKED_DEFENDER_CHOICE -> WarScheduleAdminResult.error(

"Vote close blocked: defender choice unresolved.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ private static String formatCloseVote(War war) {
return "搂7Phase: 搂e" + formatPhase(war);
}
if (phase == BattleSchedulePhase.VOTING && war.getScheduledBattleAt() == null) {
if (war.getPostponementsThisCycle() == 0) {
return "搂7Autoresolved 搂7路 Battle day: 搂e" + formatBattleDay(war)
+ " 搂7路 Phase: 搂e" + formatPhase(war);
}
return "搂7Postponed 搂7路 Battle day: 搂e" + formatBattleDay(war)
+ " 搂7路 Phase: 搂e" + formatPhase(war);
}
Expand Down
Loading