Search in sources :

Example 26 with ResponseVo

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

the class GameInfoSongYuan method pushDan.

private void pushDan(long userId, boolean isMing) {
    for (long id : users) {
        OperateReqResp operateReqResp = new OperateReqResp();
        operateReqResp.setUserId(userId);
        operateReqResp.setOperateType(OperateReqResp.type_dan);
        operateReqResp.setIsMing(isMing);
        // if (id != userId && !isMing) {//不是自己并且是暗的
        // operateReqResp.setCard(null);
        // } else {
        operateReqResp.setCard(baoCard);
        // }
        ResponseVo vo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_OTHER_OPERATE, operateReqResp);
        MsgSender.sendMsg2Player(vo, id);
    }
}
Also used : ResponseVo(com.code.server.constant.response.ResponseVo)

Example 27 with ResponseVo

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

the class GameInfoSongYuan method doPeng.

protected void doPeng(PlayerCardsInfoMj playerCardsInfo, long userId) {
    playerCardsInfo.peng(disCard, lastPlayUserId);
    lastOperateUserId = userId;
    // 删除弃牌
    deleteDisCard(lastPlayUserId, disCard);
    // 通知其他玩家
    OperateReqResp operateReqResp = new OperateReqResp();
    operateReqResp.setOperateType(OperateReqResp.type_peng);
    operateReqResp.setCard(disCard);
    operateReqResp.setFromUserId(lastPlayUserId);
    operateReqResp.setUserId(userId);
    // 通知其他人
    ResponseVo vo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_OTHER_OPERATE, operateReqResp);
    MsgSender.sendMsg2Player(vo, users);
    // 碰完能听,杠,不能胡
    // 多一张牌
    boolean isCanTing = playerCardsInfo.isCanTing(playerCardsInfo.cards);
    boolean isCanGang = playerCardsInfo.isHasGang();
    turnId = userId;
    // 通知客户端 操作
    OperateResp operateResp = new OperateResp();
    operateResp.setIsCanTing(isCanTing);
    operateResp.setIsCanGang(isCanGang);
    ResponseVo operateVo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_OPERATE, operateResp);
    MsgSender.sendMsg2Player(operateVo, userId);
    this.disCard = null;
    // 自己将能做的处理
    playerCardsInfo.canBePeng = false;
    playerCardsInfo.canBeTing = isCanTing;
    playerCardsInfo.canBeGang = isCanGang;
    playerCardsInfo.canBeHu = false;
    resetOtherOperate(userId);
}
Also used : ResponseVo(com.code.server.constant.response.ResponseVo)

Example 28 with ResponseVo

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

the class GameInfoSongYuan method chuPai_ting.

private int chuPai_ting(long userId, String card) {
    // 出牌的玩家
    PlayerCardsInfoMj chupaiPlayerCardsInfo = playerCardsInfos.get(userId);
    if (this.turnId != userId || isAlreadyHu) {
        return ErrorCode.CAN_NOT_PLAYCARD;
    }
    playCards.add(card);
    // 上个出牌的人
    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);
    // 是否换宝
    if (changeBaoSize > 0 && baoCard != null && getPlayCardNum(baoCard) >= 3) {
        changeBao();
        CheckInfo checkInfo = new CheckInfo();
        checkZhiDui(chupaiPlayerCardsInfo, checkInfo);
        if (checkInfo.huUser != -1) {
            handleHu(playerCardsInfos.get(checkInfo.huUser));
            return 0;
        }
    }
    // 其他人能做的操作
    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 = playerCardsInfo.isCanHu_dianpao(card);
            boolean isNext = nextTurnId(chupaiPlayerCardsInfo.getUserId()) == playerCardsInfo.getUserId();
            boolean isCanChi = isNext && 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));
                add2WaitingList(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) {
        pushAllPass();
        long nextId = nextTurnId(turnId);
        mopai(nextId, "听后出牌");
    } else {
        // 比较
        compare(waitingforList);
    }
    return 0;
}
Also used : ResponseVo(com.code.server.constant.response.ResponseVo)

Example 29 with ResponseVo

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

the class GameInfoSongYuan method gang.

/**
 * 杠
 *
 * @param userId
 */
public int gang(long userId, String card) {
    if (isAlreadyHu) {
        return ErrorCode.CAN_NOT_GANG;
    }
    PlayerCardsInfoMj playerCardsInfo = playerCardsInfos.get(userId);
    if (playerCardsInfo == null) {
        return ErrorCode.USER_ERROR;
    }
    OperateReqResp operateReqResp = new OperateReqResp();
    operateReqResp.setOperateType(OperateReqResp.type_gang);
    ResponseVo vo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_OTHER_OPERATE, operateReqResp);
    if (lastOperateUserId == userId) {
        // 杠手里的牌
        if ("".equals(card)) {
            System.err.println("=======================杠牌时 没传数据========");
        }
        if (!playerCardsInfo.isCanGangThisCard(card)) {
            return ErrorCode.CAN_NOT_GANG;
        }
        int gangType = CardTypeUtil.getTypeByCard(card);
        boolean isMing = playerCardsInfo.getPengType().containsKey(gangType);
        // 自摸不吃牌
        operateReqResp.setFromUserId(userId);
        operateReqResp.setUserId(userId);
        operateReqResp.setCard(card);
        operateReqResp.setIsMing(isMing);
        // 通知所有人有杠
        MsgSender.sendMsg2Player(vo, users);
        if (isMing) {
            for (Map.Entry<Long, PlayerCardsInfoMj> entry : playerCardsInfos.entrySet()) {
                OperateResp operateResp = new OperateResp();
                // 其他玩家的处理 碰杠等 如果有加入等待列表(要等待这些玩家"过")
                if (userId != entry.getKey()) {
                    // 通知其他玩家出了什么牌 自己能有什么操作
                    PlayerCardsInfoMj playerOther = entry.getValue();
                    boolean isCanHu = playerOther.isCanHu_dianpao(card);
                    // 设置返回结果
                    operateResp.setCanBeOperate(false, false, false, false, isCanHu, false, false);
                    // 设置自己能做的操作
                    playerOther.setCanBeOperate(false, false, false, false, isCanHu, false, false);
                    boolean isWait = isCanHu;
                    if (isWait) {
                        add2WaitingList(entry.getKey(), isCanHu, false, false, false, false, false);
                    }
                }
                // 可能的操作
                ResponseVo OperateVo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_OPERATE, operateResp);
                MsgSender.sendMsg2Player(OperateVo, entry.getKey());
            }
        }
        if (this.waitingforList.size() == 0) {
            doGang_hand(playerCardsInfo, userId, card);
        } else {
            // 排序
            compare(waitingforList);
            // 出现截杠胡
            this.beJieGangUser = userId;
            this.jieGangHuCard = card;
        }
    } else {
        if (disCard == null) {
            return ErrorCode.CAN_NOT_GANG;
        }
        boolean isCanGang = playerCardsInfo.isCanGangAddThisCard(disCard);
        if (!isCanGang) {
            return ErrorCode.CAN_NOT_GANG;
        }
        handleWait(userId, WaitDetail.gangPoint);
        lastOperateUserId = userId;
    }
    return 0;
}
Also used : ResponseVo(com.code.server.constant.response.ResponseVo)

Example 30 with ResponseVo

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

the class GameInfoSongYuan method pushAllPass.

private void pushAllPass() {
    Map map = new HashMap();
    map.put("isAllPass", true);
    map.put("lastPlayUser", lastPlayUserId);
    ResponseVo responseVo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_ALL_PASS, map);
    MsgSender.sendMsg2Player(responseVo, users);
}
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