Package civquest.io

Examples of civquest.io.Messages


        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);
        }
View Full Code Here


    String whichTerrainView = ruleField.getStringValue();
    if (whichTerrainView.equals("LayeredTerrainView")) {
      terrainView = new QuadFlatLayTerrainView(position, this, registry, size, gameData);
    } else {
      Messages messages = Messages.getMessages();
     
      messages.info("QuadFlatLayeredFV", "QMapFV", "FallBack",
              "whichTerrainView is not a valid terrain-view!!!");
      messages.info("QuadFlatLayeredFV", "QMapFV", "FallBack",
              "--> Using LayeredTerrainView instead");
      terrainView = new QuadFlatLayTerrainView(position, this, registry, size, gameData);
    }
  }
View Full Code Here

      fromsea = nfromsea;
      fromland = nfromland;
  }

  public void dump() {
    Messages messages = Messages.getMessages();
   
    String modString;

      if(fromsea) {
      if(fromland) {
        modString = "sea and land";
      } else {
        modString = "sea";
      }
    } else {
      if(fromland) {
        modString = "land";
      } else {
        modString = "nothing";
      }
    }

    messages.info("PHGenerator", "PHGenConf", "        --> HeightConstData: "
            + tries + " tries with probability " + probability
            + ", distancefactor " + distancefactor + " to "
            + Field.getHeightString(to) + " from " + modString);
   
  }
