From 85638ee875e68c5e7f988c0c3401ee3a9be9f8fa Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sat, 7 Aug 2021 12:00:19 +0800 Subject: [PATCH] =?UTF-8?q?random:=E5=AE=B9=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/utils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/utils.js b/libs/utils.js index a4058388..d8798860 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -866,7 +866,7 @@ utils.prototype.rand = function (num) { ////// 生成随机数(录像方法) ////// utils.prototype.rand2 = function (num) { num = num || 2147483648; - if (num <= 0) num = 1; + num = Math.abs(num); var value; if (core.isReplaying()) { @@ -874,8 +874,8 @@ utils.prototype.rand2 = function (num) { if (action.indexOf("random:") == 0) { value = parseInt(action.substring(7)); if (isNaN(value) || value >= num || value < 0) { - core.control._replay_error(action); - return 0; + console.warn('错误!当前random:项超过范围。将重新随机生成!'); + value = Math.floor(Math.random() * num); } } else {