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:
@@ -27,8 +27,10 @@ public interface TrickCardGameService extends InvocationService
|
||||
*
|
||||
* @param client the client object
|
||||
* @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.
|
||||
|
||||
@@ -41,10 +41,10 @@ public class TrickCardGameMarshaller extends InvocationMarshaller
|
||||
public static final int PLAY_CARD = 1;
|
||||
|
||||
// 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[] {
|
||||
arg2
|
||||
arg2, new Integer(arg3)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class TrickCardGameDispatcher extends InvocationDispatcher
|
||||
case TrickCardGameMarshaller.PLAY_CARD:
|
||||
((TrickCardGameProvider)provider).playCard(
|
||||
source,
|
||||
(Card)args[0]
|
||||
(Card)args[0], ((Integer)args[1]).intValue()
|
||||
);
|
||||
return;
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
|
||||
}
|
||||
|
||||
// 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
|
||||
if (_trickCardGame.getTrickState() !=
|
||||
@@ -273,8 +273,13 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure their hand contains the specified card
|
||||
// make sure they're on the right trick
|
||||
int pidx = _cardGame.getPlayerIndex(username);
|
||||
if (_hands[pidx].size() != handSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure their hand contains the specified card
|
||||
if (!_hands[pidx].contains(card)) {
|
||||
Log.warning("Tried to play card not held [username=" + username +
|
||||
", card=" + card + "].");
|
||||
|
||||
@@ -29,9 +29,11 @@ public interface TrickCardGameProvider extends InvocationProvider
|
||||
*
|
||||
* @param client the client object
|
||||
* @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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user