Send the oid of the applicable game with the Hand.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3828 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-02-03 19:09:49 +00:00
parent 39565a6d92
commit 2f611366d9
5 changed files with 20 additions and 9 deletions
@@ -59,6 +59,16 @@ public abstract class CardGameController extends GameController
// Documentation inherited. // Documentation inherited.
public void turnDidChange (Name turnHolder) public void turnDidChange (Name turnHolder)
{} {}
/**
* Called by our sender to notify us of a received hand.
*/
public final void receivedHand (int oid, Hand hand)
{
if (oid == _gobj.getOid()) {
receivedHand(hand);
}
}
/** /**
* Called when the server deals the client a new hand of cards. Default * Called when the server deals the client a new hand of cards. Default
@@ -53,7 +53,7 @@ public class CardGameDecoder extends InvocationDecoder
switch (methodId) { switch (methodId) {
case RECEIVED_HAND: case RECEIVED_HAND:
((CardGameReceiver)receiver).receivedHand( ((CardGameReceiver)receiver).receivedHand(
(Hand)args[0] ((Integer)args[0]).intValue(), (Hand)args[1]
); );
return; return;
@@ -35,9 +35,10 @@ public interface CardGameReceiver extends InvocationReceiver
/** /**
* Dispatched to the client when it has received a hand of cards. * Dispatched to the client when it has received a hand of cards.
* *
* @param oid the oid of the game for which this hand applies
* @param hand the received hand * @param hand the received hand
*/ */
public void receivedHand (Hand hand); public void receivedHand (int oid, Hand hand);
/** /**
* Dispatched to the client when it has received a set of cards * Dispatched to the client when it has received a set of cards
@@ -108,9 +108,9 @@ public class CardGameManager extends GameManager
} else { } else {
Hand hand = deck.dealHand(size); Hand hand = deck.dealHand(size);
if (!isAI(playerIndex)) { if (!isAI(playerIndex)) {
CardGameSender.sendHand( ClientObject clobj = (ClientObject)
(ClientObject)PresentsServer.omgr.getObject( PresentsServer.omgr.getObject(_playerOids[playerIndex]);
_playerOids[playerIndex]), hand); CardGameSender.sendHand(clobj, _cardgameobj.getOid(), hand);
} }
return hand; return hand;
} }
@@ -130,8 +130,8 @@ public class CardGameManager extends GameManager
{ {
if (deck.size() < size * _playerCount) { if (deck.size() < size * _playerCount) {
return null; return null;
}
else { } else {
Hand[] hands = new Hand[_playerCount]; Hand[] hands = new Hand[_playerCount];
for (int i=0;i<_playerCount;i++) { for (int i=0;i<_playerCount;i++) {
@@ -21,11 +21,11 @@ public class CardGameSender extends InvocationSender
* CardGameReceiver#receivedHand} on a client. * CardGameReceiver#receivedHand} on a client.
*/ */
public static void sendHand ( public static void sendHand (
ClientObject target, Hand arg1) ClientObject target, int arg1, Hand arg2)
{ {
sendNotification( sendNotification(
target, CardGameDecoder.RECEIVER_CODE, CardGameDecoder.RECEIVED_HAND, target, CardGameDecoder.RECEIVER_CODE, CardGameDecoder.RECEIVED_HAND,
new Object[] { arg1 }); new Object[] { new Integer(arg1), arg2 });
} }
/** /**