Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Descriptions visible on roll #78

Merged
merged 2 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dotnet_diagnostic.MA0051.severity = none
# MA0051.skip_local_functions = false # skip local functions when counting statements

# MA0045 - sync in async
dotnet_diagnostic.MA0045.severity = info
dotnet_diagnostic.MA0045.severity = suggestion

# MA0080 - cancellation token AsyncEnumerable iteration
dotnet_diagnostic.MA0080.severity = info
dotnet_diagnostic.MA0080.severity = suggestion
3 changes: 2 additions & 1 deletion Splitracker.Domain/ActionShorthand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public record ActionShorthand(
string? CostExpression,
int Bonus,
DiceExpression? Damage,
int PerSuccessDamageBonus
int PerSuccessDamageBonus,
int TargetValue
)
{
public ActionTemplate ToTemplate()
Expand Down
2 changes: 1 addition & 1 deletion Splitracker.Domain/Commands/CharacterCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ IImmutableSet<string> TagIds
}

public abstract record UpsertCharacterInstance(
string Name
string? Name
) : ICharacterCommand
{
protected abstract string? OptionalCharacterId { get; }
Expand Down
16 changes: 11 additions & 5 deletions Splitracker.Persistence.Test/CharacterRepositoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@ async Task<Character> withCharacterCreated()
3,
4,
5),
1))
1,
15))
.Add("a2",
new("a2",
"Action 2",
Expand All @@ -585,7 +586,8 @@ async Task<Character> withCharacterCreated()
4,
1,
6),
0))
0,
16))
.Add("a3",
new("a3",
"Action 3",
Expand All @@ -595,7 +597,8 @@ async Task<Character> withCharacterCreated()
"K3v1",
14,
null,
0)),
0,
17)),
default,
[]);

Expand All @@ -615,7 +618,9 @@ string docId
1,
3,
0,
2), 1))
2),
1,
15))
.Add("a4",
new("a4",
"Action 4",
Expand All @@ -630,7 +635,8 @@ string docId
2,
5,
6),
4)),
4,
16)),
!CreateCharacterExample.IsOpponent,
[]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ void stopChanneling(Pool model, Domain.Pool domain, string channelingId)
model.TagIds = edit.TagIds.Order().ToList();
break;
case EditCharacterInstance edit:
model!.Name = edit.Name;
if (edit.Name is { } newName)
{
model!.Name = newName;
}

break;
case CreateCharacterInstance create:
if (!isOwner(create.TemplateId, userId))
Expand Down
1 change: 1 addition & 0 deletions Splitracker.Persistence/Model/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ActionShorthand
public int Bonus { get; set; }
public DiceExpression? Damage { get; set; }
public int PerSuccessDamageBonus { get; set; }
public int TargetValue { get; set; }
}

class DiceExpression
Expand Down
4 changes: 3 additions & 1 deletion Splitracker.Persistence/Model/CharacterModelMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public static Domain.ActionShorthand ToDomain(this ActionShorthand model)
model.CostExpression,
model.Bonus,
model.Damage?.ToDomain(),
model.PerSuccessDamageBonus);
model.PerSuccessDamageBonus,
model.TargetValue);
}

public static Domain.DiceExpression ToDomain(this DiceExpression model)
Expand Down Expand Up @@ -169,6 +170,7 @@ public static ActionShorthand ToDbModel(this Domain.ActionShorthand shorthand)
Bonus = shorthand.Bonus,
Damage = shorthand.Damage?.toDbModel(),
PerSuccessDamageBonus = shorthand.PerSuccessDamageBonus,
TargetValue = shorthand.TargetValue,
};
}

Expand Down
32 changes: 28 additions & 4 deletions Splitracker.UI/Shared/Characters/ActionShorthandDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,34 @@
</div>

