public Building(Coords coords,IBoard board,int structureType,BasementType basementType){
  id=coords.hashCode();
  coordinates.addElement(coords);
  originalHexes++;
  burning.put(coords,false);
  IHex startHex=board.getHex(coords);
  if (!startHex.containsTerrain(structureType)) {
    throw new IllegalArgumentException("The coordinates, " + coords.getBoardNum() + ", do not contain a building.");
  }
  type=startHex.terrainLevel(structureType);
  bldgClass=startHex.terrainLevel(Terrains.BLDG_CLASS);
  currentCF.put(coords,getDefaultCF(type));
  if (currentCF.get(coords) == Building.UNKNOWN) {
    throw new IllegalArgumentException("Unknown construction type: " + type + ".  The board is invalid.");
  }
  if ((structureType == Terrains.BUILDING) && startHex.containsTerrain(Terrains.BLDG_CF)) {
    currentCF.put(coords,startHex.terrainLevel(Terrains.BLDG_CF));
  }
  if ((structureType == Terrains.BRIDGE) && startHex.containsTerrain(Terrains.BRIDGE_CF)) {
    currentCF.put(coords,startHex.terrainLevel(Terrains.BRIDGE_CF));
  }
  if ((structureType == Terrains.FUEL_TANK) && startHex.containsTerrain(Terrains.FUEL_TANK_CF)) {
    currentCF.put(coords,startHex.terrainLevel(Terrains.FUEL_TANK_CF));
  }
  if (startHex.containsTerrain(Terrains.BLDG_ARMOR)) {
    armor.put(coords,startHex.terrainLevel(Terrains.BLDG_ARMOR));
  }
 else {
    armor.put(coords,0);
  }
  phaseCF.putAll(currentCF);
  basement.put(coords,basementType);
  basementCollapsed.put(coords,startHex.terrainLevel(Terrains.BLDG_BASE_COLLAPSED) == 1);
  for (int dir=0; dir < 6; dir++) {
    if (startHex.containsTerrainExit(structureType,dir)) {
      include(coords.translated(dir),board,structureType);
    }
  }
  StringBuffer buffer=new StringBuffer();
  if (structureType == Terrains.FUEL_TANK) {
    buffer.append("Fuel Tank #");
  }
 else   if (getType() == Building.WALL) {
    buffer.append("Wall #");
  }
 else   if (structureType == Terrains.BUILDING) {
    buffer.append("Building #");
  }
 else   if (structureType == Terrains.BRIDGE) {
    buffer.append("Bridge #");
  }
 else {
    buffer.append("Structure #");
  }
  buffer.append(id);
  name=buffer.toString();
}

public Building ( Coords coords , IBoard board , int structureType , BasementType basementType ) { id = coords . hashCode ( ) ; coordinates . addElement ( coords ) ; originalHexes ++ ; burning . put ( coords , false ) ; IHex startHex = board . getHex ( coords ) ; if ( ! startHex . containsTerrain ( structureType ) ) { throw new IllegalArgumentException ( "The coordinates, " + coords . getBoardNum ( ) + ", do not contain a building." ) ; } type = startHex . terrainLevel ( structureType ) ; bldgClass = startHex . terrainLevel ( Terrains . BLDG_CLASS ) ; currentCF . put ( coords , getDefaultCF ( type ) ) ; if ( currentCF . get ( coords ) == Building . UNKNOWN ) { throw new IllegalArgumentException ( "Unknown construction type: " + type + ".  The board is invalid." ) ; } if ( ( structureType == Terrains . BUILDING ) && startHex . containsTerrain ( Terrains . BLDG_CF ) ) { currentCF . put ( coords , startHex . terrainLevel ( Terrains . BLDG_CF ) ) ; } if ( ( structureType == Terrains . BRIDGE ) && startHex . containsTerrain ( Terrains . BRIDGE_CF ) ) { currentCF . put ( coords , startHex . terrainLevel ( Terrains . BRIDGE_CF ) ) ; } if ( ( structureType == Terrains . FUEL_TANK ) && startHex . containsTerrain ( Terrains . FUEL_TANK_CF ) ) { currentCF . put ( coords , startHex . terrainLevel ( Terrains . FUEL_TANK_CF ) ) ; } if ( startHex . containsTerrain ( Terrains . BLDG_ARMOR ) ) { armor . put ( coords , startHex . terrainLevel ( Terrains . BLDG_ARMOR ) ) ; } else { armor . put ( coords , 0 ) ; } phaseCF . putAll ( currentCF ) ; basement . put ( coords , basementType ) ; basementCollapsed . put ( coords , startHex . terrainLevel ( Terrains . BLDG_BASE_COLLAPSED ) == 1 ) ; for ( int dir = 0 ; dir < 6 ; dir ++ ) { if ( startHex . containsTerrainExit ( structureType , dir ) ) { include ( coords . translated ( dir ) , board , structureType ) ; } } StringBuffer buffer = new StringBuffer ( ) ; if ( structureType == Terrains . FUEL_TANK ) { buffer . append ( "Fuel Tank #" ) ; } else if ( getType ( ) == Building . WALL ) { buffer . append ( "Wall #" ) ; } else if ( structureType == Terrains . BUILDING ) { buffer . append ( "Building #" ) ; } else if ( structureType == Terrains . BRIDGE ) { buffer . append ( "Bridge #" ) ; } else { buffer . append ( "Structure #" ) ; } buffer . append ( id ) ; name = buffer . toString ( ) ; }
construct a building for the given coordinates from the board ' s information . if the building covers multiple hexes , every hex will be included in the building .
