-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_vm.swift
More file actions
25 lines (22 loc) · 906 Bytes
/
Copy pathtest_vm.swift
File metadata and controls
25 lines (22 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import Foundation
let dir = "/Users/dameer/Desktop/code/MTT TR/Cutoff/Resources/Ranges"
let files = try! FileManager.default.contentsOfDirectory(atPath: dir)
var hasOpp = 0
var btnVsOpenOpps = Set<String>()
for file in files where file.hasSuffix(".json") {
let url = URL(fileURLWithPath: dir).appendingPathComponent(file)
let data = try! Data(contentsOf: url)
if let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
let spot = json["spot"] as? [String: Any] {
if let opp = spot["opponentPosition"] as? String {
hasOpp += 1
let pos = spot["position"] as? String
let facing = spot["facingAction"] as? String
if pos == "BTN" && facing == "vsOpen" {
btnVsOpenOpps.insert(opp)
}
}
}
}
print("Total charts with opp: \(hasOpp)")
print("BTN vsOpen opps: \(btnVsOpenOpps)")