Get rid of the stealing neutral outcome
This commit is contained in:
		
							parent
							
								
									f354b9d6e8
								
							
						
					
					
						commit
						a45152970d
					
				
							
								
								
									
										44
									
								
								Bot/Thief.fs
									
									
									
									
									
								
							
							
						
						
									
										44
									
								
								Bot/Thief.fs
									
									
									
									
									
								
							@ -9,12 +9,11 @@ open DSharpPlus.SlashCommands
 | 
				
			|||||||
open Degenz.Messaging
 | 
					open Degenz.Messaging
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let ThiefCooldown = TimeSpan.FromMinutes(1)
 | 
					let ThiefCooldown = TimeSpan.FromMinutes(1)
 | 
				
			||||||
let VictimRecovery = TimeSpan.FromHours(4)
 | 
					let VictimRecovery = TimeSpan.FromHours(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type StealResult =
 | 
					type StealResult =
 | 
				
			||||||
    | Success
 | 
					    | Success
 | 
				
			||||||
    | WentToPrison
 | 
					    | WentToPrison
 | 
				
			||||||
    | VictimRanAway
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
//let getRandomStealBtnLabels () =
 | 
					//let getRandomStealBtnLabels () =
 | 
				
			||||||
//    let rand = Random(Guid.NewGuid().GetHashCode())
 | 
					//    let rand = Random(Guid.NewGuid().GetHashCode())
 | 
				
			||||||
@ -41,24 +40,6 @@ let payout defenderBank chance =
 | 
				
			|||||||
    let randomAmount = baseAmount + randomBonus |> int
 | 
					    let randomAmount = baseAmount + randomBonus |> int
 | 
				
			||||||
    max 1 randomAmount
 | 
					    max 1 randomAmount
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let getStealEmbed amount (chance : double) prize (target : PlayerData) =
 | 
					 | 
				
			||||||
    let chance = int (chance * 100.0)
 | 
					 | 
				
			||||||
    let buttons =
 | 
					 | 
				
			||||||
        let btnId = $"Steal-yes-{target.DiscordId}-{target.Name}-{amount}"
 | 
					 | 
				
			||||||
        [ DiscordButtonComponent(ButtonStyle.Success, btnId, "Do it") ]
 | 
					 | 
				
			||||||
        |> Seq.cast<DiscordComponent>
 | 
					 | 
				
			||||||
    let embed =
 | 
					 | 
				
			||||||
        DiscordEmbedBuilder()
 | 
					 | 
				
			||||||
          .AddField("Chance of Success", $"{chance}%%", true)
 | 
					 | 
				
			||||||
          .AddField("Payout", $"{prize}", true)
 | 
					 | 
				
			||||||
          .WithTitle($"Steal $GBT from {target.Name}")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    DiscordFollowupMessageBuilder()
 | 
					 | 
				
			||||||
        .AddEmbed(embed)
 | 
					 | 
				
			||||||
        .AddComponents(buttons)
 | 
					 | 
				
			||||||
        .AsEphemeral(true)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
let getResultEmbed chance prize (bank : int<GBT>) thief (victim : DiscordPlayer) result =
 | 
					let getResultEmbed chance prize (bank : int<GBT>) thief (victim : DiscordPlayer) result =
 | 
				
			||||||
    let embed =
 | 
					    let embed =
 | 
				
			||||||
         DiscordEmbedBuilder()
 | 
					         DiscordEmbedBuilder()
 | 
				
			||||||
@ -74,11 +55,6 @@ let getResultEmbed chance prize (bank : int<GBT>) thief (victim : DiscordPlayer)
 | 
				
			|||||||
            + "Your mean ugly face and athletic physique intimidated your poor victim into giving you their money")
 | 
					            + "Your mean ugly face and athletic physique intimidated your poor victim into giving you their money")
 | 
				
			||||||
            , "https://f8n-production-collection-assets.imgix.net/0x3B3ee1931Dc30C1957379FAc9aba94D1C48a5405/127502/QmPLPg1CLovKzS7mP8QkrMoHws1D4VZTzpfbZBALLwKZ5b/nft.png"
 | 
					            , "https://f8n-production-collection-assets.imgix.net/0x3B3ee1931Dc30C1957379FAc9aba94D1C48a5405/127502/QmPLPg1CLovKzS7mP8QkrMoHws1D4VZTzpfbZBALLwKZ5b/nft.png"
 | 
				
			||||||
            , DiscordColor.Green
 | 
					            , DiscordColor.Green
 | 
				
			||||||
        | VictimRanAway ->
 | 
					 | 
				
			||||||
            embed.AddField("Result" , $"Ran Away", true) |> ignore
 | 
					 | 
				
			||||||
            $"Target **ran away**...\n\n{thief.Name} saw a shadowy figure and got nervous so they ran in the opposite direction"
 | 
					 | 
				
			||||||
            , "https://i.imgur.com/NLHMvVK.jpg"
 | 
					 | 
				
			||||||
            , DiscordColor.Grayple
 | 
					 | 
				
			||||||
        | WentToPrison ->
 | 
					        | WentToPrison ->
 | 
				
			||||||
            embed.AddField("Result" , $"Imprisoned", true) |> ignore
 | 
					            embed.AddField("Result" , $"Imprisoned", true) |> ignore
 | 
				
			||||||
            $"You're going to **PRISON**...\n\n{thief.Name} knows Karate and elbowed you in the nose. While unconscious, they called the cops."
 | 
					            $"You're going to **PRISON**...\n\n{thief.Name} knows Karate and elbowed you in the nose. While unconscious, they called the cops."
 | 
				
			||||||
