From 547ace1187c519ff421dd9e63e24f4b97b19d9d3 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Fri, 9 Dec 2005 23:29:48 +0000 Subject: [PATCH] Added isRandomValidTarget used for selecting a new random target. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3781 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../puzzle/data/TeamPuzzleObject.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/java/com/threerings/puzzle/data/TeamPuzzleObject.java b/src/java/com/threerings/puzzle/data/TeamPuzzleObject.java index 1cbb29b52..463905478 100644 --- a/src/java/com/threerings/puzzle/data/TeamPuzzleObject.java +++ b/src/java/com/threerings/puzzle/data/TeamPuzzleObject.java @@ -91,7 +91,7 @@ public class TeamPuzzleObject extends PuzzleObject // if this is a valid target and tcount is zero, stop; note // that we rely on the short-circuit to only decrement tcount // when we're on a valid target - if (isValidTarget(pidx, tpidx) && (tcount-- == 0)) { + if (isRandomValidTarget(pidx, tpidx) && (tcount-- == 0)) { return tpidx; } tpidx++; @@ -112,7 +112,7 @@ public class TeamPuzzleObject extends PuzzleObject { int count = 0; for (int ii = 0; ii < players.length; ii++) { - if (isValidTarget(pidx, ii)) { + if (isRandomValidTarget(pidx, ii)) { count++; } } @@ -132,6 +132,19 @@ public class TeamPuzzleObject extends PuzzleObject pidx != tpidx && isActivePlayer(tpidx) && teams[pidx] != teams[tpidx]); } + + /** + * Returns whether one player may target another player on random + * reassignment. + * + * @param pidx the player index of the player attempting to change + * their target player. + * @param tpidx the player index of the player being targeted. + */ + protected boolean isRandomValidTarget (int pidx, int tpidx) + { + return isValidTarget(pidx, tpidx); + } // AUTO-GENERATED: METHODS START /**