Search in sources :

Example 81 with ResponseVo

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

the class GameUserService method guessCarUp2Agent.

/**
 * 猜汽车
 * @param msgKey
 * @return
 */
public int guessCarUp2Agent(KafkaMsgKey msgKey) {
    final int needMoney = 1000;
    long userId = msgKey.getUserId();
    UserBean userBean = RedisManager.getUserRedisService().getUserBean(userId);
    if (userBean.getVip() != 0) {
        return ErrorCode.CAN_NOT_BING_REFERRER;
    }
    // 减钻石
    if (userBean.getMoney() < needMoney) {
        return ErrorCode.NOT_HAVE_MORE_MONEY;
    }
    userBean.setVip(Integer.valueOf("" + userId));
    RedisManager.getUserRedisService().updateUserBean(userId, userBean);
    RedisManager.getUserRedisService().addUserMoney(userId, -needMoney);
    ResponseVo vo = new ResponseVo("userService", "guessCarUp2Agent", userId);
    sendMsg(msgKey, vo);
    return 0;
}
Also used : ResponseVo(com.code.server.constant.response.ResponseVo)

Example 82 with ResponseVo

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

the class GameUserService method getReplay.

public int getReplay(KafkaMsgKey msgKey, long id) {
    Replay r = SpringUtil.getBean(ReplayService.class).getReplay(id);
    if (r == null) {
        return ErrorCode.REPLAY_NOT_EXIST;
    }
    Map<String, Object> result = new HashMap<>();
    result.put("data", r.getData());
    ResponseVo vo = new ResponseVo("userService", "getReplay", r.getData());
    sendMsg(msgKey, vo);
    return 0;
}
Also used : Replay(com.code.server.db.model.Replay) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 83 with ResponseVo

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

the class GameUserService method accessCode.

public int accessCode(KafkaMsgKey msgKey, String accessCode) {
    if (accessCode == null || "".equals(accessCode)) {
        return ErrorCode.NO_ACCESSCODE;
    }
    String ac = ServerManager.constant.getAccessCode();
    if (ac == null || !accessCode.equals(ac)) {
        return ErrorCode.NO_ACCESSCODE;
    }
    UserBean userBean = RedisManager.getUserRedisService().getUserBean(msgKey.getUserId());
    userBean.getUserInfo().setInputAccessCode(true);
    // RedisManager.getUserRedisService().setUserBean(userBean);
    RedisManager.getUserRedisService().updateUserBean(userBean.getId(), userBean);
    ResponseVo vo = new ResponseVo("userService", "accessCode", 0);
    sendMsg(msgKey, vo);
    return 0;
}
Also used : ResponseVo(com.code.server.constant.response.ResponseVo)

Example 84 with ResponseVo

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

the class GameInfo method chiTing.

public int chiTing(long userId, String one, String two) {
    PlayerCardsInfoMj playerCardsInfo = playerCardsInfos.get(userId);
    boolean isCanChi = playerCardsInfo.isCanChiThisCard(disCard, one, two);
    if (!isCanChi) {
        return ErrorCode.CAN_NOT_CHI_TING;
    }
    if (disCard == null) {
        return ErrorCode.CAN_NOT_CHI_TING;
    }
    // 从等待列表删除
    if (waitingforList.size() > 0) {
        WaitDetail waitDetail = waitingforList.get(0);
        if (waitDetail.myUserId == userId && waitDetail.isChiTing) {
            // waitingforList.remove(waitDetail);
            waitingforList.clear();
        } else {
            return ErrorCode.NOT_TURN;
        }
    }
    OperateReqResp operateReqResp = new OperateReqResp();
    operateReqResp.setOperateType(OperateReqResp.type_chi_ting);
    operateReqResp.setUserId(userId);
    ResponseVo vo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_OTHER_OPERATE, operateReqResp);
    // 通知其他玩家听
    MsgSender.sendMsg2Player(vo, users);
    // 回放
    replay.getOperate().add(operateReqResp);
    // 吃
    playerCardsInfo.chi(disCard, one, two);
    // 吃完只能听
    turnId = userId;
    // 通知客户端 操作
    OperateResp operateResp = new OperateResp();
    operateResp.setIsCanTing(true);
    operateResp.setIsCanGang(false);
    ResponseVo operateVo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_OPERATE, operateResp);
    MsgSender.sendMsg2Player(operateVo, userId);
    this.disCard = null;
    // 自己将能做的处理
    playerCardsInfo.canBeChi = false;
    playerCardsInfo.canBeTing = true;
    playerCardsInfo.canBeGang = false;
    return 0;
}
Also used : ResponseVo(com.code.server.constant.response.ResponseVo)

Example 85 with ResponseVo

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

the class GameInfo method chupai.

