]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/helpers/Participant.js
lock tournaments
[alttp.git] / resources / js / helpers / Participant.js
index e5a135f1b14c47f09182898f0d92aa8aaf5cfa13..a44d465a4e57609b0e45ff5e756fde2344a1a8e2 100644 (file)
@@ -1,8 +1,8 @@
 export const compareResult = round => (a, b) => {
        const a_result = findResult(a, round);
        const b_result = findResult(b, round);
-       const a_time = a_result ? a_result.time : 0;
-       const b_time = b_result ? b_result.time : 0;
+       const a_time = a_result && !a_result.forfeit ? a_result.time : 0;
+       const b_time = b_result && !b_result.forfeit ? b_result.time : 0;
        if (a_time) {
                if (b_time) {
                        if (a_time < b_time) return -1;
@@ -14,7 +14,18 @@ export const compareResult = round => (a, b) => {
        if (b_time) {
                return 1;
        }
-       return 0;
+       const a_forfeit = a_result && a_result.forfeit;
+       const b_forfeit = b_result && b_result.forfeit;
+       if (a_forfeit) {
+               if (b_forfeit) {
+                       return 0;
+               }
+               return -1;
+       }
+       if (b_forfeit) {
+               return 1;
+       }
+       return compareUsername(a, b);
 };
 
 export const compareUsername = (a, b) => {