using Avalonia.Media; using Nonemm.App.Theming; using Nonemm.Contests; namespace Nonemm.App; /// One place decides what colour a station is, so the callsign box, the frame /// above it, a row in the check window and a spot on the bandmap cannot /// disagree. The colours come from the theme in use. public static class Verdicts { public static IBrush Worth => Themes.Brush(Themes.Current.Worth); public static IBrush NewMultiplier => Themes.Brush(Themes.Current.Multiplier); public static IBrush NewMultipliers => Themes.Brush(Themes.Current.Multipliers); public static IBrush Dupe => Themes.Brush(Themes.Current.Dupe); /// A station with QTC traffic still to exchange, which is worth working in /// WAE even when it is a dupe. public static IBrush Traffic => Themes.Brush(Themes.Current.QtcCallsign); public static IBrush Nothing => Dupe; /// The frequency we are calling CQ on. public static IBrush Cq => Themes.Brush(Themes.Current.Cq); /// Our own call, heard back from the other station. It is neither worth /// working nor a dupe, so it gets the colour that means us. public static IBrush MyCall => Cq; /// Nothing typed yet is the same colour as a station worth working: that is /// what N1MM leaves the callsign box. /// /// WAE has two states the other contests do not, and N1MM paints them in /// colours it already has: a new station with QTC traffic still to /// exchange takes the more-than-one-multiplier colour, green, because WAE /// has no second multiplier to use it; a dupe with traffic left takes the /// QTC colour, black, rather than the grey of a dupe worth nothing. A new /// multiplier still wins over both. public static IBrush Colour(Verdict? verdict) => verdict is null ? Worth : verdict.IsDupe ? verdict.TrafficLeft > 0 ? Traffic : Dupe : verdict.NewMultipliers.Count > 1 ? NewMultipliers : verdict.NewMultipliers.Count == 1 ? NewMultiplier : verdict.TrafficLeft > 0 ? NewMultipliers : Worth; /// The same four states as backgrounds, which is what N1MM paints behind a /// spot and in the band panel. public static IBrush Background(Verdict? verdict) => Themes.Brush(BackgroundColour(verdict)); /// The same as a colour, for a caller that has to pick readable text to go /// on top of it. public static Color BackgroundColour(Verdict? verdict) => verdict is null ? Themes.Current.WorthBackground : verdict.IsDupe ? Themes.Current.DupeBackground : verdict.NewMultipliers.Count > 1 ? Themes.Current.MultipliersBackground : verdict.NewMultipliers.Count == 1 ? Themes.Current.MultiplierBackground : Themes.Current.WorthBackground; public static string Describe(Verdict? verdict) { if (verdict is null) { return ""; } // a dupe in WAE is still worth working while it has traffic left, so // the line says how much rather than only that the station is worked string traffic = verdict.TrafficLeft > 0 ? $" · {verdict.TrafficLeft} QTCs left" : ""; if (verdict.IsDupe) { return $"dupe{traffic}"; } string points = $"{verdict.Points} {(verdict.Points == 1 ? "point" : "points")}"; return verdict.IsNewMultiplier ? $"{points} · new {string.Join(", ", verdict.NewMultipliers.Select(m => m.Value))}{traffic}" : $"{points}{traffic}"; } }