优化机器人
parent
652d2963e7
commit
838ea4b82a
|
|
@ -39,8 +39,10 @@ public class Config {
|
|||
/** 游戏服务器主机地址 */
|
||||
/*public static final String GAME_SERVER_HOST = "8.134.76.43";
|
||||
public static final String DEFAULT_GROUP_ID = "762479";*/
|
||||
/*public static final String DEFAULT_GROUP_ID = "383709";
|
||||
public static final String GAME_SERVER_HOST = "8.163.97.101";*/
|
||||
public static final String DEFAULT_GROUP_ID = "383709";
|
||||
public static final String GAME_SERVER_HOST = "8.163.97.101";
|
||||
public static final String GAME_SERVER_HOST = "8.138.6.129";
|
||||
|
||||
/** 游戏服务器端口 */
|
||||
public static final String GAME_SERVER_PORT = "26421";
|
||||
|
|
|
|||
|
|
@ -406,10 +406,14 @@ public class RobotConnectionManager {
|
|||
HuNanHongZhong huNanHongZhong = getHuNanHongZhongInstance(connecId);
|
||||
Jedis jedis0 = Redis.use().getJedis();
|
||||
Jedis jedis2 = Redis.use("group1_db2").getJedis();
|
||||
Jedis jedis3 = Redis.use("group1_db3").getJedis();
|
||||
try {
|
||||
//红中麻将 机器人处理事件
|
||||
//初始化手牌
|
||||
if ("811".equalsIgnoreCase(command)) {
|
||||
//设置机器人占用标记
|
||||
jedis3.set("wokelock" + robotUser.getRobotId(), String.valueOf(1));
|
||||
jedis3.expire("wokelock" + robotUser.getRobotId(), 900);
|
||||
robotUser.setStatus(ROBOTEventType.ROBOT_INTOROOM_WORKING);
|
||||
huNanHongZhong.cardInHead(command, message, client);
|
||||
//处理完协议后保存到Redis
|
||||
|
|
@ -454,6 +458,7 @@ public class RobotConnectionManager {
|
|||
if (type == 1) {
|
||||
markPlayerRobot(robotUser);
|
||||
}
|
||||
jedis3.expire("wokelock" + robotUser.getRobotId(), 2);
|
||||
}
|
||||
ITObject params = TObject.newInstance();
|
||||
params.putString("session", client.getSession());
|
||||
|
|
@ -564,18 +569,38 @@ public class RobotConnectionManager {
|
|||
}
|
||||
}, 6, TimeUnit.SECONDS);
|
||||
}
|
||||
//解散房间投票事件
|
||||
else if ("2006".equalsIgnoreCase(command)) {
|
||||
ITObject params = TObject.newInstance();
|
||||
params.putBoolean("result", false);
|
||||
int delaySeconds = ThreadLocalRandom.current().nextInt(3, 8);
|
||||
log.debug("执行延迟{}秒", delaySeconds);
|
||||
Thread.sleep(delaySeconds * 1000);
|
||||
client.send("1008", params, response -> {
|
||||
log.info("机器人解决解散,robotId: {" + robotId + "}");
|
||||
});
|
||||
}
|
||||
//玩家解散房间
|
||||
else if ("2005".equalsIgnoreCase(command)) {
|
||||
EXGameController.removeRobotRoomInfo(String.valueOf(robotId));
|
||||
/*EXGameController.removeRobotRoomInfo(String.valueOf(robotId));
|
||||
//更新机器人剩余数量
|
||||
updateLeftoverRobot(robotId);
|
||||
disconnectFromGameServer(connecId);
|
||||
disconnectFromGameServer(connecId);*/
|
||||
ITObject params = TObject.newInstance();
|
||||
params.putBoolean("result", false);
|
||||
int delaySeconds = ThreadLocalRandom.current().nextInt(3, 8);
|
||||
log.debug("执行延迟{}秒", delaySeconds);
|
||||
Thread.sleep(delaySeconds * 1000);
|
||||
client.send("1008", params, response -> {
|
||||
log.info("机器人解决解散,robotId: {" + robotId + "}");
|
||||
});
|
||||
log.info("2005玩家发送解散房间协议,robotId: {" + robotId + "}");
|
||||
}
|
||||
//解散房间时候恢复机器人账号可以使用
|
||||
else if ("2008".equalsIgnoreCase(command)) {
|
||||
updateLeftoverRobot(Integer.parseInt(robotUser.getRobotId()));
|
||||
disconnectFromGameServer(connecId);
|
||||
/*updateLeftoverRobot(Integer.parseInt(robotUser.getRobotId()));
|
||||
disconnectFromGameServer(connecId);*/
|
||||
log.info("2008拒绝玩家解散房间协议,robotId: {" + robotId + "}");
|
||||
} else if ("2009".equalsIgnoreCase(command)) {
|
||||
scheduleDelay(() -> {
|
||||
Jedis jedis = null;
|
||||
|
|
@ -627,6 +652,7 @@ public class RobotConnectionManager {
|
|||
} finally {
|
||||
jedis0.close();
|
||||
jedis2.close();
|
||||
jedis3.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue