Search in sources :

Example 71 with ResponseVo

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

the class GameClubService method joinClub.

/**
 * 加入俱乐部
 *
 * @param msgKey
 * @param userId
 * @param clubId
 * @return
 */
public int joinClub(KafkaMsgKey msgKey, long userId, String clubId, String mark) {
    Club club = ClubManager.getInstance().getClubById(clubId);
    if (club == null) {
        return ErrorCode.CLUB_NO_THIS;
    }
    // 自己加入了几个俱乐部
    List<String> joinList = ClubManager.getInstance().getUserClubs(userId);
    if (joinList.size() >= JOIN_LIMIT) {
        return ErrorCode.CLUB_CANNOT_NUM;
    }
    if (joinList.contains(clubId)) {
        return ErrorCode.CLUB_CANNOT_JOIN;
    }
    // 加入申请列表
    if (isInApplyList(club, userId)) {
        return ErrorCode.CLUB_CANNOT_JOIN;
    }
    UserBean userBean = RedisManager.getUserRedisService().getUserBean(userId);
    String name = userBean.getUsername();
    String image = userBean.getImage();
    ClubMember apply = new ClubMember().setTime(System.currentTimeMillis()).setUserId(userId).setMark(mark).setName(name).setImage(image);
    club.getClubInfo().getApplyList().add(apply);
    Map<String, Object> result = new HashMap<>();
    sendMsg(msgKey, new ResponseVo("clubService", "joinClub", result));
    return 0;
}
Also used : UserBean(com.code.server.constant.game.UserBean) HashMap(java.util.HashMap) Club(com.code.server.db.model.Club) ClubMember(com.code.server.constant.club.ClubMember) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 72 with ResponseVo

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

the class GameClubService method setClub.

/**
 * 设置俱乐部
 *
 * @param msgKey
 * @param userId
 * @param clubId
 * @param clubName
 * @param wx
 * @param area
 * @param desc
 * @return
 */
public int setClub(KafkaMsgKey msgKey, long userId, String clubId, String clubName, String wx, String area, String desc) {
    Club club = ClubManager.getInstance().getClubById(clubId);
    if (club == null) {
        return ErrorCode.CLUB_NO_THIS;
    }
    if (userId != club.getPresident()) {
        return ErrorCode.CLUB_CANNOT_NO_PRESIDENT;
    }
    club.setName(clubName).setPresidentWx(wx).setArea(area).setClubDesc(desc);
    sendMsg(msgKey, new ResponseVo("clubService", "setClub", getClubVo_simple(club)));
    return 0;
}
Also used : Club(com.code.server.db.model.Club) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 73 with ResponseVo

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

the class GameClubService method getChargeRecord.

public int getChargeRecord(KafkaMsgKey msgKey, long userId, String clubId) {
    Club club = ClubManager.getInstance().getClubById(clubId);
    if (club == null) {
        return ErrorCode.CLUB_NO_THIS;
    }
    if (club.getPresident() != userId) {
        return ErrorCode.CLUB_NOT_PRESIDENT;
    }
    List<ClubCharge> list = clubChargeService.getClubChargeDao().getClubChargesByClubId(clubId);
    sendMsg(msgKey, new ResponseVo("clubService", "getChargeRecord", list));
    return 0;
}
Also used : ClubCharge(com.code.server.db.model.ClubCharge) Club(com.code.server.db.model.Club) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 74 with ResponseVo

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

the class GameClubService method dissolve.

/**
 * 解散
 *
 * @param msgKey
 * @param userId
 * @param clubId
 * @return
 */
public int dissolve(KafkaMsgKey msgKey, long userId, String clubId) {
    Club club = ClubManager.getInstance().getClubById(clubId);
    if (club == null) {
        return ErrorCode.CLUB_NO_THIS;
    }
    if (userId != club.getPresident()) {
        return ErrorCode.CLUB_CANNOT_NO_PRESIDENT;
    }
    // 玩家删除id
    List<String> removeList = new ArrayList<>();
    removeList.addAll(club.getClubInfo().getMember().keySet());
    for (String uid : removeList) {
        clubRemoveMember(club, Long.valueOf(uid));
    }
    // 删除club
    ClubManager.getInstance().getClubMap().remove(clubId);
    // 把钱加回去
    RedisManager.getUserRedisService().addUserMoney(userId, club.getMoney());
    // todo 在建的房间 是否退钱
    sendMsg(msgKey, new ResponseVo("clubService", "dissolve", club));
    return 0;
}
Also used : Club(com.code.server.db.model.Club) ArrayList(java.util.ArrayList) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 75 with ResponseVo

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

the class GameClubService method createClub.

/**
 * 创建俱乐部
 *
 * @param msgKey
 * @param userId
 * @param clubName
 * @param wx
 * @param area
 * @param desc
 * @return
 */
public int createClub(KafkaMsgKey msgKey, long userId, String clubName, String wx, String area, String desc) {
    // 钱是否够
    double money = RedisManager.getUserRedisService().getUserMoney(userId);
    if (money < getCreateMoney()) {
        return ErrorCode.CLUB_CANNOT_MONEY;
    }
    // 多于5个俱乐部 不可以创建
    int num = ClubManager.getInstance().getUserClubNum(userId);
    if (num >= JOIN_LIMIT) {
        return ErrorCode.CLUB_CANNOT_NUM;
    }
    // 人减钱
    RedisManager.getUserRedisService().addUserMoney(userId, -getCreateMoney());
    Club club = new Club();
    UserBean userBean = RedisManager.getUserRedisService().getUserBean(userId);
    // id
    club.setId(ClubManager.getInstance().getClubId());
    club.setPresident(userId);
    club.setName(clubName);
    club.setPresidentName(userBean.getUsername());
    club.setPresidentWx(wx);
    club.setArea(area);
    club.setMoney(getCreateMoney());
    club.setClubDesc(desc);
    clubAddMember(club, userBean);
    clubService.getClubDao().save(club);
    ClubManager.getInstance().getClubMap().put(club.getId(), club);
    ResponseVo vo = new ResponseVo("clubService", "createClub", club);
    sendMsg(msgKey, vo);
    return 0;
}
Also used : UserBean(com.code.server.constant.game.UserBean) Club(com.code.server.db.model.Club) 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