Search in sources :

Example 1 with CardStruct

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);
    }
}
Also used : ServerConfig(com.code.server.game.poker.config.ServerConfig) CardStruct(com.code.server.constant.game.CardStruct) HashMap(java.util.HashMap) MsgProducer(com.code.server.kafka.MsgProducer) KafkaMsgKey(com.code.server.constant.kafka.KafkaMsgKey) ResponseRobotVo(com.code.server.game.poker.robot.ResponseRobotVo)

Aggregations

CardStruct (com.code.server.constant.game.CardStruct)1 KafkaMsgKey (com.code.server.constant.kafka.KafkaMsgKey)1 ServerConfig (com.code.server.game.poker.config.ServerConfig)1 ResponseRobotVo (com.code.server.game.poker.robot.ResponseRobotVo)1 MsgProducer (com.code.server.kafka.MsgProducer)1 HashMap (java.util.HashMap)1