Fixed state update not clamping or checking if dead
This commit is contained in:
parent
e4640a94f8
commit
e9c10bc34f
@ -197,6 +197,10 @@ impl LilFren {
|
||||
|
||||
pub fn update_fren(&mut self, db: &Database) -> Result<(), Error> {
|
||||
if let Some(mut lil_fren) = Self::get_lil_fren(db)? {
|
||||
if lil_fren.is_alive() != AliveState::Alive {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let (hunger_diff, thirst_diff, entertainment_diff) = match lil_fren.state {
|
||||
LilFrenState::Standing => (-0.01, -0.02, -0.01),
|
||||
LilFrenState::TaxFraud => (-0.01, -0.02, 0.01),
|
||||
@ -205,9 +209,9 @@ impl LilFren {
|
||||
LilFrenState::Sleep => (-0.005, -0.01, 0.00),
|
||||
};
|
||||
|
||||
lil_fren.hunger += hunger_diff * self.metabolism;
|
||||
lil_fren.thirst += thirst_diff * self.metabolism;
|
||||
lil_fren.entertainment += entertainment_diff * self.smarts;
|
||||
lil_fren.hunger = (lil_fren.hunger + hunger_diff * self.metabolism).clamp(-1.0, 1.0);
|
||||
lil_fren.thirst = (lil_fren.thirst + thirst_diff * self.metabolism).clamp(-1.0, 1.0);
|
||||
lil_fren.thirst = (lil_fren.entertainment + entertainment_diff * self.smarts).clamp(-1.0, 1.0);
|
||||
|
||||
if thread_rng().gen_bool(0.75) {
|
||||
println!("fren is now {:?}", self.state);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user