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 Shared/LobbyClient/Protocol/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,9 @@ public class VoteOption
public List<string> StructureImages { get; set; }
public int IconSize { get; set; }
public string PlanetName { get; set; }
public bool CanSelectForBattle { get; set; }
public bool PlayerIsAttacker { get; set; }
public bool PlayerIsDefender { get; set; }
}
}

Expand Down
2 changes: 1 addition & 1 deletion Shared/PlasmaShared/GlobalConst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static void SetMode(ModeType newMode)
public const double PlanetMetalPerTurn = 1;
public const double PlanetWarsEnergyToMetalRatio = 0.0;
public const double PlanetWarsMaximumIP = 100.0; //maximum IP on each planet
public const int PlanetWarsVictoryPointsToWin = 100;
public const int PlanetWarsVictoryPointsToWin = 50;
public const int VictoryPointDecay = 1;
public const int BaseInfluencePerBattle = 32;
public const int InfluencePerAttacker = 1;
Expand Down
22 changes: 13 additions & 9 deletions Zero-K.info/Controllers/PlanetwarsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,23 @@ public ActionResult BombPlanet(int planetID, int count, bool? useWarp)
double ipKillAmmount = ipKillCount * GlobalConst.BomberKillIpAmount;
if (ipKillAmmount > 0)
{
var influenceDecayMin = planet.PlanetStructures.Where(x => x.IsActive && x.StructureType.EffectPreventInfluenceDecayBelow != null).Select(x => x.StructureType.EffectPreventInfluenceDecayBelow).OrderByDescending(x => x).FirstOrDefault() ?? 0;
var structureFloor = planet.PlanetStructures.Where(x => x.IsActive && x.StructureType.EffectPreventInfluenceDecayBelow != null).Select(x => x.StructureType.EffectPreventInfluenceDecayBelow).OrderByDescending(x => x).FirstOrDefault() ?? 0;
var globalFloor = DynamicConfig.Instance.PwBomberMinimumIpFloor;
var selfRate = DynamicConfig.Instance.PwBomberSelfIpRate;


foreach (PlanetFaction pf in planet.PlanetFactions.Where(x => x.FactionID != acc.FactionID))
foreach (PlanetFaction pf in planet.PlanetFactions)
{
pf.Influence -= ipKillAmmount;
if (pf.Influence < 0) pf.Influence = 0;

// prevent bombing below influence decaymin for owner - set by active structures
if (pf.FactionID == planet.OwnerFactionID && pf.Influence < influenceDecayMin) pf.Influence = influenceDecayMin;
}
bool isOwn = pf.FactionID == acc.FactionID;
double damage = isOwn ? ipKillAmmount * selfRate : ipKillAmmount;
if (damage <= 0) continue;

// owner gets max of global floor and any structure-provided floor; everyone else gets global only
double floor = (pf.FactionID == planet.OwnerFactionID) ? Math.Max(globalFloor, structureFloor) : globalFloor;

// floor only prevents pushing below it — a faction already below the floor is not raised by bombing
double effectiveFloor = Math.Min(pf.Influence, floor);
pf.Influence = Math.Max(pf.Influence - damage, Math.Max(effectiveFloor, 0));
}
}

var args = new List<object>
Expand Down
16 changes: 16 additions & 0 deletions ZkData/Ef/DynamicConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,23 @@ public class DynamicConfig

[Description("Map vote always tries to include some of the most popular maps (precentile <0.2), this value controls how big fraction of offers is most popular maps.")]
public double MapVoteFractionOfPopularMaps { get; set; } = 0.5;


[Description("PlanetWars: number of attack options shown to the attacking faction each turn.")]
public int PwAttackOptionCount { get; set; } = 6;

[Description("PlanetWars: maximum attack charges a player can hold. 0 disables the charge system.")]
public int PwAttackChargesMax { get; set; } = 2;

[Description("PlanetWars: minutes a player must sit below max charges before gaining one passively.")]
public int PwAttackChargesRechargeMinutes { get; set; } = 60;

[Description("PlanetWars: fraction of enemy bomber IP damage also applied to the bomber's own faction. 0 disables self-damage.")]
public double PwBomberSelfIpRate { get; set; } = 0.5;

[Description("PlanetWars: minimum IP (0-100) below which bombers cannot push any faction. 0 disables the floor.")]
public double PwBomberMinimumIpFloor { get; set; } = 5.0;


public static DynamicConfig Instance;

Expand Down
15 changes: 15 additions & 0 deletions ZkData/Ef/Planet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,31 +93,46 @@ public int GetUpkeepCost()
return PlanetStructures.Sum(y => (int?)y.StructureType.UpkeepEnergy) ?? 0;
}

