Skip to content

Commit

Permalink
Update activity system to use new team pick time
Browse files Browse the repository at this point in the history
  • Loading branch information
Slendy committed Mar 25, 2024
1 parent 0f02a93 commit 0445a0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ public async Task Slot_WithTeamPickChange_ShouldCreateLevelActivity()
{
SlotId = 1,
CreatorId = 1,
TeamPick = true,
TeamPickTime = 1,
};

eventHandler.OnEntityChanged(database, oldSlot, newSlot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,13 @@ public void OnEntityChanged<T>(DatabaseContext database, T origEntity, T current
{
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
case false when slotEntity.TeamPick:
case false when newIsTeamPick:
activity = new LevelActivityEntity
{
Type = EventType.MMPickLevel,
Expand All @@ -257,7 +260,7 @@ public void OnEntityChanged<T>(DatabaseContext database, T origEntity, T current
};
break;
// 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>()
.Where(a => a.Type == EventType.MMPickLevel)
.Where(a => a.SlotId == slotEntity.SlotId)
Expand Down

0 comments on commit 0445a0b

Please sign in to comment.