use of com.code.server.game.poker.config.ServerConfig in project summer by foxsugar.
the class PokerApplication method main.
public static void main(String[] args) throws RegisterFailedException, IOException {
SpringApplication.run(PokerApplication.class, args);
ServerConfig serverConfig = SpringUtil.getBean(ServerConfig.class);
// 加载数据
DataManager.initData(serverConfig.getDataFile());
// 注册
RedisManager.getGameRedisService().register(serverConfig.getServerType(), serverConfig.getServerId());
// timer
ThreadPool.execute(GameTimer.getInstance()::fire);
// 心跳
GameTimer.addTimerNode(new TimerNode(System.currentTimeMillis(), IConstant.SECOND_5, true, () -> RedisManager.getGameRedisService().heart(serverConfig.getServerId())));
// 机器人线程
RobotManager robotManager = RobotManager.getInstance();
// 添加斗地主的机器人
robotManager.addRobot(new DouDiZhuGoldRobot());
robotManager.addRobot(new CowRobot());
robotManager.addRobot(new TTZRobot());
ThreadPool.getInstance().executor.execute(robotManager);
// MsgConsumer.startAConsumer("gameService", serverConfig.getServerId(), MsgDispatch::dispatch);
// MsgConsumer.startAConsumer("reconnService", serverConfig.getServerId(), MsgDispatch::dispatch);
// MsgConsumer.startAConsumer("pokerRoomService", serverConfig.getServerId(), MsgDispatch::dispatch);
// MsgConsumer.startAConsumer("roomService", serverConfig.getServerId(), RoomMsgDispatch::dispatch);
}
use of com.code.server.game.poker.config.ServerConfig in project summer by foxsugar.
the class RoomDouDiZhuGold method joinGoldRoom.
/*public static String getRoomIdStr() {
return System.currentTimeMillis()+"" + random.nextInt(999999);
}*/
// 金币场加入房间
public static int joinGoldRoom(long userId, Double goldRoomType, String roomType, String gameType) throws DataNotFoundException {
if (RedisManager.getUserRedisService().getRoomId(userId) != null) {
return ErrorCode.CANNOT_CREATE_ROOM_USER_HAS_IN_ROOM;
}
if (RedisManager.getUserRedisService().getUserMoney(userId) < needMoney.get(goldRoomType)) {
return ErrorCode.CANNOT_JOIN_ROOM_NO_MONEY;
}
Room nullRoom = RoomManager.getNullRoom(goldRoomType);
if (nullRoom == null) {
switch(roomType) {
case "2":
nullRoom = new RoomDouDiZhuGold();
break;
case "3":
nullRoom = new RoomDouDiZhuPlus();
break;
default:
nullRoom = new RoomDouDiZhuPlus();
break;
}
nullRoom.setPersonNumber(PERSONNUM);
nullRoom.setRoomId(getRoomIdStr(genRoomId()));
nullRoom.setCreateUser(userId);
nullRoom.setGoldRoomType(goldRoomType);
nullRoom.setGameType(GAMETYPE_LONGQI);
nullRoom.setRoomType(roomType);
nullRoom.setAA(true);
nullRoom.setCreaterJoin(true);
nullRoom.init(1, -1);
nullRoom.setCreateType(1);
}
nullRoom.joinRoom(userId, true);
/*ArrayList<Long> userslist = new ArrayList<>();
userslist.add(userId);
HashMap<Long, Integer> userStatusMap = new HashMap<>();
userStatusMap.put(userId, 0);
HashMap<Long, Double> userScoresMap = new HashMap<>();
userScoresMap.put(userId, 0D);
HashMap<Long, RoomStatistics> roomStatisticsMap = new HashMap<>();
roomStatisticsMap.put(userId, new RoomStatistics(userId));
room.setUsers(userslist);
room.setUserStatus(userStatusMap);
room.setUserScores(userScoresMap);
room.setRoomStatisticsMap(roomStatisticsMap);*/
// room.getReady(userId);//准备
// list.add(room);
ServerConfig serverConfig = SpringUtil.getBean(ServerConfig.class);
RoomManager.addRoom(nullRoom.getRoomId(), "" + serverConfig.getServerId(), nullRoom);
IdWorker idWorker = new IdWorker(serverConfig.getServerId(), 0);
nullRoom.setUuid(idWorker.nextId());
MsgSender.sendMsg2Player(new ResponseVo("pokerRoomService", "joinGoldRoom", nullRoom.toVo(userId)), userId);
return 0;
}
use of com.code.server.game.poker.config.ServerConfig in project summer by foxsugar.
the class RoomGuessCar method createRoom.
public static int createRoom(long userId, int chip, String gameType, String roomType) {
// 身上的钱够不够
if (RedisManager.getUserRedisService().getUserMoney(userId) < chip) {
return ErrorCode.NOT_HAVE_MORE_MONEY;
}
RoomGuessCar roomGuessCar = new RoomGuessCar();
roomGuessCar.personNumber = PERSONNUM;
roomGuessCar.roomId = getRoomIdStr(genRoomId());
roomGuessCar.createUser = userId;
roomGuessCar.gameType = gameType;
roomGuessCar.roomType = roomType;
roomGuessCar.bankerId = userId;
ServerConfig serverConfig = SpringUtil.getBean(ServerConfig.class);
RoomManager.addRoom(roomGuessCar.roomId, "" + serverConfig.getServerId(), roomGuessCar);
// 扣掉
RedisManager.getUserRedisService().addUserMoney(userId, -chip);
roomGuessCar.bankerScore = chip;
roomGuessCar.chip = chip;
IdWorker idWorker = new IdWorker(serverConfig.getServerId(), 0);
roomGuessCar.setUuid(idWorker.nextId());
MsgSender.sendMsg2Player(new ResponseVo("pokerRoomService", "createGuessRoom", roomGuessCar.toVo(userId)), userId);
roomGuessCar.joinRoom(userId, true);
return 0;
}
use of com.code.server.game.poker.config.ServerConfig 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.game.poker.config.ServerConfig in project summer by foxsugar.
the class RoomHitGoldFlower method createHitGoldFlowerRoom.
public static int createHitGoldFlowerRoom(long userId, int gameNumber, int personNumber, int cricleNumber, int multiple, int caiFen, int menPai, String gameType, String roomType, boolean isAA, boolean isJoin) throws DataNotFoundException {
RoomHitGoldFlower 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.caiFen = caiFen;
room.menPai = menPai;
room.bankerId = userId;
room.cricleNumber = cricleNumber;
room.init(gameNumber, multiple);
int code = room.joinRoom(userId, isJoin);
if (code != 0) {
return code;
}
// 代建房 定时解散
if (!isJoin) {
// 给代建房 开房者 扣钱
if (RedisManager.getUserRedisService().getUserMoney(userId) < room.createNeedMoney) {
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", "createHitGoldFlowerRoom", room.toVo(userId)), userId);
return 0;
}
Aggregations