public bool BlocksBombers()
{
return PlanetStructures.Any(x => x.IsActive && x.StructureType.EffectBlocksBombers == true);
}

public bool BlocksInvasion()
{
return PlanetStructures.Any(x => x.IsActive && x.StructureType.EffectBlocksInvasion == true);
}

public bool CanDropshipsAttack(Faction attacker)
{
if (attacker.FactionID == OwnerFactionID) return false; // cannot attack own
if (BlocksInvasion()) return false;
return CheckLinkAttack(attacker, x => x.EffectPreventDropshipAttack == true, x => x.EffectAllowDropshipPass == true);
}

public bool CanDropshipsWarp(Faction attacker)
{
if (attacker.FactionID == OwnerFactionID) return false; // cannot attack own
if (BlocksInvasion()) return false;
return CheckWarpAttack(attacker, x => x.EffectPreventDropshipAttack == true);
}

public bool CanBombersAttack(Faction attacker)
{
if (BlocksBombers()) return false;
return CheckLinkAttack(attacker, x => x.EffectPreventBomberAttack == true, x => x.EffectAllowBomberPass == true);
}

public bool CanBombersWarp(Faction attacker)
{
if (BlocksBombers()) return false;
return CheckWarpAttack(attacker, x => x.EffectPreventBomberAttack == true);
}

public bool CanMatchMakerPlay(Faction attacker)
{
if (attacker == null) return false;
if (BlocksInvasion()) return false;

if (CanDropshipsAttack(attacker) ||
PlanetFactions.Where(x => x.FactionID == attacker.FactionID).Sum(y => y.Dropships) >
Expand Down
5 changes: 4 additions & 1 deletion ZkData/Ef/StructureType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ public StructureType()

public double? EffectPreventInfluenceDecayBelow { get; set; }


public bool? EffectBlocksBombers { get; set; }
public bool? EffectBlocksInvasion { get; set; }


public double Cost { get; set; }
public bool IsBuildable { get; set; }
public bool IsIngameDestructible { get; set; }
Expand Down
29 changes: 29 additions & 0 deletions ZkData/Migrations/202604222356320_AddPwDynamicConfigs.Designer.cs

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

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

public partial class AddPwDynamicConfigs : DbMigration
{
public override void Up()
{
AddColumn("dbo.DynamicConfigs", "PwAttackOptionCount", c => c.Int(nullable: false, defaultValue: 6));
AddColumn("dbo.DynamicConfigs", "PwAttackChargesMax", c => c.Int(nullable: false, defaultValue: 2));
AddColumn("dbo.DynamicConfigs", "PwAttackChargesRechargeMinutes", c => c.Int(nullable: false, defaultValue: 60));
}

public override void Down()
{
DropColumn("dbo.DynamicConfigs", "PwAttackChargesRechargeMinutes");
DropColumn("dbo.DynamicConfigs", "PwAttackChargesMax");
DropColumn("dbo.DynamicConfigs", "PwAttackOptionCount");
}
}
}
126 changes: 126 additions & 0 deletions ZkData/Migrations/202604222356320_AddPwDynamicConfigs.resx

Large diffs are not rendered by default.

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

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

public partial class AddStructureBlockFlags : DbMigration
{
public override void Up()
{
AddColumn("dbo.StructureTypes", "EffectBlocksBombers", c => c.Boolean());
AddColumn("dbo.StructureTypes", "EffectBlocksInvasion", c => c.Boolean());

// HQ-class structures (those that win the game on capture) become immune to both attack vectors by default.
Sql("UPDATE dbo.StructureTypes SET EffectBlocksBombers = 1, EffectBlocksInvasion = 1 WHERE OwnerChangeWinsGame = 1");
}

public override void Down()
{
DropColumn("dbo.StructureTypes", "EffectBlocksInvasion");
DropColumn("dbo.StructureTypes", "EffectBlocksBombers");
}
}
}
126 changes: 126 additions & 0 deletions ZkData/Migrations/202604231755110_AddStructureBlockFlags.resx

Large diffs are not rendered by default.

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/202604231826040_AddPwBomberNerfConfigs.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 AddPwBomberNerfConfigs : DbMigration
{
public override void Up()
{
AddColumn("dbo.DynamicConfigs", "PwBomberSelfIpRate", c => c.Double(nullable: false, defaultValue: 0.5));
AddColumn("dbo.DynamicConfigs", "PwBomberMinimumIpFloor", c => c.Double(nullable: false, defaultValue: 5.0));
}

public override void Down()
{
DropColumn("dbo.DynamicConfigs", "PwBomberMinimumIpFloor");
DropColumn("dbo.DynamicConfigs", "PwBomberSelfIpRate");
}
}
}
Loading
Loading