Skip to content
Browse files

Added conf_core.json

  • Loading branch information...
1 parent 0d7d1dc commit 0b43066d0257f9aa91725c9ab110664424b461f2 @ozkriff committed Mar 5, 2014
Showing with 10 additions and 1 deletion.
  1. +6 −0 conf_core.json
  2. +4 −1 core/core.rs
View
6 conf_core.json
@@ -0,0 +1,6 @@
+{
+ "map_size": {
+ "w": 9,
+ "h": 6
+ }
+}
View
5 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<PlayerId, ~[Event]> {
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}));

0 comments on commit 0b43066

Please sign in to comment.
Something went wrong with that request. Please try again.