class FakeUserCreator {
constructor() {
this.abbrMap = {};
return this;
}
createUser(maxSize) {
const name = faker.internet.userName();
let abbr = name.slice(0, 2).toUpperCase();
this.abbrMap[abbr] = (this.abbrMap[abbr] || 0) + 1;
if (this.abbrMap[abbr] > 1) abbr = `${abbr}${this.abbrMap[abbr]}`;
const win = parseInt(Math.random() * maxSize, 10);
const lose = maxSize - win;
const icon = `${faker.image.imageUrl(150, 150, 'abstract')}?${abbr}`;
return {
win,
lose,
abbr,
name,
icon
};
}
}