82 lines
3.2 KiB
C#
82 lines
3.2 KiB
C#
namespace TeleWave.Domain.Broadcast;
|
|
|
|
/// <summary>
|
|
/// Подблок заставки (текст-вариант) внутри <see cref="BumperTemplate"/>. Наследует от блока звук,
|
|
/// стиль и фон, но задаёт собственный текст и правило показа (<see cref="Trigger"/>). Позволяет иметь
|
|
/// несколько текстов на одной музыке/оформлении, не дублируя блок.
|
|
/// </summary>
|
|
public class BumperTextVariant
|
|
{
|
|
public Guid Id { get; private set; }
|
|
public Guid BumperTemplateId { get; private set; }
|
|
public int Position { get; private set; }
|
|
public string Name { get; private set; } = string.Empty;
|
|
|
|
public BumperTextKind Kind { get; private set; }
|
|
|
|
// ── Режим NowNext: подписи (названия шоу подставляет генератор) ──
|
|
public string NowLabel { get; private set; } = DefaultNowLabel;
|
|
public string NextLabel { get; private set; } = DefaultNextLabel;
|
|
|
|
// ── Режим Free: произвольные строки (например название канала и совет) ──
|
|
public string Line1 { get; private set; } = string.Empty;
|
|
public string Line2 { get; private set; } = string.Empty;
|
|
|
|
public BumperTrigger Trigger { get; private set; }
|
|
|
|
/// <summary>Вес при стратегии <see cref="BumperSelection.WeightedRandom"/> (0 — не выбирается). Иначе игнорируется.</summary>
|
|
public int Weight { get; private set; } = DefaultWeight;
|
|
|
|
public DateTimeOffset CreatedAt { get; private set; }
|
|
|
|
public const int DefaultWeight = 1;
|
|
|
|
public const string DefaultNowLabel = "СЕЙЧАС";
|
|
public const string DefaultNextLabel = "ДАЛЕЕ";
|
|
|
|
private BumperTextVariant() { }
|
|
|
|
internal static BumperTextVariant Create(
|
|
Guid bumperTemplateId,
|
|
int position,
|
|
string name,
|
|
BumperTrigger trigger
|
|
) =>
|
|
new()
|
|
{
|
|
Id = Guid.NewGuid(),
|
|
BumperTemplateId = bumperTemplateId,
|
|
Position = position,
|
|
Name = name,
|
|
Kind = BumperTextKind.NowNext,
|
|
NowLabel = DefaultNowLabel,
|
|
NextLabel = DefaultNextLabel,
|
|
Line1 = string.Empty,
|
|
Line2 = string.Empty,
|
|
Trigger = trigger,
|
|
Weight = DefaultWeight,
|
|
CreatedAt = DateTimeOffset.UtcNow,
|
|
};
|
|
|
|
public void Update(string name, BumperTextContent text, BumperTrigger trigger, int weight)
|
|
{
|
|
Name = name;
|
|
Kind = text.Kind;
|
|
NowLabel = text.NowLabel;
|
|
NextLabel = text.NextLabel;
|
|
Line1 = text.Line1;
|
|
Line2 = text.Line2;
|
|
Trigger = trigger;
|
|
Weight = Math.Max(0, weight);
|
|
}
|
|
|
|
/// <summary>Подходит ли подблок для перехода: <paramref name="isShowChange"/> — сменилось ли шоу.</summary>
|
|
public bool Matches(bool isShowChange) =>
|
|
Trigger switch
|
|
{
|
|
BumperTrigger.OnShowChange => isShowChange,
|
|
BumperTrigger.BetweenEpisodes => !isShowChange,
|
|
_ => true,
|
|
};
|
|
}
|