Package civquest.map

Examples of civquest.map.FieldReader


  }

  /** Adds a city for the given Nation somewhere on land */
  private void addACity(Nation nation) {
    MapData mapData = Game.getMapData();
    FieldReader fieldReader = Game.getGame().getFieldReader();
    CityReader cityReader = Game.getGame().getCityReader();
    Random random = new Random();
   
    int x = 0, y = 0;

    for (int n = 0; n < 100; n++) {
      x = random.nextInt(mapData.getArrayWidth());
      y = random.nextInt(mapData.getArrayHeight());
     
      if (mapData.isArrayCoordOnMap(x, y)
        && civquest.map.Field.isLand(fieldReader.getHeightLevel(new Coordinate(x, y)))
        && cityReader.getCityID(new Coordinate(x, y)) == null) {
        break;
      }
    }

View Full Code Here


    if (position != null) {
      Field field = quadMap.getFieldAtPosition(position);
   
      if (field != null) {
        GameDataAccessor gameData = quadMap.getGameData();
        FieldReader fieldReader = gameData.getFieldReader();

        Messages messages = Messages.getMessages();
        messages.info("MoveUnitsToWF", "FieldProp", "Information about field at coord "
                + field.getPosition() + ": " + field);
      }
View Full Code Here

  public void initialize() {
    // We don't backup any values
  }

  public boolean isResourceProductionAvailable(Coordinate pos) {
    FieldReader fieldReader = gameData.getFieldReader();
    return fieldReader.isHeightLevelAvailable(pos)
      && fieldReader.isVegetationNameAvailable(pos)
      && fieldReader.isPopulationAvailable(pos);
  }
View Full Code Here

  public ResourceSet getResourceProduction(Coordinate pos) {
    if (!(isResourceProductionAvailable(pos))) {
      throw new InformationNotAvailableException("PropResourceDistributor",
                             "ResourceProduction");
    } else {
      FieldReader fieldReader = gameData.getFieldReader();
      Field.Height heightLevel = fieldReader.getHeightLevel(pos);
      String vegetation = fieldReader.getVegetationName(pos);
      long population = fieldReader.getPopulation(pos);

      ResourceSet resources = getBasicAmount(heightLevel, vegetation);
      resources = resources.mult(population);

      return resources;
View Full Code Here

    public void paintBorders(Coordinate coord, Graphics g) {

      Session session = quadMap.getSession();
      MapData mapData = Game.getMapData();
     
      FieldReader fieldReader = gameData.getFieldReader();
      if (fieldReader.isFieldOwnerAvailable(position)) {
        Long owner = fieldReader.getFieldOwner(position);

        if (owner == null) {
          return;
        }

        g.setColor(session.getNationColor(owner));

        Coordinate[] neighborCoords = position.getDirectNeighborCoords();

        for (Coordinate neighborPos : neighborCoords) {
          Coordinate adjustedNeighborPos
            = mapData.adjustToMapSize((Coordinate)neighborPos.clone());
          if (adjustedNeighborPos == null) {
            continue;
          }

          if (fieldReader.isFieldOwnerAvailable(adjustedNeighborPos)) {
            Long neighborOwner = fieldReader.getFieldOwner(adjustedNeighborPos);
            if (!(owner.equals(neighborOwner))) {
//             if (neighborOwner != null && !(owner.equals(neighborOwner))) {
              Coordinate offset = neighborPos.sub(position);
              paintBorder(g, position, offset, coord);
            }
View Full Code Here

  public Coordinate getPaintSize() {
    return size;
  }

  public int getInformationScore() {
    FieldReader fieldReader = gameData.getFieldReader();

    if (!fieldReader.isVegetationNameAvailable(position)
      || !fieldReader.isHeightLevelAvailable(position)) {
      return 0;
    } else {
      return 100;
    }
  }
View Full Code Here

    }

  }

  private void updateImage() throws RulesetException {
    FieldReader fieldReader = gameData.getFieldReader();

    if (!fieldReader.isVegetationNameAvailable(position)
      || !fieldReader.isHeightLevelAvailable(position)) {
      heightLevelImage = null;
    } else {
      String vegetationName = fieldReader.getVegetationName(position);
      Field.Height heightLevel = fieldReader.getHeightLevel(position);

      ImageSet vegSpecificImageSet
        = getVegSpecificImageSet(layTerrainImageSet, vegetationName);

      heightLevelImage = vegSpecificImageSet.getImage(getImageHeightString(heightLevel));
View Full Code Here

      Section matchingSection = getOverlapSection(vegName, heightLevel);
     
      if (matchingSection == null) {
        images[index] = null;
      } else {
        FieldReader fieldReader = gameData.getFieldReader();
        String toVegName = fieldReader.getVegetationName(position);
        Field.Height toHeightLevel = fieldReader.getHeightLevel(position);

        civquest.parser.ruleset.Field matchingField
          = getOverlapField(matchingSection, toVegName, toHeightLevel);

        if (matchingField != null) {
View Full Code Here

  public Coordinate getPaintSize() {
    return size;
  }

  public int getInformationScore() {
    FieldReader fieldReader = gameData.getFieldReader();

    // TODO: Add case that unit-model is not known
    if (!fieldReader.areUnitsAvailable(position)) {
      return 0;
    }
    return 100;
  }
View Full Code Here

   *  located on the field associated to this unit-view.
   *  This means, units no longer present are removed from the unit-list,
   *  units present on the field, but not yet in the unit-list are added.
   */
  private void updateUnitList() throws RulesetException {
    FieldReader fieldReader = gameData.getFieldReader();
    MapObjectReader moReader = gameData.getMapObjectReader();

    if (!fieldReader.areUnitsAvailable(position)) {
      // No information given according to VisibilityManager
      units.clear();
    } else {
      Iterator<Long> ruIterator = fieldReader.getUnits(position);
      Set<Long> realUnitIDs = new HashSet<Long>();
      while (ruIterator.hasNext()) {
        realUnitIDs.add(ruIterator.next());
      }

View Full Code Here

TOP

Related Classes of civquest.map.FieldReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.