Package civquest.map

Examples of civquest.map.MapObjectReader


   * @param gameData game-data to operate on
   * @param movings group of movings
   * @return owner as described, null if not available
   */
  public static Long getOwner(GameDataAccessor gameData, Long[] movings) {
    MapObjectReader moReader = gameData.getMapObjectReader();
    Long owner = null;

    for (Long moving : movings) {
      if (moReader.isMapObjectOwnerAvailable(moving)) {
        Long currOwner = moReader.getMapObjectOwner(moving);
        if (owner == null) {
          owner = currOwner;
        } else
          assert owner.equals(currOwner) : "All movings must have the same owner!";
        }
View Full Code Here


                     Long owner, Coordinate to) {
    if (owner == null) {
      return false;
    } else {
      FieldReader fieldReader = gameData.getFieldReader();
      MapObjectReader moReader = gameData.getMapObjectReader();
      RestrictedToNation resToNation = gameData.getRestrictedToNation();

      if (fieldReader.areMapObjectsAvailable(to)) {
        Iterator<Long> mapObjects = fieldReader.getMapObjects(to);
        while (mapObjects.hasNext()) {
          Long mo = mapObjects.next();
          if (moReader.isMapObjectOwnerAvailable(mo)) {
            Long toOwner = moReader.getMapObjectOwner(mo);
            if (!(owner.equals(toOwner))) {
              return true;
            }
          }
        }
View Full Code Here

    public static Set<Set<Long>> constructUnitGroups(GameDataAccessor data,
                           Set<Long> units) {
    Map<Coordinate, Set<Long>> coordToGroup
      = new HashMap<Coordinate, Set<Long>>();
    MapObjectReader moReader = data.getMapObjectReader();
    for (Long unit : units) {
      Coordinate pos = moReader.getMapObjectPosition(unit);
      if (!coordToGroup.containsKey(pos)) {
        coordToGroup.put(pos, new HashSet<Long>());
      }
      coordToGroup.get(pos).add(unit);
    }
View Full Code Here

  }

  public MoveInfo getMovementChanges(Game game, MoveStep step)
    throws MovementException {

    MapObjectReader moReader = game.getMapObjectReader();
    Coordinate to = step.getTo();

    if (step.getNumberOfUnits() == 0) {
        // there are no Units to move
      throw new MovementException("UnitMover.getMovementChanges: "
                    + "Where are my Units??? "
                    + "I need them!!!");
    }

    Iterator<Long> iterator = step.getUnitIterator();
    int numberOfUnits = 1;

    // exists because of test above
    Long aUnit = iterator.next();
    Coordinate from = moReader.getMapObjectPosition(aUnit);
    // all units need to be on the same field
   
    while (iterator.hasNext()) {
      if (!(from.equals(moReader.getMapObjectPosition(iterator.next())))) {
        // for now
        throw new MovementException("UnitMover.getMovementChanges: "
                      + "All given Units need to be "
                      + "located on the same field!");
      }
View Full Code Here

    private int turn = 0;
    private Coordinate to = null;

    private StepInfo(GameDataAccessor gameData, Long[] units,
             Coordinate to) {
      MapObjectReader moReader = gameData.getMapObjectReader();
      time = new int[units.length];
      for (int n = 0; n < units.length; n++) {
        if (moReader.isMapObjectTimeAvailable(units[n])) {
          time[n] = moReader.getMapObjectTime(units[n]);
        } else {
          // for now
          time[n] = 0;
        }
View Full Code Here

       g.drawString("Remaining time not known", x, y);
     }   
   }

   private void drawHealth(Graphics g, Long unitID, int x, int y, int width) {
    MapObjectReader moReader = gameData.getMapObjectReader();
    if (moReader.isMapObjectHealthAvailable(unitID)) {
       double health = moReader.getMapObjectHealth(unitID);
       float healthPercentile = (float)(health);
       g.drawString("Health: " + (int)(healthPercentile * 100) + "%", x, y);

       int barX = x + 90;
       int barY = y - 8;
View Full Code Here

    g.drawRect(x, y, width, height);
  }

  private void drawDetailInformation(Graphics g, Long unitID,
                     int x, int y, int width) {
    MapObjectReader moReader = gameData.getMapObjectReader();
    if (moReader.asMapObjectAvailable(unitID)) {
      MapObject mo = moReader.getAsMapObject(unitID);
      detailPainter.set(g, x, y, mo);
      try {
        detailCaller.callV(detailPainter, mo);
      } catch (MethodCallerException e) {
        Messages.getMessages().err("DetailedUnitInfoComponent", "Problem with "
View Full Code Here

   *
   *
   * @param unitChange
   */
    private void process(UnitChange unitChange) {
    MapObjectReader moReader = gameData.getMapObjectReader();
    Long[] ids = unitChange.getUnits();
    for (int n = 0;n < ids.length; n++) {
      if (ids[n] >= 0) {
        Long currID = new Long(ids[n]);
        if (moReader.isMapObjectPositionAvailable(currID)) {
          Coordinate position = moReader.getMapObjectPosition(ids[n]);
          fieldViews[position.x][position.y].dataChanged();
        }
      }
    }
  }
View Full Code Here

   *  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 {
View Full Code Here

      blinking = activeGroup.containsUnit(topUnitID);

      // Fetch unit-image
      Section imageSection = ruleset.getSection("unitimages");
     
      MapObjectReader moReader = gameData.getMapObjectReader();
     
      if (!moReader.isMapObjectModelNameAvailable(topUnitID)) {
        // Model-name unknown - TODO: Better handling of the situation
        // "We know there is a unit, but we don't know the type"
        unitImage = null;
        Messages.getMessages().info("QuadIsoLayUnitView", "QMapWarn",
                      "Warning: There is a unit (id: "
                      + topUnitID + "), but I "
                      + "don't know its type!");
      } else {
        String modelName = moReader.getMapObjectModelName(topUnitID)
        String imageName = imageSection.getField(modelName).getStringValue();
        unitImage = layUnitImageSet.getImage(imageName);

        if (unitImage == null) {
          Messages messages = Messages.getMessages();
          messages.err("QuadIsoLayUnitView", "updateImage: No image for unit "
                 + modelName);
          messages.err("QuadIsoLayUnitView",
                 "--> For now we take this as a fatal error - "
                 + "CivQuest will ABORT NOW!!!");
          System.exit(-1);
        }

        if (moReader.isMapObjectOwnerAvailable(topUnitID)) {
          Long owner = moReader.getMapObjectOwner(topUnitID);
          topUnitNationColor = quadMap.getNationColor(owner);
        } else {
          topUnitNationColor = null;
        }
      }
View Full Code Here

TOP

Related Classes of civquest.map.MapObjectReader

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.