Search in sources :

Example 31 with ResponseVo

use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.

the class GameInfoSongYuan method doPengTing.

protected void doPengTing(PlayerCardsInfoMj playerCardsInfo, long userId) {
    playerCardsInfo.peng(disCard, lastPlayUserId);
    lastOperateUserId = userId;
    // 删除弃牌
    deleteDisCard(lastPlayUserId, disCard);
    // 通知其他玩家
    OperateReqResp operateReqResp = new OperateReqResp();
    operateReqResp.setOperateType(OperateReqResp.type_peng_ting);
    operateReqResp.setCard(disCard);
    operateReqResp.setFromUserId(lastPlayUserId);
    operateReqResp.setUserId(userId);
    // 通知其他人
    ResponseVo vo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_OTHER_OPERATE, operateReqResp);
    MsgSender.sendMsg2Player(vo, users);
    // 碰完能听,杠,不能胡
    turnId = userId;
    // 通知客户端 操作
    OperateResp operateResp = new OperateResp();
    // 客户端特殊处理
    operateResp.setIsCanTing(false);
    operateResp.setIsCanGang(false);
    ResponseVo operateVo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_OPERATE, operateResp);
    MsgSender.sendMsg2Player(operateVo, userId);
    this.disCard = null;
    // 自己将能做的处理
    playerCardsInfo.canBePeng = false;
    playerCardsInfo.canBeTing = true;
    playerCardsInfo.canBePengTing = false;
    playerCardsInfo.canBeGang = false;
    resetOtherOperate(userId);
}
Also used : ResponseVo(com.code.server.constant.response.ResponseVo)

Example 32 with ResponseVo

use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.

the class RoomTuiTongZi method createRoom.

public static int createRoom(long userId, String roomType, String gameType, int gameNumber, int personNumber, boolean isJoin, int multiple) throws DataNotFoundException {
    RoomTuiTongZi room = getRoomInstance(roomType);
    room.personNumber = personNumber;
    room.roomId = getRoomIdStr(genRoomId());
    room.createUser = userId;
    room.gameType = gameType;
    room.isCreaterJoin = isJoin;
    room.multiple = multiple;
    room.bankerId = userId;
    room.roomType = roomType;
    room.init(gameNumber, multiple);
    int code = room.joinRoom(userId, isJoin);
    if (code != 0) {
        return code;
    }
    // 代建房 定时解散
    if (!isJoin) {
        // 给代建房 开房者 扣钱
        if (RedisManager.getUserRedisService().getUserMoney(userId) < room.createNeedMoney) {
            RoomManager.removeRoom(room.getRoomId());
            return ErrorCode.CANNOT_CREATE_ROOM_MONEY;
        }
        room.spendMoney();
        TimerNode prepareRoomNode = new TimerNode(System.currentTimeMillis(), IConstant.HOUR_1, false, room::dissolutionRoom);
        room.prepareRoomTimerNode = prepareRoomNode;
        GameTimer.addTimerNode(prepareRoomNode);
    }
    ServerConfig serverConfig = SpringUtil.getBean(ServerConfig.class);
    RoomManager.addRoom(room.roomId, "" + serverConfig.getServerId(), room);
    IdWorker idWorker = new IdWorker(serverConfig.getServerId(), 0);
    room.setUuid(idWorker.nextId());
    MsgSender.sendMsg2Player(new ResponseVo("pokerRoomService", "createTTZRoom", room.toVo(userId)), userId);
    return 0;
}
Also used : ServerConfig(com.code.server.game.poker.config.ServerConfig) IdWorker(com.code.server.util.IdWorker) TimerNode(com.code.server.util.timer.TimerNode) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 33 with ResponseVo

use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.

the class CenterMsgService method getRoomClubByUser.

private static void getRoomClubByUser(String msg) {
    JsonNode jsonNode = JsonUtil.readTree(msg);
    Map<String, Object> map = JsonUtil.readValue(msg, new TypeReference<HashMap<String, Object>>() {
    });
    Map<String, Object> result = JsonUtil.readValue(msg, Map.class);
    Long userId = jsonNode.path("userId").asLong();
    List<String> clubs = ClubManager.getInstance().getUserClubs(userId);
    map.put("clubs", clubs);
    GameClubService.sendMsg2Player(new ResponseVo("roomService", "getRoomClubByUser", map), userId);
}
Also used : HashMap(java.util.HashMap) JsonNode(com.fasterxml.jackson.databind.JsonNode) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 34 with ResponseVo

