Search in sources :

Example 6 with ServerConfig

use of com.code.server.game.poker.config.ServerConfig in project summer by foxsugar.

the class RoomGoldPaijiu method createGoldRoom.

public static int createGoldRoom(Long userId, String roomType, String gameType, int gameNumber, int isGold, int goldType) throws DataNotFoundException {
    RoomGoldPaijiu roomGoldPaijiu = new RoomGoldPaijiu();
    roomGoldPaijiu.setRoomId(Room.getRoomIdStr(Room.genRoomId()));
    roomGoldPaijiu.setRoomType(roomType);
    roomGoldPaijiu.setGameType(gameType);
    roomGoldPaijiu.setGameNumber(gameNumber);
    roomGoldPaijiu.setBankerId(userId);
    roomGoldPaijiu.setCreateUser(userId);
    roomGoldPaijiu.setPersonNumber(4);
    roomGoldPaijiu.setIsGold(isGold);
    roomGoldPaijiu.setGoldType(goldType);
    roomGoldPaijiu.init(gameNumber, 1);
    int code = roomGoldPaijiu.joinRoom(userId, true);
    if (code != 0) {
        return code;
    }
    ServerConfig serverConfig = SpringUtil.getBean(ServerConfig.class);
    RoomManager.addRoom(roomGoldPaijiu.getRoomId(), "" + serverConfig.getServerId(), roomGoldPaijiu);
    IdWorker idword = new IdWorker(serverConfig.getServerId(), 0);
    roomGoldPaijiu.setUuid(idword.nextId());
    MsgSender.sendMsg2Player(new ResponseVo("pokerRoomService", "createPaijiuGoldRoom", roomGoldPaijiu.toVo(userId)), userId);
    return 0;
}
Also used : ServerConfig(com.code.server.game.poker.config.ServerConfig) IdWorker(com.code.server.util.IdWorker) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 7 with ServerConfig

use of com.code.server.game.poker.config.ServerConfig in project summer by foxsugar.

the class RoomPaijiuByNotInRoom method createRoomNotInRoom.

public static int createRoomNotInRoom(long userId, String roomType, String gameType, Integer gameNumber, boolean isCreaterJoin) throws DataNotFoundException {
    RoomPaijiu roomPaijiu = new RoomPaijiu();
    roomPaijiu.setRoomId(Room.getRoomIdStr(Room.genRoomId()));
    roomPaijiu.setRoomType(roomType);
    roomPaijiu.setGameType(gameType);
    roomPaijiu.setGameNumber(gameNumber);
    roomPaijiu.setBankerId(0L);
    roomPaijiu.setCreateUser(userId);
    roomPaijiu.setPersonNumber(4);
    roomPaijiu.setCreaterJoin(isCreaterJoin);
    roomPaijiu.init(gameNumber, 1);
    // 代建房 定时解散
    if (!isCreaterJoin) {
        // 给代建房 开房者 扣钱
        if (RedisManager.getUserRedisService().getUserMoney(userId) < roomPaijiu.getCreateNeedMoney()) {
            RoomManager.removeRoom(roomPaijiu.getRoomId());
            return ErrorCode.CANNOT_JOIN_ROOM_NO_MONEY;
        }
        roomPaijiu.spendMoney();
        TimerNode prepareRoomNode = new TimerNode(System.currentTimeMillis(), IConstant.HOUR_1, false, roomPaijiu::dissolutionRoom);
        roomPaijiu.prepareRoomTimerNode = prepareRoomNode;
        GameTimer.addTimerNode(prepareRoomNode);
    }
    ServerConfig serverConfig = SpringUtil.getBean(ServerConfig.class);
    RoomManager.addRoom(roomPaijiu.getRoomId(), "" + serverConfig.getServerId(), roomPaijiu);
    IdWorker idword = new IdWorker(serverConfig.getServerId(), 0);
    roomPaijiu.setUuid(idword.nextId());
    MsgSender.sendMsg2Player(new ResponseVo("pokerRoomService", "createPaijiuRoomNotInRoom", roomPaijiu.toVo(userId)), userId);
    return 0;
}
Also used : ServerConfig(com.code.server.game.poker.config.ServerConfig) IdWorker(com.code.server.util.IdWorker) TimerNode(com.code.server.util.timer.TimerNode) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 8 with ServerConfig

use of com.code.server.game.poker.config.ServerConfig in project summer by foxsugar.

the class RoomPullMice method createRoom.

public static int createRoom(long userId, String roomType, String gameType, int gameNumber, int personNumber, boolean isJoin, int multiple, boolean hasWubuFeng) throws DataNotFoundException {
    RoomPullMice room = new RoomPullMice();
    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.setCanWuBuFeng(hasWubuFeng);
    room.init(gameNumber, multiple);
    // 假设最大局数是8局
    room.maxGameCount = gameNumber;
    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", "createPullMiceRoom", room.toVo(userId)), userId);
    return 0;
}
Also used : ServerConfig(com.code.server.game.poker.config.ServerConfig) IdWorker(com.code.server.util.IdWorker) TimerNode(com.code.server.util.timer.TimerNode) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 9 with ServerConfig

use of com.code.server.game.poker.config.ServerConfig 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;
}
Also used : ServerConfig(com.code.server.game.poker.config.ServerConfig) IdWorker(com.code.server.util.IdWorker) TimerNode(com.code.server.util.timer.TimerNode)

Example 10 with ServerConfig

use of com.code.server.game.poker.config.ServerConfig 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;
}
Also used : ServerConfig(com.code.server.game.poker.config.ServerConfig) IdWorker(com.code.server.util.IdWorker) TimerNode(com.code.server.util.timer.TimerNode) ResponseVo(com.code.server.constant.response.ResponseVo)

Aggregations

ServerConfig (com.code.server.game.poker.config.ServerConfig)10 IdWorker (com.code.server.util.IdWorker)9 ResponseVo (com.code.server.constant.response.ResponseVo)7 TimerNode (com.code.server.util.timer.TimerNode)7 UserOfRoom (com.code.server.constant.response.UserOfRoom)1 CowRobot (com.code.server.game.poker.cow.CowRobot)1 DouDiZhuGoldRobot (com.code.server.game.poker.doudizhu.DouDiZhuGoldRobot)1 RobotManager (com.code.server.game.poker.robot.RobotManager)1 TTZRobot (com.code.server.game.poker.tuitongzi.TTZRobot)1 Room (com.code.server.game.room.Room)1