@@ -846,25 +846,37 @@ export class DefaultConfig implements Config {
846846 }
847847
848848 /**
849- * Estimate how many of the player's current troops are attributable to
850- * territory-derived capacity. This is a proportional estimate based on the
851- * ratio of territory capacity to total capacity, multiplied by current troops.
852- * Note: this is only an estimate and not precise tracking of troop sources.
849+ * Private helper to estimate troop source breakdowns for a player.
850+ * Returns both territory and city estimates as an object.
853851 * @param player Player or PlayerView used to compute the estimate.
854852 */
855- estimatedTroopsTerritory ( player : Player | PlayerView ) : number {
853+ private estimateTroopSources ( player : Player | PlayerView ) : {
854+ territory : number ;
855+ city : number ;
856+ } {
856857 const maxTroopsTerritory = this . maxTroopsTerritory ( player ) ;
857858 const maxTroopsCity = this . maxTroopsCity ( player ) ;
858-
859859 const baseCapacity = maxTroopsTerritory + maxTroopsCity ;
860- if ( baseCapacity === 0 ) return 0 ;
861-
860+ if ( baseCapacity === 0 ) return { territory : 0 , city : 0 } ;
862861 const currentTroops = player . troops ( ) ;
862+ return {
863+ territory : Math . round (
864+ ( maxTroopsTerritory / baseCapacity ) * currentTroops ,
865+ ) ,
866+ city : Math . round ( ( maxTroopsCity / baseCapacity ) * currentTroops ) ,
867+ } ;
868+ }
863869
864- // Proportionally attribute current troops based on territory's share of the
865- // unscaled base capacity (territory + city). This keeps the numerator and
866- // denominator consistent for all player types.
867- return Math . round ( ( maxTroopsTerritory / baseCapacity ) * currentTroops ) ;
870+ /**
871+ * Estimate how many of the player's current troops are attributable to
872+ * territory-derived capacity. This is a proportional estimate based on the
873+ * ratio of territory capacity to total capacity, multiplied by current troops.
874+ * Note: this is only an estimate and not precise tracking of troop sources.
875+ * @param player Player or PlayerView used to compute the estimate.
876+ * @returns Estimated number of the player's troops attributable to territory-derived capacity (proportional, not exact).
877+ */
878+ estimatedTroopsTerritory ( player : Player | PlayerView ) : number {
879+ return this . estimateTroopSources ( player ) . territory ;
868880 }
869881
870882 /**
@@ -873,20 +885,10 @@ export class DefaultConfig implements Config {
873885 * ratio of city capacity to total capacity, multiplied by current troops.
874886 * Note: this is only an estimate and not precise tracking of troop sources.
875887 * @param player Player or PlayerView used to compute the estimate.
888+ * @returns Estimated number of troops attributable to city capacity as a number.
876889 */
877890 estimatedTroopsCity ( player : Player | PlayerView ) : number {
878- const maxTroopsTerritory = this . maxTroopsTerritory ( player ) ;
879- const maxTroopsCity = this . maxTroopsCity ( player ) ;
880-
881- const baseCapacity = maxTroopsTerritory + maxTroopsCity ;
882- if ( baseCapacity === 0 ) return 0 ;
883-
884- const currentTroops = player . troops ( ) ;
885-
886- // Proportionally attribute current troops based on cities' share of the
887- // unscaled base capacity (territory + city). This keeps the numerator and
888- // denominator consistent for all player types.
889- return Math . round ( ( maxTroopsCity / baseCapacity ) * currentTroops ) ;
891+ return this . estimateTroopSources ( player ) . city ;
890892 }
891893
892894 /**
0 commit comments