diff --git a/dist/index.d.ts b/dist/index.d.ts index 68c5c5b..fc4f1c0 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -625,7 +625,6 @@ declare const REACTION_TIME: { }; declare const BOOSTS: { - [part: string]: { [boost: string]: { [action: string]: number } }; work: { UO: { harvest: 3; @@ -739,7 +738,7 @@ declare const BOOSTS: { damage: 0.3; }; }; -}; +} & Record>>; declare const INTERSHARD_RESOURCES: InterShardResourceConstant[]; @@ -1746,7 +1745,7 @@ type BodyPartDefinition = T exten * * If the body part is boosted, this property specifies the mineral type which is used for boosting. */ - boost?: keyof (typeof BOOSTS)[T]; + boost?: keyof typeof BOOSTS[T]; /** * One of the body part types constants. */ @@ -2777,6 +2776,21 @@ type EffectConstant = EFFECT_INVULNERABILITY | EFFECT_COLLAPSE_TIMER; type EFFECT_INVULNERABILITY = 1001; type EFFECT_COLLAPSE_TIMER = 1002; + +type BoostModifier = + | "harvest" + | "build" + | "repair" + | "dismantle" + | "upgradeController" + | "attack" + | "rangedAttack" + | "rangedMassAttack" + | "heal" + | "rangedHeal" + | "capacity" + | "fatigue" + | "damage"; /** * The options that can be accepted by `findRoute()` and friends. */ diff --git a/dist/screeps-tests.ts b/dist/screeps-tests.ts index 27af63d..93406fc 100644 --- a/dist/screeps-tests.ts +++ b/dist/screeps-tests.ts @@ -1201,7 +1201,7 @@ function atackPower(creep: Creep) { return creep.body .map((part) => { if (part.type === ATTACK) { - const multiplier = part.boost ? BOOSTS[part.type][part.boost].attack : 1; + const multiplier = part.boost ? BOOSTS[part.type][part.boost]?.attack ?? 0 : 1; return multiplier * ATTACK_POWER; } return 0; diff --git a/src/constants.ts b/src/constants.ts index edfe468..df4320a 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -610,7 +610,6 @@ declare const REACTION_TIME: { }; declare const BOOSTS: { - [part: string]: { [boost: string]: { [action: string]: number } }; work: { UO: { harvest: 3; @@ -724,7 +723,7 @@ declare const BOOSTS: { damage: 0.3; }; }; -}; +} & Record>>; declare const INTERSHARD_RESOURCES: InterShardResourceConstant[]; diff --git a/src/helpers.ts b/src/helpers.ts index 62519b7..919c548 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -147,7 +147,7 @@ type BodyPartDefinition = T exten * * If the body part is boosted, this property specifies the mineral type which is used for boosting. */ - boost?: keyof (typeof BOOSTS)[T]; + boost?: keyof typeof BOOSTS[T]; /** * One of the body part types constants. */ diff --git a/src/literals.ts b/src/literals.ts index 53ac152..6c237be 100644 --- a/src/literals.ts +++ b/src/literals.ts @@ -700,3 +700,18 @@ type EffectConstant = EFFECT_INVULNERABILITY | EFFECT_COLLAPSE_TIMER; type EFFECT_INVULNERABILITY = 1001; type EFFECT_COLLAPSE_TIMER = 1002; + +type BoostModifier = + | "harvest" + | "build" + | "repair" + | "dismantle" + | "upgradeController" + | "attack" + | "rangedAttack" + | "rangedMassAttack" + | "heal" + | "rangedHeal" + | "capacity" + | "fatigue" + | "damage";