Prefer const variables
| @@ -1006,7 +1006,7 @@ function activateNaturalOrder(members, input, lastMessage, allowSelfResponses, i | |||
| 1006 | } | 1006 | } |
| 1007 | } | 1007 | } |
| 1008 | 1008 | ||
| 1009 | let chattyMembers = []; | 1009 | const chattyMembers = []; |
| 1010 | // activation by talkativeness (in shuffled order, except banned) | 1010 | // activation by talkativeness (in shuffled order, except banned) |
| 1011 | const shuffledMembers = shuffle([...members]); | 1011 | const shuffledMembers = shuffle([...members]); |
| 1012 | for (let member of shuffledMembers) { | 1012 | for (let member of shuffledMembers) { |
| @@ -1017,10 +1017,9 @@ function activateNaturalOrder(members, input, lastMessage, allowSelfResponses, i | |||
| 1017 | } | 1017 | } |
| 1018 | 1018 | ||
| 1019 | const rollValue = Math.random(); | 1019 | const rollValue = Math.random(); |
| 1020 | let talkativeness = Number(character.talkativeness); | 1020 | const talkativeness = isNaN(character.talkativeness) |
| 1021 | talkativeness = Number.isNaN(talkativeness) | ||
| 1022 | ? talkativeness_default | 1021 | ? talkativeness_default |
| 1023 | : talkativeness; | 1022 | : Number(character.talkativeness); |
| 1024 | if (talkativeness >= rollValue) { | 1023 | if (talkativeness >= rollValue) { |
| 1025 | activatedMembers.push(member); | 1024 | activatedMembers.push(member); |
| 1026 | } | 1025 | } |
| @@ -1032,7 +1031,7 @@ function activateNaturalOrder(members, input, lastMessage, allowSelfResponses, i | |||
| 1032 | // pick 1 at random if no one was activated | 1031 | // pick 1 at random if no one was activated |
| 1033 | let retries = 0; | 1032 | let retries = 0; |
| 1034 | // try to limit the selected random character to those with talkativeness > 0 | 1033 | // try to limit the selected random character to those with talkativeness > 0 |
| 1035 | let randomPool = chattyMembers.length > 0? chattyMembers : members; | 1034 | const randomPool = chattyMembers.length > 0 ? chattyMembers : members; |
| 1036 | while (activatedMembers.length === 0 && ++retries <= randomPool.length) { | 1035 | while (activatedMembers.length === 0 && ++retries <= randomPool.length) { |
| 1037 | const randomIndex = Math.floor(Math.random() * randomPool.length); | 1036 | const randomIndex = Math.floor(Math.random() * randomPool.length); |
| 1038 | const character = characters.find((x) => x.avatar === randomPool[randomIndex]); | 1037 | const character = characters.find((x) => x.avatar === randomPool[randomIndex]); |