Search in sources :

Example 1 with ResponseRobotVo

use of com.code.server.game.poker.robot.ResponseRobotVo 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)

Example 2 with ResponseRobotVo

use of com.code.server.game.poker.robot.ResponseRobotVo in project summer by foxsugar.

the class DouDiZhuGoldRobot method qiangDizhu.

@Override
public void qiangDizhu(GameDouDiZhu game) {
    String roomId = game.getRoom().getRoomId();
    int partition = SpringUtil.getBean(ServerConfig.class).getServerId();
    KafkaMsgKey msgKey = new KafkaMsgKey();
    msgKey.setUserId(game.canQiangUser);
    msgKey.setRoomId(roomId);
    msgKey.setPartition(partition);
    // 按service的名字 分topic
    // {"service":"gameService","method":"qiangDizhu","params":{"isQiang":false}}
    Map<String, Object> put = new HashMap<>();
    put.put("isQiang", false);
    ResponseRobotVo result = new ResponseRobotVo("gameService", "qiangDizhu", put);
    SpringUtil.getBean(MsgProducer.class).send2Partition("gameService", partition, msgKey, result);
}
Also used : ServerConfig(com.code.server.game.poker.config.ServerConfig) 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)

Example 3 with ResponseRobotVo

use of com.code.server.game.poker.robot.ResponseRobotVo in project summer by foxsugar.

the class TTZRobot method open.

@Override
public void open(GameTuiTongZi game) {
    String roomId = game.getRoom().getRoomId();
    int partition = SpringUtil.getBean(ServerConfig.class).getServerId();
    KafkaMsgKey msgKey = new KafkaMsgKey();
    msgKey.setRoomId(roomId);
    msgKey.setPartition(partition);
    Map<String, Object> put = new HashMap();
    for (PlayerTuiTongZi p : game.getPlayerCardInfos().values()) {
        if (!p.isOpen()) {
            msgKey.setUserId(p.getUserId());
            put.put("userId", p.getUserId());
        }
    }
    ResponseRobotVo result = new ResponseRobotVo("gameService", "open", put);
    SpringUtil.getBean(MsgProducer.class).send2Partition("gameService", partition, msgKey, result);
}
Also used : ServerConfig(com.code.server.game.poker.config.ServerConfig) 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)

Example 4 with ResponseRobotVo

use of com.code.server.game.poker.robot.ResponseRobotVo in project summer by foxsugar.

the class TTZRobot method crap.

@Override
public void crap(GameTuiTongZi game) {
    String roomId = game.getRoom().getRoomId();
    int partition = SpringUtil.getBean(ServerConfig.class).getServerId();
    KafkaMsgKey msgKey = new KafkaMsgKey();
    msgKey.setRoomId(roomId);
    msgKey.setPartition(partition);
    Map<String, Object> put = new HashMap();
    for (PlayerTuiTongZi p : game.getPlayerCardInfos().values()) {
        if (p.getUserId() == game.room.getBankerId()) {
            msgKey.setUserId(p.getUserId());
            put.put("userId", p.getUserId());
        }
    }
    ResponseRobotVo result = new ResponseRobotVo("gameService", "crap", put);
    SpringUtil.getBean(MsgProducer.class).send2Partition("gameService", partition, msgKey, result);
}
Also used : ServerConfig(com.code.server.game.poker.config.ServerConfig) 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)

Example 5 with ResponseRobotVo

use of com.code.server.game.poker.robot.ResponseRobotVo in project summer by foxsugar.

the class TTZRobot method getReady.

@Override
public void getReady(RoomTuiTongZi room) {
    String roomId = room.getRoomId();
    int partition = SpringUtil.getBean(ServerConfig.class).getServerId();
    KafkaMsgKey msgKey = new KafkaMsgKey();
    msgKey.setRoomId(roomId);
    msgKey.setPartition(partition);
    for (Long l : room.getUserStatus().keySet()) {
        if (0 == room.getUserStatus().get(l)) {
            msgKey.setUserId(l);
        }
    }
    Map<String, Object> put = new HashMap();
    ResponseRobotVo result = new ResponseRobotVo("roomService", "getReady", put);
    SpringUtil.getBean(MsgProducer.class).send2Partition("roomService", partition, msgKey, result);
}
Also used : ServerConfig(com.code.server.game.poker.config.ServerConfig) 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

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