From: <ev...@us...> - 2010-09-20 21:31:23
|
Revision: 1429 http://rails.svn.sourceforge.net/rails/?rev=1429&view=rev Author: evos Date: 2010-09-20 21:31:16 +0000 (Mon, 20 Sep 2010) Log Message: ----------- Allow hex sides to be "open", i.e. track can be laid against such sides, even if at a board edge. This is required for 1825. Modified Paths: -------------- trunk/18xx/data/1825/Map.xml trunk/18xx/rails/game/MapHex.java trunk/18xx/rails/ui/swing/hexmap/GUITile.java Modified: trunk/18xx/data/1825/Map.xml =================================================================== --- trunk/18xx/data/1825/Map.xml 2010-09-19 19:30:35 UTC (rev 1428) +++ trunk/18xx/data/1825/Map.xml 2010-09-20 21:31:16 UTC (rev 1429) @@ -1,43 +1,15 @@ <Map mapClass="rails.ui.swing.hexmap.EWHexMap" tileOrientation="EW" letterOrientation="vertical" even="R"> - <!-- The tiles numbered -10000 do not exist on the board. - These are there only to enable edge tile placement, - which is allowed where board extensions exist. - The tiles are not upgradable, i.e. no yellow tiles can be laid on these hexes --> - <!-- Edge tiles in case Unit 2 is not used --> - <Hex name="Q9" tile="-10000"/> - <Hex name="Q11" tile="-10000"/> - <Hex name="Q13" tile="-10000"/> - <Hex name="Q15" tile="-10000"/> - <Hex name="Q17" tile="-10000"/> - <Hex name="Q19" tile="-10000"/> - <!-- End of U2 edge tiles --> - <!-- Edge tiles in case kit R3 (North Norfolk) is not used --> - <Hex name="Q23" tile="-10000"/> - <Hex name="Q25" tile="-10000"/> - <!-- End of R3 edge tiles --> - <!-- Edge tiles in case kit R1 (Wales) is not used --> - <Hex name="Q7" tile="-10000"/> - <Hex name="R6" tile="-10000"/> - <Hex name="S7" tile="-10000"/> - <Hex name="T6" tile="-10000"/> - <Hex name="U7" tile="-10000"/> - <Hex name="V6" tile="-10000"/> - <!-- End of R1 edge tiles --> - <!-- Edge tiles in case kit R2 (S/W England) is not used --> - <Hex name="X6" tile="-10000"/> - <Hex name="Y7" tile="-10000"/> - <!-- End of R2 edge tiles --> - <Hex name="R8" tile="0"/> - <Hex name="R10" tile="-1" city="Shrewsbury" orientation="3" /> - <Hex name="R12" tile="-20" orientation="1" city="Wolverhampton, Walsall"/> - <Hex name="R14" tile="0"/> - <Hex name="R16" tile="-10" city="Leicester" /> - <Hex name="R18" tile="0"/> - <Hex name="R20" tile="-1" city="Peterborough" orientation="3" /> - <Hex name="R22" tile="0"/> - <Hex name="R24" tile="-10" city="Norwich" orientation="4" /> - <Hex name="R26" tile="-1" city="Great Yarmouth" orientation="1" /> - <Hex name="S9" tile="0"/> + <Hex name="R8" tile="0" open="0,1,2,3"/> + <Hex name="R10" tile="-1" city="Shrewsbury" orientation="3" open="2,3"/> + <Hex name="R12" tile="-20" orientation="1" city="Wolverhampton, Walsall" open="2,3"/> + <Hex name="R14" tile="0" open="2,3"/> + <Hex name="R16" tile="-10" city="Leicester" open="2,3"/> + <Hex name="R18" tile="0" open="2,3"/> + <Hex name="R20" tile="-1" city="Peterborough" orientation="3" open="2"/> + <Hex name="R22" tile="0" open="3"/> + <Hex name="R24" tile="-10" city="Norwich" orientation="4" open="2,3"/> + <Hex name="R26" tile="-1" city="Great Yarmouth" orientation="1" open="2"/> + <Hex name="S9" tile="0" open="1"/> <Hex name="S11" tile="0"/> <Hex name="S13" tile="-25002" city="Birmingham" /> <Hex name="S15" tile="-1" city="Northampton" orientation="2" /> @@ -46,7 +18,7 @@ <Hex name="S21" tile="0"/> <Hex name="S23" tile="0"/> <Hex name="S25" tile="0"/> - <Hex name="T8" tile="0" cost="100"></Hex> + <Hex name="T8" tile="0" cost="100" open="0,1,2"></Hex> <Hex name="T10" tile="0"/> <Hex name="T12" tile="0"/> <Hex name="T14" tile="0"/> @@ -55,7 +27,7 @@ <Hex name="T20" tile="-1" city="Cambridge" /> <Hex name="T22" tile="0"/> <Hex name="T24" tile="-1" city="Ipswich" orientation="1" /> - <Hex name="U9" tile="0"/> + <Hex name="U9" tile="0" open="1"/> <Hex name="U11" tile="-1" cost="40" city="Gloucester" orientation="1" ></Hex> <Hex name="U13" tile="0"/> @@ -65,7 +37,7 @@ <Hex name="U21" tile="0"/> <Hex name="U23" tile="-1" city="Colchester" /> <Hex name="U25" tile="-104" orientation="2" city="Harwich"/> - <Hex name="V8" tile="-20" city="Cardiff, Newport" /> + <Hex name="V8" tile="-20" city="Cardiff, Newport" open="1,2"/> <Hex name="V10" tile="-25003" city="Bristol"/> <Hex name="V12" tile="0"/> <Hex name="V14" tile="-25005" city="Swindon"/> @@ -83,7 +55,7 @@ <Hex name="W21" tile="0"/> <Hex name="W23" tile="-10" city="Ashford" orientation="5" /> <Hex name="W25" tile="-5" orientation="2" city="Dover"/> - <Hex name="X8" tile="0"/> + <Hex name="X8" tile="0" open="0,1"/> <Hex name="X10" tile="0"/> <Hex name="X12" tile="0"/> <Hex name="X14" tile="-10" city="Southampton" orientation="5" /> @@ -93,7 +65,7 @@ <Hex name="X20" tile="-10" city="Brighton" orientation="5" /> <Hex name="X22" tile="-1" city="Hastings" orientation="2" /> <Hex name="X24" tile="0"/> - <Hex name="Y9" tile="0"/> + <Hex name="Y9" tile="0" open="1"/> <Hex name="Y11" tile="-1" city="Weymouth" orientation="3" /> <Hex name="Y13" tile="-25007" city="Bournemouth"/> <Hex name="Y17" tile="-7" orientation="4" /> Modified: trunk/18xx/rails/game/MapHex.java =================================================================== --- trunk/18xx/rails/game/MapHex.java 2010-09-19 19:30:35 UTC (rev 1428) +++ trunk/18xx/rails/game/MapHex.java 2010-09-20 21:31:16 UTC (rev 1429) @@ -112,6 +112,9 @@ /** Storage of revenueBonus that are bound to the hex */ protected List<RevenueBonusTemplate> revenueBonuses = null; + /** Any open sides against which track may be laid even at board edges (1825) */ + protected boolean[] openHexSides; + protected MapManager mapManager = null; protected static Logger log = @@ -207,6 +210,12 @@ revenueBonuses.add(bonus); } } + + // Open sides (as in 1825, track may be laid against some board edges) + for (int side : tag.getAttributeAsIntegerArray("open", new int[0])) { + if (openHexSides == null) openHexSides = new boolean[6]; + openHexSides[side%6] = true; + } } public void finishConfiguration (GameManagerI gameManager) { @@ -258,6 +267,10 @@ return true; } + public boolean isOpenSide (int side) { + return openHexSides != null && openHexSides[side%6]; + } + public int getTileOrientation() { return mapManager.getTileOrientation(); } @@ -1012,15 +1025,15 @@ /** * @return Returns false if no base tokens may yet be laid on this hex and station. - * + * * NOTE: this method currently only checks for prohibitions caused * by the presence of unlaid home base tokens. * It does NOT (yet) check for free space. * * * There are the following cases to check for each company located there - * - * A) City is decided or there is only one city + * + * A) City is decided or there is only one city * => check if the city has a free slot or not * (examples: NYNH in 1830 for a two city tile, NYC for a one city tile) * B) City is not decided (example: Erie in 1830) @@ -1029,14 +1042,14 @@ * - (false): no city of the hex has remaining slots available * C) Or the company does not block its home city at all (example:Pr in 1835) * then isBlockedForTokenLays attribute is used - * + * * NOTE: It now deals with more than one company with a home base on the - * same hex. - * + * same hex. + * * Previously there was only the variable isBlockedForTokenLays * which is set to yes to block the whole hex for the token lays * until the (home) company laid their token - * + * */ public boolean isBlockedForTokenLays(PublicCompanyI company, int cityNumber) { @@ -1071,7 +1084,7 @@ anyBlockCompanies ++; // companies which are located somewhere else } } - log.debug("IsBlockedForTokenLays: allBlockCompanies = " + allBlockCompanies + + log.debug("IsBlockedForTokenLays: allBlockCompanies = " + allBlockCompanies + ", anyBlockCompanies = " + anyBlockCompanies + " , cityBlockCompanies = " + cityBlockCompanies); // check if there are sufficient individual city slots if (allBlockCompanies + cityBlockCompanies + 1 > cityToLay.getTokenSlotsLeft()) { Modified: trunk/18xx/rails/ui/swing/hexmap/GUITile.java =================================================================== --- trunk/18xx/rails/ui/swing/hexmap/GUITile.java 2010-09-19 19:30:35 UTC (rev 1428) +++ trunk/18xx/rails/ui/swing/hexmap/GUITile.java 2010-09-20 21:31:16 UTC (rev 1429) @@ -80,7 +80,7 @@ MapHex nHex; boolean connected; - + int fixedRotation = getTile().getFixedOrientation(); if (fixedRotation >= 0) { setRotation (fixedRotation); @@ -102,7 +102,7 @@ if (tile.hasTracks(tempTileSide)) { // If the tile has tracks against that side, but there is no // neighbour, forbid this rotation. - if (!hex.hasNeighbour(j)) { + if (!hex.hasNeighbour(j) && !hex.isOpenSide(j)) { continue rot; } // If the tile must be connected (i.e. not laid on the @@ -111,7 +111,7 @@ // a side of this tile that also has a track. if (mustConnect) { nHex = hex.getNeighbor(j); - if (nHex.getCurrentTile().hasTracks( + if (nHex != null && nHex.getCurrentTile().hasTracks( j + 3 - nHex.getCurrentTileRotation())) { connected = true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |