use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameInfoHM method mopai.
/**
* 摸牌
*
* @param userId
*/
protected void mopai(long userId, String... wz) {
System.err.println("摸牌===============================userId : " + userId);
noCanHuList.remove(userId);
PlayerCardsInfoMj playerCardsInfo = playerCardsInfos.get(userId);
playerCardsInfo.setGuoHu(false);
if (isHuangzhuang(playerCardsInfo)) {
handleHuangzhuang(userId);
return;
}
if (playerCardsInfo.isMoreOneCard()) {
if (wz.length > 0) {
logger.info("======1操作后的摸牌 : " + wz[0]);
}
logger.info("userId : " + userId + " ===1 more one card 抓牌时多一张牌");
logger.info("操作列表: " + playerCardsInfo.operateList.toString());
logger.info("所有操作: " + userOperateList.toString());
}
// 拿出一张
String card = getMoPaiCard(playerCardsInfo);
// 有换牌需求
// if (isTest && playerCardsInfo.nextNeedCard != -1) {
// String needCard = getCardByTypeFromRemainCards(playerCardsInfo.nextNeedCard);
// playerCardsInfo.nextNeedCard = -1;
// if (needCard != null) {
// card = needCard;
// remainCards.remove(needCard);
// } else {
// card = remainCards.remove(0);
// }
// } else {
// card = remainCards.remove(0);
// }
playerCardsInfo.mopai(card);
//
turnId = userId;
this.lastMoPaiUserId = userId;
lastOperateUserId = userId;
this.catchCard = card;
// 把摸到的牌 推给摸牌的玩家
int remainSize = remainCards.size();
for (long user : users) {
GetCardResp getCardResp = new GetCardResp();
getCardResp.setRemainNum(remainSize);
getCardResp.setUserId(userId);
if (user == userId) {
getCardResp.setCard(card);
}
ResponseVo responseVo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_GET_CARD, getCardResp);
MsgSender.sendMsg2Player(responseVo, user);
// 能做的操作全置成不能
PlayerCardsInfoMj other = playerCardsInfos.get(user);
resetCanBeOperate(other);
}
boolean isCanGang = playerCardsInfo.isHasGang();
// 多一张
boolean isCanTing = playerCardsInfo.isCanTing(playerCardsInfo.cards);
boolean isCanHu = playerCardsInfo.isCanHu_zimo(catchCard);
// 能做的操作
playerCardsInfo.setCanBeGang(isCanGang);
playerCardsInfo.setCanBePeng(false);
playerCardsInfo.setCanBeHu(isCanHu);
playerCardsInfo.setCanBeTing(isCanTing);
OperateResp resp = new OperateResp();
resp.setIsCanGang(isCanGang);
resp.setIsCanHu(isCanHu);
resp.setIsCanTing(isCanTing);
// 回放 抓牌
OperateReqResp operateReqResp = new OperateReqResp();
operateReqResp.setCard(card);
operateReqResp.setUserId(userId);
operateReqResp.setOperateType(OperateReqResp.type_mopai);
replay.getOperate().add(operateReqResp);
// 可能的操作
ResponseVo OperateResponseVo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_OPERATE, resp);
MsgSender.sendMsg2Player(OperateResponseVo, userId);
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameInfoHasChi method pushTing.
private void pushTing(int userId) {
// 通知其他玩家
OperateReqResp operateReqResp = new OperateReqResp();
operateReqResp.setOperateType(OperateReqResp.type_peng_ting);
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);
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameInfoHasChi 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);
// 其他人能做的操作
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;
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameInfoHasChi method doGang.
protected void doGang(PlayerCardsInfoMj playerCardsInfo, long userId) {
OperateReqResp operateReqResp = new OperateReqResp();
operateReqResp.setOperateType(OperateReqResp.type_gang);
ResponseVo vo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_OTHER_OPERATE, operateReqResp);
// 删除弃牌
deleteDisCard(lastPlayUserId, disCard);
playerCardsInfo.gang_discard(room, this, lastPlayUserId, disCard);
// 谁出的牌
operateReqResp.setFromUserId(lastPlayUserId);
operateReqResp.setUserId(userId);
operateReqResp.setCard(disCard);
operateReqResp.setIsMing(true);
// 通知所有人有杠
MsgSender.sendMsg2Player(vo, users);
mopai(userId, "杠后摸牌 点杠");
turnId = userId;
this.disCard = null;
lastOperateUserId = userId;
resetOtherOperate(userId);
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameInfoHasChi method doPengTing.
protected void doPengTing(PlayerCardsInfoMj playerCardsInfo, long userId) {
playerCardsInfo.peng(disCard, lastPlayUserId);
lastOperateUserId = userId;
// 删除弃牌
deleteDisCard(lastPlayUserId, disCard);
// 通知其他玩家
OperateReqResp operateReqResp = new OperateReqResp();
operateReqResp.setOperateType(OperateReqResp.type_peng_ting);
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);
// 碰完能听,杠,不能胡
turnId = userId;
// 通知客户端 操作
OperateResp operateResp = new OperateResp();
// 客户端特殊处理
operateResp.setIsCanTing(false);
operateResp.setIsCanGang(false);
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 = true;
playerCardsInfo.canBePengTing = false;
playerCardsInfo.canBeGang = false;
resetOtherOperate(userId);
}
Aggregations