Simplify workspace composition root
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using RpgRoller.Contracts;
|
||||
using RpgRoller.Domain;
|
||||
using RpgRoller.Components.Pages.HomeControls;
|
||||
|
||||
namespace RpgRoller.Components.Pages;
|
||||
|
||||
@@ -147,4 +148,37 @@ public sealed class WorkspaceState
|
||||
};
|
||||
|
||||
public string AppCssClass => IsPlayScreen ? "rr-app app-play" : "rr-app";
|
||||
|
||||
public string OwnerLabel(Guid ownerUserId)
|
||||
{
|
||||
if (User is not null && ownerUserId == User.Id)
|
||||
return "You";
|
||||
|
||||
if (SelectedCampaign is null)
|
||||
return "Unknown owner";
|
||||
|
||||
if (ownerUserId == SelectedCampaign.Gm.Id)
|
||||
return $"{SelectedCampaign.Gm.DisplayName} (GM)";
|
||||
|
||||
var ownerDisplayName = SelectedCampaign.Characters
|
||||
.Where(character => character.OwnerUserId == ownerUserId)
|
||||
.Select(character => character.OwnerDisplayName)
|
||||
.FirstOrDefault(displayName => !string.IsNullOrWhiteSpace(displayName));
|
||||
|
||||
return string.IsNullOrWhiteSpace(ownerDisplayName) ? "Unknown owner" : ownerDisplayName;
|
||||
}
|
||||
|
||||
public string SkillDefinitionLabel(CharacterSheetSkill skill)
|
||||
{
|
||||
if (!string.Equals(SelectedCampaign?.RulesetId, "d6", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (string.Equals(SelectedCampaign?.RulesetId, RulesetFormHelpers.RulesetIds.Rolemaster, StringComparison.OrdinalIgnoreCase))
|
||||
return RulesetFormHelpers.DescribeRolemasterExpression(skill.DiceRollDefinition, skill.FumbleRange);
|
||||
|
||||
return skill.DiceRollDefinition;
|
||||
}
|
||||
|
||||
var fumbleLabel = skill.AllowFumble ? "fumble on" : "fumble off";
|
||||
return $"{skill.DiceRollDefinition}, wild {skill.WildDice}, {fumbleLabel}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user