@ -130,7 +106,6 @@ let steal target amount (ctx : IDiscordContext) =
 | 
				
			|||||||
    Game.executePlayerActionWithTarget target ctx (fun thief victim -> async { do!
 | 
					    Game.executePlayerActionWithTarget target ctx (fun thief victim -> async { do!
 | 
				
			||||||
        thief
 | 
					        thief
 | 
				
			||||||
        |> checkVictimStealingCooldown victim
 | 
					        |> checkVictimStealingCooldown victim
 | 
				
			||||||
        >>= checkThiefCooldown
 | 
					 | 
				
			||||||
        |> handleResultWithResponse ctx (fun _ -> async {
 | 
					        |> handleResultWithResponse ctx (fun _ -> async {
 | 
				
			||||||
            let cappedPrize , winPercentage , wasCapped =
 | 
					            let cappedPrize , winPercentage , wasCapped =
 | 
				
			||||||
                calculateWinPercentage amount (int victim.Bank) thief.Traits.Strength victim.Traits.Strength
 | 
					                calculateWinPercentage amount (int victim.Bank) thief.Traits.Strength victim.Traits.Strength
 | 
				
			||||||
@ -172,7 +147,6 @@ let handleSteal (ctx : IDiscordContext) =
 | 
				
			|||||||
        let rand = Random(Guid.NewGuid().GetHashCode())
 | 
					        let rand = Random(Guid.NewGuid().GetHashCode())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let num = rand.NextDouble()
 | 
					        let num = rand.NextDouble()
 | 
				
			||||||
        let result = winPercentage >= num , rand.Next(0,3) = 0
 | 
					 | 
				
			||||||
        let dp = { DiscordPlayer.Id = targetId ; DiscordPlayer.Name = targetName }
 | 
					        let dp = { DiscordPlayer.Id = targetId ; DiscordPlayer.Name = targetName }
 | 
				
			||||||
        let stealAction result = {
 | 
					        let stealAction result = {
 | 
				
			||||||
             ItemId = -1
 | 
					             ItemId = -1
 | 
				
			||||||
@ -186,11 +160,9 @@ let handleSteal (ctx : IDiscordContext) =
 | 
				
			|||||||
        let getResultEmbed' = getResultEmbed winPercentage prize thief.Bank thief dp
 | 
					        let getResultEmbed' = getResultEmbed winPercentage prize thief.Bank thief dp
 | 
				
			||||||
        // TODO: Send event to the hall of privacy
 | 
					        // TODO: Send event to the hall of privacy
 | 
				
			||||||
        // TODO: We need to check if the player is on cooldown
 | 
					        // TODO: We need to check if the player is on cooldown
 | 
				
			||||||
        match result with
 | 
					        match winPercentage >= num with
 | 
				
			||||||
        | true , _ ->
 | 
					        | true  ->
 | 
				
			||||||
            let embed = getResultEmbed' Success
 | 
					            let embed = getResultEmbed' Success
 | 
				
			||||||
//            let xp = 25
 | 
					 | 
				
			||||||
//            embed.AddField("XP Gained", $"{xp}") |> ignore
 | 
					 | 
				
			||||||
            do! Messaging.sendFollowUpEmbed ctx (embed.Build())
 | 
					            do! Messaging.sendFollowUpEmbed ctx (embed.Build())
 | 
				
			||||||
            match! DbService.tryFindPlayer targetId with
 | 
					            match! DbService.tryFindPlayer targetId with
 | 
				
			||||||
            | Some t ->
 | 
					            | Some t ->
 | 
				
			||||||
@ -217,14 +189,8 @@ let handleSteal (ctx : IDiscordContext) =
 | 
				
			|||||||
                Cooldown = ThiefCooldown.Minutes * 1<mins>
 | 
					                Cooldown = ThiefCooldown.Minutes * 1<mins>
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            let actions = thief |> Player.removeExpiredActions |> fun p -> Array.append [| stole |] p.Events
 | 
					            let actions = thief |> Player.removeExpiredActions |> fun p -> Array.append [| stole |] p.Events
 | 
				
			||||||
            do! DbService.updatePlayer { thief with Bank = thief.Bank + prize ; XP = thief.XP + 0 ; Events = actions }
 | 
					            do! DbService.updatePlayer { thief with Bank = thief.Bank + prize ; Events = actions }
 | 
				
			||||||
//            do! Async.Sleep 2000
 | 
					        | false ->
 | 
				
			||||||
//            do! ctx.FollowUp (XP.getRewardsEmbed 1 player) |> Async.AwaitTask
 | 
					 | 
				
			||||||
        | false , false ->
 | 
					 | 
				
			||||||
            let embed = getResultEmbed' VictimRanAway
 | 
					 | 
				
			||||||
            do! DbService.updatePlayer { thief with Events = Array.append [| stealAction PlayerEventResult.Neutral |] thief.Events }
 | 
					 | 
				
			||||||
            do! Messaging.sendFollowUpEmbed ctx (embed.Build())
 | 
					 | 
				
			||||||
        | false , true ->
 | 
					 | 
				
			||||||
            let embed = getResultEmbed' WentToPrison
 | 
					            let embed = getResultEmbed' WentToPrison
 | 
				
			||||||
            do! DbService.updatePlayer { thief with Events = Array.append [| stealAction PlayerEventResult.Neutral |] thief.Events }
 | 
					            do! DbService.updatePlayer { thief with Events = Array.append [| stealAction PlayerEventResult.Neutral |] thief.Events }
 | 
				
			||||||
            do! Messaging.sendFollowUpEmbed ctx (embed.Build())
 | 
					            do! Messaging.sendFollowUpEmbed ctx (embed.Build())
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user