Check the size of the hand to make sure the request isn't for an earlier trick.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3545 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Andrzej Kapolka
2005-05-07 01:17:49 +00:00
parent 0f4fe33c75
commit 77a9438c69
5 changed files with 17 additions and 8 deletions
@@ -27,8 +27,10 @@ public interface TrickCardGameService extends InvocationService
* *
* @param client the client object * @param client the client object
* @param card the card to play * @param card the card to play
* @param handSize the size of the player's hand, which is used to verify
* that the request is for the current trick
*/ */
public void playCard (Client client, Card card); public void playCard (Client client, Card card, int handSize);
/** /**
* A request for a rematch. * A request for a rematch.
@@ -41,10 +41,10 @@ public class TrickCardGameMarshaller extends InvocationMarshaller
public static final int PLAY_CARD = 1; public static final int PLAY_CARD = 1;
// documentation inherited from interface // documentation inherited from interface
public void playCard (Client arg1, Card arg2) public void playCard (Client arg1, Card arg2, int arg3)
{ {
sendRequest(arg1, PLAY_CARD, new Object[] { sendRequest(arg1, PLAY_CARD, new Object[] {
arg2 arg2, new Integer(arg3)
}); });
} }
@@ -59,7 +59,7 @@ public class TrickCardGameDispatcher extends InvocationDispatcher
case TrickCardGameMarshaller.PLAY_CARD: case TrickCardGameMarshaller.PLAY_CARD:
((TrickCardGameProvider)provider).playCard( ((TrickCardGameProvider)provider).playCard(
source, source,
(Card)args[0] (Card)args[0], ((Integer)args[1]).intValue()
); );
return; return;
@@ -259,7 +259,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
} }
// Documentation inherited. // Documentation inherited.
public void playCard (ClientObject client, Card card) public void playCard (ClientObject client, Card card, int handSize)
{ {
// make sure we're playing a trick // make sure we're playing a trick
if (_trickCardGame.getTrickState() != if (_trickCardGame.getTrickState() !=
@@ -273,8 +273,13 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
return; return;
} }
// make sure their hand contains the specified card // make sure they're on the right trick
int pidx = _cardGame.getPlayerIndex(username); int pidx = _cardGame.getPlayerIndex(username);
if (_hands[pidx].size() != handSize) {
return;
}
// make sure their hand contains the specified card
if (!_hands[pidx].contains(card)) { if (!_hands[pidx].contains(card)) {
Log.warning("Tried to play card not held [username=" + username + Log.warning("Tried to play card not held [username=" + username +
", card=" + card + "]."); ", card=" + card + "].");
@@ -29,9 +29,11 @@ public interface TrickCardGameProvider extends InvocationProvider
* *
* @param client the client object * @param client the client object
* @param card the card to play * @param card the card to play
* @param handSize the size of the player's hand, which is used to verify
* that the request is for the current trick
*/ */
public void playCard (ClientObject client, Card card); public void playCard (ClientObject client, Card card, int handSize);
/** /**
* Processes a request for a rematch. * Processes a request for a rematch.
* *