Search in sources :

Example 76 with ResponseVo

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

the class GameClubService method isHasClub.

/**
 * 是否有此俱乐部
 *
 * @param msgKey
 * @param userId
 * @param clubId
 * @return
 */
public int isHasClub(KafkaMsgKey msgKey, long userId, String clubId) {
    Map<String, Object> result = new HashMap<>();
    result.put("isHas", ClubManager.getInstance().getClubMap().containsKey(clubId));
    sendMsg(msgKey, new ResponseVo("clubService", "isHasClub", result));
    return 0;
}
Also used : HashMap(java.util.HashMap) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 77 with ResponseVo

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

the class GameClubService method removeRoomModel.

/**
 * 删除房间模式
 *
 * @param msgKey
 * @param userId
 * @param clubId
 * @param roomModelId
 * @return
 */
public int removeRoomModel(KafkaMsgKey msgKey, long userId, String clubId, String roomModelId) {
    Club club = ClubManager.getInstance().getClubById(clubId);
    if (club == null) {
        return ErrorCode.CLUB_NO_THIS;
    }
    if (club.getPresident() != userId) {
        return ErrorCode.CLUB_NOT_PRESIDENT;
    }
    RoomModel roomModel = getRoomModel(club, roomModelId);
    if (roomModel != null) {
        club.getClubInfo().getRoomModels().remove(roomModel);
    }
    // todo 退钱
    sendMsg(msgKey, new ResponseVo("clubService", "removeRoomModel", "ok"));
    return 0;
}
Also used : Club(com.code.server.db.model.Club) RoomModel(com.code.server.constant.club.RoomModel) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 78 with ResponseVo

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

the class GameClubService method agree.

/**
 * 同意加入俱乐部
 *
 * @param msgKey
 * @param userId
 * @param clubId
 * @param agreeId
 * @param isAgree
 * @return
 */
public int agree(KafkaMsgKey msgKey, long userId, String clubId, long agreeId, boolean isAgree) {
    Club club = ClubManager.getInstance().getClubById(clubId);
    if (club == null) {
        return ErrorCode.CLUB_NO_THIS;
    }
    if (club.getPresident() != userId) {
        return ErrorCode.CLUB_NOT_PRESIDENT;
    }
    if (ClubManager.getInstance().getUserClubNum(agreeId) >= JOIN_LIMIT) {
        return ErrorCode.CLUB_CANNOT_JOIN;
    }
    // 加入俱乐部
    ClubMember apply = getApply(club, agreeId);
    if (isAgree) {
        if (apply != null) {
            clubAddMember(club, apply);
        }
        String name = apply == null ? "" : apply.getName();
    }
    // 删除申请列表
    // removeUserFromApplyList(club, agreeId);
    club.getClubInfo().getApplyList().remove(apply);
    sendMsg(msgKey, new ResponseVo("clubService", "agree", "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 79 with ResponseVo

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

the class GameUserService method giveOtherMoney.

/**
 * 给人充钱
 *
 * @param msgKey
 * @param rechargeUserId 充值玩家ID
 * @param money          充值数量
 * @return
 */
public int giveOtherMoney(KafkaMsgKey msgKey, Long rechargeUserId, double money) {
    // 充值玩家id
    Long userid = msgKey.getUserId();
    UserBean userBeanOwn = userRedisService.getUserBean(userid);
    if (userBeanOwn == null) {
        return ErrorCode.YOU_HAVE_NOT_LOGIN;
    }
    // 充值玩家钱数
    double userMoney = userRedisService.getUserMoney(userid);
    // 被充值玩家余额
    double rechargeUserMoney = userRedisService.getUserMoney(rechargeUserId);
    // 被充值玩家对象
    UserBean userBean = userRedisService.getUserBean(rechargeUserId);
    if (userMoney - money >= 0 && money > 0) {
        if (userBean != null) {
            userRedisService.addUserMoney(rechargeUserId, money);
            // 减掉充值玩家相应的钱数
            userRedisService.addUserMoney(userid, -money);
            Map<String, Object> results = new HashMap<String, Object>();
            results.put("result", "success");
            ResponseVo vo = new ResponseVo("userService", "giveOtherMoney", results);
            sendMsg(msgKey, vo);
        } else {
            User accepter = userService.getUserByUserId(rechargeUserId);
            if (accepter == null) {
                ResponseVo vo = new ResponseVo("userService", "giveOtherMoney", ErrorCode.NOT_HAVE_THIS_ACCEPTER);
                sendMsg(msgKey, vo);
            } else {
                accepter.setMoney(accepter.getMoney() + money);
                userService.save(accepter);
                // 减掉充值玩家相应的钱数
                userRedisService.setUserMoney(userid, userMoney - money);
                Map<String, Object> results = new HashMap<String, Object>();
                results.put("result", "success");
                ResponseVo vo = new ResponseVo("userService", "giveOtherMoney", results);
                sendMsg(msgKey, vo);
            }
        }
    } else {
        return ErrorCode.NOT_HAVE_MORE_MONEY;
    }
    return 0;
}
Also used : User(com.code.server.db.model.User) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 80 with ResponseVo

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

the class GameUserService method reportingCoord.

public int reportingCoord(KafkaMsgKey msgKey, String coord) {
    long userId = msgKey.getUserId();
    UserBean userBean = RedisManager.getUserRedisService().getUserBean(userId);
    if (userBean != null) {
        userBean.setCoord(coord);
        RedisManager.getUserRedisService().setUserBean(userBean);
    }
    sendMsg(msgKey, new ResponseVo("userService", "reportingCoord", 0));
    return 0;
}
Also used : 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