|
From: Stefan F. <ste...@us...> - 2012-09-19 09:38:45
|
dev/null |binary
src/data/18EU/Game.xml | 2
src/data/profiles/test.profile | 2
src/rails/algorithms/NetworkTrain.java | 2
src/rails/algorithms/RevenueAdapter.java | 1
src/rails/game/Bank.java | 15
src/rails/game/BankPortfolio.java | 4
src/rails/game/BaseToken.java | 2
src/rails/game/Certificate.java | 2
src/rails/game/GameManager.java | 21
src/rails/game/MapHex.java | 29
src/rails/game/OperatingRound.java | 32
src/rails/game/Player.java | 5
src/rails/game/PlayerManager.java | 6
src/rails/game/PrivateCompany.java | 10
src/rails/game/PublicCompany.java | 56
src/rails/game/RailsRoot.java | 8
src/rails/game/StartRound.java | 4
src/rails/game/StockMarket.java | 4
src/rails/game/StockRound.java | 8
src/rails/game/Stop.java | 6
src/rails/game/Train.java | 2
src/rails/game/TrainCertificateType.java | 4
src/rails/game/TrainManager.java | 4
src/rails/game/TreasuryShareRound.java | 2
src/rails/game/action/BuyBonusToken.java | 2
src/rails/game/action/BuyCertificate.java | 2
src/rails/game/action/BuyTrain.java | 3
src/rails/game/action/ExchangeTokens.java | 9
src/rails/game/action/ExchangeableToken.java | 7
src/rails/game/action/StartCompany.java | 3
src/rails/game/model/CertificatesModel.java | 23
src/rails/game/model/PortfolioModel.java | 378 +--
src/rails/game/special/LocatedBonus.java | 4
src/rails/game/special/SellBonusToken.java | 4
src/rails/game/specific/_1835/FoldIntoPrussian.java | 8
src/rails/game/specific/_1835/GameManager_1835.java | 10
src/rails/game/specific/_1835/PrussianFormationRound.java | 10
src/rails/game/specific/_1856/CGRFormationRound.java | 13
src/rails/game/specific/_1856/OperatingRound_1856.java | 5
src/rails/game/specific/_1856/PublicCompany_1856.java | 3
src/rails/game/specific/_1856/PublicCompany_CGR.java | 2
src/rails/game/specific/_1856/StockRound_1856.java | 5
src/rails/game/specific/_18AL/NameTrains.java | 28
src/rails/game/specific/_18AL/NameableTrain.java | 9
src/rails/game/specific/_18AL/NamedTrainToken.java | 10
src/rails/game/specific/_18AL/OperatingRound_18AL.java | 2
src/rails/game/specific/_18EU/OperatingRound_18EU.java | 12
src/rails/game/specific/_18EU/PullmanRevenueModifier.java | 3
src/rails/game/specific/_18EU/StartCompany_18EU.java | 10
src/rails/game/specific/_18EU/StockRound_18EU.java | 25
src/rails/game/state/Observable.java | 6
src/rails/game/state/PortfolioChange.java | 11
src/rails/game/state/StateManager.java | 14
src/rails/game/state/Trigger.java | 11
src/rails/game/state/Triggerable.java | 11
src/rails/ui/swing/GameSetupWindow.java | 7
src/rails/ui/swing/GameUIManager.java | 2
src/rails/ui/swing/ORUIManager.java | 4
src/rails/ui/swing/gamespecific/_18AL/NameTrainsDialog.java | 2
src/rails/ui/swing/gamespecific/_18EU/StatusWindow_18EU.java | 2
src/test/TestGameBuilder.java | 4
src/test/data/real/1830_A.report | 2
src/test/data/real/1856_A.report | 2
src/test/data/real/1889_B.report | 2
src/test/data/real/1889_C.report | 2
src/test/data/real/18AL_A.report | 2
src/test/data/real/18EU_A.report | 23
src/test/data/test/1835_PR_3rdTrain.rails |binary
src/test/data/test/1835_PR_3rdTrain.report | 43
src/test/data/test/18EU_After2nd8Train.report | 1194 -----------
71 files changed, 497 insertions(+), 1668 deletions(-)
New commits:
commit 61df3a9f1a6ae65aa4fa34a31a7caa21e820dd89
Author: Stefan Frey <ste...@we...>
Date: Wed Sep 19 11:38:07 2012 +0200
fixed issues with 1835 test game
diff --git a/src/rails/game/PublicCompany.java b/src/rails/game/PublicCompany.java
index 660d0a4..36aa8a0 100644
--- a/src/rails/game/PublicCompany.java
+++ b/src/rails/game/PublicCompany.java
@@ -221,8 +221,8 @@ public class PublicCompany extends RailsAbstractItem implements Company, MoneyOw
boolean certsAreInitiallyAvailable = true;
/** What percentage of ownership constitutes "one share" */
- protected IntegerState shareUnit = null; // configured see below
-
+ protected IntegerState shareUnit = IntegerState.create(this, "shareUnit", DEFAULT_SHARE_UNIT);
+
/** What number of share units relates to the share price
* (normally 1, but 2 for 1835 Prussian)
*/
@@ -364,7 +364,7 @@ public class PublicCompany extends RailsAbstractItem implements Company, MoneyOw
Tag shareUnitTag = tag.getChild("ShareUnit");
if (shareUnitTag != null) {
- shareUnit = IntegerState.create(this, "shareUnit", shareUnitTag.getAttributeAsInteger("percentage", DEFAULT_SHARE_UNIT));
+ shareUnit.set(shareUnitTag.getAttributeAsInteger("percentage", DEFAULT_SHARE_UNIT));
shareUnitsForSharePrice
= shareUnitTag.getAttributeAsInteger("sharePriceUnits", shareUnitsForSharePrice);
}
@@ -656,10 +656,6 @@ public class PublicCompany extends RailsAbstractItem implements Company, MoneyOw
}
- if (shareUnit == null) {
- shareUnit = IntegerState.create(this, "shareUnit", DEFAULT_SHARE_UNIT);
- }
-
int certIndex = 0;
if (certificateTags != null) {
int shareTotal = 0;
diff --git a/src/rails/game/action/StartCompany.java b/src/rails/game/action/StartCompany.java
index 8539e4c..0299976 100644
--- a/src/rails/game/action/StartCompany.java
+++ b/src/rails/game/action/StartCompany.java
@@ -51,7 +51,8 @@ public class StartCompany extends BuyCertificate {
public boolean equalsAsOption(PossibleAction action) {
if (!(action.getClass() == StartCompany.class)) return false;
StartCompany a = (StartCompany) action;
- return a.company == company && a.from == from && Ints.asList(startPrices).contains(a.price);
+ return a.company == company && a.from == from
+ && (startPrices == null && a.startPrices == null || Ints.asList(startPrices).contains(a.price));
}
@Override
diff --git a/src/rails/game/specific/_1835/FoldIntoPrussian.java b/src/rails/game/specific/_1835/FoldIntoPrussian.java
index c8322ab..b84b585 100644
--- a/src/rails/game/specific/_1835/FoldIntoPrussian.java
+++ b/src/rails/game/specific/_1835/FoldIntoPrussian.java
@@ -6,6 +6,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import com.google.common.collect.ImmutableSet;
+
import rails.game.*;
import rails.game.action.PossibleAction;
import rails.util.Util;
@@ -73,7 +75,7 @@ public class FoldIntoPrussian extends PossibleAction {
public boolean equalsAsOption(PossibleAction action) {
if (!(action instanceof FoldIntoPrussian)) return false;
FoldIntoPrussian a = (FoldIntoPrussian) action;
- return a.foldableCompanyNames.equals(foldableCompanyNames);
+ return ImmutableSet.copyOf(a.foldableCompanies).equals(ImmutableSet.copyOf(foldableCompanies));
}
@Override
@@ -95,7 +97,9 @@ public class FoldIntoPrussian extends PossibleAction {
if (foldableCompanyNames != null) {
foldableCompanies = new ArrayList<Company>();
for (String name : foldableCompanyNames.split(",")) {
- foldableCompanies.add(cmgr.getPublicCompany(name));
+ company = cmgr.getPublicCompany(name);
+ if (company == null) company = cmgr.getPrivateCompany(name);
+ if (company != null) foldableCompanies.add(company);
}
}
if (Util.hasValue(foldedCompanyNames)) {
diff --git a/src/rails/game/specific/_1835/GameManager_1835.java b/src/rails/game/specific/_1835/GameManager_1835.java
index 3852cb3..0b83cb4 100644
--- a/src/rails/game/specific/_1835/GameManager_1835.java
+++ b/src/rails/game/specific/_1835/GameManager_1835.java
@@ -54,9 +54,15 @@ public class GameManager_1835 extends GameManager {
}
public void startPrussianFormationRound(OperatingRound_1835 or) {
-
interruptedRound = or;
- createRound(PrussianFormationRound.class, "PrussianFormationRound").start ();
+ String roundName;
+ if (interruptedRound == null) {
+ // after a round
+ roundName = "PrussianFormationRound_after_" + previousRound.getId();
+ } else {
+ roundName = "PrussianFormationRound_in_" + or.getId();
+ }
+ createRound(PrussianFormationRound.class, roundName).start();
}
public void setPrussianFormationStartingPlayer(Player prFormStartingPlayer) {
diff --git a/src/rails/game/specific/_1835/PrussianFormationRound.java b/src/rails/game/specific/_1835/PrussianFormationRound.java
index 344b6fc..35804ae 100644
--- a/src/rails/game/specific/_1835/PrussianFormationRound.java
+++ b/src/rails/game/specific/_1835/PrussianFormationRound.java
@@ -250,7 +250,7 @@ public class PrussianFormationRound extends StockRound {
String message = LocalText.getText("START_MERGED_COMPANY",
PR_ID,
Currency.format(this, prussian.getIPOPrice()),
- prussian.getStartSpace());
+ prussian.getStartSpace().toText());
ReportBuffer.add(message);
if (display) DisplayBuffer.add(message);
@@ -342,7 +342,7 @@ public class PrussianFormationRound extends StockRound {
player.getId(),
cert.getShare(),
PR_ID,
- ipo.getId(),
+ ipo.getParent().getId(),
company.getId());
ReportBuffer.add(message);
if (display) DisplayBuffer.add (message);
diff --git a/src/test/data/test/1835_PR_3rdTrain.rails b/src/test/data/test/1835_PR_3rdTrain.rails
index e2e9503..e9709aa 100644
Binary files a/src/test/data/test/1835_PR_3rdTrain.rails and b/src/test/data/test/1835_PR_3rdTrain.rails differ
diff --git a/src/test/data/test/1835_PR_3rdTrain.report b/src/test/data/test/1835_PR_3rdTrain.report
index 6ddf818..2e256e6 100644
--- a/src/test/data/test/1835_PR_3rdTrain.report
+++ b/src/test/data/test/1835_PR_3rdTrain.report
@@ -1058,46 +1058,3 @@ FirstTrainBought,5
StartOfPhase,5
PrivateCloses,OBB
PrivateCloses,PfB
-CompanyDiscardsTrain,SX,3
-
-EndOfOperatingRound,7.1
-ORWorthIncrease,Alice,7.1,549
-ORWorthIncrease,Bob,7.1,824
-ORWorthIncrease,Charlie,7.1,946
-Has,BY,250
-Has,SX,175
-Has,BA,24
-Has,WT,752
-Has,HE,649
-Has,PR,663
-Has,Alice,317
-Has,Bob,770
-Has,Charlie,615
-START_OR,7.2
-
-CompanyOperates,BY,Alice
-LaysTileAt,BY,220,E19,SW
-CompanyRevenue,BY,140
-CompanyPaysOutFull,BY,140
-Payout,Alice,98,7,10
-Payout,Bob,28,2,10
-Payout,Charlie,14,1,10
-PRICE_MOVES_LOG,BY,232,J1,258,K1
-BuysTrain,BY,5,WT,1
-
-CompanyOperates,SX,Charlie
-LaysTileAt,SX,216,H20,E
-CompanyRevenue,SX,300
-CompanyWithholds,SX,300
-PRICE_MOVES_LOG,SX,166,G1,148,F1
-
-CompanyOperates,PR,Bob
-LaysTileAtFor,PR,221,C11,SW,50
-CompanyRevenue,PR,350
-CompanyPaysOutFull,PR,350
-Payout,Alice,105,6,5
-Payout,Bob,123,7,5
-Payout,Charlie,123,7,5
-PRICE_MOVES_LOG,PR,154,I4,172,J4
-BuysTrain,PR,5,IPO,500
-All 5-trains are sold out, 5+5-trains now available
commit 75076388bb90838d87bd4d3da4aa3bf379ac89d0
Author: Stefan Frey <ste...@we...>
Date: Wed Sep 19 09:53:40 2012 +0200
renamed cert# into cert_
diff --git a/src/rails/game/PublicCompany.java b/src/rails/game/PublicCompany.java
index fd812e3..660d0a4 100644
--- a/src/rails/game/PublicCompany.java
+++ b/src/rails/game/PublicCompany.java
@@ -693,7 +693,7 @@ public class PublicCompany extends RailsAbstractItem implements Company, MoneyOw
}
for (int k = 0; k < number; k++) {
- certificate = new PublicCertificate(this, "cert#" + certIndex, shares, president,
+ certificate = new PublicCertificate(this, "cert_" + certIndex, shares, president,
certIsInitiallyAvailable, certificateCount, certIndex++);
certificates.add(certificate);
shareTotal += shares * shareUnit.value();
commit 45cda25271bcf5a37bdba7aecaea9d2e466977cb
Author: Stefan Frey <ste...@we...>
Date: Wed Sep 19 09:51:56 2012 +0200
fixed issues with 1856 testgames
diff --git a/src/rails/game/Bank.java b/src/rails/game/Bank.java
index ffe7616..6a03798 100644
--- a/src/rails/game/Bank.java
+++ b/src/rails/game/Bank.java
@@ -14,7 +14,7 @@ import rails.game.model.WalletMoneyModel;
import rails.game.state.BooleanState;
import rails.game.state.Change;
import rails.game.state.Observable;
-import rails.game.state.Trigger;
+import rails.game.state.Triggerable;
import rails.game.state.UnknownOwner;
import rails.util.Util;
@@ -52,7 +52,7 @@ public class Bank extends RailsManager implements MoneyOwner, Configurable {
// Instance initializer to create a BankBroken model
{
- new Trigger() {
+ new Triggerable() {
{// instance initializer
cash.addTrigger(this);
}
diff --git a/src/rails/game/OperatingRound.java b/src/rails/game/OperatingRound.java
index 3f1d159..a9fb0dc 100644
--- a/src/rails/game/OperatingRound.java
+++ b/src/rails/game/OperatingRound.java
@@ -2095,7 +2095,7 @@ public class OperatingRound extends Round implements Observer {
ReportBuffer.add(LocalText.getText("BuysBonusTokenFrom",
operatingCompany.value().getId(),
- sbt.getId(),
+ sbt.getName(),
bank.getCurrency().format(sbt.getValue()), // TODO: Do this nicer
seller.getId(),
bank.getCurrency().format(sbt.getPrice()))); // TODO: Do this nicer
diff --git a/src/rails/game/PrivateCompany.java b/src/rails/game/PrivateCompany.java
index 7e1abd2..b968d14 100644
--- a/src/rails/game/PrivateCompany.java
+++ b/src/rails/game/PrivateCompany.java
@@ -519,7 +519,7 @@ public class PrivateCompany extends OwnableItem<PrivateCompany> implements Compa
* @return Boolean
*/
public boolean hasSpecialProperties() {
- return specialProperties != null && !specialProperties.isEmpty();
+ return !specialProperties.isEmpty();
}
// Company methods
@@ -550,7 +550,7 @@ public class PrivateCompany extends OwnableItem<PrivateCompany> implements Compa
public ImmutableSet<SpecialProperty> getSpecialProperties() {
return specialProperties.items();
}
-
+
// RailsItem methods
@Override
public RailsItem getParent() {
diff --git a/src/rails/game/PublicCompany.java b/src/rails/game/PublicCompany.java
index 4c29ee0..fd812e3 100644
--- a/src/rails/game/PublicCompany.java
+++ b/src/rails/game/PublicCompany.java
@@ -758,8 +758,8 @@ public class PublicCompany extends RailsAbstractItem implements Company, MoneyOw
// Can companies acquire special rights (such as in 1830 Coalfields)?
// TODO: Can this be simplified?
- if (portfolio.getSpecialProperties() != null) {
- for (SpecialProperty sp : portfolio.getSpecialProperties()) {
+ if (portfolio.hasSpecialProperties()) {
+ for (SpecialProperty sp : portfolio.getPersistentSpecialProperties()) {
if (sp instanceof SpecialRight) {
gameManager.setGuiParameter (GuiDef.Parm.HAS_ANY_RIGHTS, true);
// Initialize rights here to prevent overhead if not used,
@@ -2030,7 +2030,7 @@ public class PublicCompany extends RailsAbstractItem implements Company, MoneyOw
}
public ImmutableSet<SpecialProperty> getSpecialProperties() {
- return portfolio.getSpecialProperties().items();
+ return portfolio.getPersistentSpecialProperties();
}
diff --git a/src/rails/game/action/ExchangeTokens.java b/src/rails/game/action/ExchangeTokens.java
index e8cda22..aad52c7 100644
--- a/src/rails/game/action/ExchangeTokens.java
+++ b/src/rails/game/action/ExchangeTokens.java
@@ -74,7 +74,14 @@ public class ExchangeTokens extends PossibleORAction {
public boolean equalsAsOption(PossibleAction action) {
if (!(action instanceof ExchangeTokens)) return false;
ExchangeTokens a = (ExchangeTokens) action;
- return a.tokensToExchange == tokensToExchange && a.company == company;
+ if (a.company != this.company) return false;
+ // check if all tokensToExchange are equal as option (without selected)
+ for (int i=0; i< tokensToExchange.size(); i++) {
+ if (!(a.tokensToExchange.get(i).equalsAsOption(tokensToExchange.get(i)))) {
+ return false;
+ }
+ }
+ return true;
}
@Override
diff --git a/src/rails/game/action/ExchangeableToken.java b/src/rails/game/action/ExchangeableToken.java
index 5add07a..34ac130 100644
--- a/src/rails/game/action/ExchangeableToken.java
+++ b/src/rails/game/action/ExchangeableToken.java
@@ -8,6 +8,8 @@ package rails.game.action;
import java.io.Serializable;
+import com.google.common.base.Objects;
+
/**
* A simple, serializable class that holds the <i>original</i> location
* of a Base token, to facilitate its replacement even after its company
@@ -44,6 +46,11 @@ public class ExchangeableToken implements Serializable {
this.selected = selected;
}
+ public boolean equalsAsOption(ExchangeableToken other) {
+ return Objects.equal(this.cityName, other.cityName)
+ && Objects.equal(this.oldCompanyName, other.oldCompanyName);
+ }
+
public String toString() {
return cityName+"["+oldCompanyName+"]"
+ (selected ? "*" : "");
diff --git a/src/rails/game/model/PortfolioModel.java b/src/rails/game/model/PortfolioModel.java
index df3d495..db3bc30 100644
--- a/src/rails/game/model/PortfolioModel.java
+++ b/src/rails/game/model/PortfolioModel.java
@@ -19,10 +19,8 @@ import com.google.common.collect.ImmutableSortedSet;
import rails.common.LocalText;
import rails.game.Bank;
import rails.game.BankPortfolio;
-import rails.game.Bonus;
import rails.game.BonusToken;
import rails.game.Company;
-import rails.game.Currency;
import rails.game.GameManager;
import rails.game.MoneyOwner;
import rails.game.Player;
@@ -33,7 +31,6 @@ import rails.game.ReportBuffer;
import rails.game.Train;
import rails.game.TrainCertificateType;
import rails.game.TrainType;
-import rails.game.special.LocatedBonus;
import rails.game.special.SpecialProperty;
import rails.game.state.Model;
import rails.game.state.Owner;
@@ -47,13 +44,12 @@ import rails.game.state.PortfolioSet;
*/
public class PortfolioModel extends Model {
public static final String ID = "PortfolioModel";
-
- protected static Logger log =
- LoggerFactory.getLogger(PortfolioModel.class);
-
+
+ protected static Logger log = LoggerFactory.getLogger(PortfolioModel.class);
+
/** Owned certificates */
private final CertificatesModel certificates;
-
+
/** Owned private companies */
private final PrivatesModel privates;
@@ -63,13 +59,13 @@ public class PortfolioModel extends Model {
/** Owned tokens */
// TODO Currently only used to discard expired Bonus tokens.
private final Portfolio<BonusToken> bonusTokens;
-
+
/**
* Private-independent special properties. When moved here, a special
* property no longer depends on the private company being alive. Example:
* 18AL named train tokens.
*/
- private final Portfolio<SpecialProperty> specialProperties;
+ private final SpecialPropertiesModel specialProperties;
private final GameManager gameManager;
@@ -83,9 +79,10 @@ public class PortfolioModel extends Model {
certificates = CertificatesModel.create(parent);
privates = PrivatesModel.create(parent);
trains = TrainsModel.create(parent);
- bonusTokens = PortfolioSet.create(parent, "BonusTokens", BonusToken.class);
- specialProperties = PortfolioSet.create(parent, "SpecialProperties", SpecialProperty.class);
-
+ bonusTokens =
+ PortfolioSet.create(parent, "BonusTokens", BonusToken.class);
+ specialProperties = SpecialPropertiesModel.create(parent);
+
// change display style dependent on owner
if (parent instanceof PublicCompany) {
trains.setAbbrList(false);
@@ -98,7 +95,7 @@ public class PortfolioModel extends Model {
gameManager.addPortfolio(this);
}
-
+
public static PortfolioModel create(PortfolioOwner parent) {
return new PortfolioModel(parent, ID);
}
@@ -106,20 +103,20 @@ public class PortfolioModel extends Model {
public void finishConfiguration() {
certificates.initShareModels(gameManager.getAllPublicCompanies());
}
-
+
@Override
public PortfolioOwner getParent() {
- return (PortfolioOwner)super.getParent();
+ return (PortfolioOwner) super.getParent();
}
-
- // returns the associated MoneyOwner
+
+ // returns the associated MoneyOwner
public MoneyOwner getMoneyOwner() {
if (getParent() instanceof BankPortfolio) {
- return ((BankPortfolio)getParent()).getParent();
+ return ((BankPortfolio) getParent()).getParent();
}
- return (MoneyOwner)getParent();
+ return (MoneyOwner) getParent();
}
-
+
public void transferAssetsFrom(PortfolioModel otherPortfolio) {
// Move trains
@@ -129,39 +126,44 @@ public class PortfolioModel extends Model {
otherPortfolio.moveAllCertificates(this.getParent());
}
- /** Low-level method, only to be called by the local addObject() method and by initialisation code. */
+ /**
+ * Low-level method, only to be called by the local addObject() method and
+ * by initialisation code.
+ */
// TODO: Ignores position now, is this necessary?
public void addPrivateCompany(PrivateCompany company) {
// add to private Model
privates.moveInto(company);
-
- if (company.getSpecialProperties() != null) {
+
+ if (company.hasSpecialProperties()) {
log.debug(company.getId() + " has special properties!");
} else {
log.debug(company.getId() + " has no special properties");
}
- // TODO: This should not be necessary as soon as a PlayerModel works correctly
- updatePlayerWorth ();
+ // TODO: This should not be necessary as soon as a PlayerModel works
+ // correctly
+ updatePlayerWorth();
}
- // FIXME: Solve the presidentShare problem, should not be identified at position zero
-
- protected void updatePlayerWorth () {
+ // FIXME: Solve the presidentShare problem, should not be identified at
+ // position zero
+
+ protected void updatePlayerWorth() {
if (getParent() instanceof Player) {
- ((Player)getParent()).updateWorth();
+ ((Player) getParent()).updateWorth();
}
}
-
- public CertificatesModel getCertificatesModel() {
- return certificates;
- }
-
- public ShareModel getShareModel(PublicCompany company) {
- return certificates.getShareModel(company);
- }
-
+
+ public CertificatesModel getCertificatesModel() {
+ return certificates;
+ }
+
+ public ShareModel getShareModel(PublicCompany company) {
+ return certificates.getShareModel(company);
+ }
+
public ImmutableSet<PrivateCompany> getPrivateCompanies() {
return privates.getPortfolio().items();
}
@@ -173,7 +175,9 @@ public class PortfolioModel extends Model {
/** Get the number of certificates that count against the certificate limit */
public float getCertificateCount() {
- float number = privates.getPortfolio().size(); // TODO: May not hold for all games, for example 1880
+ float number = privates.getPortfolio().size(); // TODO: May not hold for
+ // all games, for example
+ // 1880
return number + certificates.getCertificateCount();
}
@@ -182,13 +186,14 @@ public class PortfolioModel extends Model {
return certificates.getPortfolio().view();
}
- public ImmutableSortedSet<PublicCertificate> getCertificates(PublicCompany company) {
+ public ImmutableSortedSet<PublicCertificate> getCertificates(
+ PublicCompany company) {
return certificates.getPortfolio().items(company);
}
/**
* Find a certificate for a given company.
- *
+ *
* @param company The public company for which a certificate is found.
* @param president Whether we look for a president or non-president
* certificate. If there is only one certificate, this parameter has no
@@ -200,14 +205,17 @@ public class PortfolioModel extends Model {
return findCertificate(company, 1, president);
}
- /** Find a specified certificate
- * @return (first) certificate found, null if not found */
- public PublicCertificate findCertificate(PublicCompany company,
- int shares, boolean president) {
+ /**
+ * Find a specified certificate
+ *
+ * @return (first) certificate found, null if not found
+ */
+ public PublicCertificate findCertificate(PublicCompany company, int shares,
+ boolean president) {
for (PublicCertificate cert : certificates.getPortfolio().items(company)) {
if (company.getShareUnit() == 100 || president
- && cert.isPresidentShare() || !president
- && !cert.isPresidentShare() && cert.getShares() == shares) {
+ && cert.isPresidentShare() || !president
+ && !cert.isPresidentShare() && cert.getShares() == shares) {
return cert;
}
}
@@ -223,16 +231,16 @@ public class PortfolioModel extends Model {
}
return list.build();
}
-
- public PublicCertificate getAnyCertOfType(String certTypeId) {
- for (PublicCertificate cert : certificates) {
- if (cert.getTypeId().equals(certTypeId)) {
- return cert;
- }
- }
- return null;
+
+ public PublicCertificate getAnyCertOfType(String certTypeId) {
+ for (PublicCertificate cert : certificates) {
+ if (cert.getTypeId().equals(certTypeId)) {
+ return cert;
+ }
+ }
+ return null;
}
-
+
/**
* Returns percentage that a portfolio contains of one company.
*/
@@ -244,7 +252,8 @@ public class PortfolioModel extends Model {
boolean president) {
int certs = 0;
if (certificates.contains(company)) {
- for (PublicCertificate cert : certificates.getPortfolio().items(company)) {
+ for (PublicCertificate cert : certificates.getPortfolio().items(
+ company)) {
if (president) {
if (cert.isPresidentShare()) return 1;
} else if (cert.getShares() == unit) {
@@ -254,7 +263,7 @@ public class PortfolioModel extends Model {
}
return certs;
}
-
+
public void moveAllCertificates(Owner owner) {
certificates.getPortfolio().moveAll(owner);
}
@@ -262,7 +271,7 @@ public class PortfolioModel extends Model {
/**
* Swap this Portfolio's President certificate for common shares in another
* Portfolio.
- *
+ *
* @param company The company whose Presidency is handed over.
* @param other The new President's portfolio.
* @return The common certificates returned.
@@ -302,11 +311,11 @@ public class PortfolioModel extends Model {
public void discardTrain(Train train) {
// FIXME: This is a horrible list of method calls
- GameManager.getInstance().getBank().getPool().getPortfolioModel().getTrainsModel().getPortfolio().moveInto(train);
-
-
+ GameManager.getInstance().getBank().getPool().getPortfolioModel().getTrainsModel().getPortfolio().moveInto(
+ train);
+
ReportBuffer.add(LocalText.getText("CompanyDiscardsTrain",
- getParent().getId(), train.toText() ));
+ getParent().getId(), train.toText()));
}
// FIXME: Is this still needed?
@@ -341,7 +350,7 @@ public class PortfolioModel extends Model {
Set<Train> trainsFound = new HashSet<Train>();
Map<TrainType, Object> trainTypesFound =
- new HashMap<TrainType, Object>();
+ new HashMap<TrainType, Object>();
...
[truncated message content] |