Skip to content

Commit ec0e8f3

Browse files
committed
Fix crystal heart stamp appearing too early on save file slots
... you just had to collect 5 hearts. No matter if mini or big.
1 parent b2c2442 commit ec0e8f3

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

LobbyHelper.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ private static void onOuiFileSelectSlotShow(On.Celeste.OuiFileSelectSlot.orig_Sh
440440
if (stats.Name.StartsWith($"{collab2}/")) {
441441
totalStrawberries += stats.TotalStrawberries;
442442
totalGoldenStrawberries += stats.TotalGoldenStrawberries;
443-
totalHeartGems += stats.TotalHeartGems;
443+
totalHeartGems += countTotalHeartGemsForMapsThatHaveHearts(stats);
444444
totalCassettes += stats.TotalCassettes;
445445
maxStrawberryCount += stats.MaxStrawberries;
446446
maxGoldenStrawberryCount += stats.MaxGoldenStrawberries;
@@ -450,7 +450,7 @@ private static void onOuiFileSelectSlotShow(On.Celeste.OuiFileSelectSlot.orig_Sh
450450
maxCrystalHeartsExcludingCSides += stats.MaxHeartGemsExcludingCSides;
451451
}
452452
}
453-
453+
454454
DynData<OuiFileSelectSlot> slotData = new DynData<OuiFileSelectSlot>(self);
455455
slotData["totalGoldenStrawberries"] = totalGoldenStrawberries;
456456
slotData["totalHeartGems"] = totalHeartGems;
@@ -474,6 +474,23 @@ private static void onOuiFileSelectSlotShow(On.Celeste.OuiFileSelectSlot.orig_Sh
474474
}
475475
}
476476

477+
private static int countTotalHeartGemsForMapsThatHaveHearts(LevelSetStats levelSetStats) {
478+
return levelSetStats.AreasIncludingCeleste.Sum((AreaStats area) => {
479+
int totalHeartGems = 0;
480+
ModeProperties[] propertiesOfAllModes = AreaData.Get(area.GetSID())?.Mode ?? new ModeProperties[0];
481+
for (int i = 0; i < propertiesOfAllModes.Length && i < area.Modes.Length; i++) {
482+
if (area.Modes[i].HeartGem) {
483+
// the crystal heart of this map/mode was collected, so check if it has one before counting it in.
484+
ModeProperties modeProperties = propertiesOfAllModes[i];
485+
if (modeProperties?.MapData != null && modeProperties.MapData.Area.Mode <= AreaMode.CSide) {
486+
totalHeartGems += (modeProperties.MapData.DetectedHeartGem ? 1 : 0);
487+
}
488+
}
489+
}
490+
return totalHeartGems;
491+
});
492+
}
493+
477494
private static void modSelectSlotLevelSetDisplayName(ILContext il) {
478495
ILCursor cursor = new ILCursor(il);
479496

0 commit comments

Comments
 (0)