From: <ste...@us...> - 2010-08-05 18:53:19
|
Revision: 1369 http://rails.svn.sourceforge.net/rails/?rev=1369&view=rev Author: stefanfrey Date: 2010-08-05 18:53:13 +0000 (Thu, 05 Aug 2010) Log Message: ----------- 1. Added DisplayBuffer report for forced selling due to certificate limit 2. Fixed problem of hermit base token in revenue calculation 3. Added gameoption for 1856 THB (but not implementation yet) Modified Paths: -------------- trunk/18xx/LocalisedText.properties trunk/18xx/data/1856/Game.xml trunk/18xx/rails/algorithms/NetworkGraphBuilder.java trunk/18xx/rails/algorithms/RevenueAdapter.java trunk/18xx/rails/game/StockRound.java trunk/18xx/rails/ui/swing/ORUIManager.java Modified: trunk/18xx/LocalisedText.properties =================================================================== --- trunk/18xx/LocalisedText.properties 2010-08-04 22:05:57 UTC (rev 1368) +++ trunk/18xx/LocalisedText.properties 2010-08-05 18:53:13 UTC (rev 1369) @@ -1,4 +1,5 @@ # Texts with lowercase keys are intended to be inserted into other messages +1856THBHomeBlocked=THB home hex is blocked for token lays (unless gray tile) 1889PrivateBactive=Player {0} (owner of Private B) may lay port tile 1889PrivateCactive=Player {0} (previous owner of Private C) may lay tile on C4 immediately 18ALOptimizeNamedTrains=Optimize named train assignment @@ -246,6 +247,9 @@ ExchangeTokensPrompt1=Select {0} cities where {1} will exchange a base token ExchangeTokensPrompt2=Select {0} through {1} cities where {2} will exchange a base token ExchangesTrain={0} exchanges a {1}-train for a {2}-train from {3} for {4} +ExceedCertificateLimit=<em>{0} exceeds certificate limit!</em><br>{1}<br>Only share selling allowed until certificate limit holds. +ExceedCertificateLimitTotal=-> Player has {0} certificates, exceeds total certificate limit of {1}. +ExceedCertificateLimitCompany=-> Player has a {1}% holding of {0}, exceeds company holding limit of {2}%. extra=extra ExtraTile= You can lay an unconnected tile on {0}. ExtraToken= You can lay an unconnected base token on {0}. @@ -501,7 +505,7 @@ SelectNoBid=Select, No Bid SelectTrain=Select a train and press OK, or press Done. SelectCheapTrain=You can buy a cheaper new train by using {0}. -SelectStationForToken={0}, select a station on tile {1} for the {2} home base token +SelectStationForToken={0}, select a station on hex {1} for the {2} home base token SelectStationForTokenOption=Place token in station {0} with tracks to {1} SelectForAuctioning=\n{0} selects {1} for auctioning SELL=Sell Modified: trunk/18xx/data/1856/Game.xml =================================================================== --- trunk/18xx/data/1856/Game.xml 2010-08-04 22:05:57 UTC (rev 1368) +++ trunk/18xx/data/1856/Game.xml 2010-08-05 18:53:13 UTC (rev 1369) @@ -9,6 +9,7 @@ <GameOption name="UnlimitedTiles" type="toggle" default="no"/> <GameOption name="LeaveAuctionOnPass" type="toggle" default="no"/> <GameOption name="SeparateSalesAtSamePrice" type="toggle" default="yes"/> + <GameOption name="1856THBHomeBlocked" type="toggle" default="no" /> <GameParameters> <StockRound class="rails.game.specific._1856.StockRound_1856" sequence="SellBuyOrBuySell"> Modified: trunk/18xx/rails/algorithms/NetworkGraphBuilder.java =================================================================== --- trunk/18xx/rails/algorithms/NetworkGraphBuilder.java 2010-08-04 22:05:57 UTC (rev 1368) +++ trunk/18xx/rails/algorithms/NetworkGraphBuilder.java 2010-08-05 18:53:13 UTC (rev 1369) @@ -265,6 +265,11 @@ for (NetworkVertex vertex:graph.vertexSet()) { Set<NetworkEdge> vertexEdges = graph.edgesOf(vertex); + // always keep protected vertices + if (protectedVertices.contains(vertex)) { + continue; + } + // remove hermit if (vertexEdges.size() == 0) { log.info("Remove hermit (no connection) = " + vertex); @@ -282,7 +287,7 @@ removed = true; break; } // vertex is not necessary and not on the protected list - else if (vertexEdges.size() == 2 && !protectedVertices.contains(vertex)) { + else if (vertexEdges.size() == 2) { NetworkEdge[] edges = vertexEdges.toArray(new NetworkEdge[2]); if (edges[0].isGreedy() == edges[1].isGreedy()) { if (!edges[0].isGreedy()) { Modified: trunk/18xx/rails/algorithms/RevenueAdapter.java =================================================================== --- trunk/18xx/rails/algorithms/RevenueAdapter.java 2010-08-04 22:05:57 UTC (rev 1368) +++ trunk/18xx/rails/algorithms/RevenueAdapter.java 2010-08-05 18:53:13 UTC (rev 1369) @@ -143,10 +143,9 @@ return startVertices; } - public boolean addStartVertex(NetworkVertex startVertex) { - if (startVertices.contains(startVertex)) return false; - - startVertices.add(startVertex); + public boolean addStartVertices(Collection<NetworkVertex> startVertices) { + this.startVertices.addAll(startVertices); + protectedVertices.addAll(startVertices); return true; } @@ -208,7 +207,7 @@ NetworkVertex.initAllRailsVertices(graph.vertexSet(), company, phase); // define startVertexes - startVertices.addAll(companyGraph.getCompanyBaseTokenVertexes(company)); + addStartVertices(companyGraph.getCompanyBaseTokenVertexes(company)); // define visit sets defineVertexVisitSets(); Modified: trunk/18xx/rails/game/StockRound.java =================================================================== --- trunk/18xx/rails/game/StockRound.java 2010-08-04 22:05:57 UTC (rev 1368) +++ trunk/18xx/rails/game/StockRound.java 2010-08-05 18:53:13 UTC (rev 1369) @@ -101,7 +101,15 @@ setSellableShares(); - if (isPlayerOverLimits (currentPlayer)) return true; + // check certification limits and display warning + if (isPlayerOverLimits (currentPlayer)) { + DisplayBuffer.add(LocalText.getText("ExceedCertificateLimit" + , currentPlayer.getName() + , isPlayerOverLimitsDetail(currentPlayer) + ) + ); + return true; + } passAllowed = true; @@ -1398,18 +1406,36 @@ } protected boolean isPlayerOverLimits(Player player) { - + return (isPlayerOverLimitsDetail(player) != null); + } + + protected String isPlayerOverLimitsDetail(Player player) { + StringBuffer violations = new StringBuffer(); + // Over the total certificate hold Limit? - if (player.getPortfolio().getCertificateCount() > gameManager.getPlayerCertificateLimit(player)) - return true; + if (player.getPortfolio().getCertificateCount() > gameManager.getPlayerCertificateLimit(player)) { + violations.append(LocalText.getText("ExceedCertificateLimitTotal", + player.getPortfolio().getCertificateCount(), + gameManager.getPlayerCertificateLimit(player))); + } + ; // Over the hold limit of any company? for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { if (company.hasStarted() && company.hasStockPrice() - && !checkAgainstHoldLimit(player, company, 0)) return true; + && !checkAgainstHoldLimit(player, company, 0)) { + violations.append(LocalText.getText("ExceedCertificateLimitCompany", + company.getName(), + player.getPortfolio().getShare(company), + getGameParameterAsInt(GameDef.Parm.PLAYER_SHARE_LIMIT) + )); + } } - - return false; + if (violations.length() != 0) { + return violations.toString(); + } else { + return null; + } } /** Modified: trunk/18xx/rails/ui/swing/ORUIManager.java =================================================================== --- trunk/18xx/rails/ui/swing/ORUIManager.java 2010-08-04 22:05:57 UTC (rev 1368) +++ trunk/18xx/rails/ui/swing/ORUIManager.java 2010-08-05 18:53:13 UTC (rev 1369) @@ -879,7 +879,11 @@ if (prompts.size () > 1) { String selected = (String) JOptionPane.showInputDialog(orWindow, - LocalText.getText("SelectStationForToken"), + LocalText.getText("SelectStationForToken", + action.getPlayerName(), + hex.getName(), + company.getName() + ), LocalText.getText("WhichStation"), JOptionPane.PLAIN_MESSAGE, null, prompts.toArray(), prompts.get(0)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |