From: John D. G. <jd...@di...> - 2012-06-03 04:12:47
|
This adds code to PublicCompany.getBaseTokenLayCost() so that the "distance" factor (cost per hex distance) can be different for each token in sequence. rails/game/PublicCompany.java 1753 /** 1754 * Calculate the cost of laying a token, given the hex where 1755 * the token is laid. This only makes a difference for the "distance" method. 1756 * @param hex The hex where the token is to be laid. 1757 * @return The cost of laying that token. 1758 */ 1759 public int getBaseTokenLayCost(MapHex hex) { 1760 1761 if (baseTokenLayCost == null) return 0; 1762 + if (index >= baseTokenLayCost.length) { + index = baseTokenLayCost.length - 1; + } else if (index < 0) { + index = 0; + } 1763 if (baseTokenLayCostMethod.equals(BASE_COST_SEQUENCE)) { 1764 - int index = getNumberOfLaidBaseTokens(); 1765 - 1766 - if (index >= baseTokenLayCost.length) { 1767 - index = baseTokenLayCost.length - 1; 1768 - } else if (index < 0) { 1769 - index = 0; 1770 - } 1771 return baseTokenLayCost[index]; 1772 } else if (baseTokenLayCostMethod.equals(BASE_COST_DISTANCE)) { 1773 if (hex == null) { 1774 - return baseTokenLayCost[0]; + return baseTokenLayCost[index]; 1775 } else { 1776 // WARNING: no provision yet for multiple home hexes. 1777 - return mapManager.getHexDistance(homeHexes.get(0), hex) * baseTokenLayCost[0]; + return mapManager.getHexDistance(homeHexes.get(0), hex) * baseTokenLayCost[index]; 1778 } 1779 } else { 1780 return 0; 1781 } 1782 } |