diff options
author | David Gay <eapoems@riseup.net> | 2023-10-16 14:09:14 -0400 |
---|---|---|
committer | David Gay <eapoems@riseup.net> | 2023-10-16 14:09:14 -0400 |
commit | ffe54d30c162ae83d9a9136a2efc166383797bc1 (patch) | |
tree | 81e786db68356f0945f00df88dc9fe3ef9e92771 /src/rules/npcs.rs | |
parent | 686726b414dcb9d0fe66ec0d64436f51919a0fd1 (diff) |
Use signed ints for ability scores
Diffstat (limited to 'src/rules/npcs.rs')
-rw-r--r-- | src/rules/npcs.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/rules/npcs.rs b/src/rules/npcs.rs index d9fdc0f..dc65dbb 100644 --- a/src/rules/npcs.rs +++ b/src/rules/npcs.rs @@ -30,7 +30,7 @@ impl Npc { pub fn roll_henchman_ability_scores(&mut self) { rand::thread_rng(); - let mut ability_score_rolls: HashMap<AbilityScore, u32> = HashMap::new(); + let mut ability_score_rolls: HashMap<AbilityScore, i32> = HashMap::new(); for &ability in &[ AbilityScore::Strength, @@ -55,14 +55,14 @@ impl Npc { debug!("Bumped prime requisites, now at {}", roll_result.total()); // At this point we don't need the individual dice anymore. - let mut total = roll_result.total(); + let mut total = roll_result.total() as i32; // Add NPC-specific class ability score modifiers. total += class_ref .npc_ability_score_modifiers .get(&ability) .copied() - .unwrap_or(0) as u32; + .unwrap_or(0); debug!("After adding NPC class modifiers, now at {}", total); // Add racial ability score modifiers. @@ -70,14 +70,14 @@ impl Npc { .npc_ability_score_modifiers .get(&ability) .copied() - .unwrap_or(0) as u32; + .unwrap_or(0); debug!("After adding racial modifiers, now at {}", total); // Ensure racial ability score limits are imposed. // TODO: Use u8 for all of these, so no conversion from u32 will be needed. let [min_score, max_score] = race_ref.ability_score_ranges.get(&ability).unwrap().male; - total = total.max(min_score as u32); - total = total.min(max_score as u32); + total = total.max(min_score as i32); + total = total.min(max_score as i32); ability_score_rolls.insert(ability, total); } |