From d250d67b331c833687f16224c223d77435e72b55 Mon Sep 17 00:00:00 2001 From: demenik Date: Sun, 30 Nov 2025 17:11:00 +0100 Subject: [PATCH] fix: Add growth_stages for seeds (#51) --- assets/config.json | 11 +++++++---- src/features/config/components.rs | 4 ++++ src/features/inventory/components.rs | 14 ++++++++++++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/assets/config.json b/assets/config.json index 43ea227..0eb9d0b 100644 --- a/assets/config.json +++ b/assets/config.json @@ -7,19 +7,22 @@ "name": "Normale Samen", "cost": 1, "grants": 2, - "slice": "Seed1" + "slice": "Seed1", + "growth_stages": 2 }, { "name": "Super-Samen", "cost": 3, "grants": 9, - "slice": "Seed2" + "slice": "Seed2", + "growth_stages": 4 }, { "name": "Zauber-Samen", "cost": 5, "grants": 20, - "slice": "Seed3" + "slice": "Seed3", + "growth_stages": 6 } ] -} +} \ No newline at end of file diff --git a/src/features/config/components.rs b/src/features/config/components.rs index 652e70e..5319dbe 100644 --- a/src/features/config/components.rs +++ b/src/features/config/components.rs @@ -16,6 +16,7 @@ pub struct BerrySeedConfig { pub cost: u32, pub grants: u32, pub slice: String, + pub growth_stages: u32, } impl Default for GameConfig { @@ -30,18 +31,21 @@ impl Default for GameConfig { cost: 1, grants: 2, slice: "Seed1".to_string(), + growth_stages: 2, }, BerrySeedConfig { name: "Super-Samen".to_string(), cost: 3, grants: 9, slice: "Seed2".to_string(), + growth_stages: 4, }, BerrySeedConfig { name: "Zauber-Samen".to_string(), cost: 5, grants: 20, slice: "Seed3".to_string(), + growth_stages: 6, }, ], } diff --git a/src/features/inventory/components.rs b/src/features/inventory/components.rs index 7b793c7..0008095 100644 --- a/src/features/inventory/components.rs +++ b/src/features/inventory/components.rs @@ -1,4 +1,4 @@ -use crate::prelude::*; +use crate::{features::config::components::BerrySeedConfig, prelude::*}; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash)] pub enum ItemType { @@ -40,7 +40,8 @@ impl ItemType { let seed_config = game_config.berry_seeds.iter().find(|s| s.name == *name); if let Some(s) = seed_config { format!( - "Im Shop kaufbar. Kann eingepflanzt werden. Erhalte beim Ernten {} {}.", + "Im Shop kaufbar. Kann eingepflanzt werden. Benötigt {} Fokus-Phasen zum Wachsen. Erhalte beim Ernten {} {}.", + s.growth_stages, s.grants, match s.grants { 1 => ItemType::Berry.singular(game_config), @@ -54,6 +55,15 @@ impl ItemType { } } + pub fn get_seed_config<'a>(&self, game_config: &'a GameConfig) -> Option<&'a BerrySeedConfig> { + match self { + ItemType::Berry => None, + ItemType::BerrySeed { name } => { + game_config.berry_seeds.iter().find(|s| s.name == *name) + } + } + } + pub fn get_sprite(&self, asset_server: Res, game_config: &GameConfig) -> AseSlice { match self { ItemType::Berry => AseSlice {