Search in sources :

Example 1 with ClubVo

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

the class GameClubService method getClubVo_simple.

/**
 * 获得俱乐部简要信息
 *
 * @param club
 * @return
 */
private ClubVo getClubVo_simple(Club club) {
    if (club == null) {
        return new ClubVo();
    }
    ClubVo clubVo = new ClubVo();
    clubVo.setId(club.getId());
    clubVo.setPresident(club.getPresident());
    clubVo.setName(club.getName());
    clubVo.setPresidentName(club.getPresidentName());
    clubVo.setNum(club.getClubInfo().getMember().size());
    clubVo.setMoney(club.getMoney());
    clubVo.setArea(club.getArea());
    clubVo.setPresidentWx(club.getPresidentWx());
    clubVo.setApplyNum(club.getClubInfo().getApplyList().size());
    return clubVo;
}
Also used : ClubVo(com.code.server.constant.response.ClubVo)

Example 2 with ClubVo

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

the class GameClubService method lookClub.

/**
 * 查看俱乐部
 *
 * @param msgKey
 * @param userId
 * @return
 */
public int lookClub(KafkaMsgKey msgKey, long userId) {
    List<ClubVo> list = new ArrayList<>();
    List<String> clubs = ClubManager.getInstance().getUserClubs(userId);
    for (String clubId : clubs) {
        list.add(getClubVo_simple(ClubManager.getInstance().getClubById(clubId)));
    }
    sendMsg(msgKey, new ResponseVo("clubService", "lookClub", list));
    return 0;
}
Also used : ClubVo(com.code.server.constant.response.ClubVo) ArrayList(java.util.ArrayList) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 3 with ClubVo

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

the class GameClubService method getClubInfo.

/**
 * 获得俱乐部信息
 *
 * @param msgKey
 * @param userId
 * @param clubId
 * @return
 */
public int getClubInfo(KafkaMsgKey msgKey, long userId, String clubId) {
    Club club = ClubManager.getInstance().getClubById(clubId);
    if (club == null) {
        return ErrorCode.CLUB_NO_THIS;
    }
    // 刷新房间
    initRoomInstance(club);
    boolean isPresident = club.getPresident() == userId;
    ClubVo clubVo = getClubVo_simple(club);
    clubVo.getRoomModels().addAll(club.getClubInfo().getRoomModels());
    // 玩家在线情况
    clubVo.getMember().addAll(club.getClubInfo().getMember().values());
    clubVo.getMember().forEach(clubMember -> {
        String gateId = RedisManager.getUserRedisService().getGateId(clubMember.getUserId());
        boolean online = gateId != null;
        clubMember.setOnline(online);
    });
    club.getClubInfo().getRoomInstance().values().forEach(roomInstance -> {
        if (roomInstance.getRoomId() != null) {
            clubVo.getRoomInstance().add(getRoomInstanceVo(roomInstance));
        }
    });
    // 房间情况
    if (isPresident) {
        clubVo.getApplyList().addAll(club.getClubInfo().getApplyList());
    }
    // todo 初始化数据
    // todo 更改玩家真实信息
    UserBean userBean = RedisManager.getUserRedisService().getUserBean(userId);
    if (isPresident) {
        club.setPresidentName(userBean.getUsername());
    }
    ClubMember clubMember = club.getClubInfo().getMember().get("" + userId);
    clubMember.setName(userBean.getUsername());
    clubMember.setImage(userBean.getImage());
    // 发送结果
    sendMsg(msgKey, new ResponseVo("clubService", "getClubInfo", clubVo));
    return 0;
}
Also used : ClubVo(com.code.server.constant.response.ClubVo) UserBean(com.code.server.constant.game.UserBean) Club(com.code.server.db.model.Club) ClubMember(com.code.server.constant.club.ClubMember) ResponseVo(com.code.server.constant.response.ResponseVo)

Aggregations

ClubVo (com.code.server.constant.response.ClubVo)3 ResponseVo (com.code.server.constant.response.ResponseVo)2 ClubMember (com.code.server.constant.club.ClubMember)1 UserBean (com.code.server.constant.game.UserBean)1 Club (com.code.server.db.model.Club)1 ArrayList (java.util.ArrayList)1