use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameInfoSongYuan 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);
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class RoomTuiTongZi method createRoom.
public static int createRoom(long userId, String roomType, String gameType, int gameNumber, int personNumber, boolean isJoin, int multiple) throws DataNotFoundException {
RoomTuiTongZi room = getRoomInstance(roomType);
room.personNumber = personNumber;
room.roomId = getRoomIdStr(genRoomId());
room.createUser = userId;
room.gameType = gameType;
room.isCreaterJoin = isJoin;
room.multiple = multiple;
room.bankerId = userId;
room.roomType = roomType;
room.init(gameNumber, multiple);
int code = room.joinRoom(userId, isJoin);
if (code != 0) {
return code;
}
// 代建房 定时解散
if (!isJoin) {
// 给代建房 开房者 扣钱
if (RedisManager.getUserRedisService().getUserMoney(userId) < room.createNeedMoney) {
RoomManager.removeRoom(room.getRoomId());
return ErrorCode.CANNOT_CREATE_ROOM_MONEY;
}
room.spendMoney();
TimerNode prepareRoomNode = new TimerNode(System.currentTimeMillis(), IConstant.HOUR_1, false, room::dissolutionRoom);
room.prepareRoomTimerNode = prepareRoomNode;
GameTimer.addTimerNode(prepareRoomNode);
}
ServerConfig serverConfig = SpringUtil.getBean(ServerConfig.class);
RoomManager.addRoom(room.roomId, "" + serverConfig.getServerId(), room);
IdWorker idWorker = new IdWorker(serverConfig.getServerId(), 0);
room.setUuid(idWorker.nextId());
MsgSender.sendMsg2Player(new ResponseVo("pokerRoomService", "createTTZRoom", room.toVo(userId)), userId);
return 0;
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class CenterMsgService method getRoomClubByUser.
private static void getRoomClubByUser(String msg) {
JsonNode jsonNode = JsonUtil.readTree(msg);
Map<String, Object> map = JsonUtil.readValue(msg, new TypeReference<HashMap<String, Object>>() {
});
Map<String, Object> result = JsonUtil.readValue(msg, Map.class);
Long userId = jsonNode.path("userId").asLong();
List<String> clubs = ClubManager.getInstance().getUserClubs(userId);
map.put("clubs", clubs);
GameClubService.sendMsg2Player(new ResponseVo("roomService", "getRoomClubByUser", map), userId);
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameClubService method invite.
/**
* 邀请其他玩家
*
* @param msgKey
* @param clubId
* @param roomId
* @param inviteUser
* @return
*/
public int invite(KafkaMsgKey msgKey, String clubId, String roomId, String inviteUser, String roomModel, String name) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
Map<String, Object> result = new HashMap<>();
result.put("clubId", clubId);
result.put("roomId", roomId);
result.put("inviteUser", inviteUser);
result.put("roomModelInfo", getRoomModel(club, roomModel));
result.put("name", name);
msgProducer.send();
sendMsg2Player(new ResponseVo("clubService", "inviteUser", result), Long.valueOf(inviteUser));
sendMsg(msgKey, new ResponseVo("clubService", "invite", "ok"));
return 0;
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameClubService method setRoomModel.
/**
* 修改房间模式
*
* @param msgKey
* @param userId
* @param clubId
* @param roomModelId
* @param createCommand
* @param gameType
* @param gameNumber
* @param desc
* @return
*/
public int setRoomModel(KafkaMsgKey msgKey, long userId, String clubId, String roomModelId, String createCommand, String gameType, int gameNumber, String desc) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
if (club.getPresident() != userId) {
return ErrorCode.CLUB_NOT_PRESIDENT;
}
// 初始化 房间数据
initRoomData();
StaticDataProto.RoomData roomData = DataManager.data.getRoomDataMap().get(gameType);
if (roomData == null || !roomData.getMoneyMap().containsKey(gameNumber)) {
return ErrorCode.REQUEST_PARAM_ERROR;
}
JsonNode jsonNode = JsonUtil.readTree(createCommand);
String serviceName = jsonNode.path("service").asText();
// 设置创建命令
RoomModel roomModel = getRoomModel(club, roomModelId);
if (roomModel == null) {
return ErrorCode.REQUEST_PARAM_ERROR;
}
createCommand = setRoomModelCommand(createCommand, clubId, roomModel.getId());
roomModel.setCreateCommand(createCommand);
roomModel.setDesc(desc);
roomModel.setTime(System.currentTimeMillis());
roomModel.setMoney(roomData.getMoneyMap().get(gameNumber));
roomModel.setServiceName(serviceName);
sendMsg(msgKey, new ResponseVo("clubService", "setRoomModel", roomModel));
// 实例化房间
initRoomInstance(club);
return 0;
}
Aggregations