Skip to content

Commit

Permalink
Fix secret handling in BG
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoraes74 committed Jun 26, 2024
1 parent 46c840b commit daa78ca
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
14 changes: 12 additions & 2 deletions HSTracker/BobsBuddy/BobsBuddyInvoker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -826,10 +826,20 @@ class BobsBuddyInvoker {

if friendly {
let target = inputPlayer.secrets
MonoHelper.listClear(obj: target)
let params = UnsafeMutablePointer<Int32>.allocate(capacity: 1)
let i32c = mono_get_int32_class()

for secret in game.player.secrets {
input?.addSecretFromDbfid(id: secret.id, target: target)
var obj: UnsafeMutablePointer<MonoObject>?
params.pointee = Int32(secret.id)

obj = mono_value_box(MonoHelper._monoInstance, i32c, params)

MonoHelper.addToList(list: target, element: MonoHandle(obj: obj))
}

params.deallocate()

let playerHand = inputPlayer.hand

for e in gamePlayer.hand {
Expand Down
4 changes: 2 additions & 2 deletions HSTracker/Core/Extensions/Task.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import Foundation

@available(macOS 10.15, *)
extension Task<Never, Never> {
static func sleep(seconds: UInt64) async {
static func sleep(milliseconds: UInt64) async {
do {
try await Task.sleep(nanoseconds: seconds * 1_000_000)
try await Task.sleep(nanoseconds: milliseconds * 1_000_000)
} catch {
logger.error(error)
}
Expand Down
12 changes: 9 additions & 3 deletions HSTracker/Logging/Game.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2613,14 +2613,20 @@ class Game: NSObject, PowerEventHandler {
OpponentDeadForTracker.reset()
var heroes = [Entity]()
for _ in 0 ..< 10 {
await Task.sleep(seconds: 500)
await Task.sleep(milliseconds: 500)
heroes = player.playerEntities.filter { x in x.isHero && (x.has(tag: .bacon_hero_can_be_drafted) || x.has(tag: .bacon_skin))}
if heroes.count >= 2 {
break
}
}

await Task.sleep(seconds: 500)
await Task.sleep(milliseconds: 500)

var counter = 0
while availableRaces == nil && counter < 5 {
await Task.sleep(milliseconds: 500)
counter += 1
}

await windowManager.battlegroundsSession.update()

Expand All @@ -2642,7 +2648,7 @@ class Game: NSObject, PowerEventHandler {
// Wait for the mulligan to be ready
await waitForMulliganStart()

async let waitAndAppear: () = Task.sleep(seconds: 500)
async let waitAndAppear: () = Task.sleep(milliseconds: 500)

var battlegroundsHeroPickStats: BattlegroundsHeroPickStats?

Expand Down

0 comments on commit daa78ca

Please sign in to comment.