public static Element factory(Map data) throws Exception {
        if (data == null) {
            return null;
        }
        Element element = null;

        if (data.get("type").equals("wall")) {
            element = new Wall();
        } else if (data.get("type").equals("bomb")) {
            element = new Bomb();
        } else if (data.get("type").equals("bonus")) {
            element = new Bonus();
            ((Bonus) element).setType(Client.convertToInt(data.get("bonus_type")));
        }

        if (element == null) {
            throw new Exception("Unknown Element");
        }

        element.setIndex(Client.convertToInt(data.get("index")));
        if (data.containsKey("breakable")) {
            element.setBreakable((Boolean) data.get("breakable"));
        }
        if (data.containsKey("walkable")) {
            element.setWalkable((Boolean) data.get("walkable"));
        }
        return element;

    }