Add AND ALL logic for WI secondary keys
This commit is contained in:
parent
b315778e32
commit
a69f92444b
|
@ -4274,6 +4274,7 @@
|
|||
<small class="textAlignCenter">Logic</small>
|
||||
<select name="entryLogicType" class="widthFitContent margin0">
|
||||
<option value="0">AND ANY</option>
|
||||
<option value="3">AND ALL</option>
|
||||
<option value="1">NOT ALL</option>
|
||||
<option value="2">NOT ANY</option>
|
||||
</select>
|
||||
|
|
|
@ -39,6 +39,7 @@ const world_info_logic = {
|
|||
AND_ANY: 0,
|
||||
NOT_ALL: 1,
|
||||
NOT_ANY: 2,
|
||||
AND_ALL: 3,
|
||||
};
|
||||
|
||||
let world_info = {};
|
||||
|
@ -1789,6 +1790,7 @@ async function checkWorldInfo(chat, maxContext) {
|
|||
) {
|
||||
console.debug(`WI UID:${entry.uid} found. Checking logic: ${entry.selectiveLogic}`);
|
||||
let hasAnyMatch = false;
|
||||
let hasAllMatch = true;
|
||||
secondary: for (let keysecondary of entry.keysecondary) {
|
||||
const secondarySubstituted = substituteParams(keysecondary);
|
||||
const hasSecondaryMatch = secondarySubstituted && matchKeys(textToScan, secondarySubstituted.trim());
|
||||
|
@ -1798,6 +1800,10 @@ async function checkWorldInfo(chat, maxContext) {
|
|||
hasAnyMatch = true;
|
||||
}
|
||||
|
||||
if (!hasSecondaryMatch) {
|
||||
hasAllMatch = false;
|
||||
}
|
||||
|
||||
// Simplified AND ANY / NOT ALL if statement. (Proper fix for PR#1356 by Bronya)
|
||||
// If AND ANY logic and the main checks pass OR if NOT ALL logic and the main checks do not pass
|
||||
if ((selectiveLogic === world_info_logic.AND_ANY && hasSecondaryMatch) || (selectiveLogic === world_info_logic.NOT_ALL && !hasSecondaryMatch)) {
|
||||
|
@ -1817,6 +1823,12 @@ async function checkWorldInfo(chat, maxContext) {
|
|||
console.debug(`(NOT ANY Check) Activating WI Entry ${entry.uid}, no secondary keywords found.`);
|
||||
activatedNow.add(entry);
|
||||
}
|
||||
|
||||
// Handle AND ALL logic
|
||||
if (selectiveLogic === world_info_logic.AND_ALL && hasAllMatch) {
|
||||
console.debug(`(AND ALL Check) Activating WI Entry ${entry.uid}, all secondary keywords found.`);
|
||||
activatedNow.add(entry);
|
||||
}
|
||||
} else {
|
||||
// Handle cases where secondary is empty
|
||||
console.debug(`WI UID ${entry.uid}: Activated without filter logic.`);
|
||||
|
|
Loading…
Reference in New Issue