From a5be7996fd4430ecba9368fa2c1dd49a665d3bde Mon Sep 17 00:00:00 2001 From: Benedikt Magnus <magnus@magnuscraft.de> Date: Mon, 15 Nov 2021 10:49:12 +0100 Subject: [PATCH] Assignment: Improved pairing sort algorithm. If both are prioritised, the sorting now calculates the accumulated score as if they both were not prioritised. --- .../message/modules/assignmentModule.ts | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/scripts/wichtelbot/message/modules/assignmentModule.ts b/scripts/wichtelbot/message/modules/assignmentModule.ts index c44bfbd..7b2e294 100644 --- a/scripts/wichtelbot/message/modules/assignmentModule.ts +++ b/scripts/wichtelbot/message/modules/assignmentModule.ts @@ -358,21 +358,15 @@ export class AssignmentModule const aIsPriority = priorities.has(pairingA.giver); const bIsPriority = priorities.has(pairingB.giver); - if (aIsPriority || bIsPriority) + if (aIsPriority && !bIsPriority) { - if (aIsPriority && bIsPriority) - { - return 0; - } - else if (aIsPriority) - { - return -1; - } - else - { - return 1; - } + return -1; + } + else if (bIsPriority && !aIsPriority) + { + return 1; } + // If both are prioritised, sort by score as if both were not. // The value of the chain is determined by the accumulated weighting of all the wichtel plus their total number. // The higher the value, the less important the user is for the selection. -- GitLab