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 } |
From: Erik V. <eri...@xs...> - 2012-06-05 20:11:16
|
Thanks for the patch, this is indeed required for 1837. It's now in the 'master' repository. Your code didn't compile because the initialisation of 'index' was missing. I have added that line, as well as a comment. Erik. > -----Original Message----- > From: John David Galt [mailto:jd...@di...] > Sent: Sunday, June 03, 2012 6:13 AM > To: rai...@li... > Subject: [Rails-devel] Patch > > 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 } > > ---------------------------------------------------------------------------- -- > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and threat > landscape has changed and how IT managers can respond. Discussions will > include endpoint security, mobile security and the latest in malware threats. > http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Rails-devel mailing list > Rai...@li... > https://lists.sourceforge.net/lists/listinfo/rails-devel |