|
From: <ev...@us...> - 2010-10-12 17:36:15
|
Revision: 1447
http://rails.svn.sourceforge.net/rails/?rev=1447&view=rev
Author: evos
Date: 2010-10-12 17:36:09 +0000 (Tue, 12 Oct 2010)
Log Message:
-----------
Phil1825.patch
Modified Paths:
--------------
trunk/18xx/data/GamesList.xml
trunk/18xx/rails/game/PublicCompany.java
trunk/18xx/rails/game/PublicCompanyI.java
trunk/18xx/rails/game/StockRound.java
trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java
trunk/18xx/rails/game/specific/_1825/PublicCompany_1825.java
trunk/18xx/rails/game/specific/_1825/StockRound_1825.java
Modified: trunk/18xx/data/GamesList.xml
===================================================================
--- trunk/18xx/data/GamesList.xml 2010-10-11 17:31:34 UTC (rev 1446)
+++ trunk/18xx/data/GamesList.xml 2010-10-12 17:36:09 UTC (rev 1447)
@@ -202,6 +202,7 @@
Designed by Francis Tresham
Known Issues:
+- change the formationOrderIndex from an Integer variable to an IntegerState variable
- BUG: prompt on placing GWR token when upgrading London, needs investigation
- BUG: Trains do not have to own a train and directors cannot fund the purchase of one
- Tile lays that send track off the board are legal in 1825 as long as they don't run into the
Modified: trunk/18xx/rails/game/PublicCompany.java
===================================================================
--- trunk/18xx/rails/game/PublicCompany.java 2010-10-11 17:31:34 UTC (rev 1446)
+++ trunk/18xx/rails/game/PublicCompany.java 2010-10-12 17:36:09 UTC (rev 1447)
@@ -269,8 +269,6 @@
protected StockMarketI stockMarket;
protected MapManager mapManager;
- //PD: used to track floatation order for games that need this (1825)
- protected int formationOrderIndex = 0;
/**
* The constructor. The way this class is instantiated does not allow
* arguments.
@@ -2010,12 +2008,4 @@
return "";
}
- public int getFormationOrderIndex() {
- return formationOrderIndex;
- }
-
- public void setFormationOrderIndex(int formationOrderIndex) {
- this.formationOrderIndex = formationOrderIndex;
- }
-
}
Modified: trunk/18xx/rails/game/PublicCompanyI.java
===================================================================
--- trunk/18xx/rails/game/PublicCompanyI.java 2010-10-11 17:31:34 UTC (rev 1446)
+++ trunk/18xx/rails/game/PublicCompanyI.java 2010-10-12 17:36:09 UTC (rev 1447)
@@ -358,7 +358,5 @@
public ModelObject getInGameModel ();
public ModelObject getIsClosedModel ();
-
- public int getFormationOrderIndex ();
- public void setFormationOrderIndex (int formationOrderIndex);
+
}
Modified: trunk/18xx/rails/game/StockRound.java
===================================================================
--- trunk/18xx/rails/game/StockRound.java 2010-10-11 17:31:34 UTC (rev 1446)
+++ trunk/18xx/rails/game/StockRound.java 2010-10-12 17:36:09 UTC (rev 1447)
@@ -1013,6 +1013,9 @@
}
}
}
+ if (potentialDirector == null) {
+ //TODO: No one to dump the Presidency onto, work out how to handle the receivership
+ }
// The poor sod.
dumpedPlayer = potentialDirector;
presSharesToSell = numberToSell;
Modified: trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java
===================================================================
--- trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java 2010-10-11 17:31:34 UTC (rev 1446)
+++ trunk/18xx/rails/game/specific/_1825/OperatingRound_1825.java 2010-10-12 17:36:09 UTC (rev 1447)
@@ -16,18 +16,20 @@
int space;
int key;
for (PublicCompanyI company : companyManager.getAllPublicCompanies()) {
+ PublicCompany_1825 companycasted = (PublicCompany_1825)company;
+ if (!canCompanyOperateThisRound(companycasted)) continue;
if (!canCompanyOperateThisRound(company)) continue;
// Key must put companies in reverse operating order, because sort
// is ascending.
- space = company.getIPOPrice();
+ space = companycasted.getIPOPrice();
//Corps operate in descending IPO price
//Corps with the same IPO price operate in the order they were floated
//IPO price will inherently be in the right order
//subtracting the formation order index will put it at the right point to operate
//This wouldn't work if there are lots of corps at the same price
//there are not too many corps in each banding for this to be an issue in 1825 even with all 3 units
- key = 1000000 - (space - company.getFormationOrderIndex());
- operatingCompanies.put(new Integer(key), company);
+ key = 1000000 - (space - companycasted.getFormationOrderIndex());
+ operatingCompanies.put(new Integer(key), companycasted);
}
return new ArrayList<PublicCompanyI>(operatingCompanies.values());
}
Modified: trunk/18xx/rails/game/specific/_1825/PublicCompany_1825.java
===================================================================
--- trunk/18xx/rails/game/specific/_1825/PublicCompany_1825.java 2010-10-11 17:31:34 UTC (rev 1446)
+++ trunk/18xx/rails/game/specific/_1825/PublicCompany_1825.java 2010-10-12 17:36:09 UTC (rev 1447)
@@ -2,10 +2,27 @@
import rails.game.PublicCompany;
import rails.game.PublicCompanyI;
+import rails.game.StockSpaceI;
+import rails.game.state.IntegerState;
public class PublicCompany_1825 extends PublicCompany {
+ protected IntegerState formationOrderIndex;
+ public void start(StockSpaceI startSpace) {
+ super.start(startSpace);
+ //PD: used to track flotation order
+ formationOrderIndex = new IntegerState(name+"_formationOrderIndex");
+ }
+
+ public int getFormationOrderIndex() {
+ return formationOrderIndex.intValue();
+ }
+
+ public void setFormationOrderIndex(int formationOrderIndex) {
+ this.formationOrderIndex.set(formationOrderIndex);
+ }
+
@Override
public void payout(int amount) {
if (amount == 0) return;
@@ -39,7 +56,7 @@
//Yes, we share IPO prices, has this other company been launched yet?
if (company.hasFloated()){
//it has, we need to skip ahead of this corp
- formationOrderIndex++;
+ formationOrderIndex.add(1);
}
}
Modified: trunk/18xx/rails/game/specific/_1825/StockRound_1825.java
===================================================================
--- trunk/18xx/rails/game/specific/_1825/StockRound_1825.java 2010-10-11 17:31:34 UTC (rev 1446)
+++ trunk/18xx/rails/game/specific/_1825/StockRound_1825.java 2010-10-12 17:36:09 UTC (rev 1447)
@@ -8,6 +8,7 @@
import java.util.List;
import rails.game.*;
+import rails.game.action.SellShares;
public class StockRound_1825 extends StockRound {
@@ -79,4 +80,87 @@
}
+ @Override
+ public void setSellableShares() {
+ if (!mayCurrentPlayerSellAnything()) return;
+
+ String compName;
+ int price;
+ int number;
+ int share, maxShareToSell;
+ boolean dumpAllowed;
+ Portfolio playerPortfolio = currentPlayer.getPortfolio();
+
+ /*
+ * First check of which companies the player owns stock, and what
+ * maximum percentage he is allowed to sell.
+ */
+ for (PublicCompanyI company : companyManager.getAllPublicCompanies()) {
+
+ // Check if shares of this company can be sold at all
+ if (!mayPlayerSellShareOfCompany(company)) continue;
+
+ share = maxShareToSell = playerPortfolio.getShare(company);
+ if (maxShareToSell == 0) continue;
+
+ /* May not sell more than the Pool can accept */
+ maxShareToSell =
+ Math.min(maxShareToSell,
+ getGameParameterAsInt(GameDef.Parm.POOL_SHARE_LIMIT)
+ - pool.getShare(company));
+ if (maxShareToSell == 0) continue;
+
+ /*
+ * Check what share units the player actually owns. In some games
+ * (e.g. 1835) companies may have different ordinary shares: 5% and
+ * 10%, or 10% and 20%. The president's share counts as a multiple
+ * of the smallest ordinary share unit type.
+ */
+ // Take care for max. 4 share units per share
+ int[] shareCountPerUnit = new int[5];
+ compName = company.getName();
+ for (PublicCertificateI c : playerPortfolio.getCertificatesPerCompany(compName)) {
+ if (c.isPresidentShare()) {
+ shareCountPerUnit[1] += c.getShares();
+ } else {
+ ++shareCountPerUnit[c.getShares()];
+ }
+ }
+ // TODO The above ignores that a dumped player must be
+ // able to exchange the president's share.
+
+ /*
+ * Check the price. If a cert was sold before this turn, the
+ * original price is still valid
+ */
+ price = getCurrentSellPrice(company);
+
+ // removed as this is done in getCurrentSellPrice
+ // price /= company.getShareUnitsForSharePrice();
+
+ /* Allow for different share units (as in 1835) */
+ for (int i = 1; i <= 4; i++) {
+ number = shareCountPerUnit[i];
+ if (number == 0) continue;
+ number =
+ Math.min(number, maxShareToSell
+ / (i * company.getShareUnit()));
+
+ /* In some games (1856), a just bought share may not be sold */
+ // This code ignores the possibility of different share units
+ if ((Boolean)gameManager.getGameParameter(GameDef.Parm.NO_SALE_OF_JUST_BOUGHT_CERT)
+ && company.equals(companyBoughtThisTurnWrapper.get())) {
+ number--;
+ }
+ if (number <= 0) continue;
+
+ possibleActions.add(new SellShares(compName, i, number, price));
+
+ }
+ }
+
+
+ }
+
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|