diff --git a/src/Parser.cs b/src/Parser.cs index e6604c6..8945d00 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -169,8 +169,9 @@ namespace WorldOfPeacecraft } Map map = new Map(height, width); foreach (Block cell in cellsBlock.GetBlocks()) { - // TODO Fertigstellen + map.SetTile(MapMapcell(cell)); } + backend.SetMap(map); } private void ProcessMessage (Block block) @@ -238,13 +239,39 @@ namespace WorldOfPeacecraft return new Player (id, x, y, desc, busy, score); } - private ITile MapMapcell (Block cellBlock) + private Tile MapMapcell (Block cellBlock) { - CheckBlocksSize(cellBlock, 1, 1); - int x = cellBlock.GetIntValue("col"); - int y = cellBlock.GetIntValue("row"); + CheckBlocksSize (cellBlock, 1, 1); + int x = cellBlock.GetIntValue ("col"); + int y = cellBlock.GetIntValue ("row"); Block propsBlock = cellBlock.GetBlocks ().First.Value; - // TODO Fertigstellen + bool walkable = false; + bool wall = false; + bool forest = false; + bool water = false; + bool huntable = false; + foreach (string prop in propsBlock.GetUnnamedValues()) { + switch (prop) { + case "WALKABLE": + walkable = true; + break; + case "WALL": + wall = true; + break; + case "FOREST": + forest = true; + break; + case "WATER": + water = true; + break; + case "HUNTABLE": + huntable = true; + break; + default: + throw new ParsingException("Unknown mapcell-property '" + prop + "'"); + } + } + return new Tile(x,y,walkable, wall, forest, huntable, water); } private void ThrowUnknownBlockException (Block parentBlock, Block childBlock)