Search in sources :

Example 6 with ResponseRobotVo

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

the class TTZRobot method bet.

@Override
public void bet(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();
    put.put("zhu", 1);
    for (PlayerTuiTongZi p : game.getPlayerCardInfos().values()) {
        if (p.getUserId() != game.room.getBankerId() && p.getBet() == null) {
            msgKey.setUserId(p.getUserId());
            put.put("userId", p.getUserId());
        }
    }
    ResponseRobotVo result = new ResponseRobotVo("gameService", "bet", 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 7 with ResponseRobotVo

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

the class CowRobot method raise.

@Override
public void raise(GameCow 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();
    put.put("addChip", 1);
    for (PlayerCow p : game.getPlayerCardInfos().values()) {
        if (p.userId != game.room.getBankerId() && 0 == p.getRaise()) {
            msgKey.setUserId(p.getUserId());
            put.put("userId", p.getUserId());
        }
    }
    ResponseRobotVo result = new ResponseRobotVo("gameService", "raise", 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 8 with ResponseRobotVo

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

the class CowRobot method getReady.

@Override
public void getReady(RoomCow roomCow) {
    String roomId = roomCow.getRoomId();
    int partition = SpringUtil.getBean(ServerConfig.class).getServerId();
    KafkaMsgKey msgKey = new KafkaMsgKey();
    msgKey.setRoomId(roomId);
    msgKey.setPartition(partition);
    for (Long l : roomCow.getUserStatus().keySet()) {
        if (0 == roomCow.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)

Example 9 with ResponseRobotVo

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

the class CowRobot method compare.

@Override
public void compare(GameCow 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 (PlayerCow p : game.getPlayerCardInfos().values()) {
        if (0 == p.getKill()) {
            msgKey.setUserId(p.getUserId());
            put.put("userId", p.getUserId());
        }
    }
    ResponseRobotVo result = new ResponseRobotVo("gameService", "compare", 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 10 with ResponseRobotVo

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

the class DouDiZhuGoldRobot method pass.

@Override
public void pass(GameDouDiZhu game) {
    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的名字 分topic
    // {"service":"gameService","method":"pass","params":{"userId":"8"}}
    Map<String, Object> put = new HashMap<>();
    put.put("userId", game.getPlayTurn());
    ResponseRobotVo result = new ResponseRobotVo("gameService", "pass", 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)

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