Yet more formatting changes. Should be just about compliant with the standard.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3138 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: OrientableImageSprite.java,v 1.3 2004/10/15 00:59:53 andrzej Exp $
|
||||
// $Id: OrientableImageSprite.java,v 1.4 2004/10/15 03:09:46 andrzej Exp $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -75,8 +75,7 @@ public class OrientableImageSprite extends ImageSprite
|
||||
{
|
||||
double theta;
|
||||
|
||||
switch(_orient)
|
||||
{
|
||||
switch(_orient) {
|
||||
case NORTH:
|
||||
default:
|
||||
theta = 0.0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: CardGameController.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $
|
||||
// $Id: CardGameController.java,v 1.3 2004/10/15 03:09:46 andrzej Exp $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -54,8 +54,7 @@ public abstract class CardGameController extends GameController
|
||||
// Documentation inherited
|
||||
public void messageReceived (MessageEvent event)
|
||||
{
|
||||
if(event.getName().equals(TAKE_HAND))
|
||||
{
|
||||
if(event.getName().equals(TAKE_HAND)) {
|
||||
handDealt((Hand)event.getArgs()[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: CardPanel.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $
|
||||
// $Id: CardPanel.java,v 1.3 2004/10/15 03:09:46 andrzej Exp $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -52,9 +52,6 @@ public abstract class CardPanel extends VirtualMediaPanel
|
||||
/** Calls CardSpriteObserver.cardSpriteClicked. */
|
||||
protected static class CardSpriteClickedOp implements ObserverList.ObserverOp
|
||||
{
|
||||
protected CardSprite _sprite;
|
||||
protected MouseEvent _me;
|
||||
|
||||
public CardSpriteClickedOp (CardSprite sprite, MouseEvent me)
|
||||
{
|
||||
_sprite = sprite;
|
||||
@@ -66,14 +63,14 @@ public abstract class CardPanel extends VirtualMediaPanel
|
||||
((CardSpriteObserver)observer).cardSpriteClicked(_sprite, _me);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected CardSprite _sprite;
|
||||
protected MouseEvent _me;
|
||||
}
|
||||
|
||||
/** Calls CardSpriteObserver.cardSpriteDragged. */
|
||||
protected static class CardSpriteDraggedOp implements ObserverList.ObserverOp
|
||||
{
|
||||
protected CardSprite _sprite;
|
||||
protected MouseEvent _me;
|
||||
|
||||
public CardSpriteDraggedOp (CardSprite sprite, MouseEvent me)
|
||||
{
|
||||
_sprite = sprite;
|
||||
@@ -85,6 +82,9 @@ public abstract class CardPanel extends VirtualMediaPanel
|
||||
((CardSpriteObserver)observer).cardSpriteDragged(_sprite, _me);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected CardSprite _sprite;
|
||||
protected MouseEvent _me;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,93 +97,77 @@ public abstract class CardPanel extends VirtualMediaPanel
|
||||
{
|
||||
super(frameManager);
|
||||
|
||||
addMouseListener(
|
||||
new MouseAdapter()
|
||||
{
|
||||
public void mousePressed (MouseEvent me)
|
||||
{
|
||||
ArrayList al = new ArrayList();
|
||||
MouseAdapter ma = new MouseAdapter() {
|
||||
public void mousePressed (MouseEvent me) {
|
||||
ArrayList al = new ArrayList();
|
||||
|
||||
_spritemgr.getHitSprites(al, me.getX(), me.getY());
|
||||
_spritemgr.getHitSprites(al, me.getX(), me.getY());
|
||||
|
||||
if(al.size() > 0)
|
||||
{
|
||||
Iterator it = al.iterator();
|
||||
int highestLayer = Integer.MIN_VALUE;
|
||||
CardSprite highestSprite = null;
|
||||
if(al.size() > 0) {
|
||||
Iterator it = al.iterator();
|
||||
int highestLayer = Integer.MIN_VALUE;
|
||||
CardSprite highestSprite = null;
|
||||
|
||||
while(it.hasNext())
|
||||
{
|
||||
Sprite sprite = (Sprite)it.next();
|
||||
while(it.hasNext()) {
|
||||
Sprite sprite = (Sprite)it.next();
|
||||
|
||||
if(sprite instanceof CardSprite)
|
||||
{
|
||||
CardSprite cs = (CardSprite)sprite;
|
||||
if(sprite instanceof CardSprite) {
|
||||
CardSprite cs = (CardSprite)sprite;
|
||||
|
||||
if(cs.getRenderOrder() > highestLayer)
|
||||
{
|
||||
highestLayer = cs.getRenderOrder();
|
||||
highestSprite = cs;
|
||||
}
|
||||
if(cs.getRenderOrder() > highestLayer) {
|
||||
highestLayer = cs.getRenderOrder();
|
||||
highestSprite = cs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_activeCardSprite = highestSprite;
|
||||
|
||||
if(_activeCardSprite != null)
|
||||
{
|
||||
_handleX = _activeCardSprite.getX() - me.getX();
|
||||
_handleY = _activeCardSprite.getY() - me.getY();
|
||||
_activeCardSprite = highestSprite;
|
||||
|
||||
if(_activeCardSprite != null) {
|
||||
_handleX = _activeCardSprite.getX() - me.getX();
|
||||
_handleY = _activeCardSprite.getY() - me.getY();
|
||||
|
||||
_hasBeenDragged = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_activeCardSprite = null;
|
||||
_hasBeenDragged = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseReleased (MouseEvent me)
|
||||
{
|
||||
if(_activeCardSprite != null && _hasBeenDragged)
|
||||
{
|
||||
_activeCardSprite.queueNotification(
|
||||
new CardSpriteDraggedOp(_activeCardSprite, me)
|
||||
);
|
||||
}
|
||||
else {
|
||||
_activeCardSprite = null;
|
||||
}
|
||||
|
||||
public void mouseClicked (MouseEvent me)
|
||||
{
|
||||
if(_activeCardSprite != null)
|
||||
{
|
||||
_activeCardSprite.queueNotification(
|
||||
new CardSpriteClickedOp(_activeCardSprite, me)
|
||||
);
|
||||
}
|
||||
}
|
||||
public void mouseReleased (MouseEvent me) {
|
||||
if(_activeCardSprite != null && _hasBeenDragged) {
|
||||
_activeCardSprite.queueNotification(
|
||||
new CardSpriteDraggedOp(_activeCardSprite, me)
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
public void mouseClicked (MouseEvent me) {
|
||||
if(_activeCardSprite != null) {
|
||||
_activeCardSprite.queueNotification(
|
||||
new CardSpriteClickedOp(_activeCardSprite, me)
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
addMouseListener(ma);
|
||||
|
||||
addMouseMotionListener(
|
||||
new MouseMotionAdapter()
|
||||
MouseMotionAdapter mma = new MouseMotionAdapter() {
|
||||
public void mouseDragged (MouseEvent me)
|
||||
{
|
||||
public void mouseDragged (MouseEvent me)
|
||||
{
|
||||
if(_activeCardSprite != null &&
|
||||
_activeCardSprite.isDraggable())
|
||||
{
|
||||
_activeCardSprite.setLocation(
|
||||
me.getX() + _handleX,
|
||||
me.getY() + _handleY
|
||||
);
|
||||
if(_activeCardSprite != null &&
|
||||
_activeCardSprite.isDraggable()) {
|
||||
_activeCardSprite.setLocation(
|
||||
me.getX() + _handleX,
|
||||
me.getY() + _handleY
|
||||
);
|
||||
|
||||
_hasBeenDragged = true;
|
||||
}
|
||||
_hasBeenDragged = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
addMouseMotionListener(mma);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: Card.java,v 1.3 2004/10/15 00:14:23 andrzej Exp $
|
||||
// $Id: Card.java,v 1.4 2004/10/15 03:09:46 andrzej Exp $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -125,8 +125,7 @@ public class Card implements CardCodes,
|
||||
// Documentation inherited.
|
||||
public Comparable getKey ()
|
||||
{
|
||||
if(_key == null)
|
||||
{
|
||||
if(_key == null) {
|
||||
_key = new Byte(_value);
|
||||
}
|
||||
|
||||
@@ -151,12 +150,10 @@ public class Card implements CardCodes,
|
||||
*/
|
||||
public boolean equals (Object other)
|
||||
{
|
||||
if(other instanceof Card)
|
||||
{
|
||||
if(other instanceof Card) {
|
||||
return _value == ((Card)other)._value;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -170,22 +167,17 @@ public class Card implements CardCodes,
|
||||
{
|
||||
int number = getNumber();
|
||||
|
||||
if(number == JOKER)
|
||||
{
|
||||
if(number == JOKER) {
|
||||
return "Jk";
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
if(number >= 2 && number <= 9)
|
||||
{
|
||||
if(number >= 2 && number <= 9) {
|
||||
sb.append(Integer.toString(number));
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(number)
|
||||
{
|
||||
else {
|
||||
switch(number) {
|
||||
case 10: sb.append('T'); break;
|
||||
case JACK: sb.append('J'); break;
|
||||
case QUEEN: sb.append('Q'); break;
|
||||
@@ -195,8 +187,7 @@ public class Card implements CardCodes,
|
||||
}
|
||||
}
|
||||
|
||||
switch(getSuit())
|
||||
{
|
||||
switch(getSuit()) {
|
||||
case HEARTS: sb.append('h'); break;
|
||||
case DIAMONDS: sb.append('d'); break;
|
||||
case CLUBS: sb.append('c'); break;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: Deck.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $
|
||||
// $Id: Deck.java,v 1.3 2004/10/15 03:09:46 andrzej Exp $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -72,16 +72,13 @@ public class Deck implements CardCodes,
|
||||
{
|
||||
cards.clear();
|
||||
|
||||
for(int i=HEARTS;i<=SPADES;i++)
|
||||
{
|
||||
for(int j=2;j<=ACE;j++)
|
||||
{
|
||||
for(int i=HEARTS;i<=SPADES;i++) {
|
||||
for(int j=2;j<=ACE;j++) {
|
||||
cards.add(new Card(j, i));
|
||||
}
|
||||
}
|
||||
|
||||
if(includeJokers)
|
||||
{
|
||||
if(includeJokers) {
|
||||
cards.add(new Card(JOKER, -1));
|
||||
cards.add(new Card(JOKER, -1));
|
||||
}
|
||||
@@ -104,16 +101,13 @@ public class Deck implements CardCodes,
|
||||
*/
|
||||
public Hand dealHand (int size)
|
||||
{
|
||||
if(cards.size() < size)
|
||||
{
|
||||
if(cards.size() < size) {
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
Hand hand = new Hand();
|
||||
|
||||
for(int i=0;i<size;i++)
|
||||
{
|
||||
for(int i=0;i<size;i++) {
|
||||
hand.cards.add(cards.get(cards.size()-1));
|
||||
cards.remove(cards.size()-1);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: Hand.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $
|
||||
// $Id: Hand.java,v 1.3 2004/10/15 03:09:46 andrzej Exp $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -57,10 +57,8 @@ public class Hand implements CardCodes,
|
||||
|
||||
Iterator it = cards.iterator();
|
||||
|
||||
while(it.hasNext())
|
||||
{
|
||||
if(((Card)it.next()).getSuit() == suit)
|
||||
{
|
||||
while(it.hasNext()) {
|
||||
if(((Card)it.next()).getSuit() == suit) {
|
||||
members++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: CardGameManager.java,v 1.3 2004/10/15 00:14:23 andrzej Exp $
|
||||
// $Id: CardGameManager.java,v 1.4 2004/10/15 03:09:46 andrzej Exp $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -50,12 +50,10 @@ public class CardGameManager extends GameManager
|
||||
*/
|
||||
public Hand dealHand (Deck deck, int size, int playerIndex)
|
||||
{
|
||||
if(deck.cards.size() < size)
|
||||
{
|
||||
if(deck.cards.size() < size) {
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
Hand hand = deck.dealHand(size);
|
||||
|
||||
_omgr.postEvent(
|
||||
@@ -82,16 +80,13 @@ public class CardGameManager extends GameManager
|
||||
*/
|
||||
public Hand[] dealHands (Deck deck, int size)
|
||||
{
|
||||
if(deck.cards.size() < size * _playerCount)
|
||||
{
|
||||
if(deck.cards.size() < size * _playerCount) {
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
Hand[] hands = new Hand[_playerCount];
|
||||
|
||||
for(int i=0;i<_playerCount;i++)
|
||||
{
|
||||
for(int i=0;i<_playerCount;i++) {
|
||||
hands[i] = dealHand(deck, size, i);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TrickCardGameControllerDelegate.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $
|
||||
// $Id: TrickCardGameControllerDelegate.java,v 1.3 2004/10/15 03:09:46 andrzej Exp $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -50,12 +50,10 @@ public class TrickCardGameControllerDelegate extends TurnGameControllerDelegate
|
||||
|
||||
TrickCardGameObject tcgObj = (TrickCardGameObject)_gameObj;
|
||||
|
||||
if(ace.getName().equals(tcgObj.getPlayingHandFieldName()))
|
||||
{
|
||||
if(ace.getName().equals(tcgObj.getPlayingHandFieldName())) {
|
||||
_tcgctrl.playingHandDidChange(tcgObj.getPlayingHand());
|
||||
}
|
||||
else if(ace.getName().equals(tcgObj.getPlayingTrickFieldName()))
|
||||
{
|
||||
else if(ace.getName().equals(tcgObj.getPlayingTrickFieldName())) {
|
||||
_tcgctrl.playingTrickDidChange(tcgObj.getPlayingTrick());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TrickCardGameManagerDelegate.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $
|
||||
// $Id: TrickCardGameManagerDelegate.java,v 1.3 2004/10/15 03:09:46 andrzej Exp $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -48,12 +48,10 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
|
||||
// Documentation inherited.
|
||||
public void setFirstTurnHolder ()
|
||||
{
|
||||
if(_trickCardGame.getPlayingHand() && _trickCardGame.getPlayingTrick())
|
||||
{
|
||||
if(_trickCardGame.getPlayingHand() && _trickCardGame.getPlayingTrick()) {
|
||||
super.setFirstTurnHolder();
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
_turnIdx = -1;
|
||||
}
|
||||
}
|
||||
@@ -61,12 +59,10 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
|
||||
// Documentation inherited.
|
||||
public void setNextTurnHolder ()
|
||||
{
|
||||
if(_trickCardGame.getPlayingHand() && _trickCardGame.getPlayingTrick())
|
||||
{
|
||||
if(_trickCardGame.getPlayingHand() && _trickCardGame.getPlayingTrick()) {
|
||||
super.setNextTurnHolder();
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
_turnIdx = -1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user