use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameInfoHasChi 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;
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameInfoNZZ 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 GameInfoNZZ method chupai.
/**
* 出牌
*
* @param userId
* @param card
*/
@Override
public int chupai(long userId, String card) {
if (isAlreadyHu) {
return ErrorCode.CAN_PLAYCARD_IS_HU;
}
System.out.println("出牌的人 = " + userId);
// 出牌的玩家
PlayerCardsInfoNZZ chupaiPlayerCardsInfo = (PlayerCardsInfoNZZ) playerCardsInfos.get(userId);
if (this.turnId != userId) {
return ErrorCode.CAN_NOT_PLAYCARD;
}
if (!chupaiPlayerCardsInfo.checkPlayCard(card)) {
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);
// 回放 出牌
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()) {
// 通知其他玩家出了什么牌 自己能有什么操作
PlayerCardsInfoNZZ playerCardsInfo = (PlayerCardsInfoNZZ) entry.getValue();
boolean isCanGang = playerCardsInfo.isCanGangAddThisCard(card);
boolean isCanPeng;
boolean isCanHu;
// 如果上一次操作为过,这一轮不能再碰和胡
if (!noCanHuList.contains(playerCardsInfo.getUserId())) {
isCanHu = playerCardsInfo.isCanHu_dianpao(card);
} else {
isCanHu = false;
}
// 同一张牌只能碰一次
if (noCanPengList.keySet().contains(playerCardsInfo.getUserId()) && noCanPengList.get(playerCardsInfo.getUserId()).contains(CardTypeUtil.cardType.get(disCard))) {
isCanPeng = false;
} else {
isCanPeng = playerCardsInfo.isCanPengAddThisCard(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);
System.out.println("======= waiting list : " + waitingforList.size());
// 如果等待列表为空 就轮到下个人摸牌
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 GameInfoNZZ method doChi.
protected void doChi(PlayerCardsInfoMj playerCardsInfo, long userId, String one, String two) {
deleteDisCard(lastPlayUserId, disCard);
List<String> chiCards = new ArrayList<>();
chiCards.add(one);
chiCards.add(disCard);
chiCards.add(two);
OperateReqResp operateReqResp = new OperateReqResp();
operateReqResp.setOperateType(OperateReqResp.type_chi);
operateReqResp.setUserId(userId);
operateReqResp.setChiCards(chiCards);
operateReqResp.setFromUserId(lastPlayUserId);
ResponseVo vo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_OTHER_OPERATE, operateReqResp);
// 通知其他玩家听
MsgSender.sendMsg2Player(vo, users);
// 吃
playerCardsInfo.chi(disCard, one, two);
// 吃完能听,杠,不能胡
// 多一张牌
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.canBeChi = false;
playerCardsInfo.canBeTing = isCanTing;
playerCardsInfo.canBeGang = isCanGang;
playerCardsInfo.canBeHu = false;
resetOtherOperate(userId);
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameInfoNZZ method doChiTing.
protected void doChiTing(PlayerCardsInfoMj playerCardsInfo, long userId, String one, String two) {
deleteDisCard(lastPlayUserId, disCard);
List<String> chiCards = new ArrayList<>();
chiCards.add(one);
chiCards.add(disCard);
chiCards.add(two);
OperateReqResp operateReqResp = new OperateReqResp();
operateReqResp.setOperateType(OperateReqResp.type_chi_ting);
operateReqResp.setUserId(userId);
operateReqResp.setChiCards(chiCards);
operateReqResp.setFromUserId(lastPlayUserId);
ResponseVo vo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_OTHER_OPERATE, operateReqResp);
// 通知其他玩家听
MsgSender.sendMsg2Player(vo, users);
// 吃
playerCardsInfo.chi(disCard, one, two);
// 吃完只能听
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.canBeChi = false;
playerCardsInfo.canBeTing = true;
playerCardsInfo.canBeChiTing = false;
playerCardsInfo.canBeGang = false;
resetOtherOperate(userId);
}
Aggregations