use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameUserService method shareWX.
public int shareWX(KafkaMsgKey msgKey, String game) {
UserBean userBean = RedisManager.getUserRedisService().getUserBean(msgKey.getUserId());
if (userBean == null) {
return ErrorCode.YOU_HAVE_NOT_LOGIN;
}
long lastShareTime = userBean.getUserInfo().getLastShareTime();
long now = System.currentTimeMillis();
if (DateUtil.isSameDate(lastShareTime, now)) {
return ErrorCode.CANNOT_SHARE;
}
double money = getShareMoney(game);
int shareCount = userBean.getUserInfo().getShareWXCount();
// 加钱
double nowMoney = RedisManager.getUserRedisService().addUserMoney(msgKey.getUserId(), money);
userBean.setMoney(nowMoney);
// 分享时间
userBean.getUserInfo().setLastShareTime(now);
// 分享次数
userBean.getUserInfo().setShareWXCount(shareCount + 1);
// 保存
RedisManager.getUserRedisService().updateUserBean(userBean.getId(), userBean);
// 分享记录
Charge charge = new Charge();
charge.setOrderId("" + IdWorker.getDefaultInstance().nextId());
charge.setUsername(userBean.getUsername());
charge.setMoney(money);
charge.setMoney_point(money);
charge.setCreatetime(new Date());
charge.setCallbacktime(new Date());
charge.setRecharge_source("" + IChargeType.SHARE);
charge.setStatus(1);
chargeService.save(charge);
ResponseVo vo = new ResponseVo("userService", "shareWX", 0);
sendMsg(msgKey, vo);
return 0;
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class UserServiceMsgDispatch method dispatchMsg.
public void dispatchMsg(KafkaMsgKey msgKey, JsonNode params) {
String service = params.get("service").asText();
String method = params.get("method").asText();
JsonNode node = params.get("params");
int rtn = dispatchUserService(msgKey, method, node, params);
if (rtn != 0) {
ResponseVo vo = new ResponseVo(service, method, rtn);
kafkaMsgProducer.send2Partition(IKafaTopic.GATE_TOPIC, msgKey.getPartition(), "" + msgKey.getUserId(), vo);
}
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameInfo method chi.
public int chi(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;
}
if (disCard == null || !playerCardsInfo.canBeChi) {
return ErrorCode.CAN_NOT_CHI;
}
// 从等待列表删除
// if (waitingforList.size() > 0) {
WaitDetail waitDetail = waitingforList.get(0);
if (waitDetail != null && waitDetail.myUserId == userId && waitDetail.isChi) {
waitingforList.clear();
} else {
return ErrorCode.NOT_TURN;
}
// }
OperateReqResp operateReqResp = new OperateReqResp();
operateReqResp.setOperateType(OperateReqResp.type_chi);
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);
// 吃完能听,杠,不能胡
// 多一张牌
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;
return 0;
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameInfo method fapai.
/**
* 发牌
*/
public void fapai() {
// 打乱顺序
Collections.shuffle(remainCards);
for (int i = 0; i < playerSize; i++) {
PlayerCardsInfoMj playerCardsInfo = PlayerCardsInfoFactory.getInstance(room);
playerCardsInfo.setGameInfo(this);
long userId = users.get(i);
// 设置id
playerCardsInfo.setUserId(userId);
List<String> playerCards = new ArrayList<>();
// 发牌
for (int j = 0; j < cardSize; j++) {
playerCards.add(remainCards.remove(0));
}
// 初始化
playerCardsInfo.init(playerCards);
// 放进map
playerCardsInfos.put(userId, playerCardsInfo);
// 发牌状态通知
HandCardsResp resp = new HandCardsResp();
resp.setCards(playerCards);
ResponseVo vo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_GET_HAND_CARDS, resp);
MsgSender.sendMsg2Player(vo, userId);
}
doAfterFapai();
// 回放的牌信息
for (PlayerCardsInfoMj playerCardsInfoMj : playerCardsInfos.values()) {
List<String> cs = new ArrayList<>();
cs.addAll(playerCardsInfoMj.getCards());
replay.getCards().put(playerCardsInfoMj.getUserId(), cs);
}
// 第一个人抓牌
mopai(firstTurn, "发牌");
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameInfo method sendResult.
/**
* 发送结果
*
* @param isHasWinner
* @param winnerId
* @param yipaoduoxiang
*/
protected void sendResult(boolean isHasWinner, Long winnerId, List<Long> yipaoduoxiang) {
ResultResp result = new ResultResp();
ResponseVo vo = new ResponseVo(ResponseType.SERVICE_TYPE_GAMELOGIC, ResponseType.METHOD_TYPE_RESULT, result);
if (isHasWinner) {
if (yipaoduoxiang == null) {
result.setWinnerId(winnerId);
} else {
result.setYipaoduoxiang(yipaoduoxiang);
}
result.setBaoCard(baoCard);
}
List<PlayerCardsResp> list = new ArrayList<>();
for (PlayerCardsInfoMj info : playerCardsInfos.values()) {
PlayerCardsResp resp = new PlayerCardsResp(info);
resp.setAllScore(room.getUserScores().get(info.getUserId()));
list.add(resp);
}
result.setUserInfos(list);
result.setLaZhuang(this.room.laZhuang);
result.setLaZhuangStatus(this.room.laZhuangStatus);
MsgSender.sendMsg2Player(vo, users);
// 回放
replay.setResult(result);
// 生成记录
genRecord();
}
Aggregations