View Full Code Here

      List<Object> spdata = ruleset.getSection("spotcoastlineadjustor").getField("conf").getListValue();
      String howtochoose = (String)spdata.get(0);
      if(howtochoose.equals("BYCHANCE")) {
      spotadjustCL_conf.howtochoosedata = spotadjustCL_conf.BYCHANCE;
    } else {
      Messages messages = Messages.getMessages();
      messages.info("PHGenerator", "PHGenWarn", "FallDefault",
              "spotcoastlineadjustor: conf: HOWTOCHOOSEDATA not valid!");
      messages.info("PHGenerator", "PHGenWarn", "FallDefault",
              "--> Assuming BYCHANCE instead");
        spotadjustCL_conf.howtochoosedata = spotadjustCL_conf.BYCHANCE;
    }
      for(int n = 1;n < spdata.size();n++)
    {
View Full Code Here

      dtcShallowSeaCreator = new DTCShallowSeaCreator(ruleset.getSection("DTCShallowSeaCreator"));
  }    

  /** Dumps the current configuration to the screen */
  public void dump() {
    Messages messages = Messages.getMessages();

    messages.info("PHGenerator", "PHGenConf", "PlateHeightGenerator-Configuration");
      messages.info("PHGenerator", "PHGenConf", "--> Edgenumber = " + edgenumber);
      messages.info("PHGenerator", "PHGenConf", "--> maxedgefails = " + maxedgefails);

      switch(whichedgestarter) {
      case ARRAYEDGESTARTER:
      messages.info("PHGenerator", "PHGenConf",
              "--> whichedgestarter = ARRAYEDGESTARTER");
      break;
      case RANDOMPOINTEDGESTARTER:
      messages.info("PHGenerator", "PHGenConf",
              "--> whichedgestarter = RANDOMPOINTEDGESTARTER");
      }

      switch(whichsealandcreator) {
      case SIMPLESEALANDCREATOR:
      messages.info("PHGenerator", "PHGenConf",
              "--> whichsealandcreator = SIMPLESEALANDCREATOR");
      break;
      case RICSEALANDCREATOR:
      messages.info("PHGenerator", "PHGenConf",
              "--> whichsealandcreator = RICSEALANDCREATOR");
      }

      messages.info("PHGenerator", "PHGenConf",
            "--> SimpleSeaLandCreator:");
      messages.info("PHGenerator", "PHGenConf",
            "    --> Seaprobability = " + simpleSLC_seaprobability);
      messages.info("PHGenerator", "PHGenConf",
            "--> RICSeaLandCreator:");
      messages.info("PHGenerator", "PHGenConf",
            "    --> landsize = " + RICSLC_landsize);
      messages.info("PHGenerator", "PHGenConf",
            "    --> correctsize = " + RICSLC_correctsize);
      messages.info("PHGenerator", "PHGenConf",
            "    --> randomprobability = " + RICSLC_randomprob);
      messages.info("PHGenerator", "PHGenConf",
            "    --> islandprobability = " + RICSLC_islandprob);
      messages.info("PHGenerator", "PHGenConf",
            "    --> continentprobability = " + RICSLC_continentprob);
      messages.info("PHGenerator", "PHGenConf",
            "    --> islandnumberoftests = " + RICSLC_islandnumberoftests);
      messages.info("PHGenerator", "PHGenConf",
            "    --> continentnewcprob = " + RICSLC_continentnewcprob);
      messages.info("PHGenerator", "PHGenConf",
            "    --> continentgrowtries = " + RICSLC_continentgrowtries);
      messages.info("PHGenerator", "PHGenConf",
            "--> addEdge_anglemodpastlength = " + addEdge_anglemodpastlength);
      messages.info("PHGenerator", "PHGenConf",
            "--> addEdge_maxcomputetries = " + addEdge_maxcomputetries);
      messages.info("PHGenerator", "PHGenConf",
            "--> addEdge_anglemod = " + addEdge_anglemod);
      messages.info("PHGenerator", "PHGenConf",
            "--> anglechangeprobability = " + anglechangeprobability);
      messages.info("PHGenerator", "PHGenConf",
            "--> adjustplatedirections_sizefactor = "
            + adjustplatedirections_sizefactor);
      messages.info("PHGenerator", "PHGenConf",
            "--> adjustCL_ignoreedgeprobability = "
            + adjustCL_ignoreedgeprobability);
      messages.info("PHGenerator", "PHGenConf",
            "--> adjustCL_spotprobability = " + adjustCL_spotprobability);
      messages.info("PHGenerator", "PHGenConf",
            "--> spotadjustCL_conf:");     

      if(spotadjustCL_conf.howtochoosedata == spotadjustCL_conf.BYCHANCE) {
      messages.info("PHGenerator", "PHGenConf", "    --> howtochoosedata = BYCHANCE");
    }

      for(int n = 0;n < spotadjustCL_conf.data.size();n++) {       
        List currconf = (List)(spotadjustCL_conf.data.get(n));  
        messages.info("PHGenerator", "PHGenConf", "    --> Configuration " + n
              + ", used with probability " +
              ((Double)(currconf.get(0))).doubleValue()
              + " and NoIsolatedSea = "
              + ((Boolean)(currconf.get(1))).toString() + ":");
        for(int m = 2;m < currconf.size();m++) {
          SpotAdjustCoastLineData currdata = (SpotAdjustCoastLineData)
          (currconf.get(m));
          messages.info("PHGenerator", "PHGenConf", "        --> Deep "
                + (m-1) + ": " + currdata.tries
                + " tries, seatolandprob = " + currdata.seatolandprob
                + ", landtoseaprob = " + currdata.landtoseaprob);
      }
    }

      messages.info("PHGenerator", "PHGenConf", "--> hills_number = " + hills_number);
      messages.info("PHGenerator", "PHGenConf", "--> hills_sizefactor = " + hills_sizefactor);
      messages.info("PHGenerator", "PHGenConf", "--> hills_sizeoffset = " + hills_sizeoffset);
      messages.info("PHGenerator", "PHGenConf", "--> islands_number = " + islands_number);
      messages.info("PHGenerator", "PHGenConf",
            "--> islands_sizefactor = " + islands_sizefactor);
      messages.info("PHGenerator", "PHGenConf",
            "--> islands_sizeoffset = " + islands_sizeoffset);
      messages.info("PHGenerator", "PHGenConf",
            "--> Plate-depending-heights: Configuration");
      messages.info("PHGenerator", "PHGenConf",
            "    --> maxdistance = " + pldepheights_maxdistance);

      for(int m = 0;m < 6;m++) {
      for(int n = 0;n < NUMBEROFPRESSURETYPES;n++) {
        switch(m) {
          case 0: messages.info("PHGenerator", "PHGenConf",
                    "    --> uplandland for pressure " + (n+1) + ":");
        break;
          case 1: messages.info("PHGenerator", "PHGenConf",
                    "    --> upsealand for pressure " + (n+1) + ":");
        break;
          case 2: messages.info("PHGenerator", "PHGenConf",
                    "    --> upseasea for pressure " + (n+1) + ":");
        break;
          case 3: messages.info("PHGenerator", "PHGenConf",
                    "    --> downlandland for pressure " + (-(n+1)) + ":");
        break;
          case 4: messages.info("PHGenerator", "PHGenConf",
                    "    --> downsealand for pressure " + (-(n+1)) + ":");
        break;
          case 5: messages.info("PHGenerator", "PHGenConf",
                    "    --> downseasea for pressure " + (-(n+1)) + ":");
        break;
          }
        for(int z = 0;z < platedependingheights[m][n].size();z++) {
          List currv = (List)(platedependingheights[m][n].get(z));
          messages.info("PHGenerator", "PHGenConf",
                  "    --> Configuration " + z+ " used with probability "
                  + ((Double)(currv.get(0))).doubleValue());
          for(int k = 1;k < currv.size();k++)
            ((HeightConstructionData)currv.get(k)).dump();
          }
View Full Code Here

    else
        configuration[distances[n] - 1] = getDistanceValues(fields[n]);
  }

  public void dumpConfiguration() {
    Messages messages = Messages.getMessages();

    messages.info("PHGenerator", "PHGenSSea", "DTCShallowSeaCreator.dumpConfiguration:");
      for(int n = 0;n < configuration.length;n++) {
     
        if(n < configuration.length - 1) {
        messages.info("PHGenerator", "PHGenSSea",
                "--> Configuration for Distance " + (n+1) + ": ");
      } else {
        messages.info("PHGenerator", "PHGenSSea",
                "--> Configuration for greater distances: ");
      }

      StringBuffer confString = new StringBuffer();
     
        for(int z = 0;z < 4;z++) {
        confString.append(configuration[n][z] + " ");
      }

      messages.info("PHGenerator", "PHGenSSea", confString.toString());
    }
  }
View Full Code Here

        startpoint.set(width - 1,startnum - 2 * width
               - edgecoords.size() - height);
        angle = (randomgen.nextDouble() + 0.5) * Math.PI;
          }

    Messages messages = Messages.getMessages();
    messages.info("PHGenerator", "PHGenEdges2",
            "ArrayEdgeStarter: Start at: " + startpoint.x + "," + startpoint.y
            + " with angle " + (angle * (360 / (2 * Math.PI))));
      number = getNewEdgeNumber();
  }
