summaryrefslogtreecommitdiff
path: root/src/inhabitant.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/inhabitant.rs')
-rw-r--r--src/inhabitant.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/inhabitant.rs b/src/inhabitant.rs
new file mode 100644
index 0000000..2ed7de7
--- /dev/null
+++ b/src/inhabitant.rs
@@ -0,0 +1,46 @@
+use std::fmt;
+
+use coordinate;
+
+#[derive(Clone)]
+pub enum Inhabitant {
+ Critter {
+ species: String,
+ offense: i32,
+ defense: i32,
+ size: i32,
+ energy: u32,
+ posture: i32,
+ position: coordinate::Coordinate,
+ direction: coordinate::Direction,
+ },
+ Nothing,
+ Rock,
+ Food {
+ amount: i32,
+ },
+}
+
+impl fmt::Debug for Inhabitant {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ match *self {
+ Inhabitant::Nothing => write!(f, "__"),
+ Inhabitant::Rock => write!(f, "RR"),
+ Inhabitant::Food { amount: amount } => {
+ if amount < 50 {
+ write!(f, "ff")
+ }
+ else if amount < 100 {
+ write!(f, "fF")
+ }
+ else if amount < 200 {
+ write!(f, "Ff")
+ }
+ else {
+ write!(f, "FF")
+ }
+ },
+ Inhabitant::Critter {..} => write!(f, "CC")
+ }
+ }
+}