51 lines
801 B
Rust
51 lines
801 B
Rust
|
use serde::Deserialize;
|
||
|
|
||
|
use crate::marble_engine::board::Board;
|
||
|
|
||
|
#[derive(Debug, Deserialize)]
|
||
|
pub struct Level {
|
||
|
id: String,
|
||
|
name: String,
|
||
|
description: String,
|
||
|
init_board: Option<String>,
|
||
|
inputs: Vec<u8>,
|
||
|
outputs: Vec<u8>,
|
||
|
}
|
||
|
|
||
|
impl Level {
|
||
|
pub fn new_sandbox() -> Self {
|
||
|
Self {
|
||
|
id: "sandbox".into(),
|
||
|
name: "Sandbox".into(),
|
||
|
description: String::new(),
|
||
|
init_board: None,
|
||
|
inputs: Vec::new(),
|
||
|
outputs: Vec::new(),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub fn id(&self) -> &str {
|
||
|
&self.id
|
||
|
}
|
||
|
|
||
|
pub fn name(&self) -> &str {
|
||
|
&self.name
|
||
|
}
|
||
|
|
||
|
pub fn description(&self) -> &str {
|
||
|
&self.description
|
||
|
}
|
||
|
|
||
|
pub fn init_board(&self) -> Option<Board> {
|
||
|
self.init_board.as_deref().map(Board::parse)
|
||
|
}
|
||
|
|
||
|
pub fn inputs(&self) -> &[u8] {
|
||
|
&self.inputs
|
||
|
}
|
||
|
|
||
|
pub fn outputs(&self) -> &[u8] {
|
||
|
&self.outputs
|
||
|
}
|
||
|
}
|