// Path: src/VASL/LOS/counters/CounterMetadata.java
// public class CounterMetadata {
// 
//     /*
//         name = game piece name (i.e. piece.getName())
//         hindrance = # of hindrances/hex
//         height = height of LOS hindrance
//         terrain = map terrain type
//         level - denotes location level
//         position - for location denotes if pieces above/below the counter are in the location.
//         coverArch - covered arch of location
// 
//      */
//     private String name;
//     private String terrain;
//     private int height;
//     private int hindrance;
//     private CounterType type;
//     private int level;
//     private String position;
//     private int coverArch;
// 
//     public static enum CounterType {SMOKE, WRECK, OBA, TERRAIN, IGNORE, BUILDING_LEVEL, CREST, ROOF, ENTRENCHMENT, CLIMB, BRIDGE, HEXSIDE}
// 
//     public CounterMetadata(String name, CounterType type) {
//         this.name = name;
//         this.type = type;
//     }
// 
//     /**
//      * @return the counter name
//      */
//     public String getName() {
//         return name;
//     }
// 
//     /**
//      * @return the terrain name (for terrain-type counters)
//      */
//     public String getTerrain() {
//         return terrain;
//     }
// 
//     /**
//      * @return the height (for smoke-type counters)
//      */
//     public int getHeight() {
//         return height;
//     }
// 
//     /**
//      * @return the hindrance amount (for smoke counters)
//      */
//     public int getHindrance() {
//         return hindrance;
//     }
// 
//     /**
//      * @return the counter type
//      */
//     public CounterType getType() {
//         return type;
//     }
// 
//     /**
//      * Set the terrain (for terrain-type counters)
//      * @param terrain the terrain name
//      */
//     public void setTerrain(String terrain) {
//         this.terrain = terrain;
//     }
// 
//     /**
//      * Set the smoke height (for smoke-type counter)
//      * @param height the smoke height
//      */
//     public void setHeight(int height) {
//         this.height = height;
//     }
// 
//     /**
//      * Set the smoke hindrance (for smoke-type counters)
//      * @param hindrance the smoke hindrance level
//      */
//     public void setHindrance(int hindrance) {
//         this.hindrance = hindrance;
//     }
// 
//     /**
//      * @return the location level
//      */
//     public int getLevel() {
//         return level;
//     }
// 
//     /**
//      * Set the location level
//      * @param level the level
//      */
//     public void setLevel(int level) {
//         this.level = level;
//     }
// 
//     /**
//      * @return the piece covered arch
//      */
//     public int getCoverArch() {
//         return coverArch -1;
//     }  //counters use 1-6, code uses 0-5
// 
//     /**
//      * Set the piece covered arch
//      * @param coverArch the covered arch
//      */
//     public void setCoverArch(int coverArch) {
//         this.coverArch = coverArch;
//     }
// 
//     /**
//      * @return the location position
//      */
//     public String getPosition() {
//         return position;
//     }
// 
//     /**
//      * Set the location position
//      * @param position the covered arch
//      */
//     public void setPosition(String position) {
//         this.position = position;
//     }
// }


import java.util.LinkedHashMap;
import VASL.LOS.counters.CounterMetadata;
import VASSAL.build.GameModule;
import VASSAL.tools.DataArchive;
import VASSAL.tools.ErrorDialog;
import org.apache.commons.io.IOUtils;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
import java.io.IOException;
import java.io.InputStream;
/*
 * $Id: CounterMetadataFile 3/30/14 davidsullivan1 $
 *
 * Copyright (c) 2014 by David Sullivan
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License (LGPL) as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, copies are available
 * at http://www.opensource.org.
 */
package VASL.LOS.counters;



/**
 * This class provides access to the counter metadata file in the module archive
 */
public class CounterMetadataFile {

    // name of the counter metadata file in the module archive
    private final static String counterMetadataFileName = "CounterMetadata.xml";

    // XML element and attribute names
    protected static final String counterMetadataElement = "counterMetadata";
    protected static final String smokeCounterElement = "smoke";
    protected static final String OBACounterElement = "OBA";
    protected static final String terrainCounterElement = "terrain";
    protected static final String wreckCounterElement = "wreck";
    protected static final String ignoreCounterElement = "ignore";
    protected static final String bridgeCounterElement = "bridge";
    protected static final String hexsideCounterElement = "hexside";

    protected static final String buildingLevelCounterElement = "buildingLevel";
    protected static final String roofCounterElement = "roof";
    protected static final String entrenchmentCounterElement = "entrenchment";
    protected static final String crestCounterElement = "crest";
    protected static final String climbCounterElement = "climb";

    protected static final String locationCounterElement = "locationCounter";
    protected static final String counterNameAttribute = "name";
    protected static final String counterHindranceAttribute = "hindrance";
    protected static final String counterHeightAttribute = "height";
    protected static final String counterTerrainAttribute = "terrain";
    protected static final String counterLevelAttribute = "level";
    protected static final String counterPositionAttribute = "position";
    protected static final String counterCoveredArchAttribute = "ca";

    // constant values for the counter position attribute
    public static final String counterPositionAbove = "above";
    public static final String getCounterPositionBelow = "below";

