fix: account for lobby

This commit is contained in:
Anna 2023-02-19 22:56:28 -05:00
parent 073943c799
commit 238ab34a9d
2 changed files with 20 additions and 15 deletions

View File

@ -3,17 +3,18 @@
namespace OrangeGuidanceTomestone; namespace OrangeGuidanceTomestone;
internal static class HousingLocationExt { internal static class HousingLocationExt {
internal const ushort Apt = 10_000;
internal const ushort Wng = 5_000;
internal static ushort? CombinedPlot(this HousingLocation housing) { internal static ushort? CombinedPlot(this HousingLocation housing) {
if (housing is { Apartment: { } apt, ApartmentWing: { } wing }) { return housing switch {
return (ushort) (10_000 // lobby
+ (wing - 1) * 5_000 { Apartment: null, ApartmentWing: { } wang } => (ushort) (Apt + (wang - 1) * Wng),
+ apt); // apartment
} { Apartment: { } apt, ApartmentWing: { } wing } => (ushort) (Apt + (wing - 1) * Wng + apt),
// normal plot interior
if (housing.Plot is { } plotNum) { { Plot: { } plotNum } => plotNum,
return plotNum; _ => null,
} };
return null;
} }
} }

View File

@ -79,12 +79,16 @@ internal class MessageList : ITab {
loc += $" (Ward {message.Ward.Value}"; loc += $" (Ward {message.Ward.Value}";
if (message.Plot != null) { if (message.Plot != null) {
if (message.Plot.Value >= 10_000) { if (message.Plot.Value >= HousingLocationExt.Apt) {
var apartment = message.Plot.Value - 10_000; var apartment = message.Plot.Value - 10_000;
var wing = apartment < 5_000 ? 1 : 2; var wing = apartment < HousingLocationExt.Wng ? 1 : 2;
var apt = wing == 2 ? apartment - 5_000 : apartment; 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 { } else {
loc += $", Plot {message.Plot.Value}"; loc += $", Plot {message.Plot.Value}";
} }