Skip to content

Commit

Permalink
Group various params in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
nenadalm committed Jun 29, 2023
1 parent f7f500b commit f53a632
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::str::FromStr;

use cosmwasm_schema::cw_serde;

use crate::ContractError;
use crate::{params, ContractError};

#[cw_serde]
pub enum SlotType {
Expand Down Expand Up @@ -96,7 +96,7 @@ impl Slot {
pub fn is_field_turned_meadow(&self, block: u64) -> bool {
self.r#type == SlotType::Field
&& match &self.plant {
None => block - self.created_at > 10,
None => block - self.created_at > params::FIELD_TURNS_MEADOW,
Some(_) => false,
}
}
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mod error;
pub mod farm;
pub mod helpers;
pub mod msg;
pub mod params;
pub mod receive;
pub mod state;
#[cfg(test)]
Expand Down
3 changes: 3 additions & 0 deletions src/params.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub const GROWTH_PERIOD_SUNFLOWER: u64 = 10;
pub const GROWTH_PERIOD_WHEET: u64 = 10;
pub const FIELD_TURNS_MEADOW: u64 = 10;
6 changes: 3 additions & 3 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
farm::{KomplePlant, Plant, PlantType, Slot, SlotType},
helpers::throw_err,
msg::ContractInformationResponse,
ContractError,
params, ContractError,
};

fn plant_dto(plant: &Option<Plant>, block: u64) -> Option<PlantDto> {
Expand Down Expand Up @@ -109,15 +109,15 @@ fn create_plant(plant_type: &PlantType, komple: Option<KomplePlant>, block: u64)
r#type: PlantType::Sunflower,
stages: 5,
komple,
growth_period: 10,
growth_period: params::GROWTH_PERIOD_SUNFLOWER,
created_at: block,
watered_at: vec![block],
},
PlantType::Wheat => Plant {
r#type: PlantType::Wheat,
stages: 4,
komple,
growth_period: 10,
growth_period: params::GROWTH_PERIOD_WHEET,
created_at: block,
watered_at: vec![block],
},
Expand Down

0 comments on commit f53a632

Please sign in to comment.