@@ -24,7 +24,7 @@ import { Player } from "@player";
24
24
import { Router } from "../ui/GameRoot" ;
25
25
import { ConsoleHelpText } from "./data/Help" ;
26
26
import { exceptionAlert } from "../utils/helpers/exceptionAlert" ;
27
- import { getRandomInt } from "../utils/helpers/getRandomInt " ;
27
+ import { getRandomIntInclusive } from "../utils/helpers/getRandomIntInclusive " ;
28
28
import { BladeburnerConstants } from "./data/Constants" ;
29
29
import { formatExp , formatMoney , formatPercent , formatBigNumber , formatStamina } from "../ui/formatNumber" ;
30
30
import { currentNodeMults } from "../BitNode/BitNodeMultipliers" ;
@@ -64,7 +64,7 @@ export class Bladeburner {
64
64
65
65
storedCycles = 0 ;
66
66
67
- randomEventCounter : number = getRandomInt ( 240 , 600 ) ;
67
+ randomEventCounter : number = getRandomIntInclusive ( 240 , 600 ) ;
68
68
69
69
actionTimeToComplete = 0 ;
70
70
actionTimeCurrent = 0 ;
@@ -522,11 +522,11 @@ export class Bladeburner {
522
522
const sourceCity = this . cities [ sourceCityName ] ;
523
523
524
524
const rand = Math . random ( ) ;
525
- let percentage = getRandomInt ( 3 , 15 ) / 100 ;
525
+ let percentage = getRandomIntInclusive ( 3 , 15 ) / 100 ;
526
526
527
527
if ( rand < 0.05 && sourceCity . comms > 0 ) {
528
528
// 5% chance for community migration
529
- percentage *= getRandomInt ( 2 , 4 ) ; // Migration increases population change
529
+ percentage *= getRandomIntInclusive ( 2 , 4 ) ; // Migration increases population change
530
530
-- sourceCity . comms ;
531
531
++ destCity . comms ;
532
532
}
@@ -565,7 +565,7 @@ export class Bladeburner {
565
565
if ( chance <= 0.05 ) {
566
566
// New Synthoid Community, 5%
567
567
++ sourceCity . comms ;
568
- const percentage = getRandomInt ( 10 , 20 ) / 100 ;
568
+ const percentage = getRandomIntInclusive ( 10 , 20 ) / 100 ;
569
569
const count = Math . round ( sourceCity . pop * percentage ) ;
570
570
sourceCity . pop += count ;
571
571
if ( sourceCity . pop < BladeburnerConstants . PopGrowthCeiling ) {
@@ -579,7 +579,7 @@ export class Bladeburner {
579
579
if ( sourceCity . comms <= 0 ) {
580
580
// If no comms in source city, then instead trigger a new Synthoid community event
581
581
++ sourceCity . comms ;
582
- const percentage = getRandomInt ( 10 , 20 ) / 100 ;
582
+ const percentage = getRandomIntInclusive ( 10 , 20 ) / 100 ;
583
583
const count = Math . round ( sourceCity . pop * percentage ) ;
584
584
sourceCity . pop += count ;
585
585
if ( sourceCity . pop < BladeburnerConstants . PopGrowthCeiling ) {
@@ -593,7 +593,7 @@ export class Bladeburner {
593
593
++ destCity . comms ;
594
594
595
595
// Change pop
596
- const percentage = getRandomInt ( 10 , 20 ) / 100 ;
596
+ const percentage = getRandomIntInclusive ( 10 , 20 ) / 100 ;
597
597
const count = Math . round ( sourceCity . pop * percentage ) ;
598
598
sourceCity . pop -= count ;
599
599
destCity . pop += count ;
@@ -608,7 +608,7 @@ export class Bladeburner {
608
608
}
609
609
} else if ( chance <= 0.3 ) {
610
610
// New Synthoids (non community), 20%
611
- const percentage = getRandomInt ( 8 , 24 ) / 100 ;
611
+ const percentage = getRandomIntInclusive ( 8 , 24 ) / 100 ;
612
612
const count = Math . round ( sourceCity . pop * percentage ) ;
613
613
sourceCity . pop += count ;
614
614
if ( sourceCity . pop < BladeburnerConstants . PopGrowthCeiling ) {
@@ -632,13 +632,13 @@ export class Bladeburner {
632
632
} else if ( chance <= 0.7 ) {
633
633
// Synthoid Riots (+chaos), 20%
634
634
sourceCity . chaos += 1 ;
635
- sourceCity . chaos *= 1 + getRandomInt ( 5 , 20 ) / 100 ;
635
+ sourceCity . chaos *= 1 + getRandomIntInclusive ( 5 , 20 ) / 100 ;
636
636
if ( this . logging . events ) {
637
637
this . log ( "Tensions between Synthoids and humans lead to riots in " + sourceCityName + "! Chaos increased" ) ;
638
638
}
639
639
} else if ( chance <= 0.9 ) {
640
640
// Less Synthoids, 20%
641
- const percentage = getRandomInt ( 8 , 20 ) / 100 ;
641
+ const percentage = getRandomIntInclusive ( 8 , 20 ) / 100 ;
642
642
const count = Math . round ( sourceCity . pop * percentage ) ;
643
643
sourceCity . pop -= count ;
644
644
if ( this . logging . events ) {
@@ -753,7 +753,7 @@ export class Bladeburner {
753
753
const teamCount = action . teamCount ;
754
754
if ( teamCount >= 1 ) {
755
755
const maxLosses = success ? Math . ceil ( teamCount / 2 ) : Math . floor ( teamCount ) ;
756
- const losses = getRandomInt ( 0 , maxLosses ) ;
756
+ const losses = getRandomIntInclusive ( 0 , maxLosses ) ;
757
757
this . teamSize -= losses ;
758
758
if ( this . teamSize < this . sleeveSize ) {
759
759
const sup = Player . sleeves . filter ( ( x ) => isSleeveSupportWork ( x . currentWork ) ) ;
@@ -803,13 +803,13 @@ export class Bladeburner {
803
803
} ) ;
804
804
-- city . comms ;
805
805
} else {
806
- const change = getRandomInt ( - 10 , - 5 ) / 10 ;
806
+ const change = getRandomIntInclusive ( - 10 , - 5 ) / 10 ;
807
807
city . changePopulationByPercentage ( change , {
808
808
nonZero : true ,
809
809
changeEstEqually : false ,
810
810
} ) ;
811
811
}
812
- city . changeChaosByPercentage ( getRandomInt ( 1 , 5 ) ) ;
812
+ city . changeChaosByPercentage ( getRandomIntInclusive ( 1 , 5 ) ) ;
813
813
break ;
814
814
case BladeOperationName . stealthRetirement :
815
815
if ( success ) {
@@ -818,13 +818,13 @@ export class Bladeburner {
818
818
nonZero : true ,
819
819
} ) ;
820
820
}
821
- city . changeChaosByPercentage ( getRandomInt ( - 3 , - 1 ) ) ;
821
+ city . changeChaosByPercentage ( getRandomIntInclusive ( - 3 , - 1 ) ) ;
822
822
break ;
823
823
case BladeOperationName . assassination :
824
824
if ( success ) {
825
825
city . changePopulationByCount ( - 1 , { estChange : - 1 , estOffset : 0 } ) ;
826
826
}
827
- city . changeChaosByPercentage ( getRandomInt ( - 5 , 5 ) ) ;
827
+ city . changeChaosByPercentage ( getRandomIntInclusive ( - 5 , 5 ) ) ;
828
828
break ;
829
829
default :
830
830
throw new Error ( "Invalid Action name in completeOperation: " + this . action . name ) ;
@@ -838,7 +838,7 @@ export class Bladeburner {
838
838
case BladeContractName . tracking :
839
839
// Increase estimate accuracy by a relatively small amount
840
840
city . improvePopulationEstimateByCount (
841
- getRandomInt ( 100 , 1e3 ) * this . getSkillMult ( BladeMultName . successChanceEstimate ) ,
841
+ getRandomIntInclusive ( 100 , 1e3 ) * this . getSkillMult ( BladeMultName . successChanceEstimate ) ,
842
842
) ;
843
843
break ;
844
844
case BladeContractName . bountyHunter :
@@ -1012,7 +1012,7 @@ export class Bladeburner {
1012
1012
1013
1013
// Calculate team losses
1014
1014
if ( teamCount >= 1 ) {
1015
- const losses = getRandomInt ( 1 , teamLossMax ) ;
1015
+ const losses = getRandomIntInclusive ( 1 , teamLossMax ) ;
1016
1016
this . teamSize -= losses ;
1017
1017
if ( this . teamSize < this . sleeveSize ) {
1018
1018
const sup = Player . sleeves . filter ( ( x ) => isSleeveSupportWork ( x . currentWork ) ) ;
@@ -1332,7 +1332,7 @@ export class Bladeburner {
1332
1332
if ( this . randomEventCounter <= 0 ) {
1333
1333
this . randomEvent ( ) ;
1334
1334
// Add instead of setting because we might have gone over the required time for the event
1335
- this . randomEventCounter += getRandomInt ( 240 , 600 ) ;
1335
+ this . randomEventCounter += getRandomIntInclusive ( 240 , 600 ) ;
1336
1336
}
1337
1337
1338
1338
this . processAction ( seconds ) ;
0 commit comments