Skip to content

Commit

Permalink
Added conf_core.json
Browse files Browse the repository at this point in the history
  • Loading branch information
ozkriff committed Mar 5, 2014
1 parent 0d7d1dc commit 0b43066
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions conf_core.json
@@ -0,0 +1,6 @@
{
"map_size": {
"w": 9,
"h": 6
}
}
5 changes: 4 additions & 1 deletion core/core.rs
Expand Up @@ -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]),
Expand Down Expand Up @@ -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}));
Expand Down

0 comments on commit 0b43066

Please sign in to comment.