I DID STUFF, GOD A PROC MACRO AND SHIT
This commit is contained in:
commit
22319e84a1
28 changed files with 3101 additions and 0 deletions
28
tests/macro_test.rs
Normal file
28
tests/macro_test.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
use open_tavern::game::character_sheet::EntryType;
|
||||
use tavern_macros::CharacterSheet;
|
||||
|
||||
#[test]
|
||||
fn test_macro() {
|
||||
trait CharacterSheet {
|
||||
fn inputs(&self) -> Vec<(String, EntryType)>;
|
||||
fn fields(&self) -> Vec<(String, EntryType)>;
|
||||
fn get(&self, entry: &str) -> Option<EntryType>;
|
||||
fn set(&mut self, entry: &str, value: EntryType);
|
||||
}
|
||||
|
||||
#[derive(CharacterSheet)]
|
||||
struct Testy {
|
||||
a: String,
|
||||
#[Input("AA")]
|
||||
b: String,
|
||||
#[Input("BB")]
|
||||
c: String,
|
||||
#[Input("Strength")]
|
||||
str: i32,
|
||||
#[Field("Athletics")]
|
||||
#[FieldExpr(self.str + (self.athletics_trained as i32) * 2)]
|
||||
athletics: i32,
|
||||
#[Input("Trained Athletics")]
|
||||
athletics_trained: bool,
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue