diff --git a/Bot/PlayerInteractions.fs b/Bot/PlayerInteractions.fs index 593923d..29f763f 100644 --- a/Bot/PlayerInteractions.fs +++ b/Bot/PlayerInteractions.fs @@ -16,8 +16,8 @@ module Commands = Name = nickname Inventory = [| hack ; shield |] Events = [||] - XP = 0 - Achievements = [||] +// XP = 0 +// Achievements = [||] Traits = PlayerTraits.empty Bank = 100 } diff --git a/Bot/Trainer.fs b/Bot/Trainer.fs index 7661870..a07fc8b 100644 --- a/Bot/Trainer.fs +++ b/Bot/Trainer.fs @@ -148,7 +148,9 @@ let handleHack (ctx : IDiscordContext) = let sb = StringBuilder("Here, ") - let isFirstTrainer = player.Achievements |> Seq.contains trainerAchievement |> not + // TODO DB: +// let isFirstTrainer = player.Achievements |> Seq.contains trainerAchievement |> not + let isFirstTrainer = true if isFirstTrainer then do! DbService.addAchievement player.DiscordId trainerAchievement @@ -180,7 +182,9 @@ let handleArsenal (ctx : IDiscordContext) = do! DbService.updatePlayer updatedPlayer let embed = Embeds.getArsenalEmbed updatedPlayer do! ctx.FollowUp(embed) |> Async.AwaitTask - if not (player.Achievements |> Array.contains trainerAchievement) then + // TODO DB: +// if not (player.Achievements |> Array.contains trainerAchievement) then + if true then do! Async.Sleep 3000 let rewards = [ $"{defaultHack.Name} Hack" ; $"{defaultShield.Name} Shield" ] let embed = Embeds.getAchievementEmbed rewards "You completed the Training Dojo and collected loot." trainerAchievement diff --git a/DbService/DbService.fs b/DbService/DbService.fs index 16f1560..3c2a800 100644 --- a/DbService/DbService.fs +++ b/DbService/DbService.fs @@ -13,6 +13,7 @@ type User = { DiscordId : uint64 Bank : int Strength : int + Inventory : int array } let mongo = MongoClient(Environment.GetEnvironmentVariable("CONN_STRING")) @@ -29,24 +30,24 @@ let mapBack user (bson : BsonDocument) : PlayerData = { DiscordId = user.DiscordId Name = user.Name Inventory = - tryWithDefault bson "Inventory" [||] (fun v -> - v.AsBsonArray - |> Seq.map (fun (bv : BsonValue) -> BsonSerializer.Deserialize(bv.ToBsonDocument())) - |> Seq.toArray) + user.Inventory + |> Array.map (fun iId -> + Armory.battleItems + |> Array.tryFind (fun i -> i.Id = iId) + |> function + | Some i -> [| i |] + | None -> [||]) + |> Array.concat Events = tryWithDefault bson "Events" [||] (fun v -> v.AsBsonArray |> Seq.map (fun (bv : BsonValue) -> BsonSerializer.Deserialize(bv.ToBsonDocument())) |> Seq.toArray) - Traits = - (let traits = - tryWithDefault bson "Traits" PlayerTraits.empty (fun v -> - BsonSerializer.Deserialize(v.ToBsonDocument())) - { traits with Strength = user.Strength}) - Achievements = - tryWithDefault bson "Achievements" [||] (fun v -> - v.AsBsonArray |> Seq.map (fun (bv : BsonValue) -> bv.AsString) |> Seq.toArray) - XP = tryWithDefault bson "XP" 0 (fun v -> v.AsInt32) + Traits = { PlayerTraits.empty with Strength = user.Strength } +// Achievements = +// tryWithDefault bson "Achievements" [||] (fun v -> +// v.AsBsonArray |> Seq.map (fun (bv : BsonValue) -> bv.AsString) |> Seq.toArray) +// XP = tryWithDefault bson "XP" 0 (fun v -> v.AsInt32) Bank = user.Bank } @@ -62,9 +63,10 @@ let tryFindPlayer connStr (id : uint64) = |> Sql.executeAsync (fun read -> { DiscordId = read.int64 "discordId" |> uint64 + Name = read.string "displayName" Bank = read.int "gbt" * 1 Strength = read.int "strength" - Name = read.string "displayName" + Inventory = read.intArray "inventory" }) |> Async.AwaitTask diff --git a/Shared/Shared.fs b/Shared/Shared.fs index 68513d3..99b004d 100644 --- a/Shared/Shared.fs +++ b/Shared/Shared.fs @@ -124,8 +124,8 @@ module Types = Inventory : Item array Events : PlayerEvent array Traits : PlayerTraits - Achievements : string array - XP : int +// Achievements : string array +// XP : int Bank : int } with member this.basicPlayer = { Id = this.DiscordId ; Name = this.Name } @@ -135,8 +135,8 @@ module Types = Inventory = [||] Events = [||] Traits = PlayerTraits.empty - Achievements = [||] - XP = 0 +// Achievements = [||] +// XP = 0 Bank = 0 } module Armory =