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

import java.util.List;
import java.util.UUID;

import de.oaa.xxx.games.chastity.tasks.Task;
import de.oaa.xxx.games.chastity.tasks.TaskListConverter;
import de.oaa.xxx.games.chastity.tasks.TaskMode;
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.DiscriminatorColumn;
import jakarta.persistence.DiscriminatorType;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
@Table(name = "lock_template")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "lock_type", discriminatorType = DiscriminatorType.STRING)
public class BaseLockTemplateEntity {

	@Id
	@GeneratedValue(strategy = GenerationType.UUID)
	@Column
	private UUID templateId;
	@Column(nullable = false)
	private UUID owner;
	@Column
	private String name;
	@Column
	private Integer hygineOpeningDurationMinutes;
	@Column
	private Integer hygineOpeningEveryMinites;
	@Convert(converter = TaskListConverter.class)
	@Column(columnDefinition = "TEXT")
	private List<Task> tasks;
	@Column
	private boolean requiresVerification;
	@Column(nullable = false)
	private TaskMode taskMode = TaskMode.RANDOM;

	@Column(nullable = false)
	private boolean published = false;

	@Column(nullable = false)
	private boolean showAuthor = false;

	@Column(nullable = false)
	private long subscriberCount = 0;

	public TaskMode getTaskCardMode() {
		return taskMode != null ? taskMode : TaskMode.RANDOM;
	}
}
