Fix not loading black card when joining a game as a spectator.

This commit is contained in:
Andy Janata 2013-11-29 03:18:49 +00:00
parent f890244df0
commit e6b3275071
2 changed files with 4 additions and 8 deletions

View File

@ -36,6 +36,7 @@ import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.socialgamer.cah.Constants.BlackCardData;
@ -1210,6 +1211,7 @@ public class Game {
* User whose hand to convert to client data.
* @return Client representation of {@code user}'s hand.
*/
@Nonnull
public List<Map<WhiteCardData, Object>> getHand(final User user) {
final Player player = getPlayerForUser(user);
if (player != null) {
@ -1218,7 +1220,7 @@ public class Game {
return getWhiteCardData(hand);
}
} else {
return null;
return new ArrayList<Map<WhiteCardData, Object>>(0);
}
}

View File

@ -23,7 +23,6 @@
package net.socialgamer.cah.handlers;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -56,18 +55,13 @@ public class GetCardsHandler extends GameWithPlayerHandler {
public static final String OP = AjaxOperation.GET_CARDS.toString();
@SuppressWarnings("unchecked")
@Override
public Map<ReturnableData, Object> handleWithUserInGame(final RequestWrapper request,
final HttpSession session, final User user, final Game game) {
final Map<ReturnableData, Object> data = new HashMap<ReturnableData, Object>();
final List<Map<WhiteCardData, Object>> hand = game.getHand(user);
if (hand != null) {
data.put(AjaxResponse.HAND, hand);
} else {
data.put(AjaxResponse.HAND, Arrays.asList(new HashMap<WhiteCardData, Object>()));
}
data.put(AjaxResponse.HAND, hand);
data.put(AjaxResponse.BLACK_CARD, game.getBlackCard());
data.put(AjaxResponse.WHITE_CARDS, game.getWhiteCards(user));
data.put(AjaxResponse.GAME_ID, game.getId());