package de.oaa.xxx.games.chastity.timelock;

import java.util.UUID;

import org.springframework.stereotype.Service;

import de.oaa.xxx.games.chastity.cardlock.CardlockRepository;
import de.oaa.xxx.games.chastity.common.BaseLockService;
import de.oaa.xxx.games.chastity.community.CommunityPilloryRepository;
import de.oaa.xxx.games.chastity.community.CommunityTaskVoteRepository;
import de.oaa.xxx.games.chastity.community.CommunityVerificationRepository;
import de.oaa.xxx.games.chastity.community.CommunityVerificationVoteRepository;
import de.oaa.xxx.games.chastity.keyholder.KeyholderNotificationRepository;
import de.oaa.xxx.games.chastity.keyholder.KeyholderTaskChoiceRepository;
import de.oaa.xxx.games.chastity.keyholder.KeyholderVerificationRepository;
import de.oaa.xxx.games.chastity.lockcontroll.LockControlFactory;
import de.oaa.xxx.games.chastity.unlock.UnlockCodeHistoryService;
import de.oaa.xxx.games.history.GameHistoryRepository;
import de.oaa.xxx.social.SystemMessageService;
import de.oaa.xxx.user.UserRepository;

@Service
public class TimeLockServiceFactory {

	private final TimeLockRepository timeLockRepository;
	private final CommunityVerificationRepository communityVerificationRepository;
	private final GameHistoryRepository gameHistoryRepository;
	private final UserRepository userRepository;
	private final KeyholderNotificationRepository keyholderNotificationRepository;
	private final CommunityPilloryRepository pilloryRepository;
	private final CommunityTaskVoteRepository communityTaskVoteRepository;
	private final KeyholderTaskChoiceRepository keyholderTaskChoiceRepository;
	private final KeyholderVerificationRepository keyholderVerificationRepository;

	private final UnlockCodeHistoryService unlockCodeHistoryService;
	private final SystemMessageService systemMessageService;
	private CommunityVerificationVoteRepository communityVerificationVoteRepository;
	private final LockControlFactory lockControlFactory;
	private final CardlockRepository cardlockRepository;

	public TimeLockServiceFactory(CommunityVerificationRepository verificationRepository,
			CommunityVerificationVoteRepository verificationVoteRepository, TimeLockRepository timeLockRepository,
			GameHistoryRepository gameHistoryRepository, UserRepository userRepository,
			KeyholderNotificationRepository keyholderNotificationRepository,
			KeyholderTaskChoiceRepository keyholderTaskChoiceRepository,
			KeyholderVerificationRepository keyholderVerificationRepository,
			CommunityTaskVoteRepository communityTaskVoteRepository, CommunityPilloryRepository pilloryRepository,
			UnlockCodeHistoryService unlockCodeHistoryService, SystemMessageService systemMessageService,
			LockControlFactory lockControlFactory, CardlockRepository cardlockRepository) {
		this.communityVerificationVoteRepository = verificationVoteRepository;
		this.timeLockRepository = timeLockRepository;
		this.communityVerificationRepository = verificationRepository;
		this.gameHistoryRepository = gameHistoryRepository;
		this.userRepository = userRepository;
		this.keyholderNotificationRepository = keyholderNotificationRepository;
		this.pilloryRepository = pilloryRepository;
		this.unlockCodeHistoryService = unlockCodeHistoryService;
		this.systemMessageService = systemMessageService;
		this.keyholderTaskChoiceRepository = keyholderTaskChoiceRepository;
		this.communityTaskVoteRepository = communityTaskVoteRepository;
		this.keyholderVerificationRepository = keyholderVerificationRepository;
		this.lockControlFactory = lockControlFactory;
		this.cardlockRepository = cardlockRepository;
	}

	public boolean hasActiveLock(UUID lockeeId) {
		return BaseLockService.hasActiveLock(lockeeId, cardlockRepository, timeLockRepository);
	}

	/**
	 * Erstellt eine neue TimeLockService-Instanz für das gegebene Lock.
	 */
	public TimeLockService create(TimeLockEntity lock) {
		return new TimeLockService(lock, communityVerificationRepository, communityVerificationVoteRepository,
				timeLockRepository, gameHistoryRepository, userRepository, keyholderNotificationRepository,
				keyholderTaskChoiceRepository, keyholderVerificationRepository, communityTaskVoteRepository,
				pilloryRepository, unlockCodeHistoryService, systemMessageService, lockControlFactory);
	}
}
