Search in sources :

Example 1 with ClubMember

use of com.code.server.constant.club.ClubMember in project summer by foxsugar.

the class GameClubService method clubAddMember.

/**
 * 俱乐部加入成员
 *
 * @param club
 * @param userBean
 */
private void clubAddMember(Club club, UserBean userBean) {
    ClubMember member = new ClubMember();
    member.setUserId(userBean.getId());
    member.setTime(System.currentTimeMillis());
    member.setImage(userBean.getImage());
    member.setName(userBean.getUsername());
    club.getClubInfo().getMember().put("" + userBean.getId(), member);
    // 加到全局列表
    ClubManager.getInstance().userAddClub(userBean.getId(), club.getId());
}
Also used : ClubMember(com.code.server.constant.club.ClubMember)

Example 2 with ClubMember

use of com.code.server.constant.club.ClubMember in project summer by foxsugar.

the class GameClubService method clubAddMember.

/**
 * 俱乐部加成员
 *
 * @param club
 * @param apply
 */
private void clubAddMember(Club club, ClubMember apply) {
    ClubMember member = new ClubMember();
    member.setUserId(apply.getUserId());
    member.setTime(System.currentTimeMillis());
    member.setImage(apply.getImage());
    member.setName(apply.getName());
    club.getClubInfo().getMember().put("" + apply.getUserId(), member);
    // 加到全局列表
    ClubManager.getInstance().userAddClub(apply.getUserId(), club.getId());
}
Also used : ClubMember(com.code.server.constant.club.ClubMember)

Example 3 with ClubMember

use of com.code.server.constant.club.ClubMember 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)

Example 4 with ClubMember

use of com.code.server.constant.club.ClubMember in project summer by foxsugar.

the class GameClubService method markUser.

/**
 * mark 用户
 *
 * @param msgKey
 * @param userId
 * @param clubId
 * @param markUser
 * @param mark
 * @return
 */
public int markUser(KafkaMsgKey msgKey, long userId, String clubId, long markUser, String mark) {
    Club club = ClubManager.getInstance().getClubById(clubId);
    if (club == null) {
        return ErrorCode.CLUB_NO_THIS;
    }
    if (userId != club.getPresident()) {
        return ErrorCode.CLUB_CANNOT_NO_PRESIDENT;
    }
    ClubMember clubMember = club.getClubInfo().getMember().get("" + markUser);
    clubMember.setMark(mark);
    sendMsg(msgKey, new ResponseVo("clubService", "markUser", "ok"));
    return 0;
}
Also used : Club(com.code.server.db.model.Club) ClubMember(com.code.server.constant.club.ClubMember) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 5 with ClubMember

use of com.code.server.constant.club.ClubMember in project summer by foxsugar.

the class GameClubService method getFreeUser.

/**
 * 获得空闲的玩家
 *
 * @param msgKey
 * @param clubId
 * @return
 */
public int getFreeUser(KafkaMsgKey msgKey, String clubId) {
    Club club = ClubManager.getInstance().getClubById(clubId);
    if (club == null) {
        return ErrorCode.CLUB_NO_THIS;
    }
    List<ClubMember> list = new ArrayList<>();
    club.getClubInfo().getMember().values().forEach(clubMember -> {
        String gateId = RedisManager.getUserRedisService().getGateId(clubMember.getUserId());
        boolean online = gateId != null;
        if (online) {
            boolean isInRoom = RedisManager.getUserRedisService().getRoomId(clubMember.getUserId()) != null;
            if (!isInRoom) {
                list.add(clubMember);
            }
        }
    });
    sendMsg(msgKey, new ResponseVo("clubService", "getFreeUser", list));
    return 0;
}
Also used : Club(com.code.server.db.model.Club) ArrayList(java.util.ArrayList) ClubMember(com.code.server.constant.club.ClubMember) ResponseVo(com.code.server.constant.response.ResponseVo)

Aggregations

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