diff options
| author | troido <troido@protonmail.com> | 2020-02-07 15:05:59 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-02-07 15:05:59 +0100 |
| commit | bed274c683ffd18a55282247d47780c4f1bf84b5 (patch) | |
| tree | 6e20e6ba099da68354e30b7f7450019188165159 /src/assemblages.rs | |
| parent | 70db58f688f0dbdd69231da570cf8dbb54e5ca81 (diff) | |
all entity construction now uses new templates
Diffstat (limited to 'src/assemblages.rs')
| -rw-r--r-- | src/assemblages.rs | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/assemblages.rs b/src/assemblages.rs deleted file mode 100644 index e8335f3..0000000 --- a/src/assemblages.rs +++ /dev/null @@ -1,50 +0,0 @@ - -use rand::Rng; -use super::components::{Visible, Blocking, Played}; -use super::assemblage; -use super::oldassemblage::Assemblage; - -assemblage!(Wall {}; Visible{sprite: "wall".to_string(), height: 2.0}, Blocking); - -assemblage!(Grass { sprite : String}; Visible{sprite: sprite.to_string(), height: 0.1}); - -impl Grass { - pub fn new() -> Grass { - Grass { - sprite: ["grass1", "grass2", "grass3", "grass1", "grass2", "grass3", "ground"][rand::thread_rng().gen_range(0,7)].to_string() - } - } -} - - -assemblage!(Player {name: String}; Visible{sprite: "player".to_string(), height: 1.0}, Played::new(name.to_string())); - -impl Player { - pub fn new(name: &str) -> Player { - Player { name: name.to_string()} - } -} - - - -#[cfg(test)] -mod tests { - use super::*; - use serde_json::json; - use super::super::hashmap; - #[test] - fn test_assemblage_from_json() { - let mut p = Player::new("Joe"); - assert_eq!(p.name, "Joe"); - p.init_from_json(vec![json!("Bob"), json!("Mike")], hashmap!()); - assert_eq!(p.name, "Bob"); - p.init_from_json(vec![], hashmap!("sprite".to_string() => json!("stone"))); - assert_eq!(p.name, "Bob"); - p.init_from_json(vec![], hashmap!("name".to_string() => json!("Teddy"))); - assert_eq!(p.name, "Teddy"); - p.init_from_json(vec![json!("Bill")], hashmap!("name".to_string() => json!("Stan"))); - assert_eq!(p.name, "Stan"); - } -} - - |
