Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990use crate::{hooks::Hooks, actor::Actor, item::Item, traits::Serialize};use std::collections::HashMap;use uuid::Uuid;use wasm_bindgen::prelude::*;
pub mod hooks;pub mod traits;pub mod actor;pub mod item;
#[cfg(feature = "pf2e")]pub mod pf2e;
#[cfg(feature = "a5e")]pub mod a5e;
#[cfg(feature = "dnd5e")]pub mod dnd5e;
#[cfg(feature = "sf2e")]pub mod sf2e;
#[wasm_bindgen]pub struct Game { hooks: Hooks, actors: HashMap<Uuid, Actor>, items: HashMap<Uuid, Item>, packs: HashMap<String, Vec<u8>>}
#[wasm_bindgen]impl Game { fn new() -> Self { let packs = HashMap::new();
// need to write code to load each system's packs // might want to embed the binary potentially
Self { hooks: Hooks::new(), actors: HashMap::new(), items: HashMap::new(), packs } }
fn get_actor(&mut self, uuid: String) -> Option<Vec<u8>> { match Uuid::parse_str(&uuid) { Ok(uuid) => { match self.actors.get_mut(&uuid) { Some(actor) => { Some(actor.serialize()) }, None => { println!("Could not find actor {}", uuid); None } } }, Err(err) => { println!("There was an error parsing UUID {}: {}", uuid, err.to_string()); None } } }
fn get_hooks(&mut self) -> &mut Hooks { &mut self.hooks }
fn get_item(&mut self, uuid: String) -> Option<Vec<u8>> { match Uuid::parse_str(&uuid) { Ok(uuid) => { match self.items.get_mut(&uuid) { Some(item) => { Some(item.serialize()) }, None => { println!("Could not find item {}", uuid); None } } }, Err(err) => { println!("There was an error parsing UUID {}: {}", uuid, err.to_string()); None } } }}