From 9fd6ce91f60a5452d42ceb6c7aa140e292e787fa Mon Sep 17 00:00:00 2001 From: zhouwei <849588297@qq.com> Date: Thu, 9 Jul 2026 22:23:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=BE=E7=82=AE=E7=BD=9A=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E4=BA=BA=E5=87=BA=E7=89=8C=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/robot/zp/Config.java | 13 +++++++++++ .../robot/zp/handler/FangPaoFaHandler.java | 23 ++++++++++++------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/robots/zhipai/robot_zp_fpf/src/main/java/robot/zp/Config.java b/robots/zhipai/robot_zp_fpf/src/main/java/robot/zp/Config.java index b9653a0..a620eee 100644 --- a/robots/zhipai/robot_zp_fpf/src/main/java/robot/zp/Config.java +++ b/robots/zhipai/robot_zp_fpf/src/main/java/robot/zp/Config.java @@ -43,4 +43,17 @@ public class Config { /** 机器人HTTP服务路径 */ 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; + } \ No newline at end of file diff --git a/robots/zhipai/robot_zp_fpf/src/main/java/robot/zp/handler/FangPaoFaHandler.java b/robots/zhipai/robot_zp_fpf/src/main/java/robot/zp/handler/FangPaoFaHandler.java index d78b0ad..e655744 100644 --- a/robots/zhipai/robot_zp_fpf/src/main/java/robot/zp/handler/FangPaoFaHandler.java +++ b/robots/zhipai/robot_zp_fpf/src/main/java/robot/zp/handler/FangPaoFaHandler.java @@ -400,9 +400,11 @@ public class FangPaoFaHandler { private void delayedAction(TaurusClient client, ITObject params, String actionName) { Thread thread = new Thread(() -> { try { - int delaySeconds = 1 + new Random().nextInt(2); - log.info("执行{}动作,延迟{}秒", actionName, delaySeconds); - Thread.sleep(delaySeconds * 1000); + int minDelay = robot.zp.Config.ACTION_DELAY_MIN_MS; + int maxDelay = robot.zp.Config.ACTION_DELAY_MAX_MS; + int delayMs = minDelay + new Random().nextInt(maxDelay - minDelay); + log.info("执行{}动作,延迟{}毫秒", actionName, delayMs); + Thread.sleep(delayMs); client.send("612", params, response -> { System.out.println("动作发送完成"); @@ -421,8 +423,11 @@ public class FangPaoFaHandler { private void delayedDiscard(TaurusClient client, ITObject params) { Thread thread = new Thread(() -> { try { - int delay = new Random().nextInt(4); - Thread.sleep(delay * 1000); + int minDelay = robot.zp.Config.DISCARD_DELAY_MIN_MS; + 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 -> { log.debug("出牌发送完成"); @@ -647,9 +652,11 @@ public class FangPaoFaHandler { private void daniao(TaurusClient client, ITObject params, String actionName) { Thread thread = new Thread(() -> { try { - int delaySeconds = 1 + new Random().nextInt(2); - log.info("执行{}动作,延迟{}秒", actionName, delaySeconds); - Thread.sleep(delaySeconds * 1000); + int minDelay = robot.zp.Config.ACTION_DELAY_MIN_MS; + int maxDelay = robot.zp.Config.ACTION_DELAY_MAX_MS; + int delayMs = minDelay + new Random().nextInt(maxDelay - minDelay); + log.info("执行{}动作,延迟{}毫秒", actionName, delayMs); + Thread.sleep(delayMs); client.send("831", params, response -> { System.out.println("动作发送完成");