/**
 * 出牌
 *
 * @param userId
 * @param card
 */
public int chupai(long userId, String card) {
    // 出牌的玩家
    PlayerCardsInfoMj chupaiPlayerCardsInfo = playerCardsInfos.get(userId);
    if (this.turnId != userId) {
        return ErrorCode.CAN_NOT_PLAYCARD;
    }
    if (!chupaiPlayerCardsInfo.checkPlayCard(card)) {
        return ErrorCode.CAN_NOT_PLAYCARD;
    }
    // 上个出牌的人
    this.lastPlayUserId = userId;
    // 上个操作的人
    lastOperateUserId = userId;
    // 出的牌
    this.disCard = card;
    chupaiPlayerCardsInfo.chupai(card);
    // 通知其他玩家出牌信息
    PlayCardResp playCardResp = new PlayCardResp();
    playCardResp.setUserId(userId);
    playCardResp.setCard(this.disCard);
    ResponseVo vo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_PLAY_CARD, playCardResp);
    MsgSender.sendMsg2Player(vo, users);
    // 回放 出牌
    OperateReqResp operateReqResp = new OperateReqResp();
    operateReqResp.setCard(card);
    operateReqResp.setUserId(userId);
    operateReqResp.setOperateType(OperateReqResp.type_play);
    replay.getOperate().add(operateReqResp);
    // 其他人能做的操作
    for (Map.Entry<Long, PlayerCardsInfoMj> entry : playerCardsInfos.entrySet()) {
        OperateResp operateResp = new OperateResp();
        // 其他玩家的处理 碰杠等 如果有加入等待列表(要等待这些玩家"过")
        if (userId != entry.getKey()) {
            // 通知其他玩家出了什么牌 自己能有什么操作
            PlayerCardsInfoMj playerCardsInfo = entry.getValue();
            boolean isCanGang = playerCardsInfo.isCanGangAddThisCard(card);
            boolean isCanPeng = playerCardsInfo.isCanPengAddThisCard(card);
            boolean isCanHu;
            if (isHasGuoHu() && playerCardsInfo.isGuoHu()) {
                isCanHu = false;
            } else {
                isCanHu = playerCardsInfo.isCanHu_dianpao(card);
            }
            boolean isCanChi = playerCardsInfo.isHasChi(card);
            boolean isCanChiTing = playerCardsInfo.isCanChiTing(card);
            boolean isCanPengTing = playerCardsInfo.isCanPengTing(card);
            // 设置返回结果
            operateResp.setCanBeOperate(isCanChi, isCanPeng, isCanGang, false, isCanHu, isCanChiTing, isCanPengTing);
            // 设置自己能做的操作
            playerCardsInfo.setCanBeOperate(isCanChi, isCanPeng, isCanGang, false, isCanHu, isCanChiTing, isCanPengTing);
            boolean isWait = isCanGang || isCanPeng || isCanHu || isCanChi || isCanChiTing || isCanPengTing;
            if (isWait) {
                this.waitingforList.add(new WaitDetail(entry.getKey(), isCanHu, isCanGang, isCanPeng, isCanChi, isCanChiTing, isCanPengTing));
            }
        }
        // 可能的操作
        ResponseVo OperateVo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_OPERATE, operateResp);
        MsgSender.sendMsg2Player(OperateVo, entry.getKey());
    }
    resetCanBeOperate(chupaiPlayerCardsInfo);
    // 如果等待列表为空 就轮到下个人摸牌
    if (this.waitingforList.size() == 0) {
        long nextId = nextTurnId(turnId);
        mopai(nextId, "userId : " + userId + " 出牌");
    } else {
        // todo 一炮多响
        if (this.room.isYipaoduoxiang && waitingforList.stream().filter(waitDetail -> waitDetail.isHu).count() >= 2) {
            handleYiPaoDuoXiang();
        } else {
            // 比较
            compare(waitingforList);
        }
    }
    return 0;
}
Also used : ResponseVo(com.code.server.constant.response.ResponseVo) java.util(java.util) GameOfResult(com.code.server.constant.response.GameOfResult) UserOfResult(com.code.server.constant.response.UserOfResult) RoomManager(com.code.server.game.room.service.RoomManager) com.code.server.game.mahjong.response(com.code.server.game.mahjong.response) SpringUtil(com.code.server.util.SpringUtil) Game(com.code.server.game.room.Game) Collectors(java.util.stream.Collectors) KafkaMsgKey(com.code.server.constant.kafka.KafkaMsgKey) IdWorker(com.code.server.util.IdWorker) Logger(org.apache.log4j.Logger) IKafaTopic(com.code.server.constant.kafka.IKafaTopic) MsgProducer(com.code.server.kafka.MsgProducer) MsgSender(com.code.server.game.room.kafka.MsgSender) 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