public static AdminLog EditRoleLog(IIdPool idPool, IClock clock, AuthUser actor, RoleId roleId, string rolename) { return(new AdminLog( Next(idPool), "role.edit", Params(roleId, rolename), actor.Id, actor.Username, Permissions.EditRoles, clock.UtcNow() )); }
public (Game game, GameState gameState) BuildGame( IIdPool idPool, GameSettings settings, UserInfo creator, Color creatorColor) { var nextGameId = new GameId(idPool.NextForGame()); var game = new Game(nextGameId, settings, _clock.UtcNow()); var gameState = GameState.InitialState(game.Id, settings.BoardSize); var player = BuildPlayer(idPool, creator, creatorColor); game.JoinGame(player, _clock.UtcNow()); return(game, gameState); }
public AuthUser CreateAuthUser(IIdPool idPool, Role pendingRegistrationRole, string?name, string?email, string?plaintextPassword) { if (pendingRegistrationRole.Rolename != Role.PENDING_REGISTRATION_ROLENAME) { throw new ArgumentException("You're supposed to add the pending registration role.", nameof(pendingRegistrationRole)); } var nextUserId = new UserId(idPool.NextForUser()); var username = new Username(name); var passwordHash = PasswordHash.Generate(plaintextPassword, nextUserId, username); return(new AuthUser(nextUserId, username, passwordHash, new Email(email), _clock.UtcNow(), new[] { pendingRegistrationRole.Id })); }
public Player BuildPlayer(IIdPool idPool, UserInfo user, Color color) { var nextPlayerId = new PlayerId(idPool.Next()); return(new Player(nextPlayerId, user.Id, user.Username, user.Rank, color, _clock.UtcNow())); }
public DefaultEntityFactory(IIdPool idPool, IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup) { IdPool = idPool; ComponentDatabase = componentDatabase; ComponentTypeLookup = componentTypeLookup; }
private static AdminLogId Next(IIdPool idPool) => new AdminLogId(idPool.Next());
public DefaultEntityFactory(IIdPool idPool, IComponentRepository componentRepository) { IdPool = idPool; ComponentRepository = componentRepository; }