Skip to content

Commit

Permalink
Fix harvesting
Browse files Browse the repository at this point in the history
  • Loading branch information
nenadalm committed Jun 30, 2023
1 parent 8493f5f commit d67811a
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ impl FarmProfile {

pub fn harvest(&mut self, x: usize, y: usize, block: u64) -> Result<(), ContractError> {
let plot = self.get_plot(x, y);
let updated_plant = match plot.plant {

match plot.plant {
None => Err(throw_err(&format!(
"Plot [{}, {}] must contain a plant to harvest.",
x, y
Expand All @@ -288,19 +289,10 @@ impl FarmProfile {
)));
}

Ok(plant)
}
}?;

self.set_plot(
x,
y,
Slot {
plant: Some(updated_plant),
..plot
},
);
self.set_plot(x, y, create_field_plot(block));

Ok(())
Ok(())
}
}
}
}

0 comments on commit d67811a

Please sign in to comment.