Search in sources :

Example 1 with AllMessage

use of com.code.server.game.mahjong.response.AllMessage in project summer by foxsugar.

the class ReconnService method reconnection.

public static int reconnection(String roomId, long userId) {
    AllMessage allMessage = new AllMessage();
    allMessage.setExist(false);
    RoomInfo roomInfo = (RoomInfo) RoomManager.getRoom(roomId);
    if (roomInfo != null) {
        allMessage.setExist(true);
        List<UserVo> userList = new ArrayList<>();
        allMessage.setRoom(getRoomInfo(roomInfo));
        allMessage.setBanker(roomInfo.getBankerId());
        allMessage.setCurGameNumber(roomInfo.getCurGameNumber());
        allMessage.setUserScores(roomInfo.getUserScores());
        allMessage.setUserStatus(roomInfo.getUserStatus());
        // 圈数
        allMessage.setCircleNum(roomInfo.getCurCircle());
        allMessage.getLaZhuang().putAll(roomInfo.getLaZhuang());
        allMessage.getLaZhuangStatus().putAll(roomInfo.getLaZhuangStatus());
        for (UserBean userBean : RedisManager.getUserRedisService().getUserBeans(roomInfo.getUsers())) {
            userList.add(userBean.toVo());
        }
        // 在线状态
        for (long uid : roomInfo.getUsers()) {
            allMessage.getOfflineStatus().put(uid, RedisManager.getUserRedisService().getGateId(uid) != null);
        }
        GameInfo gameInfo = (GameInfo) roomInfo.getGame();
        roomInfo.getReady(userId);
        if (gameInfo != null) {
            ReconnectResp reconnect = new ReconnectResp(gameInfo, userId);
            allMessage.setGameId(gameInfo.getGameId());
            allMessage.setCardNumber(gameInfo.getRemainCards().size());
            allMessage.setReconnectResp(reconnect);
        }
        allMessage.setUsers(userList);
        if (roomInfo.getTimerNode() != null) {
            long time = roomInfo.getTimerNode().getStart() + roomInfo.getTimerNode().getInterval() - System.currentTimeMillis();
            allMessage.setRemainTime(time);
        }
    }
    ResponseVo vo = new ResponseVo("reconnService", "reconnection", allMessage);
    MsgSender.sendMsg2Player(vo, userId);
    return 0;
}
Also used : AllMessage(com.code.server.game.mahjong.response.AllMessage) GameInfo(com.code.server.game.mahjong.logic.GameInfo) UserVo(com.code.server.constant.response.UserVo) UserBean(com.code.server.constant.game.UserBean) ArrayList(java.util.ArrayList) ReconnectResp(com.code.server.game.mahjong.response.ReconnectResp) RoomInfo(com.code.server.game.mahjong.logic.RoomInfo) ResponseVo(com.code.server.constant.response.ResponseVo)

Aggregations

UserBean (com.code.server.constant.game.UserBean)1 ResponseVo (com.code.server.constant.response.ResponseVo)1 UserVo (com.code.server.constant.response.UserVo)1 GameInfo (com.code.server.game.mahjong.logic.GameInfo)1 RoomInfo (com.code.server.game.mahjong.logic.RoomInfo)1 AllMessage (com.code.server.game.mahjong.response.AllMessage)1 ReconnectResp (com.code.server.game.mahjong.response.ReconnectResp)1 ArrayList (java.util.ArrayList)1