public void CreateAll(IDbConnection connection) { var ai = (AllianceInitializer)_allianceInitializer; ai.CreateAllianceRoles(connection); if (deletAuthUsers) { _authUsersInitializer.CreateAll(connection); } _npcInitializer.Init(connection); _mapGInitializer.CreateAll(connection); _npcInitializer.CreateMotherNpces(connection); var index = 999; _provider._help_reset_index(connection, "user", index); _provider._help_reset_index(connection, "alliance", index); _provider._help_reset_index(connection, "alliance_user", index); _provider._help_reset_index(connection, "alliance_user_history", index); _userInitializer.InternalRun(connection, _admUser.AuthId, _admUser.NikName, _admUser.GameId, false); var baseAlliance = ai.CreateBaseAlliance(connection); var password = Guid.NewGuid().ToString(); _channelService.CreateAllianceChannel(connection, baseAlliance, password); _userInitializer.InternalRun(connection, _textUser.AuthId, _textUser.NikName, _textUser.GameId, true); _userInitializer.InternalRun(connection, _demoUser.AuthId, _demoUser.NikName, _demoUser.GameId, true); SetMainUsersPlanet(connection); _createFakeUsers(connection); }
private void CreateNpc(IDbConnection connection, NpcModel npc) { // _dbProvider.Exec(connection, sqlResetIdentity); var npcKey = npc.NpcUser.Id; // npc.NpcUser.Id = 0; var insertedUser = _gameUserService.AddOrUpdate(connection, npc.NpcUser); if (insertedUser.Id != npcKey && npcKey != 0) { throw new NotImplementedException("insertedUser.Id!= npcKey"); } npc.NpcUser.Id = insertedUser.Id; var npcAlliance = _allianceService.AddOrUpdate(connection, npc.NpcAlliance); if (npcAlliance.Id != npcKey) { throw new NotImplementedException("npcAlliance.Id != npcKey"); } npc.NpcAlliance.Id = npcKey; var npcAllianceUser = _allianceService.GetAllianceUserById(connection, npcKey); if (npcAllianceUser == null) { throw new NotImplementedException("creator alliance user incorrect"); } var password = Guid.NewGuid().ToString(); var npcChannel = _channelService.CreateAllianceChannel(connection, npcAlliance, password); if (npc.NpcUser.Id == Npc.ConfederationGameUserId) { _channelService.CreateMessage(connection, new ChannelMessageDataModel { UserId = npc.NpcUser.Id, DateCreate = UnixTime.UtcNow(), ChannelId = npcChannel.Id, UserName = npc.NpcUser.Nickname, Message = "Welcome to Confederation!", UserIcon = npc.NpcUser.Avatar.Icon }); } }