| | | 1 | | <div> |
| | | 2 | | <h3>For Raid</h3> |
| | | 3 | | <p>You are taking these into raid with you and they will be lost if you die.</p> |
| | | 4 | | <p class="encumbrance-readout"> |
| | | 5 | | <span class="encumbrance-label">Encumbrance:</span> |
| | 0 | 6 | | <span class="encumbrance-value @GetEncumbranceSeverityCssClass()">@EncumbranceText</span> |
| | 0 | 7 | | @if (ShouldShowEncumbranceTier()) |
| | | 8 | | { |
| | 0 | 9 | | <span class="encumbrance-tier @GetEncumbranceSeverityCssClass()">@GetEncumbranceTierLabel()</span> |
| | | 10 | | } |
| | | 11 | | </p> |
| | 0 | 12 | | @if (OnPersonItems.Count == 0) |
| | | 13 | | { |
| | | 14 | | <p>Nothing selected.</p> |
| | | 15 | | } |
| | | 16 | | else |
| | | 17 | | { |
| | 0 | 18 | | @for (var i = 0; i < OnPersonItems.Count; i++) |
| | | 19 | | { |
| | 0 | 20 | | var onPersonIndex = i; |
| | 0 | 21 | | var entry = OnPersonItems[onPersonIndex]; |
| | | 22 | | <div class="row-item"> |
| | | 23 | | <ItemTypeIcon Type="entry.Item.Type" /> |
| | 0 | 24 | | <span class="item-name rarity-@entry.Item.DisplayRarity.ToString().ToLower()">@ItemPresentationCatalog.G |
| | | 25 | | <div class="row-actions"> |
| | 0 | 26 | | @if (IsSlotType(entry.Item.Type)) |
| | | 27 | | { |
| | 0 | 28 | | <button class="action" @onclick="() => ToggleEquipAsync(onPersonIndex, entry.IsEquipped)">@(entr |
| | | 29 | | } |
| | 0 | 30 | | <button class="action" disabled="@(!CanStashItem)" @onclick="() => OnStore.InvokeAsync(onPersonIndex |
| | 0 | 31 | | <button class="action" disabled="@(!CanSellItem(entry.Item))" @onclick="() => OnSell.InvokeAsync(onP |
| | | 32 | | </div> |
| | | 33 | | </div> |
| | | 34 | | } |
| | 0 | 35 | | @if (!CanStashItem) |
| | | 36 | | { |
| | | 37 | | <p>Stash full. Sell or use items first.</p> |
| | | 38 | | } |
| | | 39 | | } |
| | | 40 | | |
| | 0 | 41 | | <button class="action top-gap" disabled="@(!CanStartRaid)" @onclick="() => OnStartRaid.InvokeAsync()">Enter Raid</bu |
| | 0 | 42 | | @if (!CanStartRaid && !string.IsNullOrWhiteSpace(RaidBlockReason)) |
| | | 43 | | { |
| | 0 | 44 | | <p>@RaidBlockReason</p> |
| | | 45 | | } |
| | | 46 | | </div> |
| | | 47 | | |
| | | 48 | | @code { |
| | 0 | 49 | | [Parameter, EditorRequired] public IReadOnlyList<OnPersonEntry> OnPersonItems { get; set; } = []; |
| | 0 | 50 | | [Parameter, EditorRequired] public bool CanStashItem { get; set; } |
| | 0 | 51 | | [Parameter, EditorRequired] public bool CanStartRaid { get; set; } |
| | 0 | 52 | | [Parameter] public string? RaidBlockReason { get; set; } |
| | 0 | 53 | | [Parameter, EditorRequired] public string EncumbranceText { get; set; } = string.Empty; |
| | 0 | 54 | | [Parameter, EditorRequired] public int MaxEncumbrance { get; set; } |
| | 0 | 55 | | [Parameter, EditorRequired] public Func<Item, bool> CanSellItem { get; set; } = _ => false; |
| | 0 | 56 | | [Parameter, EditorRequired] public Func<Item, int> GetSellPrice { get; set; } = _ => 0; |
| | 0 | 57 | | [Parameter, EditorRequired] public Func<ItemType, bool> IsSlotType { get; set; } = _ => false; |
| | 0 | 58 | | [Parameter, EditorRequired] public EventCallback<int> OnEquip { get; set; } |
| | 0 | 59 | | [Parameter, EditorRequired] public EventCallback<int> OnUnequip { get; set; } |
| | 0 | 60 | | [Parameter, EditorRequired] public EventCallback<int> OnStore { get; set; } |
| | 0 | 61 | | [Parameter, EditorRequired] public EventCallback<int> OnSell { get; set; } |
| | 0 | 62 | | [Parameter, EditorRequired] public EventCallback OnStartRaid { get; set; } |
| | | 63 | | |
| | | 64 | | private Task ToggleEquipAsync(int index, bool isEquipped) |
| | | 65 | | { |
| | 0 | 66 | | return isEquipped ? OnUnequip.InvokeAsync(index) : OnEquip.InvokeAsync(index); |
| | | 67 | | } |
| | | 68 | | |
| | | 69 | | private int GetCurrentEncumbrance() |
| | | 70 | | { |
| | 0 | 71 | | return OnPersonItems.Sum(entry => Math.Max(0, entry.Item.Weight)); |
| | | 72 | | } |
| | | 73 | | |
| | | 74 | | private EncumbranceTier GetDisplayedEncumbranceTier() |
| | | 75 | | { |
| | 0 | 76 | | if (MaxEncumbrance <= 0) |
| | | 77 | | { |
| | 0 | 78 | | return EncumbranceTier.Light; |
| | | 79 | | } |
| | | 80 | | |
| | 0 | 81 | | var carriedWeight = GetCurrentEncumbrance(); |
| | 0 | 82 | | var lightThreshold = MaxEncumbrance / 3; |
| | 0 | 83 | | var mediumThreshold = (MaxEncumbrance * 2) / 3; |
| | | 84 | | |
| | 0 | 85 | | if (carriedWeight <= lightThreshold) |
| | | 86 | | { |
| | 0 | 87 | | return EncumbranceTier.Light; |
| | | 88 | | } |
| | | 89 | | |
| | 0 | 90 | | if (carriedWeight <= mediumThreshold) |
| | | 91 | | { |
| | 0 | 92 | | return EncumbranceTier.Medium; |
| | | 93 | | } |
| | | 94 | | |
| | 0 | 95 | | return EncumbranceTier.Heavy; |
| | | 96 | | } |
| | | 97 | | |
| | | 98 | | private bool ShouldShowEncumbranceTier() |
| | | 99 | | { |
| | 0 | 100 | | return GetDisplayedEncumbranceTier() is not EncumbranceTier.Light; |
| | | 101 | | } |
| | | 102 | | |
| | | 103 | | private string GetEncumbranceTierLabel() |
| | | 104 | | { |
| | 0 | 105 | | return GetDisplayedEncumbranceTier().ToString(); |
| | | 106 | | } |
| | | 107 | | |
| | | 108 | | private string GetEncumbranceSeverityCssClass() |
| | | 109 | | { |
| | 0 | 110 | | return GetDisplayedEncumbranceTier() switch |
| | 0 | 111 | | { |
| | 0 | 112 | | EncumbranceTier.Medium => "encumbrance-medium", |
| | 0 | 113 | | EncumbranceTier.Heavy => "encumbrance-heavy", |
| | 0 | 114 | | _ => string.Empty |
| | 0 | 115 | | }; |
| | | 116 | | } |
| | | 117 | | } |