Update activity system to use new team pick time

This commit is contained in:
Slendy 2024-03-11 21:32:03 -05:00
commit 0445a0b3a6
No known key found for this signature in database
GPG key ID: 7288D68361B91428
2 changed files with 7 additions and 4 deletions

View file

@ -673,7 +673,7 @@ public class ActivityEventHandlerTests
{ {
SlotId = 1, SlotId = 1,
CreatorId = 1, CreatorId = 1,
TeamPick = true, TeamPickTime = 1,
}; };
eventHandler.OnEntityChanged(database, oldSlot, newSlot); eventHandler.OnEntityChanged(database, oldSlot, newSlot);

View file

@ -245,10 +245,13 @@ public class ActivityEntityEventHandler : IEntityEventHandler
{ {
if (origEntity is not SlotEntity oldSlotEntity) break; if (origEntity is not SlotEntity oldSlotEntity) break;
switch (oldSlotEntity.TeamPick) bool oldIsTeamPick = oldSlotEntity.TeamPickTime != 0;
bool newIsTeamPick = slotEntity.TeamPickTime != 0;
switch (oldIsTeamPick)
{ {
// When a level is team picked // When a level is team picked
case false when slotEntity.TeamPick: case false when newIsTeamPick:
activity = new LevelActivityEntity activity = new LevelActivityEntity
{ {
Type = EventType.MMPickLevel, Type = EventType.MMPickLevel,
@ -257,7 +260,7 @@ public class ActivityEntityEventHandler : IEntityEventHandler
}; };
break; break;
// When a level has its team pick removed then remove the corresponding activity // When a level has its team pick removed then remove the corresponding activity
case true when !slotEntity.TeamPick: case true when !newIsTeamPick:
database.Activities.OfType<LevelActivityEntity>() database.Activities.OfType<LevelActivityEntity>()
.Where(a => a.Type == EventType.MMPickLevel) .Where(a => a.Type == EventType.MMPickLevel)
.Where(a => a.SlotId == slotEntity.SlotId) .Where(a => a.SlotId == slotEntity.SlotId)