Skip to content

Commit 729104b

Browse files
authored
Merge pull request #3039 from ZeroK-RTS/pw-match-viewer-flags
Planetwars tweaks for next round
2 parents 2b842c3 + 5439f0d commit 729104b

17 files changed

Lines changed: 649 additions & 39 deletions

Shared/LobbyClient/Protocol/Messages.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,9 @@ public class VoteOption
702702
public List<string> StructureImages { get; set; }
703703
public int IconSize { get; set; }
704704
public string PlanetName { get; set; }
705+
public bool CanSelectForBattle { get; set; }
706+
public bool PlayerIsAttacker { get; set; }
707+
public bool PlayerIsDefender { get; set; }
705708
}
706709
}
707710

Shared/PlasmaShared/GlobalConst.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static void SetMode(ModeType newMode)
161161
public const double PlanetMetalPerTurn = 1;
162162
public const double PlanetWarsEnergyToMetalRatio = 0.0;
163163
public const double PlanetWarsMaximumIP = 100.0; //maximum IP on each planet
164-
public const int PlanetWarsVictoryPointsToWin = 100;
164+
public const int PlanetWarsVictoryPointsToWin = 50;
165165
public const int VictoryPointDecay = 1;
166166
public const int BaseInfluencePerBattle = 32;
167167
public const int InfluencePerAttacker = 1;

