Remove expired actions for scan

This commit is contained in:
Joseph Ferano 2022-04-18 13:57:43 +07:00
parent 7526d8bd7c
commit c94f74e25b

View File

@ -232,9 +232,10 @@ let scan (ctx : IDiscordContext) =
let! targets = DbService.getRandomHackablePlayers (ctx.GetDiscordMember().Id)
let targets =
let hackedIds =
player.Events
|> List.choose (fun e ->
match e.Type with | Hacking hack -> Some hack.Adversary.Id | _ -> None)
player
|> Player.removeExpiredActions
|> fun p -> p.Events
|> List.choose (fun e -> match e.Type with | Hacking hack -> Some hack.Adversary.Id | _ -> None)
targets
|> List.filter (fun t -> hackedIds |> List.exists (fun hid -> hid = t.Id) |> not)
|> List.truncate 5