<div
class="default-control"
style="@($"grid-row: {row++}")">
class="@(Type is ActionShorthandType.Spell ? "dense-control" : "default-control")"
style="@($"{(Type is ActionShorthandType.Spell ? "grid-column: 1/3;" : "")} grid-row: {row}")">
<MudNumericField
T="int"
@bind-Value="bonus"
Label="Fertigkeitsbonus"
autocomplete="off"/>
</div>

@if (Type is ActionShorthandType.Spell)
{
<div
class="dense-control"
style="@($"grid-column: 3; grid-row: {row}")">
<MudTooltip
Text="Voreingestellter Zielwert">
<MudNumericField
T="int"
@bind-Value="targetValue"
Label="Zielwert"
autocomplete="off"/>
</MudTooltip>
</div>
}

@{
row++;
}

<div
class="full mt-3"
Expand Down Expand Up @@ -164,7 +184,7 @@
style="@($"grid-column: 1/3; grid-row: {row++}")">
<MudTooltip
Text="Jeder Erfolg, der für Schaden verwendet wird, verursacht 2 statt 1 zusätzlichen Schaden.">
<MudCheckBox T="int" @bind-Checked="perSuccessDamageBonus">Wuchtig</MudCheckBox>
<MudCheckBox T="int" @bind-Value="perSuccessDamageBonus">Wuchtig</MudCheckBox>
</MudTooltip>
</div>

Expand Down Expand Up @@ -250,6 +270,7 @@
int damageBonusDice;
int damageClampMin;
int perSuccessDamageBonus;
int targetValue;
string? _damageExpression;
DiceExpression? _damage;

Expand All @@ -259,6 +280,7 @@
&& damageBonusDice >= 0
&& damageClampMin >= 0
&& perSuccessDamageBonus >= 0
&& targetValue >= 0
&& damageExpressionValid;

string typeObject => Type switch {
Expand All @@ -278,6 +300,7 @@
selectedTicks = shorthand.Ticks;
cost = shorthand.CostExpression;
bonus = shorthand.Bonus;
targetValue = shorthand.TargetValue;
if (shorthand.Damage is { } shorthandDamage)
{
damage = shorthandDamage;
Expand Down Expand Up @@ -317,7 +340,8 @@
PerCriticalBonus = perCriticalDamageBonus,
}
: null,
perSuccessDamageBonus
perSuccessDamageBonus,
targetValue
)
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{
<MudTooltip
@key="shorthand.Id"
Text="@shorthand.Description"
Text="@(shorthand.Description + (shorthand.TargetValue > 0 ? $"(Zielwert: {shorthand.TargetValue})" : null))"
ShowOnClick="@(shorthand.Description != null)"
ShowOnFocus="@(shorthand.Description != null)"
ShowOnHover="@(shorthand.Description != null)">
Expand Down
30 changes: 28 additions & 2 deletions Splitracker.UI/Shared/Characters/CharacterActionDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
@using Splitracker.UI.Shared.Rolls

<MudDialog>
<TitleContent>@Action.Name</TitleContent>
<TitleContent>
<MudText Typo="Typo.h3">
@Action.Name
</MudText>
<MudText
Typo="Typo.body2">
@Action.Description
@(string.Join(", ", miniStats().Select(s => $"{s.Label}: {s.Value}")) is var block and not "" ? $" ({block})" : "")
</MudText>
</TitleContent>
<DialogContent>
<MudStack>
@* Bonus *@
Expand Down Expand Up @@ -277,7 +286,7 @@
{
base.OnParametersSet();
bonus = Action.Bonus;
target = Session.RollTarget;
target = Action.TargetValue > 0 ? Action.TargetValue : Session.RollTarget;
}

void close()
Expand Down Expand Up @@ -319,4 +328,21 @@
}
}

IEnumerable<(string Label, int Value)> miniStats()
{
if (Action.Bonus > 0)
{
yield return ("Bonus", Action.Bonus);
}

if (Action.Ticks > 0)
{
yield return ("Ticks", Action.Ticks);
}

if (Action.TargetValue > 0)
{
yield return ("Zielwert", Action.TargetValue);
}
}
}
Loading