From 642aed602372b2ffb956c7667a4c652a23a18771 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 7 Jul 2024 08:30:57 +0000 Subject: [PATCH] Implement Movement Cost (#7) Reviewed-on: https://msrd0.dev/spielemarmelade/turtlegame/pulls/7 Co-authored-by: Dominic Co-committed-by: Dominic --- src/activities/overworld/worldgen.rs | 40 +++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/activities/overworld/worldgen.rs b/src/activities/overworld/worldgen.rs index 809c7b6..49c1bdc 100644 --- a/src/activities/overworld/worldgen.rs +++ b/src/activities/overworld/worldgen.rs @@ -116,22 +116,50 @@ impl Tile { } pub fn can_stand_inside(&self) -> bool { - unimplemented!() + #[allow(clippy::match_like_matches_macro)] // I believe this is better readable + match self { + Self::House { door: false, .. } => false, + _ => true + } } pub fn movement_cost_left(&self) -> MovementCost { - unimplemented!() + match self { + Self::Grass => MovementCost::Default, + Self::Path { left: true, .. } => MovementCost::Path, + Self::Fence { left: false, .. } => MovementCost::Obstacle, + _ => MovementCost::Infinite + } } pub fn movement_cost_right(&self) -> MovementCost { - unimplemented!() + match self { + Self::Grass => MovementCost::Default, + Self::Path { right: true, .. } => MovementCost::Path, + Self::Fence { right: false, .. } => MovementCost::Obstacle, + _ => MovementCost::Infinite + } } pub fn movement_cost_up(&self) -> MovementCost { - unimplemented!() + match self { + Self::Grass => MovementCost::Default, + Self::Path { top: true, .. } => MovementCost::Path, + Self::Fence { top: false, .. } => MovementCost::Obstacle, + _ => MovementCost::Infinite + } } pub fn movement_cost_down(&self) -> MovementCost { - unimplemented!() + match self { + Self::Grass => MovementCost::Default, + Self::Path { bottom: true, .. } => MovementCost::Path, + Self::Fence { bottom: false, .. } => MovementCost::Obstacle, + _ => MovementCost::Infinite + } } pub fn can_enter_house(&self) -> bool { - unimplemented!() + #[allow(clippy::match_like_matches_macro)] // I believe this is better readable + match self { + Self::House { door: true, .. } => true, + _ => false + } } }