Zero-K.info/Controllers/PlanetwarsController.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,23 @@ public ActionResult BombPlanet(int planetID, int count, bool? useWarp)
7070
double ipKillAmmount = ipKillCount * GlobalConst.BomberKillIpAmount;
7171
if (ipKillAmmount > 0)
7272
{
73-
var influenceDecayMin = planet.PlanetStructures.Where(x => x.IsActive && x.StructureType.EffectPreventInfluenceDecayBelow != null).Select(x => x.StructureType.EffectPreventInfluenceDecayBelow).OrderByDescending(x => x).FirstOrDefault() ?? 0;
73+
var structureFloor = planet.PlanetStructures.Where(x => x.IsActive && x.StructureType.EffectPreventInfluenceDecayBelow != null).Select(x => x.StructureType.EffectPreventInfluenceDecayBelow).OrderByDescending(x => x).FirstOrDefault() ?? 0;
74+
var globalFloor = DynamicConfig.Instance.PwBomberMinimumIpFloor;
75+
var selfRate = DynamicConfig.Instance.PwBomberSelfIpRate;
7476

75-
76-
foreach (PlanetFaction pf in planet.PlanetFactions.Where(x => x.FactionID != acc.FactionID))
77+
foreach (PlanetFaction pf in planet.PlanetFactions)
7778
{
78-
pf.Influence -= ipKillAmmount;
79-
if (pf.Influence < 0) pf.Influence = 0;
80-
81-
// prevent bombing below influence decaymin for owner - set by active structures
82-
if (pf.FactionID == planet.OwnerFactionID && pf.Influence < influenceDecayMin) pf.Influence = influenceDecayMin;
83-
}
79+
bool isOwn = pf.FactionID == acc.FactionID;
80+
double damage = isOwn ? ipKillAmmount * selfRate : ipKillAmmount;
81+
if (damage <= 0) continue;
8482

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

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

8892
var args = new List<object>

ZkData/Ef/DynamicConfig.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,23 @@ public class DynamicConfig
3838

3939
[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.")]
4040
public double MapVoteFractionOfPopularMaps { get; set; } = 0.5;
41+
4142

43+
[Description("PlanetWars: number of attack options shown to the attacking faction each turn.")]
44+
public int PwAttackOptionCount { get; set; } = 6;
45+
46+
[Description("PlanetWars: maximum attack charges a player can hold. 0 disables the charge system.")]
47+
public int PwAttackChargesMax { get; set; } = 2;
48+
49+
[Description("PlanetWars: minutes a player must sit below max charges before gaining one passively.")]
50+
public int PwAttackChargesRechargeMinutes { get; set; } = 60;
51+
52+
[Description("PlanetWars: fraction of enemy bomber IP damage also applied to the bomber's own faction. 0 disables self-damage.")]
53+
public double PwBomberSelfIpRate { get; set; } = 0.5;
54+
55+
[Description("PlanetWars: minimum IP (0-100) below which bombers cannot push any faction. 0 disables the floor.")]
56+
public double PwBomberMinimumIpFloor { get; set; } = 5.0;
57+
4258

4359
public static DynamicConfig Instance;
4460

ZkData/Ef/Planet.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,31 +93,46 @@ public int GetUpkeepCost()
9393
return PlanetStructures.Sum(y => (int?)y.StructureType.UpkeepEnergy) ?? 0;
9494
}
9595

96+
public bool BlocksBombers()
97+
{
98+
return PlanetStructures.Any(x => x.IsActive && x.StructureType.EffectBlocksBombers == true);
99+
}
100+
101+
public bool BlocksInvasion()
102+
{
103+
return PlanetStructures.Any(x => x.IsActive && x.StructureType.EffectBlocksInvasion == true);
104+
}
105+
96106
public bool CanDropshipsAttack(Faction attacker)
97107
{
98108
if (attacker.FactionID == OwnerFactionID) return false; // cannot attack own
109+
if (BlocksInvasion()) return false;
99110
return CheckLinkAttack(attacker, x => x.EffectPreventDropshipAttack == true, x => x.EffectAllowDropshipPass == true);
100111
}
101112

102113
public bool CanDropshipsWarp(Faction attacker)
103114
{
104115
if (attacker.FactionID == OwnerFactionID) return false; // cannot attack own
116+
if (BlocksInvasion()) return false;
105117
return CheckWarpAttack(attacker, x => x.EffectPreventDropshipAttack == true);
106118
}
107119

108120
public bool CanBombersAttack(Faction attacker)
109121
{
122+
if (BlocksBombers()) return false;
110123
return CheckLinkAttack(attacker, x => x.EffectPreventBomberAttack == true, x => x.EffectAllowBomberPass == true);
111124
}
112125

113126
public bool CanBombersWarp(Faction attacker)
114127
{
128+
if (BlocksBombers()) return false;
115129
return CheckWarpAttack(attacker, x => x.EffectPreventBomberAttack == true);
116130
}
117131

118132
public bool CanMatchMakerPlay(Faction attacker)
119133
{
120134
if (attacker == null) return false;
135+
if (BlocksInvasion()) return false;
121136

122137
if (CanDropshipsAttack(attacker) ||
123138
PlanetFactions.Where(x => x.FactionID == attacker.FactionID).Sum(y => y.Dropships) >

ZkData/Ef/StructureType.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ public StructureType()
6161

6262
public double? EffectPreventInfluenceDecayBelow { get; set; }
6363

64-
64+
public bool? EffectBlocksBombers { get; set; }
65+
public bool? EffectBlocksInvasion { get; set; }
66+
67+
6568
public double Cost { get; set; }
6669
public bool IsBuildable { get; set; }
6770
public bool IsIngameDestructible { get; set; }

ZkData/Migrations/202604222356320_AddPwDynamicConfigs.Designer.cs

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace ZkData.Migrations
2+
{
3+
using System;
4+
using System.Data.Entity.Migrations;
5+
6+
public partial class AddPwDynamicConfigs : DbMigration
7+
{
8+
public override void Up()
9+
{
10+
AddColumn("dbo.DynamicConfigs", "PwAttackOptionCount", c => c.Int(nullable: false, defaultValue: 6));
11+
AddColumn("dbo.DynamicConfigs", "PwAttackChargesMax", c => c.Int(nullable: false, defaultValue: 2));
12+
AddColumn("dbo.DynamicConfigs", "PwAttackChargesRechargeMinutes", c => c.Int(nullable: false, defaultValue: 60));
13+
}
14+
15+
public override void Down()
16+
{
17+
DropColumn("dbo.DynamicConfigs", "PwAttackChargesRechargeMinutes");
18+
DropColumn("dbo.DynamicConfigs", "PwAttackChargesMax");
19+
DropColumn("dbo.DynamicConfigs", "PwAttackOptionCount");
20+
}
21+
}
22+
}

ZkData/Migrations/202604222356320_AddPwDynamicConfigs.resx

Lines changed: 126 additions & 0 deletions
Large diffs are not rendered by default.

ZkData/Migrations/202604231755110_AddStructureBlockFlags.Designer.cs

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)