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
2 changes: 0 additions & 2 deletions Shared/PlasmaShared/GlobalConst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ static void SetMode(ModeType newMode)
public const int PostVoteHideThreshold = -6;
public const bool OnlyAdminsSeePostVoters = false;
public const int PlanetWarsMinutesToAttackIfNoOption = 2;
public const int PlanetWarsMinutesToAttack = 2;
public const int PlanetWarsMinutesToAccept = 2;
public const int PlanetWarsDropshipsStayForMinutes = 2*60;
public const int PlanetWarsMaxTeamsize = 4;
public const double PlanetWarsDefenderWinKillCcMultiplier = 0.2;
Expand Down
6 changes: 6 additions & 0 deletions ZkData/Ef/DynamicConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ public class DynamicConfig
[Description("PlanetWars: minimum IP (0-100) below which bombers cannot push any faction. 0 disables the floor.")]
public double PwBomberMinimumIpFloor { get; set; } = 5.0;

[Description("PlanetWars: length in minutes of the attack-collect phase (attackers pick a target).")]
public int PwAttackPhaseMinutes { get; set; } = 2;

[Description("PlanetWars: length in minutes of the defend-collect phase (defenders accept).")]
public int PwDefendPhaseMinutes { get; set; } = 2;


public static DynamicConfig Instance;

Expand Down
29 changes: 29 additions & 0 deletions ZkData/Migrations/202604290948595_AddPwPhaseMinutes.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions ZkData/Migrations/202604290948595_AddPwPhaseMinutes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace ZkData.Migrations
{
using System;
using System.Data.Entity.Migrations;

public partial class AddPwPhaseMinutes : DbMigration
{
public override void Up()
{
AddColumn("dbo.DynamicConfigs", "PwAttackPhaseMinutes", c => c.Int(nullable: false, defaultValue: 2));
AddColumn("dbo.DynamicConfigs", "PwDefendPhaseMinutes", c => c.Int(nullable: false, defaultValue: 2));
}

public override void Down()
{
DropColumn("dbo.DynamicConfigs", "PwDefendPhaseMinutes");
DropColumn("dbo.DynamicConfigs", "PwAttackPhaseMinutes");
}
}
}
9 changes: 9 additions & 0 deletions ZkData/Migrations/202604290948595_AddPwPhaseMinutes.resx

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions ZkData/ZkData.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,10 @@
<Compile Include="Migrations\202604271235020_AddPwAttackChargesPassiveLimit.Designer.cs">
<DependentUpon>202604271235020_AddPwAttackChargesPassiveLimit.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\202604290948595_AddPwPhaseMinutes.cs" />
<Compile Include="Migrations\202604290948595_AddPwPhaseMinutes.Designer.cs">
<DependentUpon>202604290948595_AddPwPhaseMinutes.cs</DependentUpon>
</Compile>
<Compile Include="SpringFilesUnitsyncAttempt.cs" />
<Compile Include="SteamWebApi.cs" />
<Compile Include="UserLanguageNoteAttribute.cs" />
Expand Down Expand Up @@ -988,6 +992,9 @@
<EmbeddedResource Include="Migrations\202604271235020_AddPwAttackChargesPassiveLimit.resx">
<DependentUpon>202604271235020_AddPwAttackChargesPassiveLimit.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\202604290948595_AddPwPhaseMinutes.resx">
<DependentUpon>202604290948595_AddPwPhaseMinutes.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ZkDataResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ZkDataResources.Designer.cs</LastGenOutput>
Expand Down
14 changes: 9 additions & 5 deletions ZkLobbyServer/SpringieInterface/PlanetWarsMatchMaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,10 @@ private PwMatchCommand StampLobbyCommand(LobbySnapshot snapshot, PwPhase phase,
}
else // DefendCollect
{
// attack/defend are mutually exclusive across the whole cycle (see JoinPlanetDefense),
// so any squad's attacker list disqualifies this player from defending ANY squad.
var playerIsAttackerAnywhere = playerName != null && snapshot.Options.Any(o => o.AttackerNames.Contains(playerName));

var options = snapshot.Options.Select(s =>
{
var playerIsAttacker = playerName != null && s.AttackerNames.Contains(playerName);
Expand All @@ -942,7 +946,7 @@ private PwMatchCommand StampLobbyCommand(LobbySnapshot snapshot, PwPhase phase,
PlanetImage = s.PlanetImage,
Count = s.Count,
Needed = s.Needed,
CanSelectForBattle = canDefend && !playerIsAttacker,
CanSelectForBattle = canDefend && !playerIsAttackerAnywhere,
PlayerIsAttacker = playerIsAttacker,
PlayerIsDefender = playerName != null && s.DefenderNames.Contains(playerName),
AttackerFaction = s.AttackerFactionShortcut,
Expand Down Expand Up @@ -1139,12 +1143,12 @@ private DateTime GetAttackDeadline()
if (AttackOptions.Count == 0)
return PhaseStartTime.AddMinutes(GlobalConst.PlanetWarsMinutesToAttackIfNoOption);

return PhaseStartTime.AddMinutes(GlobalConst.PlanetWarsMinutesToAttack);
return PhaseStartTime.AddMinutes(DynamicConfig.Instance.PwAttackPhaseMinutes);
}

private DateTime GetDefendDeadline()
{
return PhaseStartTime.AddMinutes(GlobalConst.PlanetWarsMinutesToAccept);
return PhaseStartTime.AddMinutes(DynamicConfig.Instance.PwDefendPhaseMinutes);
}

/// <summary>
Expand Down Expand Up @@ -1302,8 +1306,8 @@ private static PwStatus GeneratePwStatus()
MinLevel = GlobalConst.MinPlanetWarsLevel,
PlanetWarsNextMode = MiscVar.PlanetWarsNextMode,
PlanetWarsNextModeTime = MiscVar.PlanetWarsNextModeTime,
AttackerPhaseMinutes = GlobalConst.PlanetWarsMinutesToAttack,
DefenderPhaseMinutes = GlobalConst.PlanetWarsMinutesToAccept,
AttackerPhaseMinutes = DynamicConfig.Instance.PwAttackPhaseMinutes,
DefenderPhaseMinutes = DynamicConfig.Instance.PwDefendPhaseMinutes,
MaxAttackCharges = DynamicConfig.Instance.PwAttackChargesMax,
};
}
Expand Down
Loading