diff --git a/src/java/com/threerings/media/sprite/OrientableImageSprite.java b/src/java/com/threerings/media/sprite/OrientableImageSprite.java index 7481ebc65..3b41ef629 100644 --- a/src/java/com/threerings/media/sprite/OrientableImageSprite.java +++ b/src/java/com/threerings/media/sprite/OrientableImageSprite.java @@ -1,5 +1,5 @@ // -// $Id: OrientableImageSprite.java,v 1.1 2004/10/13 02:03:44 andrzej Exp $ +// $Id: OrientableImageSprite.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -21,9 +21,11 @@ package com.threerings.media.sprite; -import java.awt.*; +import java.awt.Graphics2D; +import java.awt.Rectangle; -import java.awt.geom.*; +import java.awt.geom.AffineTransform; +import java.awt.geom.Area; import java.awt.image.*; @@ -40,7 +42,7 @@ public class OrientableImageSprite extends ImageSprite /** * Creates a new orientable image sprite. */ - public OrientableImageSprite() + public OrientableImageSprite () {} /** @@ -48,7 +50,7 @@ public class OrientableImageSprite extends ImageSprite * * @param image the image to render */ - public OrientableImageSprite(Mirage image) + public OrientableImageSprite (Mirage image) { super(image); } @@ -58,7 +60,7 @@ public class OrientableImageSprite extends ImageSprite * * @param frames the frames to render */ - public OrientableImageSprite(MultiFrameImage frames) + public OrientableImageSprite (MultiFrameImage frames) { super(frames); } @@ -69,7 +71,7 @@ public class OrientableImageSprite extends ImageSprite * * @return the newly computed rotation transform */ - private AffineTransform getRotationTransform() + private AffineTransform getRotationTransform () { double theta; @@ -149,7 +151,7 @@ public class OrientableImageSprite extends ImageSprite } // Documentation inherited. - protected void accomodateFrame(int frameIdx, int width, int height) + protected void accomodateFrame (int frameIdx, int width, int height) { Area area = new Area( new Rectangle( @@ -166,7 +168,7 @@ public class OrientableImageSprite extends ImageSprite } // Documentation inherited. - public void setOrientation(int orient) + public void setOrientation (int orient) { super.setOrientation(orient); @@ -174,14 +176,13 @@ public class OrientableImageSprite extends ImageSprite } // Documentation inherited. - public void paint(Graphics2D graphics) + public void paint (Graphics2D graphics) { AffineTransform at = graphics.getTransform(); graphics.transform(getRotationTransform()); - if(_frames != null) - { + if(_frames != null) { _frames.paintFrame( graphics, _frameIdx, @@ -189,8 +190,7 @@ public class OrientableImageSprite extends ImageSprite _oy - _oyoff ); } - else - { + else { super.paint(graphics); } diff --git a/src/java/com/threerings/parlor/card/client/CardGameController.java b/src/java/com/threerings/parlor/card/client/CardGameController.java index 0e8e26a44..1dd475d79 100644 --- a/src/java/com/threerings/parlor/card/client/CardGameController.java +++ b/src/java/com/threerings/parlor/card/client/CardGameController.java @@ -1,5 +1,5 @@ // -// $Id: CardGameController.java,v 1.1 2004/10/13 02:03:26 andrzej Exp $ +// $Id: CardGameController.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -44,7 +44,7 @@ public abstract class CardGameController extends GameController CardCodes { // Documentation inhertied - public void init(CrowdContext context, PlaceConfig config) + public void init (CrowdContext context, PlaceConfig config) { super.init(context, config); @@ -52,7 +52,7 @@ public abstract class CardGameController extends GameController } // Documentation inherited - public void messageReceived(MessageEvent event) + public void messageReceived (MessageEvent event) { if(event.getName().equals(TAKE_HAND)) { @@ -65,6 +65,6 @@ public abstract class CardGameController extends GameController * * @param hand the hand dealt to the user */ - protected void handDealt(Hand hand) + protected void handDealt (Hand hand) {} } diff --git a/src/java/com/threerings/parlor/card/client/CardPanel.java b/src/java/com/threerings/parlor/card/client/CardPanel.java index 52d967432..5395d5839 100644 --- a/src/java/com/threerings/parlor/card/client/CardPanel.java +++ b/src/java/com/threerings/parlor/card/client/CardPanel.java @@ -1,5 +1,5 @@ // -// $Id: CardPanel.java,v 1.1 2004/10/13 02:03:26 andrzej Exp $ +// $Id: CardPanel.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -52,18 +52,18 @@ public abstract class CardPanel extends VirtualMediaPanel /** Calls CardSpriteObserver.cardSpriteClicked. */ protected static class CardSpriteClickedOp implements ObserverList.ObserverOp { - protected CardSprite sprite; - protected MouseEvent me; + protected CardSprite _sprite; + protected MouseEvent _me; - public CardSpriteClickedOp(CardSprite sprite, MouseEvent me) + public CardSpriteClickedOp (CardSprite sprite, MouseEvent me) { - this.sprite = sprite; - this.me = me; + _sprite = sprite; + _me = me; } - public boolean apply(Object observer) + public boolean apply (Object observer) { - ((CardSpriteObserver)observer).cardSpriteClicked(sprite, me); + ((CardSpriteObserver)observer).cardSpriteClicked(_sprite, _me); return true; } } @@ -71,18 +71,18 @@ public abstract class CardPanel extends VirtualMediaPanel /** Calls CardSpriteObserver.cardSpriteDragged. */ protected static class CardSpriteDraggedOp implements ObserverList.ObserverOp { - protected CardSprite sprite; - protected MouseEvent me; + protected CardSprite _sprite; + protected MouseEvent _me; - public CardSpriteDraggedOp(CardSprite sprite, MouseEvent me) + public CardSpriteDraggedOp (CardSprite sprite, MouseEvent me) { - this.sprite = sprite; - this.me = me; + _sprite = sprite; + _me = me; } - public boolean apply(Object observer) + public boolean apply (Object observer) { - ((CardSpriteObserver)observer).cardSpriteDragged(sprite, me); + ((CardSpriteObserver)observer).cardSpriteDragged(_sprite, _me); return true; } } @@ -93,14 +93,14 @@ public abstract class CardPanel extends VirtualMediaPanel * * @param frameManager the frame manager */ - public CardPanel(FrameManager frameManager) + public CardPanel (FrameManager frameManager) { super(frameManager); addMouseListener( new MouseAdapter() { - public void mousePressed(MouseEvent me) + public void mousePressed (MouseEvent me) { ArrayList al = new ArrayList(); @@ -128,38 +128,38 @@ public abstract class CardPanel extends VirtualMediaPanel } } - activeCardSprite = highestSprite; + _activeCardSprite = highestSprite; - if(activeCardSprite != null) + if(_activeCardSprite != null) { - handleX = activeCardSprite.getX() - me.getX(); - handleY = activeCardSprite.getY() - me.getY(); + _handleX = _activeCardSprite.getX() - me.getX(); + _handleY = _activeCardSprite.getY() - me.getY(); - hasBeenDragged = false; + _hasBeenDragged = false; } } else { - activeCardSprite = null; + _activeCardSprite = null; } } - public void mouseReleased(MouseEvent me) + public void mouseReleased (MouseEvent me) { - if(activeCardSprite != null && hasBeenDragged) + if(_activeCardSprite != null && _hasBeenDragged) { - activeCardSprite.queueNotification( - new CardSpriteDraggedOp(activeCardSprite, me) + _activeCardSprite.queueNotification( + new CardSpriteDraggedOp(_activeCardSprite, me) ); } } - public void mouseClicked(MouseEvent me) + public void mouseClicked (MouseEvent me) { - if(activeCardSprite != null) + if(_activeCardSprite != null) { - activeCardSprite.queueNotification( - new CardSpriteClickedOp(activeCardSprite, me) + _activeCardSprite.queueNotification( + new CardSpriteClickedOp(_activeCardSprite, me) ); } } @@ -169,17 +169,17 @@ public abstract class CardPanel extends VirtualMediaPanel addMouseMotionListener( new MouseMotionAdapter() { - public void mouseDragged(MouseEvent me) + public void mouseDragged (MouseEvent me) { - if(activeCardSprite != null && - activeCardSprite.isDraggable()) + if(_activeCardSprite != null && + _activeCardSprite.isDraggable()) { - activeCardSprite.setLocation( - me.getX() + handleX, - me.getY() + handleY + _activeCardSprite.setLocation( + me.getX() + _handleX, + me.getY() + _handleY ); - hasBeenDragged = true; + _hasBeenDragged = true; } } } @@ -191,7 +191,7 @@ public abstract class CardPanel extends VirtualMediaPanel * * @return the card back image */ - public abstract Mirage getCardBackImage(); + public abstract Mirage getCardBackImage (); /** * Returns the image for the front of the specified card. @@ -199,15 +199,15 @@ public abstract class CardPanel extends VirtualMediaPanel * @param card the desired card * @return the card front image */ - public abstract Mirage getCardImage(Card card); + public abstract Mirage getCardImage (Card card); /** The last card sprite pressed. */ - private CardSprite activeCardSprite; + protected CardSprite _activeCardSprite; /** The location of the cursor in the active sprite. */ - private int handleX, handleY; + protected int _handleX, _handleY; /** Whether or not the active sprite has been dragged. */ - private boolean hasBeenDragged; + protected boolean _hasBeenDragged; } diff --git a/src/java/com/threerings/parlor/card/client/CardSprite.java b/src/java/com/threerings/parlor/card/client/CardSprite.java index 9a14475a9..a7d1b0ce0 100644 --- a/src/java/com/threerings/parlor/card/client/CardSprite.java +++ b/src/java/com/threerings/parlor/card/client/CardSprite.java @@ -1,5 +1,5 @@ // -// $Id: CardSprite.java,v 1.1 2004/10/13 02:03:26 andrzej Exp $ +// $Id: CardSprite.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -32,26 +32,13 @@ import com.threerings.parlor.card.data.Card; */ public class CardSprite extends OrientableImageSprite { - /** The panel responsible for the sprite. */ - protected CardPanel _panel; - - /** The depicted card. */ - protected Card _card; - - /** Whether or not the card is facing up. */ - protected boolean _facingUp; - - /** Whether or not the user can drag the card around the board. */ - protected boolean _draggable; - - /** * Creates a new upward-facing card sprite. * * @param panel the panel responsible for the sprite * @param card the card to depict */ - public CardSprite(CardPanel panel, Card card) + public CardSprite (CardPanel panel, Card card) { _panel = panel; _card = card; @@ -67,7 +54,7 @@ public class CardSprite extends OrientableImageSprite * @param card the card to depict * @param facingUp whether or not the card should be facing up */ - public CardSprite(CardPanel panel, Card card, boolean facingUp) + public CardSprite (CardPanel panel, Card card, boolean facingUp) { _panel = panel; _card = card; @@ -81,7 +68,7 @@ public class CardSprite extends OrientableImageSprite * * @param card the new card */ - public void setCard(Card card) + public void setCard (Card card) { _card = card; @@ -93,7 +80,7 @@ public class CardSprite extends OrientableImageSprite * * @return the current card */ - public Card getCard() + public Card getCard () { return _card; } @@ -103,7 +90,7 @@ public class CardSprite extends OrientableImageSprite * * @param facingUp whether or not the card should be facing up */ - public void setFacingUp(boolean facingUp) + public void setFacingUp (boolean facingUp) { _facingUp = facingUp; @@ -115,7 +102,7 @@ public class CardSprite extends OrientableImageSprite * * @return true if the card is facing up, false if facing down */ - public boolean isFacingUp() + public boolean isFacingUp () { return _facingUp; } @@ -125,7 +112,7 @@ public class CardSprite extends OrientableImageSprite * * @param draggable whether or not the user can drag the card */ - public void setDraggable(boolean draggable) + public void setDraggable (boolean draggable) { _draggable = draggable; } @@ -135,7 +122,7 @@ public class CardSprite extends OrientableImageSprite * * @return true if the user can drag the card, false if not */ - public boolean isDraggable() + public boolean isDraggable () { return _draggable; } @@ -143,8 +130,21 @@ public class CardSprite extends OrientableImageSprite /** * Updates the mirage according to the current state. */ - private void updateMirage() + private void updateMirage () { setMirage(_facingUp ? _panel.getCardImage(_card) : _panel.getCardBackImage()); } + + + /** The panel responsible for the sprite. */ + protected CardPanel _panel; + + /** The depicted card. */ + protected Card _card; + + /** Whether or not the card is facing up. */ + protected boolean _facingUp; + + /** Whether or not the user can drag the card around the board. */ + protected boolean _draggable; } diff --git a/src/java/com/threerings/parlor/card/client/CardSpriteObserver.java b/src/java/com/threerings/parlor/card/client/CardSpriteObserver.java index 96c113346..490680dcf 100644 --- a/src/java/com/threerings/parlor/card/client/CardSpriteObserver.java +++ b/src/java/com/threerings/parlor/card/client/CardSpriteObserver.java @@ -1,5 +1,5 @@ // -// $Id: CardSpriteObserver.java,v 1.1 2004/10/13 02:03:26 andrzej Exp $ +// $Id: CardSpriteObserver.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -21,7 +21,7 @@ package com.threerings.parlor.card.client; -import java.awt.event.*; +import java.awt.event.MouseEvent; /** * Observer interface for (draggable) card sprites. @@ -34,7 +34,7 @@ public interface CardSpriteObserver * @param sprite the dragged sprite * @param me the mouse event associated with the drag */ - public void cardSpriteClicked(CardSprite sprite, MouseEvent me); + public void cardSpriteClicked (CardSprite sprite, MouseEvent me); /** * Notifies the observer that the user dragged a card sprite to a new @@ -43,5 +43,5 @@ public interface CardSpriteObserver * @param sprite the dragged sprite * @param me the mouse event associated with the drag */ - public void cardSpriteDragged(CardSprite sprite, MouseEvent me); + public void cardSpriteDragged (CardSprite sprite, MouseEvent me); } diff --git a/src/java/com/threerings/parlor/card/data/Card.java b/src/java/com/threerings/parlor/card/data/Card.java index 9c762b72d..92c324379 100644 --- a/src/java/com/threerings/parlor/card/data/Card.java +++ b/src/java/com/threerings/parlor/card/data/Card.java @@ -1,5 +1,5 @@ // -// $Id: Card.java,v 1.2 2004/10/13 19:29:12 andrzej Exp $ +// $Id: Card.java,v 1.3 2004/10/15 00:14:23 andrzej Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -38,7 +38,7 @@ public class Card implements CardCodes, /** * No-arg constructor for deserialization. */ - public Card() + public Card () {} /** @@ -47,9 +47,9 @@ public class Card implements CardCodes, * * @return the value of the card */ - public int getNumber() + public int getNumber () { - return number; + return (_value >> 2); } /** @@ -58,9 +58,9 @@ public class Card implements CardCodes, * * @return the suit of the card */ - public int getSuit() + public int getSuit () { - return suit; + return (_value & 0x03); } /** @@ -68,8 +68,10 @@ public class Card implements CardCodes, * * @return true if the card is a number card, false otherwise */ - public boolean isNumber() + public boolean isNumber () { + int number = getNumber(); + return number >= 2 && number <= 10; } @@ -78,8 +80,10 @@ public class Card implements CardCodes, * * @return true if the card is a face card, false otherwise */ - public boolean isFace() + public boolean isFace () { + int number = getNumber(); + return number == KING || number == QUEEN || number == JACK; } @@ -88,9 +92,9 @@ public class Card implements CardCodes, * * @return true if the card is an ace, false otherwise */ - public boolean isAce() + public boolean isAce () { - return number == ACE; + return getNumber() == ACE; } /** @@ -98,9 +102,9 @@ public class Card implements CardCodes, * * @return true if the card is a joker, false otherwise */ - public boolean isJoker() + public boolean isJoker () { - return number == JOKER; + return getNumber() == JOKER; } /** @@ -109,48 +113,24 @@ public class Card implements CardCodes, * * @return true if this card is valid, false if not */ - public boolean isValid() + public boolean isValid () { + int number = getNumber(), suit = getSuit(); + return number == JOKER || (number >= 2 && number <= ACE && suit >= HEARTS && suit <= SPADES); } - /** - * Writes this object to the specified output stream. - * - * @param oos the output stream - */ - public void writeObject(ObjectOutputStream oos) - throws IOException + // Documentation inherited. + public Comparable getKey () { - oos.defaultWriteObject(); + if(_key == null) + { + _key = new Byte(_value); + } - oos.writeInt(number); - oos.writeInt(suit); - } - - /** - * Reads this object from the specified input stream. - * - * @param ois the input stream - */ - public void readObject(ObjectInputStream ois) - throws IOException, - ClassNotFoundException - { - ois.defaultReadObject(); - - number = ois.readInt(); - suit = ois.readInt(); - - key = new Integer((number << 2) | suit); - } - - // documentation inherited - public Comparable getKey() - { - return key; + return _key; } /** @@ -158,9 +138,9 @@ public class Card implements CardCodes, * * @return this card's hash code */ - public int hashCode() + public int hashCode () { - return key.intValue(); + return _value; } /** @@ -169,12 +149,11 @@ public class Card implements CardCodes, * @param other the other card to compare * @return true if the cards are equal, false otherwise */ - public boolean equals(Object other) + public boolean equals (Object other) { if(other instanceof Card) { - return number == ((Card)other).number && - suit == ((Card)other).suit; + return _value == ((Card)other)._value; } else { @@ -182,66 +161,50 @@ public class Card implements CardCodes, } } - /** - * Returns a string representation of a given number. - * - * @param number the number to represent - * @return the string representation - */ - public static String numberToString(int number) - { - switch(number) - { - case 2: return "Two"; - case 3: return "Three"; - case 4: return "Four"; - case 5: return "Five"; - case 6: return "Six"; - case 7: return "Seven"; - case 8: return "Eight"; - case 9: return "Nine"; - case 10: return "Ten"; - case JACK: return "Jack"; - case QUEEN: return "Queen"; - case KING: return "King"; - case ACE: return "Ace"; - case JOKER: return "Joker"; - default: return "???"; - } - } - - /** - * Returns a string representation of a particular suit. - * - * @param suit the suit to represent - * @return the string representation - */ - public static String suitToString(int suit) - { - switch(suit) - { - case HEARTS: return "Hearts"; - case DIAMONDS: return "Diamonds"; - case CLUBS: return "Clubs"; - case SPADES: return "Spades"; - default: return "???"; - } - } - /** * Returns a string representation of this card. * * @return a description of this card */ - public String toString() + public String toString () { + int number = getNumber(); + if(number == JOKER) { - return "Joker"; + return "Jk"; } else { - return numberToString(number) + " of " + suitToString(suit); + StringBuffer sb = new StringBuffer(); + + if(number >= 2 && number <= 9) + { + sb.append(Integer.toString(number)); + } + else + { + switch(number) + { + case 10: sb.append('T'); break; + case JACK: sb.append('J'); break; + case QUEEN: sb.append('Q'); break; + case KING: sb.append('K'); break; + case ACE: sb.append('A'); break; + default: sb.append('?'); break; + } + } + + switch(getSuit()) + { + case HEARTS: sb.append('h'); break; + case DIAMONDS: sb.append('d'); break; + case CLUBS: sb.append('c'); break; + case SPADES: sb.append('s'); break; + default: sb.append('?'); break; + } + + return sb.toString(); } } @@ -251,21 +214,15 @@ public class Card implements CardCodes, * @param number the number of the card * @param suit the suit of the card */ - Card(int number, int suit) + Card (int number, int suit) { - this.number = number; - this.suit = suit; - - key = new Integer((number << 2) | suit); + _value = (byte)((number << 2) | suit); } /** The number of the card. */ - private int number; - - /** The suit of the card. */ - private int suit; + protected byte _value; /** The comparison key. */ - private Integer key; + protected transient Byte _key; } diff --git a/src/java/com/threerings/parlor/card/data/Deck.java b/src/java/com/threerings/parlor/card/data/Deck.java index ced89fa1e..4f9ee0dc2 100644 --- a/src/java/com/threerings/parlor/card/data/Deck.java +++ b/src/java/com/threerings/parlor/card/data/Deck.java @@ -1,5 +1,5 @@ // -// $Id: Deck.java,v 1.1 2004/10/13 02:03:26 andrzej Exp $ +// $Id: Deck.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -41,7 +41,7 @@ public class Deck implements CardCodes, * Default constructor creates an unshuffled deck of cards without * jokers. */ - public Deck() + public Deck () { cards = new StreamableArrayList(); @@ -54,7 +54,7 @@ public class Deck implements CardCodes, * @param includeJokers whether or not to include the two jokers * in the deck */ - public Deck(boolean includeJokers) + public Deck (boolean includeJokers) { cards = new StreamableArrayList(); @@ -68,7 +68,7 @@ public class Deck implements CardCodes, * @param includeJokers whether or not to include the two jokers * in the deck */ - public void reset(boolean includeJokers) + public void reset (boolean includeJokers) { cards.clear(); @@ -90,7 +90,7 @@ public class Deck implements CardCodes, /** * Shuffles the deck. */ - public void shuffle() + public void shuffle () { Collections.shuffle(cards); } @@ -102,7 +102,7 @@ public class Deck implements CardCodes, * @return the newly created and populated hand, or null * if there are not enough cards in the deck to deal the hand */ - public Hand dealHand(int size) + public Hand dealHand (int size) { if(cards.size() < size) { @@ -127,7 +127,7 @@ public class Deck implements CardCodes, * * @param hand the hand of cards to return */ - public void returnHand(Hand hand) + public void returnHand (Hand hand) { cards.addAll(hand.cards); hand.cards.clear(); @@ -138,7 +138,7 @@ public class Deck implements CardCodes, * * @return a description of this deck */ - public String toString() + public String toString () { return "[cards=" + cards.toString() + "]"; } diff --git a/src/java/com/threerings/parlor/card/data/Hand.java b/src/java/com/threerings/parlor/card/data/Hand.java index b943e9cbc..b6fe5e8e6 100644 --- a/src/java/com/threerings/parlor/card/data/Hand.java +++ b/src/java/com/threerings/parlor/card/data/Hand.java @@ -1,5 +1,5 @@ // -// $Id: Hand.java,v 1.1 2004/10/13 02:03:26 andrzej Exp $ +// $Id: Hand.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -21,7 +21,7 @@ package com.threerings.parlor.card.data; -import java.util.*; +import java.util.Iterator; import com.threerings.io.Streamable; @@ -40,7 +40,7 @@ public class Hand implements CardCodes, /** * Default constructor creates an empty hand. */ - public Hand() + public Hand () { cards = new StreamableArrayList(); } @@ -51,7 +51,7 @@ public class Hand implements CardCodes, * @param suit the suit of interest * @return the number of cards in the specified suit */ - public int getSuitMemberCount(int suit) + public int getSuitMemberCount (int suit) { int members = 0; @@ -73,7 +73,7 @@ public class Hand implements CardCodes, * * @return a description of this hand */ - public String toString() + public String toString () { return "[cards=" + cards.toString() + "]"; } diff --git a/src/java/com/threerings/parlor/card/server/CardGameManager.java b/src/java/com/threerings/parlor/card/server/CardGameManager.java index 3caccf9d6..a7148a9d7 100644 --- a/src/java/com/threerings/parlor/card/server/CardGameManager.java +++ b/src/java/com/threerings/parlor/card/server/CardGameManager.java @@ -1,5 +1,5 @@ // -// $Id: CardGameManager.java,v 1.2 2004/10/13 19:29:12 andrzej Exp $ +// $Id: CardGameManager.java,v 1.3 2004/10/15 00:14:23 andrzej Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -48,7 +48,7 @@ public class CardGameManager extends GameManager * @return the hand dealt to the player, or null if the deal * was canceled because the deck did not contain enough cards */ - public Hand dealHand(Deck deck, int size, int playerIndex) + public Hand dealHand (Deck deck, int size, int playerIndex) { if(deck.cards.size() < size) { @@ -80,7 +80,7 @@ public class CardGameManager extends GameManager * the deal was canceled because the deck did not contain enough * cards */ - public Hand[] dealHands(Deck deck, int size) + public Hand[] dealHands (Deck deck, int size) { if(deck.cards.size() < size * _playerCount) { diff --git a/src/java/com/threerings/parlor/card/trick/TrickCardGameController.java b/src/java/com/threerings/parlor/card/trick/TrickCardGameController.java index 1baaa6dff..0ec3d432d 100644 --- a/src/java/com/threerings/parlor/card/trick/TrickCardGameController.java +++ b/src/java/com/threerings/parlor/card/trick/TrickCardGameController.java @@ -1,5 +1,5 @@ // -// $Id: TrickCardGameController.java,v 1.1 2004/10/13 02:03:26 andrzej Exp $ +// $Id: TrickCardGameController.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -35,7 +35,7 @@ public interface TrickCardGameController extends TurnGameController * @param playingHand true if the gameplay entered a hand, false if * it left one */ - public void playingHandDidChange(boolean playingHand); + public void playingHandDidChange (boolean playingHand); /** * Notifies the controller that the gameplay entered or left a trick. @@ -43,5 +43,5 @@ public interface TrickCardGameController extends TurnGameController * @param playingTrick true if the gameplay entered a trick, false if * it left one */ - public void playingTrickDidChange(boolean playingTrick); + public void playingTrickDidChange (boolean playingTrick); } diff --git a/src/java/com/threerings/parlor/card/trick/TrickCardGameControllerDelegate.java b/src/java/com/threerings/parlor/card/trick/TrickCardGameControllerDelegate.java index 40ec6bede..e1c5cfc6d 100644 --- a/src/java/com/threerings/parlor/card/trick/TrickCardGameControllerDelegate.java +++ b/src/java/com/threerings/parlor/card/trick/TrickCardGameControllerDelegate.java @@ -1,5 +1,5 @@ // -// $Id: TrickCardGameControllerDelegate.java,v 1.1 2004/10/13 02:03:26 andrzej Exp $ +// $Id: TrickCardGameControllerDelegate.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -31,16 +31,12 @@ import com.threerings.presents.dobj.AttributeChangedEvent; */ public class TrickCardGameControllerDelegate extends TurnGameControllerDelegate { - /** The trick card game controller. */ - protected TrickCardGameController _tcgctrl; - - /** * Constructor. * * @param controller the game controller */ - public TrickCardGameControllerDelegate(TrickCardGameController controller) + public TrickCardGameControllerDelegate (TrickCardGameController controller) { super(controller); @@ -48,7 +44,7 @@ public class TrickCardGameControllerDelegate extends TurnGameControllerDelegate } // Documentation inherited - public void attributeChanged(AttributeChangedEvent ace) + public void attributeChanged (AttributeChangedEvent ace) { super.attributeChanged(ace); @@ -63,4 +59,8 @@ public class TrickCardGameControllerDelegate extends TurnGameControllerDelegate _tcgctrl.playingTrickDidChange(tcgObj.getPlayingTrick()); } } + + + /** The trick card game controller. */ + protected TrickCardGameController _tcgctrl; } diff --git a/src/java/com/threerings/parlor/card/trick/TrickCardGameManager.java b/src/java/com/threerings/parlor/card/trick/TrickCardGameManager.java index ad764204f..e464344e3 100644 --- a/src/java/com/threerings/parlor/card/trick/TrickCardGameManager.java +++ b/src/java/com/threerings/parlor/card/trick/TrickCardGameManager.java @@ -1,5 +1,5 @@ // -// $Id: TrickCardGameManager.java,v 1.1 2004/10/13 02:03:26 andrzej Exp $ +// $Id: TrickCardGameManager.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -32,30 +32,30 @@ public interface TrickCardGameManager extends TurnGameManager /** * Notifies the manager that a hand is about to start. */ - public void handWillStart(); + public void handWillStart (); /** * Notifies the manager that a hand just started. */ - public void handDidStart(); + public void handDidStart (); /** * Notifies the manager that a hand has ended. */ - public void handDidEnd(); + public void handDidEnd (); /** * Notifies the manager that a trick is about to start. */ - public void trickWillStart(); + public void trickWillStart (); /** * Notifies the manager that a trick just started. */ - public void trickDidStart(); + public void trickDidStart (); /** * Notifies the manager that a trick has ended. */ - public void trickDidEnd(); + public void trickDidEnd (); } diff --git a/src/java/com/threerings/parlor/card/trick/TrickCardGameManagerDelegate.java b/src/java/com/threerings/parlor/card/trick/TrickCardGameManagerDelegate.java index e07cc87ac..b3e34b9b3 100644 --- a/src/java/com/threerings/parlor/card/trick/TrickCardGameManagerDelegate.java +++ b/src/java/com/threerings/parlor/card/trick/TrickCardGameManagerDelegate.java @@ -1,5 +1,5 @@ // -// $Id: TrickCardGameManagerDelegate.java,v 1.1 2004/10/13 02:03:26 andrzej Exp $ +// $Id: TrickCardGameManagerDelegate.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -32,20 +32,13 @@ import com.threerings.parlor.turn.TurnGameManagerDelegate; * Spades and Hearts. */ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate -{ - /** The trick card game manager. */ - protected TrickCardGameManager _tcgmgr; - - /** The game object. */ - protected TrickCardGameObject _trickCardGame; - - +{ /** * Constructor. * * @param manager the game manager */ - public TrickCardGameManagerDelegate(TrickCardGameManager manager) + public TrickCardGameManagerDelegate (TrickCardGameManager manager) { super(manager); @@ -53,7 +46,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate } // Documentation inherited. - public void setFirstTurnHolder() + public void setFirstTurnHolder () { if(_trickCardGame.getPlayingHand() && _trickCardGame.getPlayingTrick()) { @@ -66,7 +59,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate } // Documentation inherited. - public void setNextTurnHolder() + public void setNextTurnHolder () { if(_trickCardGame.getPlayingHand() && _trickCardGame.getPlayingTrick()) { @@ -79,7 +72,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate } // Documentation inherited. - public void didStartup(PlaceObject plobj) + public void didStartup (PlaceObject plobj) { super.didStartup(plobj); @@ -89,7 +82,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate /** * Starts a hand of cards. */ - public void startHand() + public void startHand () { _tcgmgr.handWillStart(); @@ -101,7 +94,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate /** * Ends a hand of cards. */ - public void endHand() + public void endHand () { _trickCardGame.setPlayingHand(false); @@ -111,7 +104,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate /** * Starts a trick. */ - public void startTrick() + public void startTrick () { _tcgmgr.trickWillStart(); @@ -123,10 +116,17 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate /** * Ends a trick. */ - public void endTrick() + public void endTrick () { _trickCardGame.setPlayingTrick(false); _tcgmgr.trickDidEnd(); } + + + /** The trick card game manager. */ + protected TrickCardGameManager _tcgmgr; + + /** The game object. */ + protected TrickCardGameObject _trickCardGame; } diff --git a/src/java/com/threerings/parlor/card/trick/TrickCardGameObject.java b/src/java/com/threerings/parlor/card/trick/TrickCardGameObject.java index 8679af63d..3618a62c0 100644 --- a/src/java/com/threerings/parlor/card/trick/TrickCardGameObject.java +++ b/src/java/com/threerings/parlor/card/trick/TrickCardGameObject.java @@ -1,5 +1,5 @@ // -// $Id: TrickCardGameObject.java,v 1.1 2004/10/13 02:03:26 andrzej Exp $ +// $Id: TrickCardGameObject.java,v 1.2 2004/10/15 00:14:23 andrzej Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -34,21 +34,21 @@ public interface TrickCardGameObject extends TurnGameObject * * @return the name of the playingHand field */ - public String getPlayingHandFieldName(); + public String getPlayingHandFieldName (); /** * Checks whether the users are currently playing a hand. * * @return true if the users are playing a hand, false otherwise */ - public boolean getPlayingHand(); + public boolean getPlayingHand (); /** * Brings the gameplay in or out of a hand. * * @param playingHand true to enter a hand, false to leave one */ - public void setPlayingHand(boolean playingHand); + public void setPlayingHand (boolean playingHand); /** * Returns the name of the field that signals whether or not the users @@ -56,19 +56,19 @@ public interface TrickCardGameObject extends TurnGameObject * * @return the name of the playingTrick field */ - public String getPlayingTrickFieldName(); + public String getPlayingTrickFieldName (); /** * Checks whether the users are currently playing a trick. * * @return true if the users are playing a trick, false otherwise */ - public boolean getPlayingTrick(); + public boolean getPlayingTrick (); /** * Brings the gameplay in or out of a trick. * * @param playingTrick true to enter a trick, false to leave one */ - public void setPlayingTrick(boolean playingTrick); + public void setPlayingTrick (boolean playingTrick); }