diff --git a/levels/00_zeroes.json b/levels/00_zeroes.json deleted file mode 100644 index 2094e3b..0000000 --- a/levels/00_zeroes.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "00_zeroes", - "name": "Zeroes", - "description": "learn how to output data\nthis is a multi-line test", - "init_board": null, - "inputs": [], - "outputs": [0, 0, 0, 0, 0, 0, 0, 0] -} \ No newline at end of file diff --git a/levels/01_cat.json b/levels/01_cat.json index ba72b4f..0318e87 100644 --- a/levels/01_cat.json +++ b/levels/01_cat.json @@ -1,7 +1,8 @@ { - "id": "01_cat", + "id": "intro_copy_input", + "sort_order": 12, "name": "Copy Cat", - "description": "learn how to meow", + "description": "read input and output the same thing", "init_board": null, "inputs": [72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 103, 33], "outputs": [72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 103, 33] diff --git a/levels/01_loop.json b/levels/01_loop.json new file mode 100644 index 0000000..960b5c8 --- /dev/null +++ b/levels/01_loop.json @@ -0,0 +1,9 @@ +{ + "id": "intro_loop", + "sort_order": 11, + "name": "Loop", + "description": "repeated output", + "init_board": "o o\n \n*P \n \n \n ", + "inputs": [], + "outputs": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] +} \ No newline at end of file diff --git a/levels/01_zero.json b/levels/01_zero.json new file mode 100644 index 0000000..7de9959 --- /dev/null +++ b/levels/01_zero.json @@ -0,0 +1,9 @@ +{ + "id": "intro_output", + "sort_order": 10, + "name": "Zero", + "description": "learn how to output data", + "init_board": "o o\n \n*P \n \n \n ", + "inputs": [], + "outputs": [0] +} \ No newline at end of file diff --git a/src/level.rs b/src/level.rs index 912a65c..592195c 100644 --- a/src/level.rs +++ b/src/level.rs @@ -3,6 +3,7 @@ use serde::Deserialize; #[derive(Debug, Clone, Deserialize)] pub struct Level { id: String, + sort_order: i32, name: String, description: String, init_board: Option, @@ -15,6 +16,10 @@ impl Level { &self.id } + pub fn sort_order(&self) -> i32 { + self.sort_order + } + pub fn name(&self) -> &str { &self.name } diff --git a/src/main.rs b/src/main.rs index 35159da..74e6ad8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -236,7 +236,7 @@ fn get_levels() -> Vec { levels.push(level); } } - levels.sort_by(|a, b| a.id().cmp(b.id())); + levels.sort_by(|a, b| a.sort_order().cmp(&b.sort_order())); levels }