View Full Code Here

    }
    private class RICSeaLandCreator implements SeaLandCreator  // RIC = RandomIslandContinent
    {
  public void computeSeaLand()
  {
    Messages messages = Messages.getMessages();
    messages.info("PHGenerator", "PHGenSLC", "RICSLC-computeSeaLand");
      for(int n = 0;n < plates.size();n++// As long as we don't declare a plate land, it is sea...
    ((Plate)(plates.get(n))).setSea(true);
      if(config.RICSLC_randomprob + config.RICSLC_islandprob + config.RICSLC_continentprob < 0.01)
    {
      messages.info("PHGenerator", "PHGenSLC",
                    "RICSLC: Warning: Probability-sum too small!!!");
      messages.info("PHGenerator", "PHGenSLC",
                    "RICSLC: Danger of endless-loop! Aborting...");
      return;
    }
      if(config.RICSLC_islandnumberoftests < 1) {
     
        messages.err("PHGenerator",
             "RICSLC: islandnumberoftests < 1!!! Would result in endless-loop!");
      messages.err("PHGenerator", "CivQuest will abort NOW!!!");
      System.exit(-1);
    }
      if(config.RICSLC_continentgrowtries < 1) {
        messages.err("PHGenerator",
             "RICSLC: contgrowtries < 1!!! Might result in endless-loop!");
      messages.err("PHGenerator", "CivQuest will abort NOW!!!");
      System.exit(-1);     
    }
      int distrsize = 0;                    // landsize distributed up to now
      int wantedsize = (int)(config.RICSLC_landsize * platesize); // landsize wanted
      if(wantedsize > platesize) {
      String[] categories = {"PHGenWarn", "PHGenPlates", "PHGenSLC"};
        messages.info("PHGenerator", categories,
              "RICSLC: RICSLC_landsize > 1!!! Setting wantedsize = platesize!");
        wantedsize = platesize;
    }
      int platenumber = plates.size();
      Vector<Plate> continent = null;
      while(distrsize < wantedsize)
    {
        double probvalue = randomgen.nextDouble();
        if(probvalue < config.RICSLC_randomprob)
      {
          Plate currplate = (Plate)(plates.get(randomgen.nextInt(platenumber)));
          if(currplate.isSea())
        distrsize += currplate.getSize();
          currplate.setSea(false);

        messages.info("PHGenerator", "PHGenPlates", "PHGenSLC",
                "RICSLC: Turning plate with size " + currplate.getSize()
                + " into land. Distrsize now: " + distrsize);
      }
        else
      if(probvalue < config.RICSLC_randomprob + config.RICSLC_islandprob)
View Full Code Here

   
    public void generate(MapData mapdata) throws RulesetException {
    this.mapdata = mapdata;

    Messages messages = Messages.getMessages();
    init();
    if(mapdata.isFlatEarth()) {
      messages.info("PHGenerator", "PHGenConf", "Generating flat map");
    } else {
      messages.info("PHGenerator", "PHGenConf", "Generating "
              +"right-left-linked map");
    }

    int failnumber = 0;
    while((edges.size() < config.edgenumber) && (failnumber < config.maxedgefails))
      {
        boolean failed = addEdge();
        if(failed)
          failnumber++;
        else
          failnumber = 0;
      }

   
    messages.info("PHGenerator", "PHGenState", edges.size() + " Edges created");
    computeEdgeList();
    messages.info("PHGenerator", "PHGenState", "Edgelist created");
    computePlates();
    messages.info("PHGenerator", "PHGenState", plates.size() + " Plates created");
    computePlateList();
    messages.info("PHGenerator", "PHGenState", "Platelist created");
    computeNeighborPlates();
    messages.info("PHGenerator", "PHGenState", "Neighborplates located");
    computePlateProperties()
    messages.info("PHGenerator", "PHGenState", "Plate properties defined");
    adjustPlateDirections();
    messages.info("PHGenerator", "PHGenState",
            "Move-directions of small plates adjusted.");
    createHGMapData();
    messages.info("PHGenerator", "PHGenState", "HGMapData-object created");
    computeSeaLandInMapdata();
    messages.info("PHGenerator", "PHGenState", "Sea and land in mapdata created");
    adjustCoastLines();
    messages.info("PHGenerator", "PHGenState", "Coastlines adjusted");
    computeHills();
    messages.info("PHGenerator", "PHGenState", "Hills calculated");
    computeIslands();
    messages.info("PHGenerator", "PHGenState", "Islands calculated");
    computePlateDependingHeights();
    messages.info("PHGenerator", "PHGenState", "Mountains, very deep sea, mountains below");
    messages.info("PHGenerator", "PHGenState", " the sea-level, volcanos calculated");
    dumpPlates();
    dumpMapData();
    //        generateCoasts();
    saveToMapData();
    mapdata.calculateDistanceFromCoast();
    computeShallowSea();
    messages.info("PHGenerator", "PHGenState", "Shallow sea calculated");
    }
View Full Code Here

  starting-point and an starting-angle). If the edge starts on an existing edge, the
  existing one is split up into two edges. Then, new fields are added to the edge until
  one of the stopping-criteria is met (they are documented in the source). Finally, the new
  edge is saved in the {@link #edges}-vector. */
    private boolean addEdge() {
    Messages messages = Messages.getMessages();

   
  boolean startfromexistingedge = false;
  int source = config.NOPLATE;
  edgestarter.computeNewStartPoint();
  int number = edgestarter.getNumber();
  Edge newedge = new Edge(number);
  Coordinate currpos = edgestarter.getStartPoint();
  double angle = edgestarter.getStartAngle();

  Messages.getMessages().info("PHGenerator", "PHGenEdges1"
                "Starting new edge at position " + currpos.x + "," + currpos.y
                + " with angle " + angle + " and number " + number);

  if(platemap[currpos.y][currpos.x] == config.NOPLATE)
      {   
    platemap[currpos.y][currpos.x] = number;
    newedge.addCoord(currpos);
    edgecoords.add(currpos);
    wasawayfromsource = true;
    startfromexistingedge = false;
      }
  else
      {
    wasawayfromsource = false;
    startfromexistingedge = true;
    Edge otheredge = getEdge(platemap[currpos.y][currpos.x]);
    int index = otheredge.getIndex(currpos.x,currpos.y);
    source = otheredge.getNumber();
    if((index < otheredge.getLength() - 1) && (index >= 1))
        {
      Coordinate nextcoord = otheredge.getCoord(index + 1);
      Coordinate prevcoord = otheredge.getCoord(index - 1);
      int deltanx = nextcoord.x - currpos.x;
      int deltany = nextcoord.y - currpos.y;
      int deltapx = currpos.x - prevcoord.x;
      int deltapy = currpos.y - prevcoord.y;
      if((deltanx == deltapx) && (deltany == deltapy))
          otheredge.splitUp(currpos.x,currpos.y,false);
      else
          {
        newedge.addCoord(currpos);        
        edgecoords.add(currpos);
        platemap[currpos.y][currpos.x] = number;
        otheredge.splitUp(currpos.x,currpos.y,true);
          }
        }
      }

  while(true) {
    Messages.getMessages().info("PHGenerator", "PHGenEdges2",
                  "--> Loop: Currpos: " + currpos.x + "," + currpos.y +
                  "Angle: " + (angle * (360 / (2 * Math.PI))));


    if((newedge.wasAwayFromMapEdge() == true) && (mapdata.isOnMapEdge(currpos))) {
        // If the edge was already away from the edge of the map (this in order to
        // avoid stopping an edge starting at and parallel to the map-edge right at
        // the beginning) and is now back at it,
        // calculation is stopped and the new edge is saved.

        messages.info("PHGenerator", "PHGenEdges2",
              "--> Stopping edge " + number + " at " + currpos.x + ","
              + currpos.y + " because edge of map is reached.");
      edges.add(newedge);
      // newedge.dump();
      return true;
    }

    Coordinate oldcurrpos = new Coordinate(currpos.x,currpos.y);
    Coordinate prevpos = null;
    Coordinate prevprevpos = null;
    if(newedge.getLength() >= 2)
        prevpos = newedge.getCoord(newedge.getLength() - 2);
    if(newedge.getLength() >= 3)
        prevprevpos = newedge.getCoord(newedge.getLength() - 3);
   
    Coordinate forcednextpos = forceNextPos(currpos,number,source,prevpos,prevprevpos);
   
    int ctries = 0;
    do
        {
      if(forcednextpos == currpos) {
          double realangle = angle;
          if(newedge.getLength() >= config.addEdge_anglemodpastlength)
        {
            double anglemod = config.addEdge_anglemod / (360 / (2 * Math.PI));
            realangle += randomgen.nextDouble() * anglemod - anglemod / 2;
        }
          currpos = mapdata.adjustToMapSize(computeNextPos(oldcurrpos,realangle));
      } else {
          currpos = forcednextpos;

        if (currpos != null) {
          messages.info("PHGenerator", "PHGenEdges2",
                  "--> Forcing position " + currpos.x + "," + currpos.y);
        } else {
          messages.info("PHGenerator", "PHGenEdges2", "--> Forcing position null");
        }

          startfromexistingedge = false;
      }
     
      if(currpos == null) {
          // If the edge exceeds the map, it is stopped.
        if(newedge.wasAwayFromMapEdge()) {
          edges.add(newedge);

          messages.info("PHGenerator", "PHGenEdges2",
                  "Stopping edge " + number + " at " + currpos.x + ","
                  + currpos.y + " because it ran over edge of map.");
          return true;
        } else
            {
            if(newedge.getLength() > 0)
              {
                removeFromEdgeCoordsAfter(newedge.getCoord(0));
                newedge.removeFromPlateMap();
              }

            messages.info("PHGenerator", "PHGenEdges2",
                    "Not saving edge because it hasn't" +
                    " left the edge of map.");
            return false;
            }
       
          }
      ctries++;
        }
    while((startfromexistingedge == true)
          && (platemap[currpos.y][currpos.x] == source)
          && (ctries < config.addEdge_maxcomputetries));

    startfromexistingedge = false;

    if(platemap[currpos.y][currpos.x] == number)    // We were already there...
        {
      newedge.removeAfter(currpos.x,currpos.y);
      removeFromEdgeCoordsAfter(currpos);
        }
    else
        if((edgestarter.getBuddy() != config.NOPLATE)
           && (edgestarter.getBuddy() == platemap[currpos.y][currpos.x]))
      // The brutal method if a edge has touched its buddy: Killing both.
      // Alternative would be removing the part of the buddy with is outside
      // the resulting figure. Problem would be: Many small and unnecessary
      // edges.
      {
          Edge otheredge = getEdge(edgestarter.getBuddy());
          otheredge.removeFromPlateMap();
          edges.removeElement(otheredge);
          newedge.removeFromPlateMap();

        messages.info("PHGenerator", "PHGenEdges2",
                "Not saving edge because it has touched its buddy"
                + " (number of otheredge = "
                + otheredge.getNumber() + ")");
          return false;                                      
      }
        else
      if((platemap[currpos.y][currpos.x] != config.NOPLATE))
          if(newedge.getLength() > 0)
        {
            Coordinate lastcoord = newedge.getCoord(newedge.getLength() - 1);
            int offsetx = currpos.x - lastcoord.x;
            int offsety = currpos.y - lastcoord.y;
            Coordinate testcoord =
          new Coordinate(currpos.x + offsetx,currpos.y + offsety);
            Edge otheredge = getEdge(platemap[currpos.y][currpos.x]);

            if(!mapdata.isOnMap(testcoord)
               || (platemap[testcoord.y][testcoord.x] != config.NOPLATE))
            /*
            if((testcoord.x < 0) || (testcoord.y < 0)
               || (testcoord.x >= width) || (testcoord.y >= height)
               || (platemap[testcoord.y][testcoord.x] != config.NOPLATE))
            */
          {
              otheredge.splitUp(currpos.x,currpos.y,true);
              newedge.addCoord(currpos);
              platemap[currpos.y][currpos.x] = number;
          }
            else
          {
              otheredge.splitUp(currpos.x,currpos.y,false);
          }

            edges.add(newedge);

          messages.info("PHGenerator", "PHGenEdges2",
                  "Stopping edge " + number + " at "
                  + currpos.x + "," + currpos.y
                  + " because edge " + otheredge.getNumber()
                  + " is reached.");

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.