PlotDirector/PlotLine/Services/CharacterQuickAttributes.cs

20 lines
1.8 KiB
C#

using PlotLine.Models;
namespace PlotLine.Services;
// One vocabulary for the directory legend, indicators and assignment menus.
public sealed record CharacterQuickValue(string Value,string Label,string Icon,string Tone="secondary");
public sealed record CharacterQuickGroup(string Id,string Label,IReadOnlyList<CharacterQuickValue> Values);
public static class CharacterQuickAttributes
{
public static IReadOnlyList<CharacterQuickGroup> Definitions(IEnumerable<CharacterSexValue> sex) => [
new("type", "Character Type", CharacterTypes.Values),
new("importance","Story importance",[new("10","Major","attribute-star","warning"),new("6","Supporting","characters","info"),new("2","Minor","attribute-person"),new("","Unclassified","help")]),
new("life","Life status",[new("0","Living","attribute-heart","success"),new("1","Deceased","attribute-flower","data-5"),new("","Unrecorded","help")]),
new("sex","Sex",new[]{new CharacterQuickValue("","Not set","help")}.Concat(sex.Select(s=>new CharacterQuickValue(s.CharacterSexValueID.ToString(),s.SexName,"attribute-person"))).ToArray()),
new("quickAdd","Quick Add Bar",[new("1","Included","attribute-pin","primary"),new("0","Excluded","attribute-unpin")])
];
public static object Snapshot(Character c)=>new {id=c.CharacterID,name=c.CharacterName,version=c.UpdatedDate.ToString("O"),values=new Dictionary<string,string>{["type"]=c.CharacterTypeCode,["importance"]=c.CharacterImportance?.ToString()??"",["life"]=c.IsDeceased.HasValue?(c.IsDeceased.Value?"1":"0"):"",["sex"]=c.SexValueID?.ToString()??(string.IsNullOrWhiteSpace(c.Sex)?"":"legacy:"+c.Sex),["quickAdd"]=c.ShowInQuickAddBar?"1":"0"}};
}
public sealed record CharacterQuickChange(int Id,string? Value,string Version);
public sealed record CharacterQuickAssignment(int ProjectId,string Attribute,CharacterQuickChange[] Changes);