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;
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,
};
}
}

View File

@ -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}";
}