    // List of the counter elements
// Path: src/VASL/LOS/counters/CounterMetadata.java
// public class CounterMetadata {
// 
//     /*
//         name = game piece name (i.e. piece.getName())
//         hindrance = # of hindrances/hex
//         height = height of LOS hindrance
//         terrain = map terrain type
//         level - denotes location level
//         position - for location denotes if pieces above/below the counter are in the location.
//         coverArch - covered arch of location
// 
//      */
//     private String name;
//     private String terrain;
//     private int height;
//     private int hindrance;
//     private CounterType type;
//     private int level;
//     private String position;
//     private int coverArch;
// 
//     public static enum CounterType {SMOKE, WRECK, OBA, TERRAIN, IGNORE, BUILDING_LEVEL, CREST, ROOF, ENTRENCHMENT, CLIMB, BRIDGE, HEXSIDE}
// 
//     public CounterMetadata(String name, CounterType type) {
//         this.name = name;
//         this.type = type;
//     }
// 
//     /**
//      * @return the counter name
//      */
//     public String getName() {
//         return name;
//     }
// 
//     /**
//      * @return the terrain name (for terrain-type counters)
//      */
//     public String getTerrain() {
//         return terrain;
//     }
// 
//     /**
//      * @return the height (for smoke-type counters)
//      */
//     public int getHeight() {
//         return height;
//     }
// 
//     /**
//      * @return the hindrance amount (for smoke counters)
//      */
//     public int getHindrance() {
//         return hindrance;
//     }
// 
//     /**
//      * @return the counter type
//      */
//     public CounterType getType() {
//         return type;
//     }
// 
//     /**
//      * Set the terrain (for terrain-type counters)
//      * @param terrain the terrain name
//      */
//     public void setTerrain(String terrain) {
//         this.terrain = terrain;
//     }
// 
//     /**
//      * Set the smoke height (for smoke-type counter)
//      * @param height the smoke height
//      */
//     public void setHeight(int height) {
//         this.height = height;
//     }
// 
//     /**
//      * Set the smoke hindrance (for smoke-type counters)
//      * @param hindrance the smoke hindrance level
//      */
//     public void setHindrance(int hindrance) {
//         this.hindrance = hindrance;
//     }
// 
//     /**
//      * @return the location level
//      */
//     public int getLevel() {
//         return level;
//     }
// 
//     /**
//      * Set the location level
//      * @param level the level
//      */
//     public void setLevel(int level) {
//         this.level = level;
//     }
// 
//     /**
//      * @return the piece covered arch
//      */
//     public int getCoverArch() {
//         return coverArch -1;
//     }  //counters use 1-6, code uses 0-5
// 
//     /**
//      * Set the piece covered arch
//      * @param coverArch the covered arch
//      */
//     public void setCoverArch(int coverArch) {
//         this.coverArch = coverArch;
//     }
// 
//     /**
//      * @return the location position
//      */
//     public String getPosition() {
//         return position;
//     }
// 
//     /**
//      * Set the location position
//      * @param position the covered arch
//      */
//     public void setPosition(String position) {
//         this.position = position;
//     }
// }


// Path: src/VASL/LOS/counters/CounterMetadataFile.java
import java.util.LinkedHashMap;
import VASL.LOS.counters.CounterMetadata;
import VASSAL.build.GameModule;
import VASSAL.tools.DataArchive;
import VASSAL.tools.ErrorDialog;
import org.apache.commons.io.IOUtils;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
import java.io.IOException;
import java.io.InputStream;

/*
 * $Id: CounterMetadataFile 3/30/14 davidsullivan1 $
 *
 * Copyright (c) 2014 by David Sullivan
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License (LGPL) as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, copies are available
 * at http://www.opensource.org.
 */
package VASL.LOS.counters;



/**
 * This class provides access to the counter metadata file in the module archive
 */
public class CounterMetadataFile {

    // name of the counter metadata file in the module archive
    private final static String counterMetadataFileName = "CounterMetadata.xml";

    // XML element and attribute names
    protected static final String counterMetadataElement = "counterMetadata";
    protected static final String smokeCounterElement = "smoke";
    protected static final String OBACounterElement = "OBA";
    protected static final String terrainCounterElement = "terrain";
    protected static final String wreckCounterElement = "wreck";
    protected static final String ignoreCounterElement = "ignore";
    protected static final String bridgeCounterElement = "bridge";
    protected static final String hexsideCounterElement = "hexside";

    protected static final String buildingLevelCounterElement = "buildingLevel";
    protected static final String roofCounterElement = "roof";
    protected static final String entrenchmentCounterElement = "entrenchment";
    protected static final String crestCounterElement = "crest";
    protected static final String climbCounterElement = "climb";

    protected static final String locationCounterElement = "locationCounter";
    protected static final String counterNameAttribute = "name";
    protected static final String counterHindranceAttribute = "hindrance";
    protected static final String counterHeightAttribute = "height";
    protected static final String counterTerrainAttribute = "terrain";
    protected static final String counterLevelAttribute = "level";
    protected static final String counterPositionAttribute = "position";
    protected static final String counterCoveredArchAttribute = "ca";

    // constant values for the counter position attribute
    public static final String counterPositionAbove = "above";
    public static final String getCounterPositionBelow = "below";

    // List of the counter elements
    protected LinkedHashMap<String, CounterMetadata> metadataElements = new LinkedHashMap<String, CounterMetadata>(30);