Fix getActiveUser for v9

This commit is contained in:
Vincent Vandemeulebrouck 2022-01-11 23:39:51 +01:00
parent 86ea2f09e8
commit 5bb4e02915
2 changed files with 10 additions and 9 deletions

View File

@ -138,7 +138,7 @@ export class ChatUtility {
/* -------------------------------------------- */
static getUsers(filter) {
return game.users.filter(filter).map(user => user.data._id);
return Misc.getUsers().filter(filter).map(user => user.data._id);
}
/* -------------------------------------------- */

View File

@ -134,16 +134,17 @@ export class Misc {
return Misc.firstConnectedGM()?.id ?? game.user.id;
}
static getActiveUser(id) {
return game.users.entities.find(u => u.id == id && u.active);
static getUsers() {
return game.version ? game.users : game.users.entities;
}
static getActiveUser(id) {
return Misc.getUsers().find(u => u.id == id && u.active);
}
static firstConnectedGM() {
if (game.version){
return game.users.filter(u => u.isGM && u.active)[0];
} else {
return game.users.entities.sort(Misc.ascending(u => u.id)).find(u => u.isGM && u.active);
}
return Misc.getUsers().filter(u => u.isGM && u.active).sort(Misc.ascending(u => u.id)).find(u => u.isGM && u.active);
}
/**
@ -155,7 +156,7 @@ export class Misc {
/* -------------------------------------------- */
static findPlayer(name) {
return Misc.findFirstLike(name, game.users, { description: 'joueur' });
return Misc.findFirstLike(name, Misc.getUsers(), { description: 'joueur' });
}
/* -------------------------------------------- */