Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 4x 4x 4x 5x 4x 5x 5x 4x 5x 4x 5x 4x 5x 4x 5x 5x 5x 4x 9x 3x | /**
* @module Engine.Users
* Users
* @preferred
*/
import { IStateServer } from '@engine/reducers';
import { User, UserRole } from '@models';
import { Store } from 'redux';
export class UsersTools {
public static hydrater = (source: any): User => {
return {
id: source.id !== undefined ? source.id : null,
name: source.name !== undefined ? source.name : null,
hash: source.hash !== undefined ? source.hash : null,
email: source.email !== undefined ? source.email : null,
role: source.role !== undefined ? source.role : UserRole.User,
};
}
// tslint:disable-next-line: no-identical-functions
public static serializer = (source: User): any => {
const userJson: any = {};
if (source.id !== null) {
userJson.id = source.id;
}
if (source.name !== null) {
userJson.name = source.name;
}
if (source.hash !== null) {
userJson.hash = source.hash;
}
if (source.email !== null) {
userJson.email = source.email;
}
Eif (source.role !== null) {
userJson.role = source.role;
}
return userJson;
}
public static ownedChar = (store: Store<IStateServer>, user: User): number[] => {
const characters = store.getState().Characters.filter(c => c.owner === user.id);
return characters.toList().map(c => c.mat).toArray();
}
}
|