about summary refs log tree commit diff
path: root/src/entities/entity_char.rs
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2019-07-14T18·29-0400
committerGriffin Smith <root@gws.fyi>2019-07-14T18·29-0400
commite7ad87c7301f266dece36e7558c0f212e370aac6 (patch)
tree7da150d5648cc0b17d973bf4a30673f36b20be82 /src/entities/entity_char.rs
parent081146da30bcf1a17d9533c3dc9c735a3a558165 (diff)
Add (statically-included) entity raws
Add a system for statically-included entity raws (which necessitated
making a deserializable existential Color struct) and test it out by
initializing the game (for now) with a single on-screen gormlak.
Diffstat (limited to 'src/entities/entity_char.rs')
-rw-r--r--src/entities/entity_char.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/entities/entity_char.rs b/src/entities/entity_char.rs
new file mode 100644
index 000000000000..578aaf3da5c3
--- /dev/null
+++ b/src/entities/entity_char.rs
@@ -0,0 +1,22 @@
+use crate::display::color::Color;
+use std::fmt::{self, Display, Formatter};
+use termion::color;
+
+#[derive(Debug, Deserialize)]
+pub struct EntityChar {
+    color: Color,
+    #[serde(rename = "char")]
+    chr: char,
+}
+
+impl Display for EntityChar {
+    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+        write!(
+            f,
+            "{}{}{}",
+            color::Fg(&self.color),
+            self.chr,
+            color::Fg(color::Reset)
+        )
+    }
+}