use of com.code.server.util.timer.TimerNode in project summer by foxsugar.
the class RoomCow method createCowRoom.
public static int createCowRoom(long userId, int gameNumber, int personNumber, int multiple, String gameType, String roomType, boolean isAA, boolean isJoin) throws DataNotFoundException {
RoomCow room = getRoomInstance(roomType);
room.personNumber = personNumber;
room.roomId = getRoomIdStr(genRoomId());
room.createUser = userId;
room.gameType = gameType;
room.roomType = roomType;
room.isAA = isAA;
room.isCreaterJoin = isJoin;
room.multiple = multiple;
room.bankerId = userId;
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", "createCowRoom", room.toVo(userId)), userId);
return 0;
}
use of com.code.server.util.timer.TimerNode in project summer by foxsugar.
the class RoomDouDiZhu method createRoom.
public static int createRoom(long userId, int gameNumber, int multiple, String gameType, String roomType, boolean isAA, boolean isJoin, boolean showChat, String clubId, String clubRoomModel) throws DataNotFoundException {
RoomDouDiZhu room = getRoomInstance(roomType);
room.personNumber = PERSONNUM;
room.roomId = getRoomIdStr(genRoomId());
room.createUser = userId;
room.gameType = gameType;
room.roomType = roomType;
room.isAA = isAA;
room.isCreaterJoin = isJoin;
room.showChat = showChat;
room.setClubId(clubId);
room.setClubRoomModel(clubRoomModel);
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());
// todo 删除房间
return ErrorCode.CANNOT_JOIN_ROOM_NO_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", "createRoom", room.toVo(userId)), userId);
return 0;
}
Aggregations