When scoring a feature, we can't simply count up the elements in the claim
group list because that may contain the same tile multiple times when tiles that contain multiple features are included in a single claim group with both of their features. So we have to do some extra jockeying to ensure that we count a tile only once. git-svn-id: https://samskivert.googlecode.com/svn/trunk@436 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: TileUtil.java,v 1.13 2001/10/24 03:24:36 mdb Exp $
|
// $Id: TileUtil.java,v 1.14 2001/11/07 10:39:00 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.venison;
|
package com.threerings.venison;
|
||||||
|
|
||||||
@@ -307,10 +307,26 @@ public class TileUtil implements TileCodes
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if we're here, it's a road or city feature, which we score by
|
// if we're here, it's a road or city feature, which we score by
|
||||||
// loading up the group and counting its size
|
// loading up the group and counting the number of tiles in it
|
||||||
List flist = new ArrayList();
|
List flist = new ArrayList();
|
||||||
boolean complete = enumerateGroup(tiles, tile, featureIndex, flist);
|
boolean complete = enumerateGroup(tiles, tile, featureIndex, flist);
|
||||||
int score = flist.size();
|
|
||||||
|
// we sort the group which will order the tile feature objects by
|
||||||
|
// their tiles, ensuring that features on the same tile are next
|
||||||
|
// to one another, so that we can only count them once
|
||||||
|
Collections.sort(flist);
|
||||||
|
|
||||||
|
// now iterate over the list, counting only unique tiles
|
||||||
|
int score = 0;
|
||||||
|
VenisonTile lastTile = null;
|
||||||
|
int fsize = flist.size();
|
||||||
|
for (int i = 0; i < fsize; i++) {
|
||||||
|
TileFeature feat = (TileFeature)flist.get(i);
|
||||||
|
if (feat.tile != lastTile) {
|
||||||
|
score++;
|
||||||
|
lastTile = feat.tile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// for city groups, we need to add a bonus of one for every tile
|
// for city groups, we need to add a bonus of one for every tile
|
||||||
// that contains a shield and mutiply by two if the city is
|
// that contains a shield and mutiply by two if the city is
|
||||||
@@ -598,7 +614,7 @@ public class TileUtil implements TileCodes
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Used to keep track of actual features on tiles. */
|
/** Used to keep track of actual features on tiles. */
|
||||||
protected static final class TileFeature
|
protected static final class TileFeature implements Comparable
|
||||||
{
|
{
|
||||||
/** The tile that contains the feature. */
|
/** The tile that contains the feature. */
|
||||||
public VenisonTile tile;
|
public VenisonTile tile;
|
||||||
@@ -627,6 +643,12 @@ public class TileUtil implements TileCodes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** We sort based on our tiles. */
|
||||||
|
public int compareTo (Object other)
|
||||||
|
{
|
||||||
|
return tile.compareTo(((TileFeature)other).tile);
|
||||||
|
}
|
||||||
|
|
||||||
/** Generate a string representation. */
|
/** Generate a string representation. */
|
||||||
public String toString ()
|
public String toString ()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user