forked from Necrobot-Private/PokemonGo.RocketAPI
/
Client.cs
97 lines (77 loc) · 3.25 KB
/
Client.cs
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#region using directives
using System;
using System.Net;
using PokemonGo.RocketAPI.Enums;
using PokemonGo.RocketAPI.Extensions;
using PokemonGo.RocketAPI.HttpClient;
using PokemonGo.RocketAPI.Rpc;
using POGOProtos.Enums;
using POGOProtos.Networking.Envelopes;
#endregion
namespace PokemonGo.RocketAPI
{
public class Client
{
public static WebProxy Proxy;
internal readonly PokemonHttpClient PokemonHttpClient;
public Download Download;
public Encounter Encounter;
public Fort Fort;
public Inventory Inventory;
public Rpc.Login Login;
public Map Map;
public Misc Misc;
public Player Player;
public Client(ISettings settings, IApiFailureStrategy apiFailureStrategy)
{
Settings = settings;
ApiFailure = apiFailureStrategy;
Proxy = InitProxy();
PokemonHttpClient = new PokemonHttpClient();
Login = new Rpc.Login(this);
Player = new Player(this);
Download = new Download(this);
Inventory = new Inventory(this);
Map = new Map(this);
Fort = new Fort(this);
Encounter = new Encounter(this);
Misc = new Misc(this);
Player.SetCoordinates(Settings.DefaultLatitude, Settings.DefaultLongitude, Settings.DefaultAltitude);
InventoryLastUpdateTimestamp = 0;
Platform = settings.DevicePlatform.Equals("ios", StringComparison.Ordinal) ? Platform.Ios : Platform.Android;
AppVersion = 3500;
SettingsHash = "";
CurrentApiEmulationVersion = new Version("0.35.0");
}
public IApiFailureStrategy ApiFailure { get; set; }
public ISettings Settings { get; }
public string AuthToken { get; set; }
public double CurrentLatitude { get; internal set; }
public double CurrentLongitude { get; internal set; }
public double CurrentAltitude { get; internal set; }
public double CurrentAccuracy { get; internal set; }
public float CurrentSpeed { get; internal set; }
public AuthType AuthType => Settings.AuthType;
internal string ApiUrl { get; set; }
internal AuthTicket AuthTicket { get; set; }
internal string SettingsHash { get; set; }
internal long InventoryLastUpdateTimestamp { get; set; }
internal Platform Platform { get; set; }
internal uint AppVersion { get; set; }
internal long StartTime { get; set; }
public Version CurrentApiEmulationVersion { get; set; }
public Version MinimumClientVersion { get; set; }
private WebProxy InitProxy()
{
if (!Settings.UseProxy) return null;
var prox = new WebProxy(new Uri($"http://{Settings.UseProxyHost}:{Settings.UseProxyPort}"), false, null);
if (Settings.UseProxyAuthentication)
prox.Credentials = new NetworkCredential(Settings.UseProxyUsername, Settings.UseProxyPassword);
return prox;
}
public bool CheckCurrentVersionOutdated()
{
return CurrentApiEmulationVersion < MinimumClientVersion;
}
}
}