Fixed bug where getRandom would never return the last value from the list

This commit is contained in:
Yair Morgenstern 2017-11-25 22:48:34 +02:00
parent d125c6ba3e
commit 279269d4a3
2 changed files with 2 additions and 2 deletions

View file

@ -22,7 +22,7 @@ public class TileGroup extends Group {
TileGroup(TileInfo tileInfo){ TileGroup(TileInfo tileInfo){
this.tileInfo = tileInfo; this.tileInfo = tileInfo;
String terrainFileName = "TerrainIcons/" + tileInfo.GetLastTerrain().Name + "_(Civ5).png"; String terrainFileName = "TerrainIcons/" + tileInfo.GetLastTerrain().Name.replace(' ','_') + "_(Civ5).png";
terrainImage = ImageGetter.getImageByFilename(terrainFileName); terrainImage = ImageGetter.getImageByFilename(terrainFileName);
terrainImage.setSize(50,50); terrainImage.setSize(50,50);
addActor(terrainImage); addActor(terrainImage);

View file

@ -43,7 +43,7 @@ public class LinqCollection <T> extends ArrayList<T> {
public T getRandom(){ public T getRandom(){
if(size()==0) return null; if(size()==0) return null;
return get((int) (Math.random() * (size() - 1))); return get((int) (Math.random() * (size())));
} }
public interface Func<T1, T2> { public interface Func<T1, T2> {