Filter out targets the player has hacked already
This commit is contained in:
parent
70baa01d32
commit
7526d8bd7c
@ -246,7 +246,7 @@ let getRandomHackablePlayers (did : uint64) =
|
|||||||
JOIN user_achievements_achievement uaa ON "user".id = uaa.user_id
|
JOIN user_achievements_achievement uaa ON "user".id = uaa.user_id
|
||||||
JOIN achievement a ON uaa.achievement_id = a.id AND a.symbol = 'FINISHED_TRAINER'
|
JOIN achievement a ON uaa.achievement_id = a.id AND a.symbol = 'FINISHED_TRAINER'
|
||||||
WHERE "user".in_game = true AND gbt > 20 AND "user".discord_id != @did
|
WHERE "user".in_game = true AND gbt > 20 AND "user".discord_id != @did
|
||||||
ORDER BY random() LIMIT 5
|
ORDER BY random() LIMIT 10
|
||||||
"""
|
"""
|
||||||
|> Sql.executeAsync (fun read -> {| Id = read.string "discord_id" |> uint64 ; Name = read.string "display_name" |})
|
|> Sql.executeAsync (fun read -> {| Id = read.string "discord_id" |> uint64 ; Name = read.string "display_name" |})
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
@ -228,8 +228,16 @@ let handleDefense (ctx : IDiscordContext) =
|
|||||||
})
|
})
|
||||||
|
|
||||||
let scan (ctx : IDiscordContext) =
|
let scan (ctx : IDiscordContext) =
|
||||||
executePlayerAction ctx (fun _ -> async {
|
executePlayerAction ctx (fun player -> async {
|
||||||
let! targets = DbService.getRandomHackablePlayers (ctx.GetDiscordMember().Id)
|
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)
|
||||||
|
targets
|
||||||
|
|> List.filter (fun t -> hackedIds |> List.exists (fun hid -> hid = t.Id) |> not)
|
||||||
|
|> List.truncate 5
|
||||||
let sb = StringBuilder()
|
let sb = StringBuilder()
|
||||||
let mutable count = 0
|
let mutable count = 0
|
||||||
for t in targets do
|
for t in targets do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user