Messages to receiver/service.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3228 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -23,6 +23,7 @@ package com.threerings.parlor.card.client;
|
||||
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
|
||||
import com.threerings.parlor.card.data.Card;
|
||||
import com.threerings.parlor.card.data.CardCodes;
|
||||
import com.threerings.parlor.card.data.Hand;
|
||||
|
||||
@@ -33,7 +34,7 @@ import com.threerings.parlor.game.GameController;
|
||||
* accepting dealt hands.
|
||||
*/
|
||||
public abstract class CardGameController extends GameController
|
||||
implements CardCodes, CardReceiver
|
||||
implements CardCodes, CardGameReceiver
|
||||
{
|
||||
// Documentation inherited.
|
||||
public void willEnterPlace (PlaceObject plobj)
|
||||
@@ -41,7 +42,7 @@ public abstract class CardGameController extends GameController
|
||||
super.willEnterPlace(plobj);
|
||||
|
||||
_ctx.getClient().getInvocationDirector().registerReceiver(
|
||||
new CardDecoder(this));
|
||||
new CardGameDecoder(this));
|
||||
}
|
||||
|
||||
// Documentation inherited.
|
||||
@@ -50,7 +51,7 @@ public abstract class CardGameController extends GameController
|
||||
super.didLeavePlace(plobj);
|
||||
|
||||
_ctx.getClient().getInvocationDirector().unregisterReceiver(
|
||||
CardDecoder.RECEIVER_CODE);
|
||||
CardGameDecoder.RECEIVER_CODE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,4 +62,14 @@ public abstract class CardGameController extends GameController
|
||||
*/
|
||||
public void receivedHand (Hand hand)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Dispatched to the client when it has received a set of cards
|
||||
* from another player. Default implementation does nothing.
|
||||
*
|
||||
* @param plidx the index of the player providing the cards
|
||||
* @param cards the cards received
|
||||
*/
|
||||
public void receivedCardsFromPlayer (int plidx, Card[] cards)
|
||||
{}
|
||||
}
|
||||
|
||||
+18
-7
@@ -3,27 +3,32 @@
|
||||
|
||||
package com.threerings.parlor.card.client;
|
||||
|
||||
import com.threerings.parlor.card.client.CardReceiver;
|
||||
import com.threerings.parlor.card.client.CardGameReceiver;
|
||||
import com.threerings.parlor.card.data.Card;
|
||||
import com.threerings.parlor.card.data.Hand;
|
||||
import com.threerings.presents.client.InvocationDecoder;
|
||||
|
||||
/**
|
||||
* Dispatches calls to a {@link CardReceiver} instance.
|
||||
* Dispatches calls to a {@link CardGameReceiver} instance.
|
||||
*/
|
||||
public class CardDecoder extends InvocationDecoder
|
||||
public class CardGameDecoder extends InvocationDecoder
|
||||
{
|
||||
/** The generated hash code used to identify this receiver class. */
|
||||
public static final String RECEIVER_CODE = "bfa3311cedc30969d04d8b6259d6ffe0";
|
||||
public static final String RECEIVER_CODE = "0718199d459e31d8d673744c71b0e788";
|
||||
|
||||
/** The method id used to dispatch {@link CardReceiver#receivedHand}
|
||||
/** The method id used to dispatch {@link CardGameReceiver#receivedHand}
|
||||
* notifications. */
|
||||
public static final int RECEIVED_HAND = 1;
|
||||
|
||||
/** The method id used to dispatch {@link CardGameReceiver#receivedCardsFromPlayer}
|
||||
* notifications. */
|
||||
public static final int RECEIVED_CARDS_FROM_PLAYER = 2;
|
||||
|
||||
/**
|
||||
* Creates a decoder that may be registered to dispatch invocation
|
||||
* service notifications to the specified receiver.
|
||||
*/
|
||||
public CardDecoder (CardReceiver receiver)
|
||||
public CardGameDecoder (CardGameReceiver receiver)
|
||||
{
|
||||
this.receiver = receiver;
|
||||
}
|
||||
@@ -39,11 +44,17 @@ public class CardDecoder extends InvocationDecoder
|
||||
{
|
||||
switch (methodId) {
|
||||
case RECEIVED_HAND:
|
||||
((CardReceiver)receiver).receivedHand(
|
||||
((CardGameReceiver)receiver).receivedHand(
|
||||
(Hand)args[0]
|
||||
);
|
||||
return;
|
||||
|
||||
case RECEIVED_CARDS_FROM_PLAYER:
|
||||
((CardGameReceiver)receiver).receivedCardsFromPlayer(
|
||||
((Integer)args[0]).intValue(), (Card[])args[1]
|
||||
);
|
||||
return;
|
||||
|
||||
default:
|
||||
super.dispatchNotification(methodId, args);
|
||||
}
|
||||
+13
-4
@@ -21,16 +21,16 @@
|
||||
|
||||
package com.threerings.parlor.card.client;
|
||||
|
||||
import com.threerings.parlor.card.data.Card;
|
||||
import com.threerings.parlor.card.data.Hand;
|
||||
|
||||
import com.threerings.presents.client.InvocationReceiver;
|
||||
|
||||
/**
|
||||
* Defines, for the parlor services, a set of notifications delivered
|
||||
* asynchronously by the server to the client. These are handled by the
|
||||
* {@link ParlorDirector}.
|
||||
* Defines, for the card game services, a set of notifications delivered
|
||||
* asynchronously by the server to the client.
|
||||
*/
|
||||
public interface CardReceiver extends InvocationReceiver
|
||||
public interface CardGameReceiver extends InvocationReceiver
|
||||
{
|
||||
/**
|
||||
* Dispatched to the client when it has received a hand of cards.
|
||||
@@ -38,4 +38,13 @@ public interface CardReceiver extends InvocationReceiver
|
||||
* @param hand the received hand
|
||||
*/
|
||||
public void receivedHand (Hand hand);
|
||||
|
||||
/**
|
||||
* Dispatched to the client when it has received a set of cards
|
||||
* from another player.
|
||||
*
|
||||
* @param plidx the index of the player providing the cards
|
||||
* @param cards the cards received
|
||||
*/
|
||||
public void receivedCardsFromPlayer (int plidx, Card[] cards);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// $Id: RoisterService.java 17829 2004-11-12 20:24:43Z mdb $
|
||||
|
||||
package com.threerings.parlor.card.client;
|
||||
|
||||
import com.threerings.parlor.card.data.Card;
|
||||
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.InvocationService;
|
||||
|
||||
/**
|
||||
* Service calls related to card games.
|
||||
*/
|
||||
public interface CardGameService extends InvocationService
|
||||
{
|
||||
/**
|
||||
* Sends a set of cards to another player.
|
||||
*
|
||||
* @param client the client object
|
||||
* @param playerIndex the index of the player to receive the cards
|
||||
* @param cards the cards to send
|
||||
* @param cl a listener to notify on success/failure
|
||||
*/
|
||||
public void sendCardsToPlayer (Client client, int playerIndex, Card[] cards,
|
||||
ConfirmListener cl);
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public class CardSprite extends OrientableImageSprite
|
||||
/**
|
||||
* Updates the mirage according to the current state.
|
||||
*/
|
||||
private void updateMirage ()
|
||||
protected void updateMirage ()
|
||||
{
|
||||
setMirage(_facingUp ? _panel.getCardImage(_card) :
|
||||
_panel.getCardBackImage());
|
||||
|
||||
Reference in New Issue
Block a user