A lot more work on a bunch of different parts of the system.

This commit is contained in:
2022-06-11 17:22:46 +02:00
parent 10e93949e4
commit 6e8f4dd4a5
35 changed files with 735 additions and 197 deletions

View File

@@ -1,11 +1,12 @@
use crate::static_data::libraries::data_library::DataLibrary;
use crate::static_data::moves::move_data::MoveData;
use crate::StringKey;
use hashbrown::HashMap;
#[derive(Debug)]
pub struct MoveLibrary {
map: HashMap<String, MoveData>,
list: Vec<String>,
map: HashMap<StringKey, MoveData>,
list: Vec<StringKey>,
}
impl MoveLibrary {
@@ -18,15 +19,15 @@ impl MoveLibrary {
}
impl DataLibrary<'_, MoveData> for MoveLibrary {
fn map(&self) -> &HashMap<String, MoveData> {
fn map(&self) -> &HashMap<StringKey, MoveData> {
&self.map
}
fn list_values(&self) -> &Vec<String> {
fn list_values(&self) -> &Vec<StringKey> {
&self.list
}
fn get_modify(&mut self) -> (&mut HashMap<String, MoveData>, &mut Vec<String>) {
fn get_modify(&mut self) -> (&mut HashMap<StringKey, MoveData>, &mut Vec<StringKey>) {
(&mut self.map, &mut self.list)
}
}
@@ -37,11 +38,12 @@ pub mod tests {
use crate::static_data::libraries::move_library::MoveLibrary;
use crate::static_data::moves::move_data::{MoveCategory, MoveData, MoveTarget};
use crate::static_data::moves::secondary_effect::SecondaryEffect;
use crate::StringKey;
use std::collections::HashSet;
fn build_move() -> MoveData {
MoveData::new(
"foo",
&"foo".into(),
0,
MoveCategory::Physical,
100,
@@ -59,7 +61,7 @@ pub mod tests {
let m = build_move();
// Borrow as mut so we can insert
let w = &mut lib;
w.add("foo", m);
w.add(&StringKey::new("foo"), m);
// Drops borrow as mut
lib