use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.

the class GameClubService method invite.

/**
 * 邀请其他玩家
 *
 * @param msgKey
 * @param clubId
 * @param roomId
 * @param inviteUser
 * @return
 */
public int invite(KafkaMsgKey msgKey, String clubId, String roomId, String inviteUser, String roomModel, String name) {
    Club club = ClubManager.getInstance().getClubById(clubId);
    if (club == null) {
        return ErrorCode.CLUB_NO_THIS;
    }
    MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
    Map<String, Object> result = new HashMap<>();
    result.put("clubId", clubId);
    result.put("roomId", roomId);
    result.put("inviteUser", inviteUser);
    result.put("roomModelInfo", getRoomModel(club, roomModel));
    result.put("name", name);
    msgProducer.send();
    sendMsg2Player(new ResponseVo("clubService", "inviteUser", result), Long.valueOf(inviteUser));
    sendMsg(msgKey, new ResponseVo("clubService", "invite", "ok"));
    return 0;
}
Also used : MsgProducer(com.code.server.kafka.MsgProducer) HashMap(java.util.HashMap) Club(com.code.server.db.model.Club) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 35 with ResponseVo

use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.

the class GameClubService method setRoomModel.

/**
 * 修改房间模式
 *
 * @param msgKey
 * @param userId
 * @param clubId
 * @param roomModelId
 * @param createCommand
 * @param gameType
 * @param gameNumber
 * @param desc
 * @return
 */
public int setRoomModel(KafkaMsgKey msgKey, long userId, String clubId, String roomModelId, String createCommand, String gameType, int gameNumber, String desc) {
    Club club = ClubManager.getInstance().getClubById(clubId);
    if (club == null) {
        return ErrorCode.CLUB_NO_THIS;
    }
    if (club.getPresident() != userId) {
        return ErrorCode.CLUB_NOT_PRESIDENT;
    }
    // 初始化 房间数据
    initRoomData();
    StaticDataProto.RoomData roomData = DataManager.data.getRoomDataMap().get(gameType);
    if (roomData == null || !roomData.getMoneyMap().containsKey(gameNumber)) {
        return ErrorCode.REQUEST_PARAM_ERROR;
    }
    JsonNode jsonNode = JsonUtil.readTree(createCommand);
    String serviceName = jsonNode.path("service").asText();
    // 设置创建命令
    RoomModel roomModel = getRoomModel(club, roomModelId);
    if (roomModel == null) {
        return ErrorCode.REQUEST_PARAM_ERROR;
    }
    createCommand = setRoomModelCommand(createCommand, clubId, roomModel.getId());
    roomModel.setCreateCommand(createCommand);
    roomModel.setDesc(desc);
    roomModel.setTime(System.currentTimeMillis());
    roomModel.setMoney(roomData.getMoneyMap().get(gameNumber));
    roomModel.setServiceName(serviceName);
    sendMsg(msgKey, new ResponseVo("clubService", "setRoomModel", roomModel));
    // 实例化房间
    initRoomInstance(club);
    return 0;
}
Also used : StaticDataProto(com.code.server.constant.data.StaticDataProto) Club(com.code.server.db.model.Club) JsonNode(com.fasterxml.jackson.databind.JsonNode) RoomModel(com.code.server.constant.club.RoomModel) ResponseVo(com.code.server.constant.response.ResponseVo)

Aggregations

ResponseVo (com.code.server.constant.response.ResponseVo)125 Club (com.code.server.db.model.Club)17 HashMap (java.util.HashMap)15 UserBean (com.code.server.constant.game.UserBean)8 IdWorker (com.code.server.util.IdWorker)8 ServerConfig (com.code.server.game.poker.config.ServerConfig)7 ArrayList (java.util.ArrayList)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 ClubMember (com.code.server.constant.club.ClubMember)5 Charge (com.code.server.db.model.Charge)5 User (com.code.server.db.model.User)5 GameOfResult (com.code.server.constant.response.GameOfResult)4 UserOfResult (com.code.server.constant.response.UserOfResult)4 TimerNode (com.code.server.util.timer.TimerNode)4 RoomModel (com.code.server.constant.club.RoomModel)3 KafkaMsgKey (com.code.server.constant.kafka.KafkaMsgKey)3 com.code.server.game.mahjong.response (com.code.server.game.mahjong.response)3 MsgSender (com.code.server.game.room.kafka.MsgSender)3 MsgProducer (com.code.server.kafka.MsgProducer)3 Map (java.util.Map)3