From 847a577c3ede654319773cd9297b879cd04cc49c Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 13 Jan 2022 10:29:58 -0500 Subject: [PATCH] Show carried weight, and apply inititative pentalties --- src/ai/initiative_system.rs | 9 ++++++++- src/gui.rs | 25 ++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/ai/initiative_system.rs b/src/ai/initiative_system.rs index 8efa42d..535857f 100644 --- a/src/ai/initiative_system.rs +++ b/src/ai/initiative_system.rs @@ -1,7 +1,7 @@ use ::rltk::{DistanceAlg, Point, RandomNumberGenerator}; use ::specs::prelude::*; -use crate::components::{Attributes, Initiative, MyTurn, Position}; +use crate::components::{Attributes, Initiative, MyTurn, Pools, Position}; use crate::RunState; pub struct InitiativeSystem {} @@ -18,6 +18,7 @@ impl<'a> System<'a> for InitiativeSystem { WriteExpect<'a, RunState>, ReadExpect<'a, Entity>, ReadExpect<'a, Point>, + ReadStorage<'a, Pools>, ); fn run(&mut self, data: Self::SystemData) { @@ -31,6 +32,7 @@ impl<'a> System<'a> for InitiativeSystem { mut runstate, player, player_pos, + pools, ) = data; if *runstate != RunState::Ticking { @@ -54,6 +56,11 @@ impl<'a> System<'a> for InitiativeSystem { initiative.current -= attr.quickness.bonus; } + // Apply pool penalty + if let Some(pools) = pools.get(entity) { + initiative.current += f32::floor(pools.total_initiative_penalty) as i32; + } + // TODO: More initiative granting boosts/penalties will go here later // if its the player, we want to go to an AwaitingInput state diff --git a/src/gui.rs b/src/gui.rs index 3e44fb7..260ee0c 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -123,8 +123,31 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) { draw_attribute("Fitness:", &attr.fitness, 6, ctx); draw_attribute("Intelligence:", &attr.intelligence, 7, ctx); + // Initiative and weight + ctx.print_color( + 50, + 9, + white, + black, + &format!( + "{:.0} lbs ({} lbs max)", + player_pools.total_weight, + (attr.might.base + attr.might.modifiers) * 15 + ), + ); + ctx.print_color( + 50, + 10, + white, + black, + &format!( + "Initiative Penalty: {:.0}", + player_pools.total_initiative_penalty + ), + ); + // Equipped - let mut y = 9; + let mut y = 13; let equipped = ecs.read_storage::(); let name = ecs.read_storage::(); for (equipped_by, item_name) in (&equipped, &name).join() {