Javascript's < operator isn't locale aware on strings, so we can use that instead of our own custom implementation

This commit is contained in:
2021-04-14 15:14:15 +02:00
parent 376004c6c2
commit 20c5a59fe4

View File

@@ -234,18 +234,5 @@ function isResponsibleGM() {
const connectedGMs = game.users.filter(user => user.isGM && user.active); const connectedGMs = game.users.filter(user => user.isGM && user.active);
if (!game.user.isGM) if (!game.user.isGM)
return false; return false;
return !connectedGMs.some(other => strIsSmallerThan(other.data._id, game.user.data._id)); return !connectedGMs.some(other => other.data._id < game.user.data._id);
}
function strIsSmallerThan(small, big) {
let shortestLength = Math.min(small.length, big.length);
for (let i = 0;i < shortestLength;i++) {
const smallCode = small.charCodeAt(i);
const bigCode = big.charCodeAt(i);
if (smallCode < bigCode)
return true;
if (bigCode < smallCode)
return false;
}
return small.length < shortestLength;
} }