use of com.code.server.constant.game.CardStruct in project summer by foxsugar.
the class DouDiZhuGoldRobot method play.
@Override
public void play(GameDouDiZhu game) {
PlayerCardInfoDouDiZhu playerInfo = game.getPlayerCardInfos().get(game.playTurn);
if (playerInfo.cards.size() == 0) {
return;
}
if (game.lastCardStruct == null || game.playTurn == game.lastCardStruct.getUserId()) {
CardStruct cardStruct = new CardStruct();
cardStruct.type = 1;
cardStruct.dan = game.getPlayerCardInfos().get(game.getPlayTurn()).MinimumCards();
cardStruct.cards = game.getPlayerCardInfos().get(game.getPlayTurn()).MinimumCards();
cardStruct.setUserId(game.getPlayTurn());
String roomId = game.getRoom().getRoomId();
int partition = SpringUtil.getBean(ServerConfig.class).getServerId();
KafkaMsgKey msgKey = new KafkaMsgKey();
msgKey.setUserId(game.getPlayTurn());
msgKey.setRoomId(roomId);
msgKey.setPartition(partition);
// {"service":"gameService","method":"play","params":{"cards":{"userId":"5","cards":[12],"type":1,"dan":[12]}}}
Map<String, Object> put = new HashMap<>();
put.put("cards", cardStruct);
ResponseRobotVo result = new ResponseRobotVo("gameService", "play", put);
SpringUtil.getBean(MsgProducer.class).send2Partition("gameService", partition, msgKey, result);
} else {
pass(game);
}
}
Aggregations