diff options
author | metamuffin <metamuffin@disroot.org> | 2024-07-20 19:29:41 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-07-20 19:29:41 +0200 |
commit | 1a45b0e0f5de785ddf268d7371f0cdaeafe9daa7 (patch) | |
tree | 5712d2d0784da660733e41d1b69636127b71c3b3 /server/src/interaction.rs | |
parent | 89ba8a6b62b90ac72547e2ca9ea5eeae7bbc6500 (diff) | |
download | hurrycurry-1a45b0e0f5de785ddf268d7371f0cdaeafe9daa7.tar hurrycurry-1a45b0e0f5de785ddf268d7371f0cdaeafe9daa7.tar.bz2 hurrycurry-1a45b0e0f5de785ddf268d7371f0cdaeafe9daa7.tar.zst |
refactor score code (and break things)
Diffstat (limited to 'server/src/interaction.rs')
-rw-r--r-- | server/src/interaction.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/server/src/interaction.rs b/server/src/interaction.rs index 2f6c940a..71125ac4 100644 --- a/server/src/interaction.rs +++ b/server/src/interaction.rs @@ -19,7 +19,7 @@ use crate::{ data::Gamedata, game::{Involvement, Item}, }; -use hurrycurry_protocol::{ItemIndex, TileIndex}; +use hurrycurry_protocol::{ItemIndex, Score, TileIndex}; use log::info; use serde::{Deserialize, Serialize}; @@ -115,7 +115,7 @@ pub fn interact( tile: Option<TileIndex>, this: &mut Option<Item>, other: &mut Option<Item>, - points: &mut i64, + score: &mut Score, automated: bool, ) -> Option<InteractEffect> { let interactable = automated @@ -180,6 +180,7 @@ pub fn interact( }); } *this = Some(item); + score.active_recipes += 1; return Some(InteractEffect::Put); } } @@ -200,7 +201,8 @@ pub fn interact( let ok_rev = ok_rev as usize; *other = outputs[1 - ok_rev].map(|kind| Item { kind, active: None }); *this = outputs[ok_rev].map(|kind| Item { kind, active: None }); - *points += pd; + score.points += pd; + score.instant_recipes += 1; return Some(InteractEffect::Produce); } } @@ -234,6 +236,7 @@ pub fn tick_slot( data: &Gamedata, tile: Option<TileIndex>, slot: &mut Option<Item>, + score: &mut Score, ) -> Option<TickEffect> { if let Some(item) = slot { if let Some(a) = &mut item.active { @@ -246,6 +249,7 @@ pub fn tick_slot( if a.progress >= 1. { if let Recipe::Passive { output, .. } = &data.recipe(a.recipe) { *slot = output.map(|kind| Item { kind, active: None }); + score.passive_recipes += 1; return Some(TickEffect::Produce); }; a.progress = 1.; |