Print it nicer
This commit is contained in:
parent
d6888d5e4a
commit
12ba17de30
@ -26,27 +26,18 @@ let checkForExistingTarget defenderId attacker =
|
||||
Error $"You can only hack the same target once every {Player.SameTargetAttackCooldown.Hours} hours, wait {cooldown} to attempt another hack on {target.Name}."
|
||||
| None -> Ok attacker
|
||||
|
||||
let checkHackForCooldown (hack : BattleItem) attacker =
|
||||
attacker
|
||||
|> Player.attacks
|
||||
|> Array.tryFind (fun (act) -> act.ActionId = hack.Id)
|
||||
|> function
|
||||
| Some act ->
|
||||
let cooldown = getTimeTillCooldownFinishes Player.SameTargetAttackCooldown act.Timestamp
|
||||
Error $"{hack.Name} is currently on cooldown, wait {cooldown} to use it again."
|
||||
| None -> Ok attacker
|
||||
|
||||
let checkIfHackHasCooldown hackId attacker =
|
||||
let mostRecentHackAttack =
|
||||
attacker.Actions
|
||||
|> Array.tryFind (fun a -> a.ActionId = hackId)
|
||||
|> function
|
||||
| Some a -> a.Timestamp
|
||||
| None -> DateTime.MinValue;
|
||||
if DateTime.UtcNow - mostRecentHackAttack > TimeSpan.FromMinutes(5) then
|
||||
| None -> DateTime.MinValue
|
||||
let item = Armory.getItem hackId
|
||||
if DateTime.UtcNow - mostRecentHackAttack > TimeSpan.FromMinutes(int item.Cooldown) then
|
||||
Ok attacker
|
||||
else
|
||||
let cooldown = getTimeTillCooldownFinishes (TimeSpan.FromMinutes(5)) mostRecentHackAttack
|
||||
let cooldown = getTimeTillCooldownFinishes (TimeSpan.FromMinutes(int item.Cooldown)) mostRecentHackAttack
|
||||
let item = Armory.battleItems |> Array.find (fun i -> i.Id = hackId)
|
||||
Error $"{item.Name} is currently on cooldown, wait {cooldown} to use it again."
|
||||
|
||||
|
@ -117,13 +117,13 @@ module Messaging =
|
||||
}
|
||||
|
||||
let getTimeTillCooldownFinishes (timespan : TimeSpan) timestamp =
|
||||
let timeRemaining = timespan - (DateTime.UtcNow - timestamp)
|
||||
if timeRemaining.Hours > 0 then
|
||||
$"{timeRemaining.Hours} hours"
|
||||
elif timeRemaining.Minutes > 0 then
|
||||
$"{timeRemaining.Minutes} minutes"
|
||||
else
|
||||
$"{timeRemaining.Seconds} seconds"
|
||||
let remaining = timespan - (DateTime.UtcNow - timestamp)
|
||||
let plural amount = if amount = 1 then "" else "s"
|
||||
let ``and`` = if remaining.Hours > 0 then "and " else ""
|
||||
let hours = if remaining.Hours > 0 then $"{remaining.Hours} hour{plural remaining.Hours} {``and``}" else String.Empty
|
||||
let totalMins = remaining.Minutes + 1
|
||||
let minutes = if totalMins > 0 then $"{totalMins} minute{plural totalMins}" else "1 minute"
|
||||
$"{hours}{minutes}"
|
||||
|
||||
let battleItemFormat (items : BattleItem array) =
|
||||
match items with
|
||||
|
Loading…
x
Reference in New Issue
Block a user