From 5f01408fbd4cb00967983b6709243801bfde2bee Mon Sep 17 00:00:00 2001 From: Jason Jackson Date: Tue, 31 Dec 2024 08:42:18 -0500 Subject: [PATCH] Added display to dweller table that shows if they are in a room with a max stat. --- .../Extensions/RoomExtension.cs | 26 +++++++++ ShelterViewer.Shared/Pages/Dwellers.razor | 53 +++++++++++++------ 2 files changed, 62 insertions(+), 17 deletions(-) create mode 100644 ShelterViewer.Shared/Extensions/RoomExtension.cs diff --git a/ShelterViewer.Shared/Extensions/RoomExtension.cs b/ShelterViewer.Shared/Extensions/RoomExtension.cs new file mode 100644 index 0000000..8e4a3be --- /dev/null +++ b/ShelterViewer.Shared/Extensions/RoomExtension.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShelterViewer.Shared.Models; + +namespace ShelterViewer.Shared.Extensions; + +public static class RoomExtension +{ + public static Stats.SpecialStats? ToSpecialStat(this string trait) + { + return trait.ToLower() switch + { + "strength" => Stats.SpecialStats.Strength, + "perception" => Stats.SpecialStats.Perception, + "endurance" => Stats.SpecialStats.Endurance, + "charisma" => Stats.SpecialStats.Charisma, + "intelligence" => Stats.SpecialStats.Intelligence, + "agility" => Stats.SpecialStats.Agility, + "luck" => Stats.SpecialStats.Luck, + _ => null + }; + } +} diff --git a/ShelterViewer.Shared/Pages/Dwellers.razor b/ShelterViewer.Shared/Pages/Dwellers.razor index ff4d142..0c30769 100644 --- a/ShelterViewer.Shared/Pages/Dwellers.razor +++ b/ShelterViewer.Shared/Pages/Dwellers.razor @@ -1,24 +1,24 @@ @page "/dwellers" @using ShelterViewer.Shared.Components.Dwellers +@using ShelterViewer.Shared.Extensions @inject VaultService VaultService @inject NavigationManager NavigationManager @inject IDialogService DialogService -

Dwellers

- - Dwellers" + Dwellers + + AdornmentIcon="Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0"/> - + @@ -49,14 +49,25 @@ } - + + + + + @{ + var room = VaultService.GetRoom(context.Item.savedRoom); + } + @(room?.Name ?? "Coffee Break") @if(room != null && !String.IsNullOrEmpty(room.Trait)) { @($" ( {room.Trait.FirstOrDefault()} )") } + + + + View + Variant="@Variant.Filled" + Color="@Color.Primary" + OnClick="() => ShowDweller(context.Item)">View @@ -68,15 +79,15 @@ @code { @@ -108,10 +119,18 @@ return DialogService.ShowAsync("Dweller Info", parameters, options); } - private string GetRoomName(int roomNumber) + private Color MatchedRoom(Dweller dweller, Room room) { - var room = VaultService.GetRoom(roomNumber); - return room?.type ?? "Coffee Break"; + if(room == null) + return Color.Inherit; + + foreach(Stats.MaxStat stat in dweller.MaxStats) + { + if (!string.IsNullOrEmpty(room!.Trait) && stat.StatName == room!.Trait.ToSpecialStat()) + return Color.Success; + } + + return Color.Warning; } private Func _quickFilter => x =>