@@ -28,26 +28,41 @@ interface StructureRatioConfig {
2828 perceivedCostIncreasePerOwned : number ;
2929}
3030
31+ /** SAM launcher ratio per city, keyed by difficulty */
32+ const SAM_RATIO_BY_DIFFICULTY : Record < Difficulty , number > = {
33+ [ Difficulty . Easy ] : 0.15 ,
34+ [ Difficulty . Medium ] : 0.2 ,
35+ [ Difficulty . Hard ] : 0.25 ,
36+ [ Difficulty . Impossible ] : 0.3 ,
37+ } ;
38+
3139/**
32- * Default structure ratios relative to city count.
40+ * Returns structure ratios relative to city count, adjusted by difficulty .
3341 * Cities are always prioritized and built first.
3442 */
35- const STRUCTURE_RATIOS : Partial < Record < UnitType , StructureRatioConfig > > = {
36- [ UnitType . Port ] : { ratioPerCity : 0.75 , perceivedCostIncreasePerOwned : 1 } ,
37- [ UnitType . Factory ] : { ratioPerCity : 0.75 , perceivedCostIncreasePerOwned : 1 } ,
38- [ UnitType . DefensePost ] : {
39- ratioPerCity : 0.25 ,
40- perceivedCostIncreasePerOwned : 1 ,
41- } ,
42- [ UnitType . SAMLauncher ] : {
43- ratioPerCity : 0.25 ,
44- perceivedCostIncreasePerOwned : 1 ,
45- } ,
46- [ UnitType . MissileSilo ] : {
47- ratioPerCity : 0.2 ,
48- perceivedCostIncreasePerOwned : 1 ,
49- } ,
50- } ;
43+ function getStructureRatios (
44+ difficulty : Difficulty ,
45+ ) : Partial < Record < UnitType , StructureRatioConfig > > {
46+ return {
47+ [ UnitType . Port ] : { ratioPerCity : 0.75 , perceivedCostIncreasePerOwned : 1 } ,
48+ [ UnitType . Factory ] : {
49+ ratioPerCity : 0.75 ,
50+ perceivedCostIncreasePerOwned : 1 ,
51+ } ,
52+ [ UnitType . DefensePost ] : {
53+ ratioPerCity : 0.25 ,
54+ perceivedCostIncreasePerOwned : 1 ,
55+ } ,
56+ [ UnitType . SAMLauncher ] : {
57+ ratioPerCity : SAM_RATIO_BY_DIFFICULTY [ difficulty ] ,
58+ perceivedCostIncreasePerOwned : 1 ,
59+ } ,
60+ [ UnitType . MissileSilo ] : {
61+ ratioPerCity : 0.2 ,
62+ perceivedCostIncreasePerOwned : 1 ,
63+ } ,
64+ } ;
65+ }
5166
5267/** Perceived cost increase percentage per city owned */
5368const CITY_PERCEIVED_COST_INCREASE_PER_OWNED = 1 ;
@@ -119,7 +134,9 @@ export class NationStructureBehavior {
119134 cityCount : number ,
120135 hasCoastalTiles : boolean ,
121136 ) : boolean {
122- const config = STRUCTURE_RATIOS [ type ] ;
137+ const { difficulty } = this . game . config ( ) . gameConfig ( ) ;
138+ const ratios = getStructureRatios ( difficulty ) ;
139+ const config = ratios [ type ] ;
123140 if ( config === undefined ) {
124141 return false ;
125142 }
@@ -193,7 +210,9 @@ export class NationStructureBehavior {
193210 if ( type === UnitType . City ) {
194211 increasePerOwned = CITY_PERCEIVED_COST_INCREASE_PER_OWNED ;
195212 } else {
196- const config = STRUCTURE_RATIOS [ type ] ;
213+ const { difficulty } = this . game . config ( ) . gameConfig ( ) ;
214+ const ratios = getStructureRatios ( difficulty ) ;
215+ const config = ratios [ type ] ;
197216 increasePerOwned = config ?. perceivedCostIncreasePerOwned ?? 0.1 ;
198217 }
199218
0 commit comments