Fix a few bugs and disable inviter
This commit is contained in:
parent
81cd471a7f
commit
eba589746b
@ -90,7 +90,7 @@ GuildEnvironment.botUserArmory <- Some storeBot.CurrentUser
|
|||||||
|
|
||||||
stealBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
stealBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
|
|
||||||
inviterBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
//inviterBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
|
|
||||||
//let channel = hackerBattleBot.GetChannelAsync(1234uL) |> Async.AwaitTask |> Async.RunSynchronously
|
//let channel = hackerBattleBot.GetChannelAsync(1234uL) |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
//channel.invi
|
//channel.invi
|
||||||
|
@ -57,8 +57,7 @@ let pickDefense actionId player isTrainer =
|
|||||||
.WithDescription("Pick a shield to protect yourself from hacks")
|
.WithDescription("Pick a shield to protect yourself from hacks")
|
||||||
|
|
||||||
for shield in Inventory.getShields player.Inventory do
|
for shield in Inventory.getShields player.Inventory do
|
||||||
// TODO: This is returning a decimal so look into why
|
let hours = TimeSpan.FromMinutes(int shield.Cooldown).TotalHours |> int
|
||||||
let hours = TimeSpan.FromMinutes(int shield.Cooldown).TotalHours
|
|
||||||
let against = WeaponClass.getGoodAgainst(shield.Class) |> snd
|
let against = WeaponClass.getGoodAgainst(shield.Class) |> snd
|
||||||
embed.AddField(shield.Item.Name, $"Active {hours} hours\nDefeats {against}", true) |> ignore
|
embed.AddField(shield.Item.Name, $"Active {hours} hours\nDefeats {against}", true) |> ignore
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ module Inventory =
|
|||||||
inventory |> List.choose (fun item -> match item with | Accessory a -> Some a | _ -> None)
|
inventory |> List.choose (fun item -> match item with | Accessory a -> Some a | _ -> None)
|
||||||
|
|
||||||
module WeaponClass =
|
module WeaponClass =
|
||||||
let SameTargetAttackCooldown = TimeSpan.FromHours(1)
|
let SameTargetAttackCooldown = TimeSpan.FromHours(2)
|
||||||
|
|
||||||
let getClassButtonColor item =
|
let getClassButtonColor item =
|
||||||
match ItemDetails.getClass item with
|
match ItemDetails.getClass item with
|
||||||
@ -130,6 +130,6 @@ module Arsenal =
|
|||||||
let statusFormat p =
|
let statusFormat p =
|
||||||
let hacks = Player.getHackEvents p
|
let hacks = Player.getHackEvents p
|
||||||
$"**Hacks:** {Inventory.getItemsByType ItemType.Hack p.Inventory |> battleItemFormat}\n
|
$"**Hacks:** {Inventory.getItemsByType ItemType.Hack p.Inventory |> battleItemFormat}\n
|
||||||
**Shields:** {Inventory.getItemsByType ItemType.Hack p.Inventory |> battleItemFormat}\n
|
**Shields:** {Inventory.getItemsByType ItemType.Shield p.Inventory |> battleItemFormat}\n
|
||||||
**Hack Attacks:**\n{hacks |> List.take (min hacks.Length 10) |> actionFormat}\n
|
**Hack Attacks:**\n{hacks |> List.take (min hacks.Length 10) |> actionFormat}\n
|
||||||
**Active Shields:**\n{Player.getShieldEvents p |> actionFormat}"
|
**Active Shields:**\n{Player.getShieldEvents p |> actionFormat}"
|
||||||
|
@ -65,7 +65,7 @@ let checkPlayerHasShieldSlotsAvailable player =
|
|||||||
| false -> Ok updatedPlayer
|
| false -> Ok updatedPlayer
|
||||||
|
|
||||||
let checkTargetHasFunds target player =
|
let checkTargetHasFunds target player =
|
||||||
match target.Bank = 0<GBT> with
|
match target.Bank <= 0<GBT> with
|
||||||
| 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
|
||||||
|
|
||||||
@ -81,7 +81,6 @@ let runHackerBattle defender (hack : HackItem) =
|
|||||||
|> List.contains Weak
|
|> List.contains Weak
|
||||||
|
|
||||||
let updateCombatants successfulHack (attacker : PlayerData) (defender : PlayerData) (hack : HackItem) prize =
|
let updateCombatants successfulHack (attacker : PlayerData) (defender : PlayerData) (hack : HackItem) prize =
|
||||||
// TODO: Look into the prizes and how we're handling them because it seems it can be negative
|
|
||||||
let updatePlayer amount attack p =
|
let updatePlayer amount attack p =
|
||||||
{ p with Events = attack::p.Events ; Bank = max (p.Bank + amount) 0<GBT> }
|
{ p with Events = attack::p.Events ; Bank = max (p.Bank + amount) 0<GBT> }
|
||||||
let event isDefenderEvent =
|
let event isDefenderEvent =
|
||||||
@ -162,6 +161,7 @@ let handleAttack (ctx : IDiscordContext) =
|
|||||||
|> Player.removeExpiredActions
|
|> Player.removeExpiredActions
|
||||||
|> checkAlreadyHackedTarget defender
|
|> checkAlreadyHackedTarget defender
|
||||||
>>= checkPlayerOwnsWeapon hack.Item
|
>>= checkPlayerOwnsWeapon hack.Item
|
||||||
|
>>= checkTargetHasFunds defender
|
||||||
>>= checkWeaponHasCooldown hack.Item
|
>>= checkWeaponHasCooldown hack.Item
|
||||||
|> function
|
|> function
|
||||||
| Ok atkr ->
|
| Ok atkr ->
|
||||||
|
@ -82,7 +82,7 @@ let checkVictimStealingCooldown defender attacker =
|
|||||||
| None -> Ok attacker
|
| None -> Ok attacker
|
||||||
|
|
||||||
let checkTargetHasFunds target player =
|
let checkTargetHasFunds target player =
|
||||||
match target.Bank = 0<GBT> with
|
match target.Bank <= 0<GBT> with
|
||||||
| 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
|
||||||
|
|
||||||
|
@ -12,18 +12,21 @@ let Sensei = { Id = GuildEnvironment.botIdHackerBattle ; Name = "Sensei" }
|
|||||||
let defaultHack = Armory.weapons |> Inventory.findHackById (int ItemId.Virus)
|
let defaultHack = Armory.weapons |> Inventory.findHackById (int ItemId.Virus)
|
||||||
let defaultShield = Armory.weapons |> Inventory.findShieldById (int ItemId.Firewall)
|
let defaultShield = Armory.weapons |> Inventory.findShieldById (int ItemId.Firewall)
|
||||||
|
|
||||||
let TrainerEvents = [
|
let HackEvent = {
|
||||||
{ Timestamp = System.DateTime.UtcNow
|
Timestamp = System.DateTime.UtcNow
|
||||||
Cooldown = defaultHack.Cooldown
|
Cooldown = 1<mins>
|
||||||
Type = Hacking {
|
Type = Hacking {
|
||||||
Adversary = Sensei
|
Adversary = Sensei
|
||||||
Success = true
|
Success = true
|
||||||
IsInstigator = true
|
IsInstigator = true
|
||||||
HackId = defaultHack.Item.Id } }
|
HackId = defaultHack.Item.Id
|
||||||
{ Timestamp = System.DateTime.UtcNow
|
}
|
||||||
|
}
|
||||||
|
let ShieldEvent = {
|
||||||
|
Timestamp = System.DateTime.UtcNow
|
||||||
Cooldown = defaultShield.Cooldown
|
Cooldown = defaultShield.Cooldown
|
||||||
Type = Shielding defaultShield.Item.Id }
|
Type = Shielding defaultShield.Item.Id
|
||||||
]
|
}
|
||||||
|
|
||||||
let sendInitialEmbed (client : DiscordClient) =
|
let sendInitialEmbed (client : DiscordClient) =
|
||||||
async {
|
async {
|
||||||
@ -166,27 +169,39 @@ let handleHack (ctx : IDiscordContext) =
|
|||||||
|
|
||||||
let handleArsenal (ctx : IDiscordContext) =
|
let handleArsenal (ctx : IDiscordContext) =
|
||||||
PlayerInteractions.executePlayerAction ctx (fun player -> async {
|
PlayerInteractions.executePlayerAction ctx (fun player -> async {
|
||||||
let hasStockWeapons =
|
let hack =
|
||||||
// TODO: This didn't seem to work and someone was gifted both weapons when they already owned one
|
if player.Inventory |> List.exists (fun i -> i.Id = defaultHack.Item.Id)
|
||||||
player.Inventory
|
then []
|
||||||
|> List.choose (fun item -> if item.Id = defaultHack.Item.Id || item.Id = defaultShield.Item.Id then Some item else None)
|
else [ Hack defaultHack ]
|
||||||
|> List.length > 0
|
let shield =
|
||||||
let updatedPlayer =
|
if player.Inventory |> List.exists (fun i -> i.Id = defaultShield.Item.Id)
|
||||||
if not hasStockWeapons then {
|
then []
|
||||||
Player.removeExpiredActions player with
|
else [ Shield defaultShield ]
|
||||||
Events = TrainerEvents @ player.Events
|
let shieldEvent =
|
||||||
Inventory = Hack defaultHack::Shield defaultShield::player.Inventory
|
let hasShield =
|
||||||
}
|
player
|
||||||
else
|
|> Player.removeExpiredActions
|
||||||
Player.removeExpiredActions player
|
|> fun p -> p.Events
|
||||||
if not hasStockWeapons then
|
|> List.exists (fun e -> match e.Type with Shielding shieldId -> shieldId = defaultShield.Item.Id | _ -> false)
|
||||||
do!
|
if hasShield
|
||||||
[ DbService.addPlayerEvent player.DiscordId TrainerEvents.[0]
|
then []
|
||||||
DbService.addPlayerEvent player.DiscordId TrainerEvents.[1]
|
else [ ShieldEvent ]
|
||||||
DbService.updatePlayer updatedPlayer ]
|
let updatedPlayer = {
|
||||||
|> Async.Parallel
|
Player.removeExpiredActions player with
|
||||||
|> Async.Ignore
|
Events = shieldEvent @ player.Events
|
||||||
let embed = Embeds.getArsenalEmbed updatedPlayer
|
Inventory = hack @ shield @ player.Inventory
|
||||||
|
}
|
||||||
|
if not (List.isEmpty hack) || not (List.isEmpty shield) then
|
||||||
|
do! DbService.updatePlayer updatedPlayer |> Async.Ignore
|
||||||
|
if not (List.isEmpty shieldEvent) then
|
||||||
|
do! DbService.addPlayerEvent player.DiscordId (List.head shieldEvent) |> Async.Ignore
|
||||||
|
|
||||||
|
let playerForEmbed = {
|
||||||
|
player with
|
||||||
|
Events = [ HackEvent ; ShieldEvent ]
|
||||||
|
Inventory = hack @ shield @ player.Inventory
|
||||||
|
}
|
||||||
|
let embed = Embeds.getArsenalEmbed playerForEmbed
|
||||||
do! ctx.FollowUp(embed) |> Async.AwaitTask
|
do! ctx.FollowUp(embed) |> Async.AwaitTask
|
||||||
|
|
||||||
let! completed = DbService.checkHasAchievement player.DiscordId trainerAchievement
|
let! completed = DbService.checkHasAchievement player.DiscordId trainerAchievement
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
"Fields": [
|
"Fields": [
|
||||||
{
|
{
|
||||||
"Class": 2,
|
"Class": 2,
|
||||||
"Cooldown": 380,
|
"Cooldown": 360,
|
||||||
"Item": {
|
"Item": {
|
||||||
"Id": 8,
|
"Id": 8,
|
||||||
"Name": "Cypher",
|
"Name": "Cypher",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user