Skip to content

Commit 167ce6b

Browse files
committed
Merge branch 'main' into farm,-resource,-monastary-assets
2 parents e8e9a49 + 9da6460 commit 167ce6b

8 files changed

Lines changed: 229 additions & 173 deletions

File tree

.claude/scheduled_tasks.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"sessionId":"fe18cf3c-f8f6-453b-ab10-ed27610bef8e","pid":62175,"procStart":"Fri Apr 24 18:52:49 2026","acquiredAt":1777171150784}

Open Empires/Assets/Scripts/Buildings/BuildingData.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,9 @@ public enum BuildingType
3030

3131
public enum TechnologyType
3232
{
33-
// Blacksmith (Age 2)
34-
MeleeAttack1, // +1 melee attack
35-
MeleeArmor1, // +1 melee armor
36-
RangedAttack1, // +1 ranged attack
37-
RangedArmor1, // +1 ranged armor
38-
// Blacksmith (Age 3)
39-
MeleeAttack2, // +2 melee attack (cumulative)
40-
MeleeArmor2, // +2 melee armor
41-
RangedAttack2, // +2 ranged attack
42-
RangedArmor2, // +2 ranged armor
33+
// Blacksmith
34+
BlacksmithDamage, // +N to both melee AND ranged attack
35+
BlacksmithDefense, // +N to both melee AND ranged armor
4336
// University (Age 3)
4437
Ballistics, // Projectiles lead targets
4538
SiegeEngineering, // +40 siege unit HP

Open Empires/Assets/Scripts/Buildings/BuildingView.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,10 @@ private void UpdateBuildingOverlayUI()
11861186

11871187
bool damaged = buildingData.CurrentHealth < buildingData.MaxHealth;
11881188
bool training = buildingData.IsTraining;
1189-
bool upgrading = buildingData.Type == BuildingType.Tower && buildingData.IsUpgrading;
1189+
// Reuse the upgrade-bar widget for both Tower upgrades AND research progress
1190+
// (Blacksmith / University). Single visual, two underlying systems.
1191+
bool towerUpgrading = buildingData.Type == BuildingType.Tower && buildingData.IsUpgrading;
1192+
bool upgrading = towerUpgrading || buildingData.IsResearching;
11901193

11911194
// Check influence periodically (not every frame)
11921195
if (--influenceCheckCooldown <= 0)
@@ -1312,20 +1315,25 @@ private void UpdateBuildingOverlayUI()
13121315
queueContainer.gameObject.SetActive(false);
13131316
}
13141317

