mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 09:45:19 +08:00
Added include function in Conditions in UtilsFactory
This commit is contained in:
@@ -139,15 +139,26 @@ internal inline fun <T> T.conditions(initiate: Conditions<T>.() -> Unit) = Condi
|
||||
*/
|
||||
internal class Conditions<T>(internal var value: T) {
|
||||
|
||||
/** 全部判断条件数组 */
|
||||
private val conditions = ArrayList<Boolean>()
|
||||
/** 全部判断条件数组 (与) */
|
||||
private val popularConditions = ArrayList<Boolean>()
|
||||
|
||||
/** 全部判断条件数组 (与成立 - 非忽略) */
|
||||
private val includeConditions = ArrayList<Boolean>()
|
||||
|
||||
/**
|
||||
* 添加与 (and) 条件
|
||||
* @param value 条件值
|
||||
*/
|
||||
internal fun and(value: Boolean) {
|
||||
conditions.add(value)
|
||||
popularConditions.add(value)
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加与 (and) 后成立且不与 (and) 后忽略条件
|
||||
* @param value 条件值
|
||||
*/
|
||||
internal fun include(value: Boolean) {
|
||||
includeConditions.add(value)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +176,10 @@ internal class Conditions<T>(internal var value: T) {
|
||||
* 获取条件判断结果
|
||||
* @return [Boolean]
|
||||
*/
|
||||
private val result by lazy { conditions.takeIf { it.isNotEmpty() }?.any { it.not() }?.not() == true }
|
||||
private val result by lazy {
|
||||
includeConditions.takeIf { it.isNotEmpty() }?.any { it.not() }?.not() == true ||
|
||||
popularConditions.takeIf { it.isNotEmpty() }?.any { it.not() }?.not() == true
|
||||
}
|
||||
|
||||
/**
|
||||
* 当条件成立
|
||||
|
Reference in New Issue
Block a user