Fixed and finished up cloister scoring for already on the board cloisters.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@365 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2001-10-17 05:01:51 +00:00
parent 52dfdf7332
commit 6a5b6e629b
2 changed files with 67 additions and 4 deletions
@@ -1,5 +1,5 @@
//
// $Id: AtlantiManager.java,v 1.9 2001/10/17 04:34:14 mdb Exp $
// $Id: AtlantiManager.java,v 1.10 2001/10/17 05:01:51 mdb Exp $
package com.threerings.venison;
@@ -177,6 +177,69 @@ public class VenisonManager
", score=" + score + "].");
}
}
// we also may have completed a cloister, so we check that as well
for (int dx = -1; dx < 2; dx++) {
for (int dy = -1; dy < 2; dy++) {
// skip ourselves
if (dx == 0 && dy == 0) {
continue;
}
// find our neighbor and make sure they exist
VenisonTile neighbor =
TileUtil.findTile(_tiles, tile.x + dx, tile.y + dy);
if (neighbor == null) {
continue;
}
// scan their features arrays for claimed cloisters
for (int i = 0; i < neighbor.features.length; i++) {
Feature f = neighbor.features[i];
Piecen p = neighbor.piecen;
// is a cloister
if (f.type != TileCodes.CLOISTER) {
continue;
}
// tile has a piecen
if (p == null) {
Log.info("Skipping non-piecen having " +
"cloister tile [tile=" + neighbor +
", feat=" + f + "].");
continue;
}
// piecen is on cloister feature
if (neighbor.claims[i] != p.claimGroup) {
Log.info("Skipping cloister tile with piecen on " +
"non-cloister [tile=" + neighbor +
", feat=" + f + "].");
continue;
}
// score the cloister to see if it is completed
int score = TileUtil.computeFeatureScore(
_tiles, neighbor, i);
// it is, yay!
if (score > 0) {
// add the score to the owning player
_venobj.scores[p.color] += score;
_venobj.setScores(_venobj.scores);
// and clear out the piecen
_venobj.removeFromPiecens(p.getKey());
Log.info("Scored cloister [tile=" + neighbor +
", f=" + f + ", p=" + p + "].");
} else {
Log.info("Not scoring incomplete cloister " +
"[tile=" + neighbor + ", feat=" + f + "].");
}
}
}
}
}
/**
@@ -1,5 +1,5 @@
//
// $Id: TileUtil.java,v 1.8 2001/10/17 04:34:13 mdb Exp $
// $Id: TileUtil.java,v 1.9 2001/10/17 05:01:51 mdb Exp $
package com.threerings.venison;
@@ -519,8 +519,8 @@ public class TileUtil implements TileCodes
// all we need to know are how many neighbors this guy has (we
// count ourselves as well, just for code simplicity)
for (int dx = -1; dx < 1; dx++) {
for (int dy = -1; dy < 1; dy++) {
for (int dx = -1; dx < 2; dx++) {
for (int dy = -1; dy < 2; dy++) {
if (findTile(tiles, tile.x + dx, tile.y + dy) != null) {
score++;
}