Slay some cyclopian variables.

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@929 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Dave Hoover
2010-06-15 17:27:37 +00:00
parent e686402a46
commit aeecc32e38
14 changed files with 115 additions and 116 deletions
@@ -84,9 +84,9 @@ public class Deck extends StreamableArrayList
{
clear();
for (var i :int = CardCodes.SPADES; i <= CardCodes.DIAMONDS; i++) {
for (var j :int = 2; j <= CardCodes.ACE; j++) {
add(new Card(j, i));
for (var ii :int = CardCodes.SPADES; ii <= CardCodes.DIAMONDS; ii++) {
for (var jj :int = 2; jj <= CardCodes.ACE; jj++) {
add(new Card(jj, ii));
}
}
@@ -42,8 +42,8 @@ public class Hand extends StreamableArrayList
public function getSuitMemberCount (suit :int) :int
{
var members :int = 0;
for (var i :int = 0; i < length; i++) {
if ((get(i) as Card).getSuit() == suit) {
for (var ii :int = 0; ii < length; ii++) {
if ((get(ii) as Card).getSuit() == suit) {
members++;
}
}
@@ -71,8 +71,8 @@ public class Hand extends StreamableArrayList
*/
public function containsAllCards (cards :Array) :Boolean
{
for (var i :int = 0; i < cards.length; i++) {
if (!contains(cards[i])) {
for (var ii :int = 0; ii < cards.length; ii++) {
if (!contains(cards[ii])) {
return false;
}
}
@@ -84,8 +84,8 @@ public class Hand extends StreamableArrayList
*/
public function removeAllCards (cards :Array) :void
{
for (var i :int = 0; i < cards.length; i++) {
remove(cards[i]);
for (var ii :int = 0; ii < cards.length; ii++) {
remove(cards[ii]);
}
}
}
@@ -91,16 +91,16 @@ public class TableItem
gbc.weightx = 1.0;
gbc.insets = new Insets(2, 0, 2, 0);
_seats = new JButton[bcount];
for (int i = 0; i < bcount; i++) {
for (int ii = 0; ii < bcount; ii++) {
// create the button
_seats[i] = new JButton(JOIN_LABEL);
_seats[i].addActionListener(this);
_seats[ii] = new JButton(JOIN_LABEL);
_seats[ii].addActionListener(this);
// if we're on the left
if (i % 2 == 0) {
if (ii % 2 == 0) {
// if we're the last seat, then we've got an odd number
// and need to center this final seat
if (i == bcount-1) {
if (ii == bcount-1) {
gbc.gridwidth = GridBagConstraints.REMAINDER;
} else {
gbc.gridwidth = 1;
@@ -111,16 +111,16 @@ public class TableItem
}
// adjust the insets of our last element
if (i == bcount-1) {
if (ii == bcount-1) {
gbc.insets = new Insets(2, 0, 4, 0);
}
// and add the button with the configured constraints
add(_seats[i], gbc);
add(_seats[ii], gbc);
// if we just added the first button, add the "go" button
// right after it
if (i == 0) {
if (ii == 0) {
_goButton = new JButton("Go");
_goButton.setActionCommand("go");
_goButton.addActionListener(this);
@@ -147,21 +147,21 @@ public class TableItem
// now enable and label the buttons accordingly
int slength = _seats.length;
for (int i = 0; i < slength; i++) {
if (table.players[i] == null) {
_seats[i].setText(JOIN_LABEL);
_seats[i].setEnabled(!isSeated);
_seats[i].setActionCommand("join");
for (int ii = 0; ii < slength; ii++) {
if (table.players[ii] == null) {
_seats[ii].setText(JOIN_LABEL);
_seats[ii].setEnabled(!isSeated);
_seats[ii].setActionCommand("join");
} else if (table.players[i].equals(_self) &&
} else if (table.players[ii].equals(_self) &&
!table.inPlay()) {
_seats[i].setText(LEAVE_LABEL);
_seats[i].setEnabled(true);
_seats[i].setActionCommand("leave");
_seats[ii].setText(LEAVE_LABEL);
_seats[ii].setEnabled(true);
_seats[ii].setActionCommand("leave");
} else {
_seats[i].setText(table.players[i].toString());
_seats[i].setEnabled(false);
_seats[ii].setText(table.players[ii].toString());
_seats[ii].setEnabled(false);
}
}
@@ -186,9 +186,9 @@ public class TableItem
if (cmd.equals("join")) {
// figure out what position this button is in
int position = -1;
for (int i = 0; i < _seats.length; i++) {
if (_seats[i] == event.getSource()) {
position = i;
for (int ii = 0; ii < _seats.length; ii++) {
if (_seats[ii] == event.getSource()) {
position = ii;
break;
}
}
@@ -252,8 +252,8 @@ public class TableListView extends JPanel
{
// first check the match list
int ccount = _matchList.getComponentCount();
for (int i = 0; i < ccount; i++) {
TableItem child = (TableItem)_matchList.getComponent(i);
for (int ii = 0; ii < ccount; ii++) {
TableItem child = (TableItem)_matchList.getComponent(ii);
if (child.table.tableId == tableId) {
return child;
}
@@ -261,8 +261,8 @@ public class TableListView extends JPanel
// then the inplay list
ccount = _playList.getComponentCount();
for (int i = 0; i < ccount; i++) {
TableItem child = (TableItem)_playList.getComponent(i);
for (int ii = 0; ii < ccount; ii++) {
TableItem child = (TableItem)_playList.getComponent(ii);
if (child.table.tableId == tableId) {
return child;
}
@@ -296,8 +296,8 @@ public abstract class CardPanel extends VirtualMediaPanel
// create the sprites
int size = hand.size();
for (int i = 0; i < size; i++) {
CardSprite cs = new CardSprite(this, hand.get(i));
for (int ii = 0; ii < size; ii++) {
CardSprite cs = new CardSprite(this, hand.get(ii));
_handSprites.add(cs);
}
@@ -308,13 +308,13 @@ public abstract class CardPanel extends VirtualMediaPanel
// fade them in at proper locations and layers
long cardDuration = fadeDuration / size;
for (int i = 0; i < size; i++) {
CardSprite cs = _handSprites.get(i);
cs.setLocation(getHandX(size, i), _handLocation.y);
cs.setRenderOrder(i);
for (int ii = 0; ii < size; ii++) {
CardSprite cs = _handSprites.get(ii);
cs.setLocation(getHandX(size, ii), _handLocation.y);
cs.setRenderOrder(ii);
cs.addSpriteObserver(_handSpriteObserver);
addSprite(cs);
cs.fadeIn(i * cardDuration, cardDuration);
cs.fadeIn(ii * cardDuration, cardDuration);
}
// make sure we have the right card sprite active
@@ -331,7 +331,7 @@ public abstract class CardPanel extends VirtualMediaPanel
{
// fill hand will null entries to signify unknown cards
Hand hand = new Hand();
for (int i = 0; i < size; i++) {
for (int ii = 0; ii < size; ii++) {
hand.add(null);
}
setHand(hand, fadeDuration);
@@ -351,9 +351,9 @@ public abstract class CardPanel extends VirtualMediaPanel
// set the sprites
int len = Math.min(_handSprites.size(), hand.size());
for (int i = 0; i < len; i++) {
CardSprite cs = _handSprites.get(i);
cs.setCard(hand.get(i));
for (int ii = 0; ii < len; ii++) {
CardSprite cs = _handSprites.get(ii);
cs.setCard(hand.get(ii));
}
}
@@ -425,9 +425,9 @@ public abstract class CardPanel extends VirtualMediaPanel
{
// first create the sprites and add them to the list
CardSprite[] sprites = new CardSprite[cards.length];
for (int i = 0; i < cards.length; i++) {
sprites[i] = new CardSprite(this, cards[i]);
_handSprites.add(sprites[i]);
for (int ii = 0; ii < cards.length; ii++) {
sprites[ii] = new CardSprite(this, cards[ii]);
_handSprites.add(sprites[ii]);
}
// settle the hand
@@ -468,10 +468,10 @@ public abstract class CardPanel extends VirtualMediaPanel
public void flyAcross (Card[] cards, Point src, Point dest, long flightDuration,
long cardDelay, float fadePortion)
{
for (int i = 0; i < cards.length; i++) {
for (int ii = 0; ii < cards.length; ii++) {
// add on top of all board sprites
CardSprite cs = new CardSprite(this, cards[i]);
cs.setRenderOrder(getHighestBoardLayer() + 1 + i);
CardSprite cs = new CardSprite(this, cards[ii]);
cs.setRenderOrder(getHighestBoardLayer() + 1 + ii);
cs.setLocation(src.x, src.y);
addSprite(cs);
@@ -479,8 +479,8 @@ public abstract class CardPanel extends VirtualMediaPanel
Path path;
long pathDuration;
LinePath flight = new LinePath(dest, flightDuration);
if (i > 0) {
long delayDuration = cardDelay * i;
if (ii > 0) {
long delayDuration = cardDelay * ii;
LinePath delay = new LinePath(src, delayDuration);
path = new PathSequence(delay, flight);
pathDuration = delayDuration + flightDuration;
@@ -626,8 +626,8 @@ public abstract class CardPanel extends VirtualMediaPanel
*/
protected CardSprite getCardSprite (List<CardSprite> list, Card card)
{
for (int i = 0; i < list.size(); i++) {
CardSprite cs = list.get(i);
for (int ii = 0; ii < list.size(); ii++) {
CardSprite cs = list.get(ii);
if (card.equals(cs.getCard())) {
return cs;
}
@@ -664,16 +664,16 @@ public abstract class CardPanel extends VirtualMediaPanel
// Move each card to its proper position (and, optionally, layer)
int size = _handSprites.size();
for (int i = 0; i < size; i++) {
CardSprite cs = _handSprites.get(i);
for (int ii = 0; ii < size; ii++) {
CardSprite cs = _handSprites.get(ii);
if (!isManaged(cs)) {
continue;
}
if (updateLayers) {
cs.setRenderOrder(i);
cs.setRenderOrder(ii);
}
LinePath adjust = new LinePath(
new Point(getHandX(size, i), _handLocation.y), adjustDuration);
new Point(getHandX(size, ii), _handLocation.y), adjustDuration);
cs.move(adjust);
}
}
@@ -697,8 +697,8 @@ public abstract class CardPanel extends VirtualMediaPanel
updateActiveCardSprite();
int size = _handSprites.size();
for (int i = 0; i < size; i++) {
CardSprite cs = _handSprites.get(i);
for (int ii = 0; ii < size; ii++) {
CardSprite cs = _handSprites.get(ii);
if (!cs.isMoving()) {
cs.setLocation(cs.getX(), getHandY(cs));
}
@@ -781,8 +781,8 @@ public abstract class CardPanel extends VirtualMediaPanel
// lower them just enough
int size = _boardSprites.size(), adjustment = layer - highest;
for (int i = 0; i < size; i++) {
CardSprite cs = _boardSprites.get(i);
for (int ii = 0; ii < size; ii++) {
CardSprite cs = _boardSprites.get(ii);
cs.setRenderOrder(cs.getRenderOrder() + adjustment);
}
}
@@ -795,8 +795,8 @@ public abstract class CardPanel extends VirtualMediaPanel
// must be at least zero, because that's the lowest number we can push the sprites down to
// (the layer of the first card in the hand)
int size = _boardSprites.size(), highest = 0;
for (int i = 0; i < size; i++) {
highest = Math.max(highest, _boardSprites.get(i).getRenderOrder());
for (int ii = 0; ii < size; ii++) {
highest = Math.max(highest, _boardSprites.get(ii).getRenderOrder());
}
return highest;
}
@@ -64,9 +64,9 @@ public class Deck extends StreamableArrayList<Card>
{
clear();
for (int i = SPADES; i <= DIAMONDS; i++) {
for (int ii = SPADES; ii <= DIAMONDS; ii++) {
for (int j = 2; j <= ACE; j++) {
add(new Card(j, i));
add(new Card(j, ii));
}
}
@@ -59,8 +59,8 @@ public class Hand extends StreamableArrayList<Card>
@ActionScript(name="containsAllCards")
public boolean containsAll (Card[] cards)
{
for (int i = 0; i < cards.length; i++) {
if (!contains(cards[i])) {
for (int ii = 0; ii < cards.length; ii++) {
if (!contains(cards[ii])) {
return false;
}
}
@@ -76,8 +76,8 @@ public class Hand extends StreamableArrayList<Card>
public int getSuitMemberCount (int suit)
{
int len = size(), members = 0;
for (int i = 0; i < len; i++) {
if (get(i).getSuit() == suit) {
for (int ii = 0; ii < len; ii++) {
if (get(ii).getSuit() == suit) {
members++;
}
}
@@ -136,8 +136,8 @@ public class CardGameManager extends GameManager
} else {
Hand[] hands = new Hand[_playerCount];
for (int i=0;i<_playerCount;i++) {
hands[i] = dealHand(deck, size, i);
for (int ii = 0; ii < _playerCount; ii++) {
hands[ii] = dealHand(deck, size, ii);
}
return hands;
@@ -153,7 +153,7 @@ public class CardGameManager extends GameManager
int[] oids = (_gameobj.state == GameObject.GAME_OVER) ? _oldPlayerOids : _playerOids;
int oid = client.getOid();
for (int ii=0; ii < oids.length; ii++) {
for (int ii = 0; ii < oids.length; ii++) {
if (oids[ii] == oid) {
return ii;
}
@@ -453,8 +453,8 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
protected Card pickRandomPlayableCard (Hand hand)
{
List<Card> playableCards = Lists.newArrayList();
for (int i = 0; i < hand.size(); i++) {
Card card = hand.get(i);
for (int ii = 0; ii < hand.size(); ii++) {
Card card = hand.get(ii);
if (_trickCardGame.isCardPlayable(hand, card)) {
playableCards.add(card);
}
@@ -175,8 +175,8 @@ public class TrickCardGameUtil
public static PlayerCard getHighestInLeadSuit (PlayerCard[] cardsPlayed, int trumpSuit)
{
PlayerCard highest = cardsPlayed[0];
for (int i = 1; i < cardsPlayed.length; i++) {
PlayerCard other = cardsPlayed[i];
for (int ii = 1; ii < cardsPlayed.length; ii++) {
PlayerCard other = cardsPlayed[ii];
if ((other.card.getSuit() == highest.card.getSuit() &&
other.card.compareTo(highest.card) > 0) ||
(other.card.getSuit() == trumpSuit && highest.card.getSuit() != trumpSuit)) {
@@ -140,8 +140,8 @@ public class ParlorDirector extends BasicDirector
// see what our observers have to say about it
boolean handled = false;
for (int i = 0; i < _grobs.size(); i++) {
GameReadyObserver grob = _grobs.get(i);
for (int ii = 0; ii < _grobs.size(); ii++) {
GameReadyObserver grob = _grobs.get(ii);
handled = grob.receivedGameReady(gameOid) || handled;
}
@@ -287,9 +287,9 @@ public class Table
public boolean clearPlayer (Name username)
{
if (players != null) {
for (int i = 0; i < players.length; i++) {
if (username.equals(players[i])) {
clearPlayerPos(i);
for (int ii = 0; ii < players.length; ii++) {
if (username.equals(players[ii])) {
clearPlayerPos(ii);
return true;
}
}
@@ -308,9 +308,9 @@ public class Table
public boolean clearPlayerByOid (int bodyOid)
{
if (bodyOids != null) {
for (int i = 0; i < bodyOids.length; i++) {
if (bodyOid == bodyOids[i]) {
clearPlayerPos(i);
for (int ii = 0; ii < bodyOids.length; ii++) {
if (bodyOid == bodyOids[ii]) {
clearPlayerPos(ii);
return true;
}
}
@@ -143,9 +143,9 @@ public class PlacementConstraints
ObjectInfo[] removed)
{
ObjectData[] addedData = new ObjectData[added.length];
for (int i = 0; i < added.length; i++) {
addedData[i] = createObjectData(added[i]);
if (addedData[i] == null) {
for (int ii = 0; ii < added.length; ii++) {
addedData[ii] = createObjectData(added[ii]);
if (addedData[ii] == null) {
return INTERNAL_ERROR;
}
}
@@ -193,33 +193,33 @@ public class PlacementConstraints
{
DirectionType dirtype = new DirectionType();
for (int i = 0; i < added.length; i++) {
if (added[i].tile.hasConstraint(ObjectTileSet.ON_SURFACE) &&
!isOnSurface(added[i], added, removed)) {
for (int ii = 0; ii < added.length; ii++) {
if (added[ii].tile.hasConstraint(ObjectTileSet.ON_SURFACE) &&
!isOnSurface(added[ii], added, removed)) {
return MessageBundle.qualify(STAGE_MESSAGE_BUNDLE,
"m.not_on_surface");
}
if (getConstraintDirectionType(added[i], ObjectTileSet.ON_WALL,
dirtype) && !isOnWall(added[i], added, removed, dirtype.dir, dirtype.type)) {
if (getConstraintDirectionType(added[ii], ObjectTileSet.ON_WALL,
dirtype) && !isOnWall(added[ii], added, removed, dirtype.dir, dirtype.type)) {
return MessageBundle.qualify(STAGE_MESSAGE_BUNDLE,
"m.not_on_wall");
}
if (getConstraintDirectionType(added[i], ObjectTileSet.ATTACH,
dirtype) && !isAttached(added[i], added, removed,
if (getConstraintDirectionType(added[ii], ObjectTileSet.ATTACH,
dirtype) && !isAttached(added[ii], added, removed,
dirtype.dir, dirtype.type)) {
return MessageBundle.qualify(STAGE_MESSAGE_BUNDLE,
"m.not_attached");
}
int dir = getConstraintDirection(added[i], ObjectTileSet.SPACE);
if (dir != NONE && !hasSpace(added[i], added, removed, dir)) {
int dir = getConstraintDirection(added[ii], ObjectTileSet.SPACE);
if (dir != NONE && !hasSpace(added[ii], added, removed, dir)) {
return MessageBundle.qualify(STAGE_MESSAGE_BUNDLE,
"m.no_space");
}
if (hasSpaceConstrainedAdjacent(added[i], added, removed)) {
if (hasSpaceConstrainedAdjacent(added[ii], added, removed)) {
return MessageBundle.qualify(STAGE_MESSAGE_BUNDLE,
"m.no_space_adj");
}
@@ -256,8 +256,8 @@ public class PlacementConstraints
ObjectData[] removed)
{
List<ObjectData> objects = getObjectData(data.bounds, added, removed);
for (int i = 0, size = objects.size(); i < size; i++) {
ObjectData odata = objects.get(i);
for (int ii = 0, size = objects.size(); ii < size; ii++) {
ObjectData odata = objects.get(ii);
if (odata.tile.hasConstraint(ObjectTileSet.ON_SURFACE) &&
!isOnSurface(odata, added, removed)) {
return true;
@@ -276,8 +276,8 @@ public class PlacementConstraints
DirectionType dirtype = new DirectionType();
List<ObjectData> objects = getObjectData(data.bounds, added, removed);
for (int i = 0, size = objects.size(); i < size; i++) {
ObjectData odata = objects.get(i);
for (int ii = 0, size = objects.size(); ii < size; ii++) {
ObjectData odata = objects.get(ii);
if (getConstraintDirectionType(odata, ObjectTileSet.ON_WALL,
dirtype) && !isAttached(odata, added, removed,
dirtype.dir, dirtype.type)) {
@@ -298,8 +298,8 @@ public class PlacementConstraints
List<ObjectData> objects = getObjectData(getAdjacentEdge(data.bounds,
DirectionUtil.getOpposite(dir)), added, removed);
for (int i = 0, size = objects.size(); i < size; i++) {
ObjectData odata = objects.get(i);
for (int ii = 0, size = objects.size(); ii < size; ii++) {
ObjectData odata = objects.get(ii);
if (getConstraintDirectionType(odata, ObjectTileSet.ATTACH,
dirtype) && !isAttached(odata, added, removed,
dirtype.dir, dirtype.type)) {
@@ -321,8 +321,8 @@ public class PlacementConstraints
_constrainRect.setBounds(r.x - 1, r.y - 1, r.width + 2, r.height + 2);
List<ObjectData> objects = getObjectData(_constrainRect, added, removed);
for (int i = 0, size = objects.size(); i < size; i++) {
ObjectData odata = objects.get(i);
for (int ii = 0, size = objects.size(); ii < size; ii++) {
ObjectData odata = objects.get(ii);
int dir = getConstraintDirection(odata, ObjectTileSet.SPACE);
if (dir != NONE && !hasSpace(odata, added, removed, dir)) {
return true;
@@ -389,8 +389,8 @@ public class PlacementConstraints
for (int y = rect.y, ymax = rect.y + rect.height; y < ymax; y++) {
for (int x = rect.x, xmax = rect.x + rect.width; x < xmax; x++) {
boolean covered = false;
for (int i = 0, size = objects.size(); i < size; i++) {
ObjectData data = objects.get(i);
for (int ii = 0, size = objects.size(); ii < size; ii++) {
ObjectData data = objects.get(ii);
if (data.bounds.contains(x, y) && (constraint == null ||
data.tile.hasConstraint(constraint) ||
(altstraint != null &&
@@ -114,12 +114,11 @@ public abstract class SpotSceneRuleSet implements NestableRuleSet
Location loc = portal.loc;
Class<?> locClass = loc.getClass();
// iterate over the attributes, setting public fields where
// applicable
for (int i = 0; i < attrs.getLength(); i++) {
String lname = attrs.getLocalName(i);
// iterate over the attributes, setting public fields where applicable
for (int ii = 0; ii < attrs.getLength(); ii++) {
String lname = attrs.getLocalName(ii);
if (StringUtil.isBlank(lname)) {
lname = attrs.getQName(i);
lname = attrs.getQName(ii);
}
// look for a public field with this lname
@@ -145,7 +144,7 @@ public abstract class SpotSceneRuleSet implements NestableRuleSet
}
// convert the value into the appropriate object type
String valstr = attrs.getValue(i);
String valstr = attrs.getValue(ii);
// use the value marshaller to parse the
// property based on the type of the target object field
Object value = ValueMarshaller.unmarshal(