diff --git a/conf_core.json b/conf_core.json new file mode 100644 index 0000000..4dd1ddf --- /dev/null +++ b/conf_core.json @@ -0,0 +1,6 @@ +{ + "map_size": { + "w": 9, + "h": 6 + } +} diff --git a/core/core.rs b/core/core.rs index 256249d..fb95eda 100644 --- a/core/core.rs +++ b/core/core.rs @@ -3,6 +3,7 @@ use collections::hashmap::HashMap; use cgmath::vector::Vec2; use core::types::{Size2, MInt, UnitId, PlayerId, MapPos}; +use core::conf::Config; pub enum Command { CommandMove(UnitId, ~[MapPos]), @@ -45,13 +46,15 @@ fn get_event_lists() -> HashMap { impl<'a> Core<'a> { pub fn new() -> ~Core { + let config = Config::new("conf_core.json"); + let map_size = config.get("map_size"); let mut core = ~Core { units: HashMap::new(), players: ~[Player{id: PlayerId(0)}, Player{id: PlayerId(1)}], current_player_id: PlayerId(0), core_event_list: ~[], event_lists: get_event_lists(), - map_size: Size2{w: 4, h: 8}, // TODO: Read from json config + map_size: map_size, }; core.do_command(CommandCreateUnit(Vec2{x: 0, y: 0})); core.do_command(CommandCreateUnit(Vec2{x: 0, y: 1}));