Skip to content

Commit 5bc713e

Browse files
authored
Merge pull request #1566 from leotsarev/bug/charslots
A lot of bug fixes to charslots
2 parents ac63f51 + 89fbca6 commit 5bc713e

File tree

6 files changed

+21
-6
lines changed

6 files changed

+21
-6
lines changed

src/JoinRpg.Dal.Impl/Repositories/CharacterRepositoryImpl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public async Task<CharacterView> GetCharacterViewAsync(int projectId, int charac
8888
UpdatedAt = character.UpdatedAt,
8989
IsActive = character.IsActive,
9090
InGame = character.InGame,
91-
CharacterTypeInfo = new(character.IsAvailable ? CharacterType.Player : CharacterType.NonPlayer, character.IsHot, character.CharacterSlotLimit),
91+
CharacterTypeInfo = new(character.CharacterType, character.IsHot, character.CharacterSlotLimit),
9292
JsonData = character.JsonData,
9393
ApprovedClaim = await Ctx.Set<Claim>()
9494
.Where(claim => claim.CharacterId == characterId &&

src/JoinRpg.Portal/Views/GameGroups/_CharacterPartial.cshtml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@
3030
@if (Model.IsAvailable)
3131
{
3232
<text>&nbsp;</text>
33-
@Html.ActionLink("заявиться", "AddForCharacter", "Claim", new { Model.ProjectId, Model.CharacterId }, new { @class = "btn btn-default btn-xs" })
33+
<a asp-controller="Claim" asp-action="AddForCharacter" asp-route-projectid="@Model.ProjectId" asp-route-characterId="@Model.CharacterId" class="btn btn-default btn-xs">
34+
заявиться
35+
@if (Model.SlotLimit is not null)
36+
{
37+
<text>&nbsp; (@Model.SlotLimit мест)</text>
38+
}
39+
</a>
3440
if (Model.IsHot)
3541
{
3642
<span class="label label-warning">Горячая роль</span>

src/JoinRpg.Web.CharacterGroups/CharacterTypeSelector.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@if (characterType == CharacterTypeView.Slot)
1414
{
1515
<FormRow Label="Лимит персонажей в слоте" Description="Оставьте пустым, чтобы не ограничивать число персонажей, которые могут быть созданы из этого слота.">
16-
<NumberInput @bind-Value="@characterSlotLimit" name="@(Name + ".SlotLimit")" />
16+
<NumberInput @bind-Value="@characterSlotLimit" name="@(Name + ".SlotLimit")" Min="0"/>
1717
</FormRow>
1818
}
1919

src/JoinRpg.WebComponents/NumberInput.razor

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
<input type="number" class="form-control" @onchange="UpdateValue" name="@Name" value="@Value"/>
1+
<input type="number" class="form-control" @onchange="UpdateValue" name="@Name" value="@Value" min="@Min" max="@Max"/>
22

33
@code {
44
[Parameter]
5-
public int? Value { get; set; }
5+
public int? Value { get; set; }
66

77
[Parameter]
88
public EventCallback<int?> ValueChanged { get; set; }
99

1010
[Parameter]
1111
public string Name { get; set; } = null!;
1212

13+
[Parameter]
14+
public int? Min { get; set; }
15+
16+
[Parameter]
17+
public int? Max { get; set; }
18+
1319
private async Task UpdateValue(ChangeEventArgs eventArgs)
1420
{
1521
var value = eventArgs.Value?.ToString();

src/JoinRpg.WebPortal.Models/Characters/CharacterGroupListViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ private CharacterViewModel GenerateCharacter(Character arg, CharacterGroup group
126126
CharacterId = arg.CharacterId,
127127
CharacterName = arg.CharacterName,
128128
IsFirstCopy = !AlreadyOutputedChars.Contains(arg.CharacterId),
129-
IsAvailable = arg.IsAvailable,
129+
IsAvailable = arg.IsAvailable && arg.CharacterSlotLimit != 0,
130+
SlotLimit = arg.CharacterSlotLimit,
130131
Description = arg.Description.ToHtmlString(),
131132
IsPublic = arg.IsPublic,
132133
IsActive = arg.IsActive,

src/JoinRpg.WebPortal.Models/Characters/CharacterViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public class CharacterViewModel :
1818

1919
public bool IsAvailable { get; set; }
2020

21+
public int? SlotLimit { get; set; }
22+
2123
public JoinHtmlString Description { get; set; }
2224

2325
public bool IsPublic { get; set; }

0 commit comments

Comments
 (0)