Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Nearby Tracker Open #8

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Manager/Sources/RDMUICManager/BuildController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class BuildController {
"startupLocationLon=\(device.startupLocationLon)", "encounterMaxWait=\(device.encounterMaxWait)",
"encounterDelay=\(device.encounterDelay)", "fastIV=\(device.fastIV)", "ultraIV=\(device.ultraIV)",
"deployEggs=\(device.deployEggs)", "token=\(device.token)", "ultraQuests=\(device.ultraQuests)",
"attachScreenshots=\(device.attachScreenshots)"
"attachScreenshots=\(device.attachScreenshots)", "nearbyTracker=\(device.nearbyTracker)"
)

var contains = true
Expand Down Expand Up @@ -274,6 +274,15 @@ class BuildController {
if string!.contains(string: "[STATUS] IV") {
self.setStatus(uuid: device.uuid, status: "Running: IV")
}
if string!.contains(string: "[STATUS] NTM Pokemon") {
self.setStatus(uuid: device.uuid, status: "Running: NTM Pokemon")
}
if string!.contains(string: "[STATUS] NTM Raid") {
self.setStatus(uuid: device.uuid, status: "Running: NTM Raid")
}
if string!.contains(string: "[STATUS] NTM IV") {
self.setStatus(uuid: device.uuid, status: "Running: NTM IV")
}

fullLog.uic(message: string!, all: true)
debugLog.uic(message: string!, all: false)
Expand Down
17 changes: 17 additions & 0 deletions Manager/Sources/RDMUICManager/CLI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class CLI {
Ultra Quests: \(device.ultraQuests.toBool())
Enabled: \(device.enabled.toBool())
AttachScreenshots: \(device.attachScreenshots.toBool())
Nearby Tracker: \(device.nearbyTracker.toBool())
"""

print(row + "\n")
Expand Down Expand Up @@ -317,6 +318,11 @@ class CLI {
defaultDevice.attachScreenshots = attachScreenshots!.toInt()
}

let nearbyTracker = askBool("Nearby Tracker (empty = \(defaultDevice.nearbyTracker.toBool()))")
if nearbyTracker != nil {
defaultDevice.nearbyTracker = nearbyTracker!.toInt()
}

do {
try defaultDevice.save()
clear()
Expand Down Expand Up @@ -473,6 +479,11 @@ class CLI {
attachScreenshots = defaultDevice.attachScreenshots
}

var nearbyTracker = askBool("Nearby Tracker (empty = \(defaultDevice.nearbyTracker.toBool()))")?.toInt()
if nearbyTracker == nil {
nearbyTracker = defaultDevice.nearbyTracker
}

device.uuid = uuid
device.name = name
device.backendURL = backendURL
Expand Down Expand Up @@ -502,6 +513,7 @@ class CLI {
device.ultraQuests = ultraQuests!
device.enabled = enabled!
device.attachScreenshots = attachScreenshots!
device.nearbyTracker = nearbyTracker!

do {
try device.create()
Expand Down Expand Up @@ -674,6 +686,11 @@ class CLI {
device.attachScreenshots = attachScreenshots!.toInt()
}

let nearbyTracker = askBool("Nearby Tracker (empty = \(device.nearbyTracker.toBool()))")
if nearbyTracker != nil {
device.nearbyTracker = nearbyTracker!.toInt()
}

do {
try device.save()
clear()
Expand Down
14 changes: 12 additions & 2 deletions Manager/Sources/RDMUICManager/Device.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Device: SQLiteStORM, Equatable, Hashable {
var ultraQuests: Int
var enabled: Int
var attachScreenshots: Int
var nearbyTracker: Int

override init() {
self.uuid = ""
Expand Down Expand Up @@ -84,6 +85,7 @@ class Device: SQLiteStORM, Equatable, Hashable {
self.ultraQuests = 0
self.enabled = 1
self.attachScreenshots = 0
self.nearbyTracker = 0
super.init()
}

Expand All @@ -92,7 +94,7 @@ class Device: SQLiteStORM, Equatable, Hashable {
targetMaxDistance: Double, itemFullCount: Int, questFullCount: Int, itemsPerStop: Int, minDelayLogout: Double,
maxNoQuestCount: Int, maxFailedCount: Int, maxEmptyGMO: Int, startupLocationLat: Double,
startupLocationLon: Double, encounterMaxWait: Int, encounterDelay: Double, fastIV: Int, ultraIV: Int,
deployEggs: Int, token: String, ultraQuests: Int, enabled: Int, attachScreenshots: Int) {
deployEggs: Int, token: String, ultraQuests: Int, enabled: Int, attachScreenshots: Int, nearbyTracker: Int) {
self.uuid = uuid
self.name = name
self.backendURL = backendURL
Expand Down Expand Up @@ -122,6 +124,7 @@ class Device: SQLiteStORM, Equatable, Hashable {
self.ultraQuests = ultraQuests
self.enabled = enabled
self.attachScreenshots = attachScreenshots
self.nearbyTracker = nearbyTracker
super.init()
}

Expand Down Expand Up @@ -156,9 +159,10 @@ class Device: SQLiteStORM, Equatable, Hashable {
ultraIV = this.data["ultraIV"] as? Int ?? 0
deployEggs = this.data["deployEggs"] as? Int ?? 0
token = this.data["token"] as? String ?? ""
ultraQuests = this.data["ultraQuests"] as? Int ?? 0
ultraQuests = this.data["ultraQuests"] as? Int ?? 0
enabled = this.data["enabled"] as? Int ?? 1
attachScreenshots = this.data["attachScreenshots"] as? Int ?? 0
nearbyTracker = this.data["nearbyTracker"] as? Int ?? 0
}

static func getAll() -> [Device] {
Expand Down Expand Up @@ -213,6 +217,7 @@ class Device: SQLiteStORM, Equatable, Hashable {
var hasUltraQuests = false
var hasEnabled = false
var hasAttachScreenshots = false
var hasNearbyTracker = false

let rows = try sqlRows("PRAGMA table_info(\(table()))", params: [String]())
for row in rows {
Expand All @@ -235,6 +240,8 @@ class Device: SQLiteStORM, Equatable, Hashable {
hasEnabled = true
} else if name == "attachScreenshots" {
hasAttachScreenshots = true
} else if name == "nearbyTracker" {
hasNearbyTracker = true
}
}

Expand Down Expand Up @@ -265,6 +272,9 @@ class Device: SQLiteStORM, Equatable, Hashable {
if !hasAttachScreenshots {
try sqlExec("ALTER TABLE \(table()) ADD COLUMN attachScreenshots INTEGER DEFAULT 0")
}
if !hasNearbyTracker {
try sqlExec("ALTER TABLE \(table()) ADD COLUMN nearbyTracker INTEGER DEFAULT 0")
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@
value = "$(attachScreenshots)"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "nearbyTracker"
value = "$(nearbyTracker)"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<AdditionalOptions>
</AdditionalOptions>
Expand Down
2 changes: 2 additions & 0 deletions RealDeviceMap-UIControl/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Config {
var ultraQuests: Bool
var enabled: Bool
var attachScreenshots: Bool
var nearbyTracker: Bool

init() {

Expand Down Expand Up @@ -74,6 +75,7 @@ class Config {
ultraQuests = enviroment["ultraQuests"]?.toBool() ?? false
enabled = enviroment["enabled"]?.toBool() ?? true
attachScreenshots = enviroment["attachScreenshots"]?.toBool() ?? false
nearbyTracker = enviroment["nearbyTracker"]?.toBool() ?? false
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ protocol DeviceConfigProtocol {

/** Green pixel in green button of startup popup. */
var startup: DeviceCoordinate { get }
/** Nearby Tracker. */
var nearby: DeviceCoordinate { get }
/** Nearby Tracker Pixel. */
var nearbypixel: DeviceCoordinate { get }

// Handling Multiple startup prompts
/* White Pixel (on 3 line prompt) or Greenish-Blue Pixel (on 2 line prompt) bottom right corner of 2line popup */
Expand Down
6 changes: 6 additions & 0 deletions RealDeviceMap-UIControl/DeviceConfig/DeviceIPhoneNormal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ class DeviceIPhoneNormal: DeviceRatio1775 {
override var startup: DeviceCoordinate {
return DeviceCoordinate(x: 325, y: 960, tapScaler: tapScaler)
}
override var nearby: DeviceCoordinate {
return DeviceCoordinate(x: 645, y: 1215, tapScaler: tapScaler)
}
override var nearbypixel: DeviceCoordinate {
return DeviceCoordinate(x: 146, y: 310, tapScaler: tapScaler)
}
override var startupNewButton: DeviceCoordinate {
return DeviceCoordinate(x: 475, y: 960, tapScaler: tapScaler)
}
Expand Down
6 changes: 6 additions & 0 deletions RealDeviceMap-UIControl/DeviceConfig/DeviceRatio1333.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class DeviceRatio1333: DeviceConfigProtocol {
var startup: DeviceCoordinate {
return DeviceCoordinate(x: 728, y: 1542, scaler: scaler) //was 1234
}
var nearby: DeviceCoordinate {
return DeviceCoordinate(x: 0, y: 0, scaler: scaler) // Need Screenshot Cords
}
var nearbypixel: DeviceCoordinate {
return DeviceCoordinate(x: 1387, y: 1873, scaler: scaler)
}
var startupLoggedOut: DeviceCoordinate {
return DeviceCoordinate(x: 807, y: 177, scaler: scaler)
}
Expand Down
6 changes: 6 additions & 0 deletions RealDeviceMap-UIControl/DeviceConfig/DeviceRatio1775.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ class DeviceRatio1775: DeviceConfigProtocol {
var startup: DeviceCoordinate {
return DeviceCoordinate(x: 280, y: 800, scaler: scaler)
}
var nearby: DeviceCoordinate {
return DeviceCoordinate(x: 550, y: 1040, scaler: scaler)
}
var nearbypixel: DeviceCoordinate {
return DeviceCoordinate(x: 125, y: 265, scaler: scaler)
}
var startupLoggedOut: DeviceCoordinate {
return DeviceCoordinate(x: 320, y: 175, scaler: scaler)
}
Expand Down
12 changes: 12 additions & 0 deletions RealDeviceMap-UIControl/Misc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,18 @@ extension XCTestCase {
return false
}

func checkNearbyPixel(screenshot: XCUIScreenshot?=nil) -> Bool {
let screenshotComp = screenshot ?? XCUIScreen.main.screenshot()
if screenshotComp.rgbAtLocation(
pos: deviceConfig.nearbypixel,
min: (red: 0.25, green: 0.40, blue: 0.41),
max: (red: 0.27, green: 0.42, blue: 0.43)) {
return true
} else {
return false
}
}

}

extension String {
Expand Down
67 changes: 64 additions & 3 deletions RealDeviceMap-UIControl/RealDeviceMap_UIControlUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class RealDeviceMap_UIControlUITests: XCTestCase {
var encounterDelay = 1.0
var server = Server()
var hasWarning = false
var hasnearby = false

var level: Int = 0
var systemAlertMonitorToken: NSObjectProtocol?
Expand Down Expand Up @@ -1123,6 +1124,20 @@ class RealDeviceMap_UIControlUITests: XCTestCase {
deviceConfig.startup.toXCUICoordinate(app: app).tap()
app.swipeDown()
}

if self.config.nearbyTracker {
Log.info("STARTUP nearbyTracker \(self.config.nearbyTracker)")
self.hasnearby = self.checkNearbyPixel()
sleep(2)
self.hasnearby = self.checkNearbyPixel()
Log.info("STARTUP hasnearby \(self.hasnearby)")
if !self.hasnearby {
deviceConfig.nearby.toXCUICoordinate(app: app).tap()
sleep(1)
Log.info("STARTUP Nearby Tap")
}
}

sleep(1 * config.delayMultiplier)

isStartupCompleted = true
Expand Down Expand Up @@ -1202,7 +1217,11 @@ class RealDeviceMap_UIControlUITests: XCTestCase {
if let data = result!["data"] as? [String: Any], let action = data["action"] as? String {
self.action = action
if action == "scan_pokemon" {
print("[STATUS] Pokemon")
if self.config.nearbyTracker {
print("[STATUS] NTM Pokemon")
} else {
print("[STATUS] Pokemon")
}
if self.hasWarning && self.config.enableAccountManager {
Log.info("Account has a warning and tried to scan for Pokemon. Logging out!")
self.lock.lock()
Expand Down Expand Up @@ -1264,9 +1283,24 @@ class RealDeviceMap_UIControlUITests: XCTestCase {
}
self.lock.unlock()
}
if self.config.nearbyTracker {
self.hasnearby = self.checkNearbyPixel()
sleep(2)
self.hasnearby = self.checkNearbyPixel()
Log.info("POKEMON hasnearby \(self.hasnearby)")
if !self.hasnearby {
self.deviceConfig.nearby.toXCUICoordinate(app: self.app).tap()
sleep(1)
Log.info("POKEMON Nearby Tap")
}
}

} else if action == "scan_raid" {
print("[STATUS] Raid")
if self.config.nearbyTracker {
print("[STATUS] NTM Raid")
} else {
print("[STATUS] Raid")
}
if self.hasWarning && self.firstWarningDate != nil &&
Int(Date().timeIntervalSince(self.firstWarningDate!)) >=
self.config.maxWarningTimeRaid && self.config.enableAccountManager {
Expand Down Expand Up @@ -1329,6 +1363,18 @@ class RealDeviceMap_UIControlUITests: XCTestCase {
}
self.lock.unlock()
}
if self.config.nearbyTracker {
self.hasnearby = self.checkNearbyPixel()
sleep(2)
self.hasnearby = self.checkNearbyPixel()
Log.info("RAID hasnearby \(self.hasnearby)")
if !self.hasnearby {
self.deviceConfig.nearby.toXCUICoordinate(app: self.app).tap()
sleep(1)
Log.info("RAID Nearby Tap")
}
}

} else if action == "scan_quest" {
print("[STATUS] Quest")

Expand Down Expand Up @@ -1553,7 +1599,11 @@ class RealDeviceMap_UIControlUITests: XCTestCase {
self.shouldExit = true
return
} else if action == "scan_iv" {
print("[STATUS] IV")
if self.config.nearbyTracker {
print("[STATUS] NTM IV")
} else {
print("[STATUS] IV")
}
if self.hasWarning && self.firstWarningDate != nil &&
Int(Date().timeIntervalSince(self.firstWarningDate!)) >=
self.config.maxWarningTimeRaid && self.config.enableAccountManager {
Expand Down Expand Up @@ -1831,6 +1881,17 @@ class RealDeviceMap_UIControlUITests: XCTestCase {
}

}
if self.config.nearbyTracker {
self.hasnearby = self.checkNearbyPixel()
sleep(2)
self.hasnearby = self.checkNearbyPixel()
Log.info("IV hasnearby \(self.hasnearby)")
if self.config.ultraIV && !self.hasnearby {
self.deviceConfig.nearby.toXCUICoordinate(app: self.app).tap()
sleep(1)
Log.info("IV Nearby Tap")
}
}

} else {
Log.error("Unkown Action: \(action)")
Expand Down