Package civquest.io

Examples of civquest.io.Messages


      if (field != null) {
        GameDataAccessor gameData = quadMap.getGameData();
        CityReader cityReader = gameData.getCityReader();
        if (cityReader.isCityIDAvailable(field.getPosition())
          && cityReader.getCityID(field.getPosition()) != null) {
          Messages messages = Messages.getMessages();
          messages.info("ConstructTestCityAction", "CityAR",
                  "You can't build more than one city on a field!");
        } else {
          Nation activeNation = Game.getGame().getActiveNation();
          if (activeNation != null) {
            ConstructCity newCityChange
View Full Code Here


        break;
      }
    }

    if (!mapData.isArrayCoordOnMap(x, y)) {
      Messages messages = Messages.getMessages();
      messages.info("CivQuest", "GUITestData",
              "addACity: No suitable place for a city found!");
      return;
    }

    ConstructCity constructCity = new ConstructCity(new Coordinate(x, y),
View Full Code Here

  public void execute() {
    notifyBefore();

    Game game = Game.getGame();
        Messages messages = Messages.getMessages();
        MapData mapData = Game.getMapData();
        Field field = mapData.getField(location);
        Nation nation = game.getNation(owner);

        Iterator<Unit> unitsIt = field.getUnitIterator();
        if (unitsIt.hasNext()) {
            Unit unit = unitsIt.next();
            if (!unit.getOwner().equals(nation)) {
                messages.err("ConstructUnit", "You try to build a unit " +
                        "on a field where another nation's unit is located.");
                return;
            }
        }
        if (field.getCityOnField() != null &&
                !field.getCityOnField().getOwner().equals(nation)) {
            messages.err("ConstructUnit", "You try to build a unit " +
            "on a field where another nation's city is located.");
            return;
        }

//     // for now to make it run
View Full Code Here

   * @return if the given Attackings can attack the given target field using a
   *         neighbor attack
   */
  public static boolean canNeighborAttack(GameDataAccessor gameData,
                      Set<Attacking> attackings, Coordinate target) {
    Messages messages = Messages.getMessages();
    Set<Long> attIDs = IDManager.getIDs(attackings);
    Long owner = getOwner(gameData, attIDs);

    if (attackings.size() == 0) {
      messages.info("CombatCalculator", "CombatCalc",
              "No Attackings given, so no attack possible!");
      return false;
    } else if (target == null) {
      messages.info("CombatCalculator", "CombatCalc",
              "Target field is null [maybe there is no wf?]");
      return false;
    } else if (!(containsForeignTargets(gameData, owner, target))) {
      messages.info("CombatCalculator", "CombatCalc",
              "No foreign targets on the target field.  "
              + "For a neighbor-attack, we need some!");
      return false;
    } else if (!(areOnOneNeighborField(attackings, target))) {
      messages.info("CombatCalculator", "CombatCalc",
              "Attackings are not located on the same neighbor field"
              + " of the target field!  No neighbor attack possible!");
      return false;
    } else {
      messages.info("CombatCalculator", "CombatCalc",
              "No problem, we can neighbor attack.");
      return true;
    }
  }
View Full Code Here

    /************************ Scrolling **********************************/

        ActionListener scrollListener = new ActionListener() {
                public void actionPerformed(ActionEvent event) {
          Messages messages = Messages.getMessages();

          messages.info("QuadMap", "QMapScr",
                  "Scrolling: " + scrollDirection + " pos: "
                  + getShowPosition());       

                    int stepSize;
                    if (config.scrollCorrectBiggerIntervals) {
                        long currentTime = System.currentTimeMillis();     
                        stepSize = (int)(((float)(currentTime - lastTimeScrolled)
                                          / (float)(config.scrollInterval)) * (float)config.scrollStepSize);
     
            messages.info("QuadMap", "QMapScr",
                    "--> stepSize = " + stepSize + " diff: "
                    + (currentTime - lastTimeScrolled) + " config: "
                    + config.scrollInterval);
     
                        lastTimeScrolled = currentTime;
                    } else {
                        stepSize = config.scrollStepSize;
                    }

                    scroll(getShowPosition().add(scrollDirection.mult(stepSize)), getShowSize(),
                           scrollDirection);
                }
            };
 
        scrollTimer = new javax.swing.Timer(config.scrollInterval, scrollListener);

        addMouseMotionListener(new MouseMotionAdapter() {       

                public void mouseMoved(MouseEvent e) {
                    processMousePositionChange(e.getX(), e.getY());
                }

        public void mouseDragged(MouseEvent e) {
                    processMousePositionChange(e.getX(), e.getY());
        }
            });

        addMouseListener(new MouseAdapter() {
                public void mouseExited(MouseEvent e) {
                    if (sensitiveAreaEnabled) {
                        scrollTimer.stop();
                        scrollDirection = new Coordinate(0,0);
                    }
                    updateWorkingField(null);
                }
            });   

    /*************************** Buffers **********************************/

        ActionListener bufferListener = new ActionListener() {
                public void actionPerformed(ActionEvent event) {

          boolean anyBufferUpdated = false;

          try {
            anyBufferUpdated = bufferManager.updateBuffers();
          } catch (InvalidImageException e) {
            Messages messages = Messages.getMessages();
            messages.err("QuadMap", "Error when trying to update buffers!");
            messages.err("QuadMap", "--> Reason: " + e);
            messages.err("QuadMap", "--> Aborting CivQuest!!!");
            System.exit(-1);                    
          }

          if (anyBufferUpdated) {
            repaint();
View Full Code Here

    }

   
   
    private void updateWorkingField(Point position) {
        Messages messages = Messages.getMessages();

        if (this.setWFByMouse()) {
            Field pointedField = this.getFieldAtPosition(position);
            if (pointedField != this.getWorkingField()) {
                Coordinate pos = null;
                if (pointedField != null) {
                    pos = pointedField.getPosition();
                }
                SetWorkingField setWFChange = new SetWorkingField(this, pos);
                setWFChange.execute();
            }          
        } else if (this.setWFByKeyboard()) {
            messages.err("QuadMap", "setWFByKeyboard not yet implemented");
        } else {
            messages.err("QuadMap", "QuadMap: BUG!!! " +
                         "Either setWFByMouse or setWFByKeyboard " +
                         "must be true!!!");
           
        }
    }
View Full Code Here

   @param gameDataAccessor new game-data, required to be != null
   */
  public void newData(GameDataAccessor gameDataAccessor) {

    // marking/unmarking?
    Messages messages = Messages.getMessages();

    assert gameDataAccessor != null;

    this.gameDataAccessor = gameDataAccessor;

    // hack to make it run in 0.0.22
    if (gameDataToNationInfo.containsKey(gameDataAccessor)
      && gameDataAccessor == Game.getGame()) {
      gameDataToNationInfo.remove(gameDataAccessor);
    }


    if (gameDataToNationInfo.containsKey(gameDataAccessor)) {
      nationInfo = gameDataToNationInfo.get(gameDataAccessor);
      scroll(nationInfo.getShowPosition(), getShowSize());
        } else {
            try {
          nationInfo = new NationInfo(gameDataAccessor, this);

        java.util.List<Section> listenerSections
          = properties.getListenerSectionsForParent();
        Iterator<Section> iterator = listenerSections.listIterator();
        while (iterator.hasNext()) {
          Section currSection = iterator.next();
          try {
            RulesetGameChangeLoader.addListener(currSection,
                              nationInfo);
          } catch (GameChangeException e) {
            messages.err("QuadMap.IsoProp", "Error "
                   + "when setting up listeners: " + e);
            System.exit(-1);       
          }
        }

               
        gameDataToNationInfo.put(gameDataAccessor, nationInfo);
        bufferManager.registerNation(gameDataAccessor);
        if (!fvFunctionsActivated) {
          Set<Function> fieldViewFunctions
            = nationInfo.getOneFieldViewFunctions();
          FunctionManager
            .addSuperComponentPrefix(fieldViewFunctions,
                         FunctionFieldViewManager.
                         FIELDVIEW_PREFIX);
          AbstractFieldView
            .constructFVFunctionActions(fieldViewFunctions, this);
          functionManager.addFunctions(fieldViewFunctions);
          functionManager.deactivateAllFunctions(this);
          functionManager.activateAllFunctions(this);
          fvFunctionsActivated = true;
        }
      } catch (InvalidInputEventException e) {
        messages.err("QuadMap", "civquest.swing.quadmap.QuadMap." +
               "newData says: ");
        messages.err("QuadMap", "Input-event " + e.getEvent()
               + " (assigned to"
               + " function " + e.getFunction() + ") has "
               + "invalid syntax!");
        messages.err("QuadMap", "===> CivQuest will abort now!");
        System.exit(-1);      
      } catch (InvalidParameterException e) {
        messages.err("QuadMap", "civquest.swing.quadmap.QuadMap.newData says: ");
        messages.err("QuadMap", "There is a problem with the parameters: "
               + e.getMessage());
        messages.err("QuadMap", "===> CivQuest will abort now!");
        System.exit(-1);     
      } catch (InvalidRulesetException e) {
        messages.err("QuadMap", "civquest.swing.quadmap.QuadMap.newData says: ");
        messages.err("QuadMap", "The structure of the ruleset-section specifying " +
               "the functions is invalid!");
        messages.err("QuadMap", "Reason: " + e);
        messages.err("QuadMap", "===> CivQuest will abort now!");
        System.exit(-1);
      } catch (FunctionException e) {
        messages.err("QuadMap", "civquest.swing.quadmap.QuadMap.newData says: ");
        messages.err("QuadMap", "Some error occured: " + e);
        messages.err("QuadMap", "===> CivQuest will abort now!");
        System.exit(-1);     
      } catch (RulesetException e) {
        e.printStackTrace();

        String message = "There was an error related to ruleset-loading:\n "
View Full Code Here

    try {
      RulesetFunctionLoader.addFunctions(functionManager,
                         globalFctSection.toSwifuSection());
    } catch (FunctionException e) {
      Messages messages = Messages.getMessages();
      messages.err("GlobalFctComp", "Some error occured: " + e);
       messages.err("GlobalFctComp", "===> CivQuest will abort now!");
       System.exit(-1);     
    }
  }
View Full Code Here

      return tArr;
  }

  public AirTemperatureMap(MapData mapdata, int mapType,
               int polTemp, int eqTemp, int bands) {
    Messages messages = Messages.getMessages();

      this.mapdata = mapdata;
      this.eqTemp = eqTemp;
      this.polTemp = polTemp;    
      this.bands = bands;
      mapwidth = mapdata.getMapWidth();
      int doubleSize = 1;
      if (mapType == Const.FLAT)
      mapheight = (mapdata.getMapHeight());
      else{
      mapheight = (mapdata.getMapHeight()*2)-1;     
      doubleSize = 2;
      }
     
      map = new int[mapwidth][mapheight];
      int temps[] = temperatures(polTemp, eqTemp, bands);
    String tempString = "";
      for (int i = 0; i<temps.length; i++)
      tempString = tempString + temps[i] + " ";

    messages.info("ClimateGenerator", "CVGenTemp", tempString);
    messages.info("ClimateGenerator", "CVGenTemp", "CVGenState", "Temperatures created");
      for (int i = 0; i<bands; i++)
      setTemps(i*(mapheight/2)/bands,mapheight-i*(mapheight/2)/bands,temps[i]);
    messages.info("ClimateGenerator", "CVGenTemp", "CVGenState", "Temperatures set");

      for (int i = 0; i<bands; i++) {
      createBand(i*(mapheight/2/bands),mapheight/(bands*2)+(i*((mapheight/2)/bands)),temps[i]+1);
        createBand(mapheight-(mapheight/(bands*2)+(i*(mapheight/2)/bands)),mapheight-i*((mapheight/2)/bands),temps[i]+1);
      }    
View Full Code Here

   
      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);
      }
    } else {
      Messages messages = Messages.getMessages();
      messages.info("MoveUnitsToWF", "FieldProp", "No field at " + position);
    }
  }
View Full Code Here

TOP

Related Classes of civquest.io.Messages

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.