Give 24 hour shields to new players
This commit is contained in:
parent
22cac7c96a
commit
f60531a15d
@ -69,7 +69,7 @@ let checkTargetHasFunds target player =
|
|||||||
| true -> Error $"Looks like the poor bastard has no $GBT... pick a different victim."
|
| true -> Error $"Looks like the poor bastard has no $GBT... pick a different victim."
|
||||||
| false -> Ok player
|
| false -> Ok player
|
||||||
|
|
||||||
let checkTargetCompletedTraining target (player : PlayerData) = async {
|
let checkTargetIsNoob target (player : PlayerData) = async {
|
||||||
let! targetCompletedTraining = DbService.checkHasAchievement target.DiscordId Trainer.TrainerAchievement
|
let! targetCompletedTraining = DbService.checkHasAchievement target.DiscordId Trainer.TrainerAchievement
|
||||||
if targetCompletedTraining || not target.Inventory.IsEmpty
|
if targetCompletedTraining || not target.Inventory.IsEmpty
|
||||||
then return Ok player
|
then return Ok player
|
||||||
@ -143,7 +143,7 @@ let failedHack (ctx : IDiscordContext) attacker defender (hack : HackItem) =
|
|||||||
|
|
||||||
let hack (target : DiscordUser) (ctx : IDiscordContext) =
|
let hack (target : DiscordUser) (ctx : IDiscordContext) =
|
||||||
executePlayerActionWithTarget target ctx (fun attacker defender -> async {
|
executePlayerActionWithTarget target ctx (fun attacker defender -> async {
|
||||||
let! result = checkTargetCompletedTraining defender attacker
|
let! result = checkTargetIsNoob defender attacker
|
||||||
do! attacker
|
do! attacker
|
||||||
|> Player.removeExpiredActions
|
|> Player.removeExpiredActions
|
||||||
|> checkAlreadyHackedTarget defender
|
|> checkAlreadyHackedTarget defender
|
||||||
@ -307,6 +307,35 @@ let handleMessageCreated (_ : DiscordClient) (event : MessageCreateEventArgs) =
|
|||||||
do! event.Message.DeleteAsync()
|
do! event.Message.DeleteAsync()
|
||||||
} :> Task
|
} :> Task
|
||||||
|
|
||||||
|
let BeginnerProtectionHours = 24
|
||||||
|
let ShieldEvents () = [
|
||||||
|
{ Timestamp = System.DateTime.UtcNow
|
||||||
|
Cooldown = BeginnerProtectionHours * 60<mins>
|
||||||
|
Type = Shielding (string ItemId.FIREWALL) }
|
||||||
|
{ Timestamp = System.DateTime.UtcNow
|
||||||
|
Cooldown = BeginnerProtectionHours * 60<mins>
|
||||||
|
Type = Shielding (string ItemId.ENCRYPTION) }
|
||||||
|
{ Timestamp = System.DateTime.UtcNow
|
||||||
|
Cooldown = BeginnerProtectionHours * 60<mins>
|
||||||
|
Type = Shielding (string ItemId.CYPHER) }
|
||||||
|
]
|
||||||
|
|
||||||
|
let handleMemberUpdated (client : DiscordClient) (event : GuildMemberUpdateEventArgs) =
|
||||||
|
let addedRole (rolesBefore : DiscordRole seq) (rolesAfter : DiscordRole seq) =
|
||||||
|
rolesAfter |> Seq.filter ((fun role -> rolesBefore |> Seq.exists (fun r -> role.Id = r.Id)) >> not)
|
||||||
|
task {
|
||||||
|
let symmetricDifference = addedRole event.RolesBefore event.RolesAfter |> Seq.toList
|
||||||
|
match symmetricDifference with
|
||||||
|
| [] -> ()
|
||||||
|
| role::_ ->
|
||||||
|
if role.Name = "Pregen" then
|
||||||
|
do! ShieldEvents ()
|
||||||
|
|> List.map (DbService.addPlayerEvent event.Member.Id)
|
||||||
|
|> Async.Parallel
|
||||||
|
|> Async.Ignore
|
||||||
|
return ()
|
||||||
|
} :> Task
|
||||||
|
|
||||||
|
|
||||||
type HackerGame() =
|
type HackerGame() =
|
||||||
inherit ApplicationCommandModule ()
|
inherit ApplicationCommandModule ()
|
||||||
|
@ -13,7 +13,6 @@ let hackItem = Arsenal.weapons |> Inventory.findItemById (string ItemId.REMOTE)
|
|||||||
let shieldItem = Arsenal.weapons |> Inventory.findItemById (string ItemId.FIREWALL)
|
let shieldItem = Arsenal.weapons |> Inventory.findItemById (string ItemId.FIREWALL)
|
||||||
let defaultHack = (Inventory.getHackItem hackItem).Value
|
let defaultHack = (Inventory.getHackItem hackItem).Value
|
||||||
let defaultShield = (Inventory.getShieldItem shieldItem ).Value
|
let defaultShield = (Inventory.getShieldItem shieldItem ).Value
|
||||||
let BeginnerProtectionHours = 24
|
|
||||||
|
|
||||||
let HackEvent () = {
|
let HackEvent () = {
|
||||||
Timestamp = System.DateTime.UtcNow
|
Timestamp = System.DateTime.UtcNow
|
||||||
@ -25,17 +24,12 @@ let HackEvent () = {
|
|||||||
HackId = defaultHack.Id
|
HackId = defaultHack.Id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let ShieldEvents () = [
|
|
||||||
{ Timestamp = System.DateTime.UtcNow
|
let ShieldEvent () = {
|
||||||
Cooldown = BeginnerProtectionHours * 60<mins>
|
Timestamp = System.DateTime.UtcNow
|
||||||
Type = Shielding (string ItemId.FIREWALL) }
|
Cooldown = defaultShield.Cooldown
|
||||||
{ Timestamp = System.DateTime.UtcNow
|
Type = Shielding defaultShield.Id
|
||||||
Cooldown = BeginnerProtectionHours * 60<mins>
|
}
|
||||||
Type = Shielding (string ItemId.ENCRYPTION) }
|
|
||||||
{ Timestamp = System.DateTime.UtcNow
|
|
||||||
Cooldown = BeginnerProtectionHours * 60<mins>
|
|
||||||
Type = Shielding (string ItemId.CYPHER) }
|
|
||||||
]
|
|
||||||
|
|
||||||
let sendInitialEmbed (ctx : IDiscordContext) =
|
let sendInitialEmbed (ctx : IDiscordContext) =
|
||||||
async {
|
async {
|
||||||
@ -169,9 +163,6 @@ Here, I'm going to gift you:
|
|||||||
1. A hack - `{defaultHack.Name}`,
|
1. A hack - `{defaultHack.Name}`,
|
||||||
2. A shield - `{defaultShield.Name}`,
|
2. A shield - `{defaultShield.Name}`,
|
||||||
|
|
||||||
I'm also going to give you some **TEMPORARY SHIELDS** until you buy your own.
|
|
||||||
They will **ONLY** protect you from hacks for **{BeginnerProtectionHours} hrs**...
|
|
||||||
|
|
||||||
To finish your training and collect all your **GIFTS**,
|
To finish your training and collect all your **GIFTS**,
|
||||||
type the `/arsenal` command NOW"""
|
type the `/arsenal` command NOW"""
|
||||||
|
|
||||||
@ -201,14 +192,6 @@ let handleArsenal (ctx : IDiscordContext) = PlayerInteractions.executePlayerActi
|
|||||||
do! DbService.addToPlayerInventory player.DiscordId hackItem |> Async.Ignore
|
do! DbService.addToPlayerInventory player.DiscordId hackItem |> Async.Ignore
|
||||||
if player.Inventory |> List.exists (fun i -> i.Id = shieldItem.Id) |> not then
|
if player.Inventory |> List.exists (fun i -> i.Id = shieldItem.Id) |> not then
|
||||||
do! DbService.addToPlayerInventory player.DiscordId shieldItem |> Async.Ignore
|
do! DbService.addToPlayerInventory player.DiscordId shieldItem |> Async.Ignore
|
||||||
try
|
|
||||||
do! ShieldEvents () @ [ HackEvent () ]
|
|
||||||
|> List.map (DbService.addPlayerEvent player.DiscordId)
|
|
||||||
|> Async.Parallel
|
|
||||||
|> Async.Ignore
|
|
||||||
with ex ->
|
|
||||||
printfn "%s" ex.Message
|
|
||||||
()
|
|
||||||
|
|
||||||
let updatedPlayer = {
|
let updatedPlayer = {
|
||||||
player with
|
player with
|
||||||
@ -216,9 +199,8 @@ let handleArsenal (ctx : IDiscordContext) = PlayerInteractions.executePlayerActi
|
|||||||
player
|
player
|
||||||
|> Player.removeExpiredActions
|
|> Player.removeExpiredActions
|
||||||
|> fun p -> p.Events
|
|> fun p -> p.Events
|
||||||
|> List.filter (fun e -> match e.Type with Shielding _ -> false | _ -> true)
|
|> List.filter (fun e -> match e.Type with Shielding shieldId -> shieldId <> defaultShield.Id | _ -> true)
|
||||||
|> List.append (ShieldEvents())
|
|> (@) [ HackEvent() ; ShieldEvent() ]
|
||||||
|> List.consTo (HackEvent())
|
|
||||||
Inventory =
|
Inventory =
|
||||||
player.Inventory
|
player.Inventory
|
||||||
|> addIfDoesntExist hackItem
|
|> addIfDoesntExist hackItem
|
||||||
|
@ -5,8 +5,8 @@ module ResultHelpers =
|
|||||||
let (>>=) x f = Result.bind f x
|
let (>>=) x f = Result.bind f x
|
||||||
let (<!>) x f = Result.map f x
|
let (<!>) x f = Result.map f x
|
||||||
|
|
||||||
[<RequireQualifiedAccess>]
|
|
||||||
[<Microsoft.FSharp.Core.AutoOpen>]
|
[<Microsoft.FSharp.Core.AutoOpen>]
|
||||||
|
[<RequireQualifiedAccess>]
|
||||||
module List =
|
module List =
|
||||||
let cons xs x = x :: xs
|
let cons xs x = x :: xs
|
||||||
let consTo x xs = x :: xs
|
let consTo x xs = x :: xs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user