use of soc.game.SOCPlayer in project JSettlers2 by jdmonin.
the class SOCDisplaylessPlayerClient method handlePUTPIECE.
/**
* handle the "put piece" message
*<P>
* This method is public static for access by
* {@code SOCRobotBrain.handlePUTPIECE_updateGameData(SOCPutPiece)}.
* @param mes the message
* @param ga Message's game from {@link SOCPutPiece#getGame()}; if {@code null}, message is ignored
*/
public static void handlePUTPIECE(final SOCPutPiece mes, SOCGame ga) {
if (ga != null) {
final int pieceType = mes.getPieceType();
final int coord = mes.getCoordinates();
final SOCPlayer pl = (pieceType != SOCPlayingPiece.VILLAGE) ? ga.getPlayer(mes.getPlayerNumber()) : null;
switch(pieceType) {
case SOCPlayingPiece.ROAD:
ga.putPiece(new SOCRoad(pl, coord, null));
break;
case SOCPlayingPiece.SETTLEMENT:
ga.putPiece(new SOCSettlement(pl, coord, null));
break;
case SOCPlayingPiece.CITY:
ga.putPiece(new SOCCity(pl, coord, null));
break;
case SOCPlayingPiece.SHIP:
ga.putPiece(new SOCShip(pl, coord, null));
break;
case SOCPlayingPiece.FORTRESS:
ga.putPiece(new SOCFortress(pl, coord, ga.getBoard()));
break;
case SOCPlayingPiece.VILLAGE:
ga.putPiece(new SOCVillage(coord, ga.getBoard()));
break;
default:
System.err.println("Displayless.handlePUTPIECE: game " + ga.getName() + ": Unknown pieceType " + pieceType);
}
}
}
use of soc.game.SOCPlayer in project JSettlers2 by jdmonin.
the class SOCGameMessageHandler method handleMAKEOFFER.
// / Player trades and bank trades ///
/**
* handle "make offer" message.
*
* @param c the connection that sent the message
* @param mes the message
* @since 1.0.0
*/
private void handleMAKEOFFER(SOCGame ga, Connection c, final SOCMakeOffer mes) {
final String gaName = ga.getName();
if (ga.isGameOptionSet("NT")) {
srv.messageToPlayer(c, gaName, "Trading is not allowed in this game.");
// <---- Early return: No Trading ----
return;
}
ga.takeMonitor();
try {
SOCTradeOffer offer = mes.getOffer();
/**
* remake the offer with data that we know is accurate,
* namely the 'from' datum
*/
SOCPlayer player = ga.getPlayer(c.getData());
/**
* announce the offer, including text message similar to bank/port trade.
*/
if (player != null) {
SOCTradeOffer remadeOffer;
{
SOCResourceSet offGive = offer.getGiveSet(), offGet = offer.getGetSet();
remadeOffer = new SOCTradeOffer(gaName, player.getPlayerNumber(), offer.getTo(), offGive, offGet);
player.setCurrentOffer(remadeOffer);
// older clients need it sent from the server
if (ga.clientVersionLowest < SOCStringManager.VERSION_FOR_I18N) {
// I18N OK: Pre-2.0.00 clients always use english
final String txt = SOCStringManager.getFallbackServerManagerForClient().formatSpecial(ga, "{0} offered to give {1,rsrcs} for {2,rsrcs}.", player.getName(), offGive, offGet);
srv.messageToGameForVersions(ga, 0, SOCStringManager.VERSION_FOR_I18N - 1, new SOCGameTextMsg(gaName, SOCServer.SERVERNAME, txt), true);
}
}
SOCMakeOffer makeOfferMessage = new SOCMakeOffer(gaName, remadeOffer);
srv.messageToGame(gaName, makeOfferMessage);
srv.recordGameEvent(gaName, makeOfferMessage);
/**
* clear all the trade messages because a new offer has been made
*/
srv.gameList.takeMonitorForGame(gaName);
if (ga.clientVersionLowest >= SOCClearTradeMsg.VERSION_FOR_CLEAR_ALL) {
srv.messageToGameWithMon(gaName, new SOCClearTradeMsg(gaName, -1));
} else {
for (int i = 0; i < ga.maxPlayers; i++) srv.messageToGameWithMon(gaName, new SOCClearTradeMsg(gaName, i));
}
srv.gameList.releaseMonitorForGame(gaName);
}
} catch (Exception e) {
D.ebugPrintStackTrace(e, "Exception caught");
}
ga.releaseMonitor();
}
use of soc.game.SOCPlayer in project JSettlers2 by jdmonin.
the class SOCGameMessageHandler method handleBUYDEVCARDREQUEST.
// / Development Cards ///
/**
* handle "buy dev card request" message.
*<P>
* Before v2.0.00 this method was {@code handleBUYCARDREQUEST}.
*
* @param c the connection that sent the message
* @param mes the message
* @since 1.0.0
*/
private void handleBUYDEVCARDREQUEST(SOCGame ga, Connection c, final SOCBuyDevCardRequest mes) {
ga.takeMonitor();
try {
final String gaName = ga.getName();
SOCPlayer player = ga.getPlayer(c.getData());
final int pn = player.getPlayerNumber();
// for robots' benefit
boolean sendDenyReply = false;
if (handler.checkTurn(c, ga)) {
if (((ga.getGameState() == SOCGame.PLAY1) || (ga.getGameState() == SOCGame.SPECIAL_BUILDING)) && (ga.couldBuyDevCard(pn))) {
int card = ga.buyDevCard();
final int devCount = ga.getNumDevCards();
srv.gameList.takeMonitorForGame(gaName);
if (ga.clientVersionLowest >= SOCPlayerElements.MIN_VERSION) {
srv.messageToGameWithMon(gaName, new SOCPlayerElements(gaName, pn, SOCPlayerElement.LOSE, SOCDevCard.COST));
srv.messageToGameWithMon(gaName, new SOCGameElements(gaName, SOCGameElements.DEV_CARD_COUNT, devCount));
} else {
srv.messageToGameWithMon(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.LOSE, SOCPlayerElement.ORE, 1));
srv.messageToGameWithMon(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.LOSE, SOCPlayerElement.SHEEP, 1));
srv.messageToGameWithMon(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.LOSE, SOCPlayerElement.WHEAT, 1));
srv.messageToGameWithMon(gaName, new SOCDevCardCount(gaName, devCount));
}
srv.gameList.releaseMonitorForGame(gaName);
if ((card == SOCDevCardConstants.KNIGHT) && (c.getVersion() < SOCDevCardConstants.VERSION_FOR_NEW_TYPES))
card = SOCDevCardConstants.KNIGHT_FOR_VERS_1_X;
srv.messageToPlayer(c, new SOCDevCardAction(gaName, pn, SOCDevCardAction.DRAW, card));
if (ga.clientVersionLowest >= SOCDevCardConstants.VERSION_FOR_NEW_TYPES) {
srv.messageToGameExcept(gaName, c, new SOCDevCardAction(gaName, pn, SOCDevCardAction.DRAW, SOCDevCardConstants.UNKNOWN), true);
} else {
srv.messageToGameForVersionsExcept(ga, -1, SOCDevCardConstants.VERSION_FOR_NEW_TYPES - 1, c, new SOCDevCardAction(gaName, pn, SOCDevCardAction.DRAW, SOCDevCardConstants.UNKNOWN_FOR_VERS_1_X), true);
srv.messageToGameForVersionsExcept(ga, SOCDevCardConstants.VERSION_FOR_NEW_TYPES, Integer.MAX_VALUE, c, new SOCDevCardAction(gaName, pn, SOCDevCardAction.DRAW, SOCDevCardConstants.UNKNOWN), true);
}
final int remain = ga.getNumDevCards();
final SOCSimpleAction actmsg = new SOCSimpleAction(gaName, pn, SOCSimpleAction.DEVCARD_BOUGHT, remain, 0);
if (ga.clientVersionLowest >= SOCSimpleAction.VERSION_FOR_SIMPLEACTION) {
srv.messageToGame(gaName, actmsg);
} else {
srv.gameList.takeMonitorForGame(gaName);
srv.messageToGameForVersions(ga, SOCSimpleAction.VERSION_FOR_SIMPLEACTION, Integer.MAX_VALUE, actmsg, false);
// Only pre-1.1.19 clients will see the game text messages. Since they're
// older than the i18n work: Skip text key lookups, always use english,
// and use SOCGameTextMsg not SOCGameServerText.
final String boughtTxt = MessageFormat.format("{0} bought a development card.", player.getName());
srv.messageToGameForVersions(ga, -1, SOCSimpleAction.VERSION_FOR_SIMPLEACTION - 1, new SOCGameTextMsg(gaName, SOCGameTextMsg.SERVERNAME, boughtTxt), false);
final String remainTxt;
switch(remain) {
case 0:
remainTxt = "There are no more Development cards.";
break;
case 1:
remainTxt = "There is 1 card left.";
break;
default:
// I18N OK: for old version compat
remainTxt = MessageFormat.format("There are {0,number} cards left.", ga.getNumDevCards());
}
srv.messageToGameForVersions(ga, -1, SOCSimpleAction.VERSION_FOR_SIMPLEACTION - 1, new SOCGameTextMsg(gaName, SOCGameTextMsg.SERVERNAME, remainTxt), false);
srv.gameList.releaseMonitorForGame(gaName);
}
handler.sendGameState(ga);
} else {
if (ga.getNumDevCards() == 0)
srv.messageToPlayer(c, gaName, "There are no more Development cards.");
else
srv.messageToPlayer(c, gaName, "You can't buy a development card now.");
sendDenyReply = true;
}
} else {
if (ga.maxPlayers <= 4) {
srv.messageToPlayer(c, gaName, "It's not your turn.");
} else {
// 6-player board: Special Building Phase
try {
ga.askSpecialBuild(pn, true);
srv.messageToGame(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.SET, SOCPlayerElement.ASK_SPECIAL_BUILD, 1));
} catch (IllegalStateException e) {
srv.messageToPlayer(c, gaName, "You can't ask to buy a card now.");
}
}
sendDenyReply = true;
}
if (sendDenyReply && ga.getPlayer(pn).isRobot()) {
// == SOCPossiblePiece.CARD
srv.messageToPlayer(c, new SOCCancelBuildRequest(gaName, -2));
}
} catch (Exception e) {
D.ebugPrintStackTrace(e, "Exception caught");
}
ga.releaseMonitor();
}
use of soc.game.SOCPlayer in project JSettlers2 by jdmonin.
the class SOCGameMessageHandler method handleCANCELBUILDREQUEST.
/**
* handle "cancel build request" message.
* Cancel placement and send new game state, if cancel is allowed.
*
* @param c the connection that sent the message
* @param mes the message
* @since 1.0.0
*/
private void handleCANCELBUILDREQUEST(SOCGame ga, Connection c, final SOCCancelBuildRequest mes) {
ga.takeMonitor();
try {
final String gaName = ga.getName();
if (handler.checkTurn(c, ga)) {
final SOCPlayer player = ga.getPlayer(c.getData());
final int pn = player.getPlayerNumber();
final int gstate = ga.getGameState();
final boolean usePlayerElements = (ga.clientVersionLowest >= SOCPlayerElements.MIN_VERSION);
// If true, there was nothing cancelable: Don't call handler.sendGameState
boolean noAction = false;
switch(mes.getPieceType()) {
case SOCPlayingPiece.ROAD:
if ((gstate == SOCGame.PLACING_ROAD) || (gstate == SOCGame.PLACING_FREE_ROAD2)) {
ga.cancelBuildRoad(pn);
if (gstate == SOCGame.PLACING_ROAD) {
if (usePlayerElements) {
srv.messageToGame(gaName, new SOCPlayerElements(gaName, pn, SOCPlayerElement.GAIN, SOCRoad.COST));
} else {
srv.messageToGame(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.GAIN, SOCPlayerElement.CLAY, 1));
srv.messageToGame(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.GAIN, SOCPlayerElement.WOOD, 1));
}
} else {
srv.messageToGameKeyed(ga, true, "action.card.roadbuilding.skip.r", player.getName());
// "{0} skipped placing the second road."
}
} else {
srv.messageToPlayer(c, gaName, /*I*/
"You didn't buy a road.");
noAction = true;
}
break;
case SOCPlayingPiece.SETTLEMENT:
if (gstate == SOCGame.PLACING_SETTLEMENT) {
ga.cancelBuildSettlement(pn);
if (usePlayerElements) {
srv.messageToGame(gaName, new SOCPlayerElements(gaName, pn, SOCPlayerElement.GAIN, SOCSettlement.COST));
} else {
srv.gameList.takeMonitorForGame(gaName);
srv.messageToGameWithMon(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.GAIN, SOCPlayerElement.CLAY, 1));
srv.messageToGameWithMon(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.GAIN, SOCPlayerElement.SHEEP, 1));
srv.messageToGameWithMon(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.GAIN, SOCPlayerElement.WHEAT, 1));
srv.messageToGameWithMon(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.GAIN, SOCPlayerElement.WOOD, 1));
srv.gameList.releaseMonitorForGame(gaName);
}
} else if ((gstate == SOCGame.START1B) || (gstate == SOCGame.START2B) || (gstate == SOCGame.START3B)) {
SOCSettlement pp = new SOCSettlement(player, player.getLastSettlementCoord(), null);
ga.undoPutInitSettlement(pp);
// Re-send to all clients to announce it
srv.messageToGame(gaName, mes);
// (Safe since we've validated all message parameters)
// "{0} cancelled this settlement placement."
srv.messageToGameKeyed(ga, true, "action.built.stlmt.cancel", player.getName());
// The handler.sendGameState below is redundant if client reaction changes game state
} else {
srv.messageToPlayer(c, gaName, /*I*/
"You didn't buy a settlement.");
noAction = true;
}
break;
case SOCPlayingPiece.CITY:
if (gstate == SOCGame.PLACING_CITY) {
ga.cancelBuildCity(pn);
if (usePlayerElements) {
srv.messageToGame(gaName, new SOCPlayerElements(gaName, pn, SOCPlayerElement.GAIN, SOCCity.COST));
} else {
srv.messageToGame(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.GAIN, SOCPlayerElement.ORE, 3));
srv.messageToGame(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.GAIN, SOCPlayerElement.WHEAT, 2));
}
} else {
srv.messageToPlayer(c, gaName, /*I*/
"You didn't buy a city.");
noAction = true;
}
break;
case SOCPlayingPiece.SHIP:
if ((gstate == SOCGame.PLACING_SHIP) || (gstate == SOCGame.PLACING_FREE_ROAD2)) {
ga.cancelBuildShip(pn);
if (gstate == SOCGame.PLACING_SHIP) {
if (usePlayerElements) {
srv.messageToGame(gaName, new SOCPlayerElements(gaName, pn, SOCPlayerElement.GAIN, SOCShip.COST));
} else {
srv.messageToGame(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.GAIN, SOCPlayerElement.SHEEP, 1));
srv.messageToGame(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.GAIN, SOCPlayerElement.WOOD, 1));
}
} else {
srv.messageToGameKeyed(ga, true, "action.card.roadbuilding.skip.s", player.getName());
// "{0} skipped placing the second ship."
}
} else {
srv.messageToPlayer(c, gaName, /*I*/
"You didn't buy a ship.");
noAction = true;
}
break;
case SOCCancelBuildRequest.INV_ITEM_PLACE_CANCEL:
SOCInventoryItem item = null;
if (gstate == SOCGame.PLACING_INV_ITEM)
item = ga.cancelPlaceInventoryItem(false);
if (item != null)
srv.messageToGame(gaName, new SOCInventoryItemAction(gaName, pn, SOCInventoryItemAction.ADD_PLAYABLE, item.itype, item.isKept(), item.isVPItem(), item.canCancelPlay));
if ((item != null) || (gstate != ga.getGameState())) {
srv.messageToGameKeyed(ga, true, "reply.placeitem.cancel", player.getName());
// "{0} canceled placement of a special item."
} else {
srv.messageToPlayerKeyed(c, gaName, "reply.placeitem.cancel.cannot");
// "Cannot cancel item placement."
noAction = true;
}
break;
default:
throw new IllegalArgumentException("Unknown piece type " + mes.getPieceType());
}
if (!noAction) {
handler.sendGameState(ga);
} else {
// bot is waiting for a gamestate reply, not text
final SOCClientData scd = (SOCClientData) c.getAppData();
if ((scd != null) && scd.isRobot)
c.put(SOCGameState.toCmd(gaName, gstate));
}
} else {
// "It's not your turn."
srv.messageToPlayerKeyed(c, gaName, "reply.not.your.turn");
}
} catch (Exception e) {
D.ebugPrintStackTrace(e, "Exception caught");
}
ga.releaseMonitor();
}
use of soc.game.SOCPlayer in project JSettlers2 by jdmonin.
the class SOCGameMessageHandler method handlePLAYDEVCARDREQUEST.
/**
* handle "play development card request" message.
*
* @param c the connection that sent the message
* @param mes the message
* @since 1.0.0
*/
private void handlePLAYDEVCARDREQUEST(SOCGame ga, Connection c, final SOCPlayDevCardRequest mes) {
ga.takeMonitor();
try {
final String gaName = ga.getName();
// if player can't play right now, send "You can't play a (cardtype) card now."
boolean denyPlayCardNow = false;
// if player can't play right now, for a different reason than denyPlayCardNow, send this
String denyTextKey = null;
if (handler.checkTurn(c, ga)) {
final SOCPlayer player = ga.getPlayer(c.getData());
final int pn = player.getPlayerNumber();
int ctype = mes.getDevCard();
if ((ctype == SOCDevCardConstants.KNIGHT_FOR_VERS_1_X) && (c.getVersion() < SOCDevCardConstants.VERSION_FOR_NEW_TYPES))
ctype = SOCDevCardConstants.KNIGHT;
switch(ctype) {
case SOCDevCardConstants.KNIGHT:
final boolean isWarshipConvert = ga.isGameOptionSet(SOCGameOption.K_SC_PIRI);
if (ga.canPlayKnight(pn)) {
final int peType = (isWarshipConvert) ? SOCPlayerElement.SCENARIO_WARSHIP_COUNT : SOCPlayerElement.NUMKNIGHTS;
ga.playKnight();
final String cardplayed = (isWarshipConvert) ? // "converted a ship to a warship."
"action.card.soldier.warship" : // "played a Soldier card."
"action.card.soldier";
srv.gameList.takeMonitorForGame(gaName);
srv.messageToGameKeyed(ga, false, cardplayed, player.getName());
if (ga.clientVersionLowest >= SOCDevCardConstants.VERSION_FOR_NEW_TYPES) {
srv.messageToGameWithMon(gaName, new SOCDevCardAction(gaName, pn, SOCDevCardAction.PLAY, SOCDevCardConstants.KNIGHT));
} else {
// JM temp
D.ebugPrintln("L7870: played soldier; clientVersionLowest = " + ga.clientVersionLowest);
srv.messageToGameForVersions(ga, -1, SOCDevCardConstants.VERSION_FOR_NEW_TYPES - 1, new SOCDevCardAction(gaName, pn, SOCDevCardAction.PLAY, SOCDevCardConstants.KNIGHT_FOR_VERS_1_X), false);
srv.messageToGameForVersions(ga, SOCDevCardConstants.VERSION_FOR_NEW_TYPES, Integer.MAX_VALUE, new SOCDevCardAction(gaName, pn, SOCDevCardAction.PLAY, SOCDevCardConstants.KNIGHT), false);
}
if (ga.clientVersionLowest >= SOCPlayerElement.VERSION_FOR_CARD_ELEMENTS)
srv.messageToGameWithMon(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.SET, SOCPlayerElement.PLAYED_DEV_CARD_FLAG, 1));
else
srv.messageToGameWithMon(gaName, new SOCSetPlayedDevCard(gaName, pn, true));
srv.messageToGameWithMon(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.GAIN, peType, 1));
srv.gameList.releaseMonitorForGame(gaName);
if (!isWarshipConvert) {
handler.sendGameState(ga);
}
} else {
denyPlayCardNow = true;
// "You can't play a " + ((isWarshipConvert) ? "Warship" : "Soldier") + " card now."
}
break;
case SOCDevCardConstants.ROADS:
if (ga.canPlayRoadBuilding(pn)) {
ga.playRoadBuilding();
srv.gameList.takeMonitorForGame(gaName);
srv.messageToGameWithMon(gaName, new SOCDevCardAction(gaName, pn, SOCDevCardAction.PLAY, SOCDevCardConstants.ROADS));
if (ga.clientVersionLowest >= SOCPlayerElement.VERSION_FOR_CARD_ELEMENTS)
srv.messageToGameWithMon(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.SET, SOCPlayerElement.PLAYED_DEV_CARD_FLAG, 1));
else
srv.messageToGameWithMon(gaName, new SOCSetPlayedDevCard(gaName, pn, true));
// "played a Road Building card."
srv.messageToGameKeyed(ga, false, "action.card.roadbuilding", player.getName());
srv.gameList.releaseMonitorForGame(gaName);
handler.sendGameState(ga);
if (ga.getGameState() == SOCGame.PLACING_FREE_ROAD1)
srv.messageToPlayerKeyed(c, gaName, (ga.hasSeaBoard) ? "action.card.road.place.2s" : "action.card.road.place.2r");
else
// "You may place 2 roads/ships." or "You may place 2 roads."
srv.messageToPlayerKeyed(c, gaName, (ga.hasSeaBoard) ? "action.card.road.place.1s" : "action.card.road.place.1r");
// "You may place your 1 remaining road or ship." or "... place your 1 remaining road."
} else {
// "You can't play a Road Building card now."
denyPlayCardNow = true;
}
break;
case SOCDevCardConstants.DISC:
if (ga.canPlayDiscovery(pn)) {
ga.playDiscovery();
srv.gameList.takeMonitorForGame(gaName);
srv.messageToGameWithMon(gaName, new SOCDevCardAction(gaName, pn, SOCDevCardAction.PLAY, SOCDevCardConstants.DISC));
if (ga.clientVersionLowest >= SOCPlayerElement.VERSION_FOR_CARD_ELEMENTS)
srv.messageToGameWithMon(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.SET, SOCPlayerElement.PLAYED_DEV_CARD_FLAG, 1));
else
srv.messageToGameWithMon(gaName, new SOCSetPlayedDevCard(gaName, pn, true));
srv.messageToGameKeyed(ga, false, "action.card.discoveryplenty", player.getName());
// "played a Year of Plenty card."
srv.gameList.releaseMonitorForGame(gaName);
handler.sendGameState(ga);
} else {
// "You can't play a Year of Plenty card now."
denyPlayCardNow = true;
}
break;
case SOCDevCardConstants.MONO:
if (ga.canPlayMonopoly(pn)) {
ga.playMonopoly();
srv.gameList.takeMonitorForGame(gaName);
srv.messageToGameWithMon(gaName, new SOCDevCardAction(gaName, pn, SOCDevCardAction.PLAY, SOCDevCardConstants.MONO));
if (ga.clientVersionLowest >= SOCPlayerElement.VERSION_FOR_CARD_ELEMENTS)
srv.messageToGameWithMon(gaName, new SOCPlayerElement(gaName, pn, SOCPlayerElement.SET, SOCPlayerElement.PLAYED_DEV_CARD_FLAG, 1));
else
srv.messageToGameWithMon(gaName, new SOCSetPlayedDevCard(gaName, pn, true));
// "played a Monopoly card."
srv.messageToGameKeyed(ga, false, "action.card.mono", player.getName());
srv.gameList.releaseMonitorForGame(gaName);
handler.sendGameState(ga);
} else {
// "You can't play a Monopoly card now."
denyPlayCardNow = true;
}
break;
default:
// "That card type is unknown."
denyTextKey = "reply.playdevcard.type.unknown";
D.ebugPrintln("* srv handlePLAYDEVCARDREQUEST: asked to play unhandled type " + mes.getDevCard());
}
} else {
// "It's not your turn."
denyTextKey = "reply.not.your.turn";
}
if (denyPlayCardNow || (denyTextKey != null)) {
final SOCClientData scd = (SOCClientData) c.getAppData();
if ((scd == null) || !scd.isRobot) {
if (denyTextKey != null)
srv.messageToPlayerKeyed(c, gaName, denyTextKey);
else
srv.messageToPlayerKeyedSpecial(c, ga, "reply.playdevcard.cannot.now", mes.getDevCard());
} else {
srv.messageToPlayer(c, new SOCDevCardAction(gaName, -1, SOCDevCardAction.CANNOT_PLAY, mes.getDevCard()));
}
}
} catch (Exception e) {
D.ebugPrintStackTrace(e, "Exception caught");
}
ga.releaseMonitor();
}
Aggregations