fix: Add growth_stages for seeds (#51)

This commit is contained in:
demenik
2025-11-30 17:11:00 +01:00
parent 710f7beb5a
commit d250d67b33
3 changed files with 23 additions and 6 deletions

View File

@@ -7,19 +7,22 @@
"name": "Normale Samen", "name": "Normale Samen",
"cost": 1, "cost": 1,
"grants": 2, "grants": 2,
"slice": "Seed1" "slice": "Seed1",
"growth_stages": 2
}, },
{ {
"name": "Super-Samen", "name": "Super-Samen",
"cost": 3, "cost": 3,
"grants": 9, "grants": 9,
"slice": "Seed2" "slice": "Seed2",
"growth_stages": 4
}, },
{ {
"name": "Zauber-Samen", "name": "Zauber-Samen",
"cost": 5, "cost": 5,
"grants": 20, "grants": 20,
"slice": "Seed3" "slice": "Seed3",
"growth_stages": 6
} }
] ]
} }

View File

@@ -16,6 +16,7 @@ pub struct BerrySeedConfig {
pub cost: u32, pub cost: u32,
pub grants: u32, pub grants: u32,
pub slice: String, pub slice: String,
pub growth_stages: u32,
} }
impl Default for GameConfig { impl Default for GameConfig {
@@ -30,18 +31,21 @@ impl Default for GameConfig {
cost: 1, cost: 1,
grants: 2, grants: 2,
slice: "Seed1".to_string(), slice: "Seed1".to_string(),
growth_stages: 2,
}, },
BerrySeedConfig { BerrySeedConfig {
name: "Super-Samen".to_string(), name: "Super-Samen".to_string(),
cost: 3, cost: 3,
grants: 9, grants: 9,
slice: "Seed2".to_string(), slice: "Seed2".to_string(),
growth_stages: 4,
}, },
BerrySeedConfig { BerrySeedConfig {
name: "Zauber-Samen".to_string(), name: "Zauber-Samen".to_string(),
cost: 5, cost: 5,
grants: 20, grants: 20,
slice: "Seed3".to_string(), slice: "Seed3".to_string(),
growth_stages: 6,
}, },
], ],
} }

View File

@@ -1,4 +1,4 @@
use crate::prelude::*; use crate::{features::config::components::BerrySeedConfig, prelude::*};
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash)] #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash)]
pub enum ItemType { pub enum ItemType {
@@ -40,7 +40,8 @@ impl ItemType {
let seed_config = game_config.berry_seeds.iter().find(|s| s.name == *name); let seed_config = game_config.berry_seeds.iter().find(|s| s.name == *name);
if let Some(s) = seed_config { if let Some(s) = seed_config {
format!( 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, s.grants,
match s.grants { match s.grants {
1 => ItemType::Berry.singular(game_config), 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<AssetServer>, game_config: &GameConfig) -> AseSlice { pub fn get_sprite(&self, asset_server: Res<AssetServer>, game_config: &GameConfig) -> AseSlice {
match self { match self {
ItemType::Berry => AseSlice { ItemType::Berry => AseSlice {