1315-
// Upgrade bar
1318+
// Upgrade bar — drives off whichever progress source is active.
13161319
if (upgrading)
13171320
{
13181321
if (!upgradeBarGO.activeSelf)
13191322
upgradeBarGO.SetActive(true);
13201323

1321-
float upgradeFraction = Mathf.Clamp01(buildingData.UpgradeProgress);
1324+
float upgradeFraction = towerUpgrading
1325+
? Mathf.Clamp01(buildingData.UpgradeProgress)
1326+
: Mathf.Clamp01(buildingData.ResearchProgress);
13221327
upgradeFillRT.anchorMax = new Vector2(upgradeFraction, 1f);
13231328

1324-
bool showQueueCount = buildingData.UpgradeQueue.Count > 1;
1329+
int queueCount = towerUpgrading
1330+
? buildingData.UpgradeQueue.Count
1331+
: buildingData.ResearchQueue.Count;
1332+
bool showQueueCount = queueCount > 1;
13251333
if (upgradeQueueText.gameObject.activeSelf != showQueueCount)
13261334
upgradeQueueText.gameObject.SetActive(showQueueCount);
13271335
if (showQueueCount)
1328-
upgradeQueueText.text = $"Queue: {buildingData.UpgradeQueue.Count}";
1336+
upgradeQueueText.text = $"Queue: {queueCount}";
13291337
}
13301338
else
13311339
{

Open Empires/Assets/Scripts/Buildings/ResearchSystem.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,9 @@ public static int GetResearchTicks(SimulationConfig config, TechnologyType tech)
6262
{
6363
switch (tech)
6464
{
65-
case TechnologyType.MeleeAttack1:
66-
case TechnologyType.MeleeArmor1:
67-
case TechnologyType.RangedAttack1:
68-
case TechnologyType.RangedArmor1:
69-
return config.ResearchTicks_Age2;
70-
case TechnologyType.MeleeAttack2:
71-
case TechnologyType.MeleeArmor2:
72-
case TechnologyType.RangedAttack2:
73-
case TechnologyType.RangedArmor2:
74-
return config.ResearchTicks_Age3;
65+
case TechnologyType.BlacksmithDamage:
66+
case TechnologyType.BlacksmithDefense:
67+
return config.ResearchTicks_Age3; // longer than Age 2; tuned for the consolidated +2 bonus
7568
case TechnologyType.Ballistics:
7669
case TechnologyType.SiegeEngineering:
7770
case TechnologyType.Chemistry:

Open Empires/Assets/Scripts/Core/GameSimulation.cs

Lines changed: 17 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,29 +2015,12 @@ private void ApplyTechnologyToUnits(int playerId, TechnologyType tech)
20152015

20162016
switch (tech)
20172017
{
2018-
case TechnologyType.MeleeAttack1:
2019-
if (!unit.IsRanged) unit.AttackDamage += config.MeleeAttackBonus1;
2018+
case TechnologyType.BlacksmithDamage:
2019+
unit.AttackDamage += config.BlacksmithDamageBonus;
20202020
break;
2021-
case TechnologyType.MeleeAttack2:
2022-
if (!unit.IsRanged) unit.AttackDamage += config.MeleeAttackBonus2;
2023-
break;
2024-
case TechnologyType.RangedAttack1:
2025-
if (unit.IsRanged) unit.AttackDamage += config.RangedAttackBonus1;
2026-
break;
2027-
case TechnologyType.RangedAttack2:
2028-
if (unit.IsRanged) unit.AttackDamage += config.RangedAttackBonus2;
2029-
break;
2030-
case TechnologyType.MeleeArmor1:
2031-
unit.MeleeArmor += config.MeleeArmorBonus1;
2032-
break;
2033-
case TechnologyType.MeleeArmor2:
2034-
unit.MeleeArmor += config.MeleeArmorBonus2;
2035-
break;
2036-
case TechnologyType.RangedArmor1:
2037-
unit.RangedArmor += config.RangedArmorBonus1;
2038-
break;
2039-
case TechnologyType.RangedArmor2:
2040-
unit.RangedArmor += config.RangedArmorBonus2;
2021+
case TechnologyType.BlacksmithDefense:
2022+
unit.MeleeArmor += config.BlacksmithDefenseBonus;
2023+
unit.RangedArmor += config.BlacksmithDefenseBonus;
20412024
break;
20422025
case TechnologyType.Chemistry:
20432026
if (unit.IsRanged) unit.AttackDamage += config.ChemistryRangedBonus;
@@ -2056,39 +2039,6 @@ public bool HasTechnology(int playerId, TechnologyType tech)
20562039
return playerTechnologies[playerId].Contains(tech);
20572040
}
20582041

2059-
public int GetMeleeAttackBonus(int playerId)
2060-
{
2061-
int bonus = 0;
2062-
if (HasTechnology(playerId, TechnologyType.MeleeAttack1)) bonus += config.MeleeAttackBonus1;
2063-
if (HasTechnology(playerId, TechnologyType.MeleeAttack2)) bonus += config.MeleeAttackBonus2;
2064-
return bonus;
2065-
}
2066-
2067-
public int GetRangedAttackBonus(int playerId)
2068-
{
2069-
int bonus = 0;
2070-
if (HasTechnology(playerId, TechnologyType.RangedAttack1)) bonus += config.RangedAttackBonus1;
2071-
if (HasTechnology(playerId, TechnologyType.RangedAttack2)) bonus += config.RangedAttackBonus2;
2072-
if (HasTechnology(playerId, TechnologyType.Chemistry)) bonus += config.ChemistryRangedBonus;
2073-
return bonus;
2074-
}
2075-
2076-
public int GetMeleeArmorBonus(int playerId)
2077-
{
2078-
int bonus = 0;
2079-
if (HasTechnology(playerId, TechnologyType.MeleeArmor1)) bonus += config.MeleeArmorBonus1;
2080-
if (HasTechnology(playerId, TechnologyType.MeleeArmor2)) bonus += config.MeleeArmorBonus2;
2081-
return bonus;
2082-
}
2083-
2084-
public int GetRangedArmorBonus(int playerId)
2085-
{
2086-
int bonus = 0;
2087-
if (HasTechnology(playerId, TechnologyType.RangedArmor1)) bonus += config.RangedArmorBonus1;
2088-
if (HasTechnology(playerId, TechnologyType.RangedArmor2)) bonus += config.RangedArmorBonus2;
2089-
return bonus;
2090-
}
2091-
20922042
private void ProcessResearchCommand(ResearchCommand cmd)
20932043
{
20942044
if (cmd.PlayerId < 0 || cmd.PlayerId >= playerCount) return;
@@ -2099,22 +2049,14 @@ private void ProcessResearchCommand(ResearchCommand cmd)
20992049

21002050
var tech = (TechnologyType)cmd.TechType;
21012051

2102-
// Already researched or queued
21032052
if (playerTechnologies[cmd.PlayerId].Contains(tech)) return;
21042053
if (building.ResearchQueue.Contains(tech)) return;
21052054

2106-
// Check building type matches tech
21072055
bool validBuilding = false;
21082056
switch (tech)
21092057
{
2110-
case TechnologyType.MeleeAttack1:
2111-
case TechnologyType.MeleeArmor1:
2112-
case TechnologyType.RangedAttack1:
2113-
case TechnologyType.RangedArmor1:
2114-
case TechnologyType.MeleeAttack2:
2115-
case TechnologyType.MeleeArmor2:
2116-
case TechnologyType.RangedAttack2:
2117-
case TechnologyType.RangedArmor2:
2058+
case TechnologyType.BlacksmithDamage:
2059+
case TechnologyType.BlacksmithDefense:
21182060
validBuilding = building.Type == BuildingType.Blacksmith;
21192061
break;
21202062
case TechnologyType.Ballistics:
@@ -2126,17 +2068,9 @@ private void ProcessResearchCommand(ResearchCommand cmd)
21262068
}
21272069
if (!validBuilding) return;
21282070

2129-
// Age requirement: tier 2 techs need age 3
21302071
int reqAge = GetRequiredAgeForTech(tech);
21312072
if (playerAges[cmd.PlayerId] < reqAge) return;
21322073

2133-
// Prerequisite: tier 2 requires tier 1
2134-
if (tech == TechnologyType.MeleeAttack2 && !playerTechnologies[cmd.PlayerId].Contains(TechnologyType.MeleeAttack1)) return;
2135-
if (tech == TechnologyType.MeleeArmor2 && !playerTechnologies[cmd.PlayerId].Contains(TechnologyType.MeleeArmor1)) return;
2136-
if (tech == TechnologyType.RangedAttack2 && !playerTechnologies[cmd.PlayerId].Contains(TechnologyType.RangedAttack1)) return;
2137-
if (tech == TechnologyType.RangedArmor2 && !playerTechnologies[cmd.PlayerId].Contains(TechnologyType.RangedArmor1)) return;
2138-
2139-
// Check cost
21402074
var resources = ResourceManager.GetPlayerResources(cmd.PlayerId);
21412075
int foodCost, goldCost;
21422076
GetResearchCost(tech, out foodCost, out goldCost);
@@ -2153,10 +2087,8 @@ private int GetRequiredAgeForTech(TechnologyType tech)
21532087
{
21542088
switch (tech)
21552089
{
2156-
case TechnologyType.MeleeAttack1:
2157-
case TechnologyType.MeleeArmor1:
2158-
case TechnologyType.RangedAttack1:
2159-
case TechnologyType.RangedArmor1:
2090+
case TechnologyType.BlacksmithDamage:
2091+
case TechnologyType.BlacksmithDefense:
21602092
return 2;
21612093
default:
21622094
return 3;
@@ -2168,14 +2100,8 @@ private void GetResearchCost(TechnologyType tech, out int food, out int gold)
21682100
food = 0;
21692101
switch (tech)
21702102
{
2171-
case TechnologyType.MeleeAttack1: gold = config.MeleeAttack1Cost; break;
2172-
case TechnologyType.MeleeArmor1: gold = config.MeleeArmor1Cost; break;
2173-
case TechnologyType.RangedAttack1: gold = config.RangedAttack1Cost; break;
2174-
case TechnologyType.RangedArmor1: gold = config.RangedArmor1Cost; break;
2175-
case TechnologyType.MeleeAttack2: gold = config.MeleeAttack2Cost; break;
2176-
case TechnologyType.MeleeArmor2: gold = config.MeleeArmor2Cost; break;
2177-
case TechnologyType.RangedAttack2: gold = config.RangedAttack2Cost; break;
2178-
case TechnologyType.RangedArmor2: gold = config.RangedArmor2Cost; break;
2103+
case TechnologyType.BlacksmithDamage: gold = config.BlacksmithDamageCost; break;
2104+
case TechnologyType.BlacksmithDefense: gold = config.BlacksmithDefenseCost; break;
21792105
case TechnologyType.Ballistics: food = config.BallisticsFoodCost; gold = config.BallisticsGoldCost; break;
21802106
case TechnologyType.SiegeEngineering: food = config.SiegeEngineeringFoodCost; gold = config.SiegeEngineeringGoldCost; break;
21812107
case TechnologyType.Chemistry: food = config.ChemistryFoodCost; gold = config.ChemistryGoldCost; break;
@@ -5192,18 +5118,12 @@ private UnitData CreateTrainedUnit(int playerId, int unitType, FixedVector3 spaw
51925118
{
51935119
switch (tech)
51945120
{
5195-
case TechnologyType.MeleeAttack1:
5196-
if (!unitData.IsRanged) unitData.AttackDamage += config.MeleeAttackBonus1; break;
5197-
case TechnologyType.MeleeAttack2:
5198-
if (!unitData.IsRanged) unitData.AttackDamage += config.MeleeAttackBonus2; break;
5199-
case TechnologyType.RangedAttack1:
5200-
if (unitData.IsRanged) unitData.AttackDamage += config.RangedAttackBonus1; break;
5201-
case TechnologyType.RangedAttack2:
5202-
if (unitData.IsRanged) unitData.AttackDamage += config.RangedAttackBonus2; break;
5203-
case TechnologyType.MeleeArmor1: unitData.MeleeArmor += config.MeleeArmorBonus1; break;
5204-
case TechnologyType.MeleeArmor2: unitData.MeleeArmor += config.MeleeArmorBonus2; break;
5205-
case TechnologyType.RangedArmor1: unitData.RangedArmor += config.RangedArmorBonus1; break;
5206-
case TechnologyType.RangedArmor2: unitData.RangedArmor += config.RangedArmorBonus2; break;
5121+
case TechnologyType.BlacksmithDamage:
5122+
unitData.AttackDamage += config.BlacksmithDamageBonus; break;
5123+
case TechnologyType.BlacksmithDefense:
5124+
unitData.MeleeArmor += config.BlacksmithDefenseBonus;
5125+
unitData.RangedArmor += config.BlacksmithDefenseBonus;
5126+
break;
52075127
case TechnologyType.Chemistry:
52085128
if (unitData.IsRanged) unitData.AttackDamage += config.ChemistryRangedBonus; break;
52095129
case TechnologyType.SiegeEngineering:

Open Empires/Assets/Scripts/Core/SimulationConfig.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -508,14 +508,8 @@ public static int GetMapSize(int playerCount)
508508
public int ResearchTicks_Age3 => 900; // 30s
509509
public int ResearchTicks_University => 750; // 25s
510510
// Blacksmith costs (gold)
511-
public int MeleeAttack1Cost => 100;
512-
public int MeleeArmor1Cost => 100;
513-
public int RangedAttack1Cost => 100;
514-
public int RangedArmor1Cost => 100;
515-
public int MeleeAttack2Cost => 200;
516-
public int MeleeArmor2Cost => 200;
517-
public int RangedAttack2Cost => 200;
518-
public int RangedArmor2Cost => 200;
511+
public int BlacksmithDamageCost => 200; // bumps both melee + ranged attack
512+
public int BlacksmithDefenseCost => 200; // bumps both melee + ranged armor
519513
// University costs (food + gold)
520514
public int BallisticsFoodCost => 200;
521515
public int BallisticsGoldCost => 200;
@@ -526,14 +520,8 @@ public static int GetMapSize(int playerCount)
526520
public int MurderHolesFoodCost => 100;
527521
public int MurderHolesGoldCost => 100;
528522
// Research bonuses
529-
public int MeleeAttackBonus1 => 1;
530-
public int MeleeAttackBonus2 => 2;
531-
public int MeleeArmorBonus1 => 1;
532-
public int MeleeArmorBonus2 => 2;
533-
public int RangedAttackBonus1 => 1;
534-
public int RangedAttackBonus2 => 2;
535-
public int RangedArmorBonus1 => 1;
536-
public int RangedArmorBonus2 => 2;
523+
public int BlacksmithDamageBonus => 2; // applied to both melee + ranged units
524+
public int BlacksmithDefenseBonus => 2; // applied to both melee + ranged armor on every military unit
537525
public int ChemistryRangedBonus => 1;
538526
public int SiegeEngineeringHPBonus => 40;
539527

0 commit comments

Comments
 (0)