diff --git a/client/HousingLocationExt.cs b/client/HousingLocationExt.cs index 181c329..bb67121 100755 --- a/client/HousingLocationExt.cs +++ b/client/HousingLocationExt.cs @@ -3,17 +3,18 @@ namespace OrangeGuidanceTomestone; internal static class HousingLocationExt { + internal const ushort Apt = 10_000; + internal const ushort Wng = 5_000; + internal static ushort? CombinedPlot(this HousingLocation housing) { - if (housing is { Apartment: { } apt, ApartmentWing: { } wing }) { - return (ushort) (10_000 - + (wing - 1) * 5_000 - + apt); - } - - if (housing.Plot is { } plotNum) { - return plotNum; - } - - return null; + return housing switch { + // lobby + { Apartment: null, ApartmentWing: { } wang } => (ushort) (Apt + (wang - 1) * Wng), + // apartment + { Apartment: { } apt, ApartmentWing: { } wing } => (ushort) (Apt + (wing - 1) * Wng + apt), + // normal plot interior + { Plot: { } plotNum } => plotNum, + _ => null, + }; } } diff --git a/client/Ui/MainWindowTabs/MessageList.cs b/client/Ui/MainWindowTabs/MessageList.cs index 5d3b15b..bc32c8c 100644 --- a/client/Ui/MainWindowTabs/MessageList.cs +++ b/client/Ui/MainWindowTabs/MessageList.cs @@ -79,12 +79,16 @@ internal class MessageList : ITab { loc += $" (Ward {message.Ward.Value}"; if (message.Plot != null) { - if (message.Plot.Value >= 10_000) { + if (message.Plot.Value >= HousingLocationExt.Apt) { var apartment = message.Plot.Value - 10_000; - var wing = apartment < 5_000 ? 1 : 2; - var apt = wing == 2 ? apartment - 5_000 : apartment; + var wing = apartment < HousingLocationExt.Wng ? 1 : 2; + var apt = wing == 2 ? apartment - HousingLocationExt.Wng : apartment; - loc += $", Apt. {apt}, Wing {wing}"; + if (apt == 0) { + loc += $", Wing {wing} Lobby"; + } else { + loc += $", Apt. {apt}, Wing {wing}"; + } } else { loc += $", Plot {message.Plot.Value}"; }