/// <summary> /// Creates a bunch of accounts /// </summary> IEnumerable <Account> CreateAccounts(AccountManager_MasterServer am) { List <Account> accounts = new List <Account>(); accounts = new List <Account>(); var userInfo = ParseMockUserData(_config.UserdataTextFilepath, _config.NumPlayers); int numAdded = 0; foreach (var ac in userInfo) { var res = am.CreateAccountAsync(ac.Username, ac.Password).Result; if (res.Item2 != 0) { throw new Exception("Account creation failed: " + res.Item2.ToString()); } accounts.Add(res.Item1); accounts[numAdded].IsAdmin = ac.IsAdmin; numAdded++; } return(accounts); }
public MinimalMockServer(GalacticProperties gp, IDatabaseManager databaseManager, IDbIdIoService dbIdIoService) { Logger.Initialize(); DatabaseManager = databaseManager; DbIdIoService = dbIdIoService; //Minimal initializations GalaxyIDManager = new LocalIDManager(null, IDTypes.GalaxyID); TeamIDManager = new LocalIDManager(null, IDTypes.TeamID); accountIDManager = new LocalIDManager(null, IDTypes.AccountID); InitializeIdData(gp); globalGalaxyIDManager = new GlobalGalaxyIDManager(dbIdIoService, gp); GenerateIDsForLocalIDManager(globalGalaxyIDManager, GalaxyIDManager, gp.IdProperties[IDTypes.GalaxyID].LastIDAdded); globalTeamIDManager = new GlobalTeamIDManager(dbIdIoService, gp); GenerateIDsForLocalIDManager(globalTeamIDManager, TeamIDManager, gp.IdProperties[IDTypes.TeamID].LastIDAdded); globalAccountIDManager = new GlobalAccountIDManager(dbIdIoService, gp); GenerateIDsForLocalIDManager(globalAccountIDManager, accountIDManager, gp.IdProperties[IDTypes.AccountID].LastIDAdded); _redisServer = new RedisServer(Logger.LogRedisError, Logger.LogRedisInfo, new RedisConfig().Address); TeamManager = new GlobalTeamManager(TeamIDManager, null, null, null, DatabaseManager); PlayerManager = new PlayerManager(DatabaseManager, null, _redisServer, GalaxyIDManager, null); GalaxyManager = new GalaxyManager(gp.SolID, TeamManager); shipManager = new ShipManager(null, GalaxyManager, null, null, DatabaseManager); CollisionManager = new CollisionManager(GalaxyManager, null, null, null); GalaxyGenerator = new DebugGalaxyGenerator(PlayerManager, GalaxyManager, shipManager); AccountManager = new AccountManager_MasterServer(accountIDManager, DatabaseManager, false); CargoSynchronizer = new Server.Managers.CargoSynchronizer(); StructureManager = new StructureManager(DatabaseManager, GalaxyManager, GalaxyIDManager, CargoSynchronizer); RegistrationManger = new GalaxyRegistrationManager(GalaxyManager, shipManager, CollisionManager, GalaxyIDManager, PlayerManager, null, CargoSynchronizer, StructureManager); ColonyFactory.Initialize(GalaxyIDManager, RegistrationManger); StructureFactory.Initialize(GalaxyIDManager, RegistrationManger); LocatorService = new LocatorService(RegistrationManger, PlayerManager, GalaxyManager, shipManager, AccountManager, TeamManager, TeamManager, null, StructureManager, null); WarpManager = new WarpManager(GalaxyManager, null, null, _redisServer, AccountManager, null); CargoSynchronizer.Start(10, 4); }