放炮罚机器人出牌时间

master
zhouwei 2026-07-09 22:23:48 +08:00
parent 60b2df3908
commit 9fd6ce91f6
2 changed files with 28 additions and 8 deletions

View File

@ -43,4 +43,17 @@ public class Config {
/** 机器人HTTP服务路径 */ /** 机器人HTTP服务路径 */
public static final String HTTP_PATH_JOIN_ROOM = "/robot/joinRoom"; public static final String HTTP_PATH_JOIN_ROOM = "/robot/joinRoom";
//==================== 机器人出牌延迟配置 ====================
/** 出牌最小延迟 */
public static final int DISCARD_DELAY_MIN_MS = 1000;
/** 出牌最大延迟 */
public static final int DISCARD_DELAY_MAX_MS = 4000;
/** 吃碰胡动作最小延迟 */
public static final int ACTION_DELAY_MIN_MS = 1500;
/** 吃碰胡动作最大延迟 */
public static final int ACTION_DELAY_MAX_MS = 3500;
} }

View File

@ -400,9 +400,11 @@ public class FangPaoFaHandler {
private void delayedAction(TaurusClient client, ITObject params, String actionName) { private void delayedAction(TaurusClient client, ITObject params, String actionName) {
Thread thread = new Thread(() -> { Thread thread = new Thread(() -> {
try { try {
int delaySeconds = 1 + new Random().nextInt(2); int minDelay = robot.zp.Config.ACTION_DELAY_MIN_MS;
log.info("执行{}动作,延迟{}秒", actionName, delaySeconds); int maxDelay = robot.zp.Config.ACTION_DELAY_MAX_MS;
Thread.sleep(delaySeconds * 1000); int delayMs = minDelay + new Random().nextInt(maxDelay - minDelay);
log.info("执行{}动作,延迟{}毫秒", actionName, delayMs);
Thread.sleep(delayMs);
client.send("612", params, response -> { client.send("612", params, response -> {
System.out.println("动作发送完成"); System.out.println("动作发送完成");
@ -421,8 +423,11 @@ public class FangPaoFaHandler {
private void delayedDiscard(TaurusClient client, ITObject params) { private void delayedDiscard(TaurusClient client, ITObject params) {
Thread thread = new Thread(() -> { Thread thread = new Thread(() -> {
try { try {
int delay = new Random().nextInt(4); int minDelay = robot.zp.Config.DISCARD_DELAY_MIN_MS;
Thread.sleep(delay * 1000); int maxDelay = robot.zp.Config.DISCARD_DELAY_MAX_MS;
int delayMs = minDelay + new Random().nextInt(maxDelay - minDelay);
log.info("出牌延迟{}毫秒", delayMs);
Thread.sleep(delayMs);
client.send("611", params, response -> { client.send("611", params, response -> {
log.debug("出牌发送完成"); log.debug("出牌发送完成");
@ -647,9 +652,11 @@ public class FangPaoFaHandler {
private void daniao(TaurusClient client, ITObject params, String actionName) { private void daniao(TaurusClient client, ITObject params, String actionName) {
Thread thread = new Thread(() -> { Thread thread = new Thread(() -> {
try { try {
int delaySeconds = 1 + new Random().nextInt(2); int minDelay = robot.zp.Config.ACTION_DELAY_MIN_MS;
log.info("执行{}动作,延迟{}秒", actionName, delaySeconds); int maxDelay = robot.zp.Config.ACTION_DELAY_MAX_MS;
Thread.sleep(delaySeconds * 1000); int delayMs = minDelay + new Random().nextInt(maxDelay - minDelay);
log.info("执行{}动作,延迟{}毫秒", actionName, delayMs);
Thread.sleep(delayMs);
client.send("831", params, response -> { client.send("831", params, response -> {
System.out.println("动作发送完成"); System.out.println("动作发送完成");