KeplerBR

[FreeCol] Interval minimum distance to create a new colony

May 11th, 2014
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 7.85 KB | None | 0 0
  1.  data/mods/bryce/specification.xml                  |  0
  2.  data/rules/classic/specification.xml               |  7 +++--
  3.  data/rules/freecol/specification.xml               |  3 ++
  4.  data/strings/FreeColMessages.properties            |  3 ++
  5.  .../freecol/client/control/InGameController.java   | 33 ++++++++++++++++------
  6.  src/net/sf/freecol/common/model/GameOptions.java   |  4 +++
  7.  6 files changed, 40 insertions(+), 10 deletions(-)
  8.  
  9. diff --git a/data/rules/classic/specification.xml b/data/rules/classic/specification.xml
  10. index 1a12abc..687d059 100644
  11. --- a/data/rules/classic/specification.xml
  12. +++ b/data/rules/classic/specification.xml
  13. @@ -3124,7 +3124,7 @@ resources of 400, lost city rumours of 500
  14.          <!-- Per turn probability that an angry AI will continue to
  15.               honour a recent peace treaty -->
  16.          <percentageOption id="model.option.peaceProbability"
  17. -                          defaultValue="90"/>
  18. +                       defaultValue="90"/>
  19.          <!-- Per turn immigration penalty for units in Europe. -->
  20.          <integerOption id="model.option.europeanUnitImmigrationPenalty"
  21.                         defaultValue="-4" minimumValue="-100" maximumValue="0"/>
  22. @@ -3149,6 +3149,9 @@ resources of 400, lost city rumours of 500
  23.          <!-- Whether to educate the least skilled unit first -->
  24.          <booleanOption id="model.option.allowStudentSelection"
  25.                         defaultValue="false"/>
  26. +        <!-- Interval minimum distance to create a new colony. -->
  27. +        <integerOption id="model.option.intervalBetweenColonies"
  28. +                       defaultValue="0" value="0" minimumValue="0" maximumValue="4" />
  29.          <!-- Enable upkeep requirement on buildings. -->
  30.          <booleanOption id="model.option.enableUpkeep"
  31.                         defaultValue="false"/>
  32. @@ -3157,7 +3160,7 @@ resources of 400, lost city rumours of 500
  33.                         defaultValue="true" />
  34.          <!-- Enable natural disasters striking colonies. -->
  35.          <percentageOption id="model.option.naturalDisasters"
  36. -                          defaultValue="0"/>
  37. +                       defaultValue="0"/>
  38.        </optionGroup>
  39.        <optionGroup id="gameOptions.victoryConditions">
  40.          <!-- Victory condition: Should the player who first defeats
  41. diff --git a/data/rules/freecol/specification.xml b/data/rules/freecol/specification.xml
  42. index 7c7dd75..25a5c51 100644
  43. --- a/data/rules/freecol/specification.xml
  44. +++ b/data/rules/freecol/specification.xml
  45. @@ -192,6 +192,9 @@
  46.          <!-- Whether to educate the least skilled unit first -->
  47.          <booleanOption id="model.option.allowStudentSelection"
  48.                         defaultValue="true"/>
  49. +        <!-- Interval minimum distance to create a new colony. -->
  50. +        <integerOption id="model.option.intervalBetweenColonies"
  51. +                       defaultValue="0" value="0" minimumValue="0" maximumValue="4"/>
  52.        </optionGroup>
  53.      </optionGroup>
  54.    </options>
  55. diff --git a/data/strings/FreeColMessages.properties b/data/strings/FreeColMessages.properties
  56. index 55d8efe..611e630 100644
  57. --- a/data/strings/FreeColMessages.properties
  58. +++ b/data/strings/FreeColMessages.properties
  59. @@ -686,6 +686,8 @@ gameOptions.colony.name=Colony Options
  60.  gameOptions.colony.shortDescription=Contains options relating to the behavior of colonies.
  61.  model.option.customIgnoreBoycott.name=Custom house ignores boycott
  62.  model.option.customIgnoreBoycott.shortDescription=The Custom house can sell goods under boycott.
  63. +model.option.intervalBetweenColonies.name=Interval minimum distance to create a new colony
  64. +model.option.intervalBetweenColonies.shortDescription=Limits the creation of colonies next according to the value specified
  65.  model.option.expertsHaveConnections.name=Experts have connections
  66.  model.option.expertsHaveConnections.shortDescription=Experts can use their connections to provide minimal amounts of resources for production in factories.
  67.  model.option.foundColonyDuringRebellion.name=Found colonies during rebellion
  68. @@ -1367,6 +1369,7 @@ buildColony.noBuildingMaterials=Your new colony would produce very little %goods
  69.  buildColony.IndianLand=Part of your new colony's land is already claimed by natives.
  70.  buildColony.EuropeanLand=Part of your new colony's land is already owned by Europeans.
  71.  buildColony.ownLand=Part of your new colony's land is already owned by you.
  72. +buildColony.ownLandForbidden=Not permitted to create a new colony's at a distance of %interval% tiles of another European colony!
  73.  buildColony.yes=Lay the foundations!
  74.  buildColony.no=We should reconsider.
  75.  buildColony.others=The %nation% have founded the new colony of %colony% in %region%.
  76. diff --git a/src/net/sf/freecol/client/control/InGameController.java b/src/net/sf/freecol/client/control/InGameController.java
  77. index ace6e0d..d575476 100644
  78. --- a/src/net/sf/freecol/client/control/InGameController.java
  79. +++ b/src/net/sf/freecol/client/control/InGameController.java
  80. @@ -1522,19 +1522,36 @@ public final class InGameController implements NetworkConstants {
  81.          if (!requireOurTurn()) return;
  82.          final Specification spec = getSpecification();
  83.          final Player player = freeColClient.getMyPlayer();
  84. -
  85. +        final Unit unit = gui.getActiveUnit();
  86. +        final Tile tile = unit.getTile();
  87. +        
  88.          // Check unit can build, and is on the map.
  89. -        // Show the colony warnings if required.
  90. -        Unit unit = gui.getActiveUnit();
  91. -        if (unit == null) {
  92. -            return;
  93. -        } else if (!unit.canBuildColony()) {
  94. +        if (!unit.canBuildColony()) {
  95.              gui.showInformationMessage(unit,
  96.                  StringTemplate.template("buildColony.badUnit")
  97.                      .addName("%unit%", unit.getName()));
  98.              return;
  99.          }
  100. -        Tile tile = unit.getTile();
  101. +        
  102. +        // Check if this next to a European colony
  103. +        int interval = player.getGame().getSpecification().getInteger(GameOptions.CUSTOM_INTERVAL_BETWEEN_COLONIES);
  104. +        if (interval > 0) {
  105. +            boolean nextColonia = false;
  106. +            for (Tile ownTile : tile.getSurroundingTiles(interval)) {
  107. +                Colony colony = ownTile.getColony();
  108. +                if (colony != null && colony.getOwner().isEuropean()) {
  109. +                    nextColonia = true;
  110. +                    break;
  111. +                }
  112. +            }
  113. +            if (nextColonia == true) {
  114. +                gui.showInformationMessage(StringTemplate.template("buildColony.ownLandForbidden")
  115. +                        .addName("%interval%", String.valueOf(interval)));
  116. +                return;
  117. +            }
  118. +        }
  119. +        
  120. +        // Show the colony warnings if required.
  121.          if (tile.getColony() != null) {
  122.              askServer().joinColony(unit, tile.getColony());
  123.              return;
  124. @@ -1562,7 +1579,7 @@ public final class InGameController implements NetworkConstants {
  125.              // One more check that founding can now proceed.
  126.              if (!player.canClaimToFoundSettlement(tile)) return;
  127.          }
  128. -
  129. +        
  130.          // Get and check the name.
  131.          String name = player.getSettlementName(null);
  132.          name = gui.showInputDialog(true, tile,
  133. diff --git a/src/net/sf/freecol/common/model/GameOptions.java b/src/net/sf/freecol/common/model/GameOptions.java
  134. index c2e7805..f654a11 100644
  135. --- a/src/net/sf/freecol/common/model/GameOptions.java
  136. +++ b/src/net/sf/freecol/common/model/GameOptions.java
  137. @@ -106,6 +106,10 @@ public class GameOptions {
  138.      public static final String CUSTOM_IGNORE_BOYCOTT
  139.          = "model.option.customIgnoreBoycott";
  140.  
  141. +    /** Interval minimum distance to create a new colony */
  142. +    public static final String CUSTOM_INTERVAL_BETWEEN_COLONIES
  143. +        = "model.option.intervalBetweenColonies";
  144. +    
  145.      /**
  146.       * Whether experts have connections, producing without raw
  147.       * materials in factories.
Add Comment
Please, Sign In to add comment