|
From: <ev...@us...> - 2011-07-08 10:08:11
|
Revision: 1611
http://rails.svn.sourceforge.net/rails/?rev=1611&view=rev
Author: evos
Date: 2011-07-08 10:08:04 +0000 (Fri, 08 Jul 2011)
Log Message:
-----------
Added location attribute to SpecialRight
Modified Paths:
--------------
trunk/18xx/data/1830/CompanyManager.xml
trunk/18xx/rails/game/special/SpecialRight.java
Modified: trunk/18xx/data/1830/CompanyManager.xml
===================================================================
--- trunk/18xx/data/1830/CompanyManager.xml 2011-07-07 19:23:32 UTC (rev 1610)
+++ trunk/18xx/data/1830/CompanyManager.xml 2011-07-08 10:08:04 UTC (rev 1611)
@@ -26,7 +26,7 @@
<CanUseSpecialProperties/>
<SpecialProperties>
<SpecialProperty condition="ifOwnedByCompany" when="orTurn" class="rails.game.special.SpecialRight">
- <SpecialRight name="Coalfields" cost="140"/>
+ <SpecialRight name="Coalfields" cost="140" location="L10"/>
</SpecialProperty>
</SpecialProperties>
</IfOption>
Modified: trunk/18xx/rails/game/special/SpecialRight.java
===================================================================
--- trunk/18xx/rails/game/special/SpecialRight.java 2011-07-07 19:23:32 UTC (rev 1610)
+++ trunk/18xx/rails/game/special/SpecialRight.java 2011-07-08 10:08:04 UTC (rev 1611)
@@ -1,7 +1,7 @@
/* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/game/special/SpecialRight.java,v 1.19 2010/05/05 21:37:18 evos Exp $ */
package rails.game.special;
-import java.util.Set;
+import java.util.*;
import rails.algorithms.NetworkVertex;
import rails.algorithms.RevenueAdapter;
@@ -19,7 +19,9 @@
protected String rightName;
protected String rightDefaultValue;
protected String rightValue;
- protected int cost;
+ protected int cost = 0;
+ protected String locationNames;
+ protected List<MapHex> locations;
@Override
public void configureFromXML(Tag tag) throws ConfigurationException {
@@ -39,6 +41,8 @@
rightDefaultValue = rightValue = rightTag.getAttributeAsString("defaultValue", null);
cost = rightTag.getAttributeAsInteger("cost", 0);
+
+ locationNames = rightTag.getAttributeAsString("location", null);
}
@Override
@@ -47,6 +51,19 @@
// add them to the call list of the RevenueManager
gameManager.getRevenueManager().addStaticModifier(this);
+
+ if (locationNames != null) {
+ locations = new ArrayList<MapHex>();
+ MapManager mmgr = gameManager.getMapManager();
+ MapHex hex;
+ for (String hexName : locationNames.split(",")) {
+ hex = mmgr.getHex(hexName);
+ if (hex == null) {
+ throw new ConfigurationException ("Unknown hex '"+hexName+"' for Special Right");
+ }
+ locations.add (hex);
+ }
+ }
}
public boolean isExecutionable() {
@@ -75,9 +92,21 @@
return cost;
}
+ public String getLocationNames() {
+ return locationNames;
+ }
+
+ public List<MapHex> getLocations() {
+ return locations;
+ }
+
@Override
public String toString() {
- return "Buy '" + rightName + "' right for " + Bank.format(cost);
+ StringBuilder b = new StringBuilder();
+ b.append(cost > 0 ? "Buy '" : "Get '").append(rightName).append("'");
+ if (locationNames != null) b.append(" at ").append(locationNames);
+ if (cost > 0) b.append(" for ").append(Bank.format(cost));
+ return b.toString();
}
@Override
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|