本文整理汇总了C#中Client.GetProfile方法的典型用法代码示例。如果您正苦于以下问题:C# Client.GetProfile方法的具体用法?C# Client.GetProfile怎么用?C# Client.GetProfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client
的用法示例。
在下文中一共展示了Client.GetProfile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
static async void Execute()
{
var client = new Client(Settings.DefaultLatitude, Settings.DefaultLongitude);
if (Settings.UsePTC)
{
await client.LoginPtc(Settings.PtcUsername, Settings.PtcPassword);
}
else
{
await client.LoginGoogle(Settings.DeviceId, Settings.Email, Settings.LongDurationToken);
}
var serverResponse = await client.GetServer();
var profile = await client.GetProfile();
var settings = await client.GetSettings();
var mapObjects = await client.GetMapObjects();
var inventory = await client.GetInventory();
var pokemons = inventory.Payload[0].Bag.Items.Select(i => i.Item?.Pokemon).Where(p => p != null && p?.PokemonId != InventoryResponse.Types.PokemonProto.Types.PokemonIds.PokemonUnset);
ExecutePrintPokemonPowerQuotient(pokemons);
//await ExecuteFarmingPokestopsAndPokemons(client);
//await ExecuteCatchAllNearbyPokemons(client);
}
示例2: Execute
static async void Execute()
{
var client = new Client(Settings.DefaultLatitude, Settings.DefaultLongitude);
//await client.LoginPtc("FeroxRev", "Sekret");
//await client.LoginGoogle(Settings.DeviceId, Settings.Email, Settings.LongDurationToken);
await client.LoginGoogle();
var serverResponse = await client.GetServer();
var profile = await client.GetProfile();
var settings = await client.GetSettings();
var mapObjects = await client.GetMapObjects();
var inventory = await client.GetInventory();
await ExecuteFarmingPokestops(client);
await ExecuteCatchAllNearbyPokemons(client);
}
示例3: Execute
private async void Execute()
{
EnabledButton(false);
textBox1.Text = "Reloading Pokemon list.";
client = new Client(ClientSettings);
try
{
switch (ClientSettings.AuthType)
{
case AuthType.Ptc:
await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword);
break;
case AuthType.Google:
await client.DoGoogleLogin();
break;
}
await client.SetServer();
profile = await client.GetProfile();
inventory = await client.GetInventory();
pokemons =
inventory.InventoryDelta.InventoryItems
.Select(i => i.InventoryItemData?.Pokemon)
.Where(p => p != null && p?.PokemonId > 0)
.OrderByDescending(key => key.Cp);
var families = inventory.InventoryDelta.InventoryItems
.Select(i => i.InventoryItemData?.PokemonFamily)
.Where(p => p != null && (int)p?.FamilyId > 0)
.OrderByDescending(p => (int)p.FamilyId);
var imageSize = 50;
var imageList = new ImageList { ImageSize = new Size(imageSize, imageSize) };
listView1.ShowItemToolTips = true;
listView1.SmallImageList = imageList;
var templates = await client.GetItemTemplates();
var myPokemonSettings = templates.ItemTemplates.Select(i => i.PokemonSettings).Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
var pokemonSettings = myPokemonSettings.ToList();
var myPokemonFamilies = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PokemonFamily).Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
var pokemonFamilies = myPokemonFamilies.ToArray();
listView1.DoubleBuffered(true);
listView1.View = View.Details;
ColumnHeader columnheader;
columnheader = new ColumnHeader();
columnheader.Text = "Name";
listView1.Columns.Add(columnheader);
columnheader = new ColumnHeader();
columnheader.Text = "CP";
listView1.Columns.Add(columnheader);
columnheader = new ColumnHeader();
columnheader.Text = "IV A-D-S";
listView1.Columns.Add(columnheader);
columnheader = new ColumnHeader();
columnheader.Text = "Candy";
listView1.Columns.Add(columnheader);
columnheader = new ColumnHeader();
columnheader.Text = "Evolvable?";
listView1.Columns.Add(columnheader);
columnheader = new ColumnHeader();
columnheader.Text = "Height";
listView1.Columns.Add(columnheader);
columnheader = new ColumnHeader();
columnheader.Text = "Weight";
listView1.Columns.Add(columnheader);
columnheader = new ColumnHeader();
columnheader.Text = "Attack";
listView1.Columns.Add(columnheader);
columnheader = new ColumnHeader();
columnheader.Text = "SpecialAttack";
listView1.Columns.Add(columnheader);
foreach (var pokemon in pokemons)
{
Bitmap pokemonImage = null;
await Task.Run(() =>
{
pokemonImage = GetPokemonImage((int)pokemon.PokemonId);
});
imageList.Images.Add(pokemon.PokemonId.ToString(), pokemonImage);
listView1.LargeImageList = imageList;
var listViewItem = new ListViewItem();
listViewItem.Tag = pokemon;
var currentCandy = families
.Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
.Select(f => f.Candy)
.First();
var currIv = Math.Round(Perfect(pokemon));
listViewItem.SubItems.Add(string.Format("{0}", pokemon.Cp));
listViewItem.SubItems.Add(string.Format("{0}% {1}-{2}-{3}", currIv, pokemon.IndividualAttack, pokemon.IndividualDefense, pokemon.IndividualStamina));
listViewItem.SubItems.Add(string.Format("{0}", currentCandy));
//.........这里部分代码省略.........
示例4: StatsLog
private async Task StatsLog(Client client)
{
var inventory = await client.GetInventory();
var profil = await client.GetProfile();
var stats = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData.PlayerStats).ToArray();
foreach (var c in stats)
{
if (c != null)
{
int l = c.Level;
var expneeded = ((c.NextLevelXp - c.PrevLevelXp) - StringUtils.getExpDiff(c.Level));
var curexp = ((c.Experience - c.PrevLevelXp) - StringUtils.getExpDiff(c.Level));
var curexppercent = (Convert.ToDouble(curexp) / Convert.ToDouble(expneeded)) * 100;
var pokemonToEvolve = (await _inventory.GetPokemonToEvolve(null)).Count();
Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "_____________________________");
Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "Level: " + c.Level);
Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "EXP Needed: " + expneeded);
Logger.ColoredConsoleWrite(ConsoleColor.Cyan, $"Current EXP: {curexp} ({Math.Round(curexppercent)}%)");
Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "EXP to Level up: " + ((c.NextLevelXp) - (c.Experience)));
Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "KM Walked: " + c.KmWalked);
Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "PokeStops visited: " + c.PokeStopVisits);
Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "Stardust: " + profil.Profile.Currency.ToArray()[1].Amount);
Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "Pokemon to evolve: " + pokemonToEvolve);
Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "_____________________________");
System.Console.Title = profil.Profile.Username + " Level " + c.Level + " - (" + ((c.Experience - c.PrevLevelXp) -
StringUtils.getExpDiff(c.Level)) + " / " + ((c.NextLevelXp - c.PrevLevelXp) - StringUtils.getExpDiff(c.Level)) + " | " + Math.Round(curexppercent) + "%) | Stardust: " + profil.Profile.Currency.ToArray()[1].Amount + " | " + _botStats.ToString();
}
}
}
示例5: Execute
private async void Execute()
{
EnabledButton(false);
textBox1.Text = "Reloading Pokemon list.";
client = new Client(ClientSettings);
try
{
switch (ClientSettings.AuthType)
{
case AuthType.Ptc:
await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword);
break;
case AuthType.Google:
await client.DoGoogleLogin();
break;
}
await client.SetServer();
profile = await client.GetProfile();
inventory = await client.GetInventory();
pokemons =
inventory.InventoryDelta.InventoryItems
.Select(i => i.InventoryItemData?.Pokemon)
.Where(p => p != null && p?.PokemonId > 0)
.OrderByDescending(key => key.Cp);
var families = inventory.InventoryDelta.InventoryItems
.Select(i => i.InventoryItemData?.PokemonFamily)
.Where(p => p != null && (int)p?.FamilyId > 0)
.OrderByDescending(p => (int)p.FamilyId);
var imageSize = 50;
var imageList = new ImageList { ImageSize = new Size(imageSize, imageSize) };
listView1.ShowItemToolTips = true;
var templates = await client.GetItemTemplates();
var myPokemonSettings = templates.ItemTemplates.Select(i => i.PokemonSettings).Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
var pokemonSettings = myPokemonSettings.ToList();
var myPokemonFamilies = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PokemonFamily).Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
var pokemonFamilies = myPokemonFamilies.ToArray();
listView1.DoubleBuffered(true);
foreach (var pokemon in pokemons)
{
Bitmap pokemonImage = null;
await Task.Run(() =>
{
pokemonImage = GetPokemonImage((int)pokemon.PokemonId);
});
imageList.Images.Add(pokemon.PokemonId.ToString(), pokemonImage);
listView1.LargeImageList = imageList;
var listViewItem = new ListViewItem();
listViewItem.Tag = pokemon;
var currentCandy = families
.Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
.Select(f => f.Candy)
.First();
var currIv = Math.Round(Perfect(pokemon));
//listViewItem.SubItems.Add();
listViewItem.ImageKey = pokemon.PokemonId.ToString();
var pokemonId2 = pokemon.PokemonId;
var pokemonName = pokemon.Id;
listViewItem.Text = string.Format("{0}\n{1} CP", pokemon.PokemonId, pokemon.Cp);
listViewItem.ToolTipText = currentCandy + " Candy\n" + currIv + "% IV";
var settings = pokemonSettings.Single(x => x.PokemonId == pokemon.PokemonId);
var familyCandy = pokemonFamilies.Single(x => settings.FamilyId == x.FamilyId);
if (settings.EvolutionIds.Count > 0 && familyCandy.Candy > settings.CandyToEvolve)
listViewItem.Checked = true;
listView1.Items.Add(listViewItem);
}
Text = "Pokemon List | User: " + profile.Profile.Username + " | Pokemons: " + pokemons.Count() + "/" + profile.Profile.PokeStorage;
EnabledButton(true);
textBox1.Text = string.Empty;
}
catch (TaskCanceledException e) {
textBox1.Text = e.Message;
Execute();
}
catch (UriFormatException e) {
textBox1.Text = e.Message;
Execute();
}
catch (ArgumentOutOfRangeException e) {
textBox1.Text = e.Message;
Execute();
}
catch (ArgumentNullException e) {
textBox1.Text = e.Message;
//.........这里部分代码省略.........
示例6: Execute
private static async void Execute()
{
ColoredConsoleWrite(ConsoleColor.Green, $"QuickPokeBOT 1.2 - Fast exp bot");
ColoredConsoleWrite(ConsoleColor.Red, $"This bot will transfer duplicate pokemons (keeping the highest cp one).");
ColoredConsoleWrite(ConsoleColor.White, $"Before Starting check external.config file.");
ColoredConsoleWrite(ConsoleColor.White, $"Increase/adjust requestDelay.");
ColoredConsoleWrite(ConsoleColor.White, $"Check Credentials settings and mode [Google/Ptc].");
ColoredConsoleWrite(ConsoleColor.White, $"Adjust item recycle settings.");
ColoredConsoleWrite(ConsoleColor.White, $"This bot will not evolve anything.");
ColoredConsoleWrite(ConsoleColor.White, $"This bot will automatically wait for softban to finish.");
ColoredConsoleWrite(ConsoleColor.White, $"");
ColoredConsoleWrite(ConsoleColor.Green, $"This bot will start in 5 seconds...");
ColoredConsoleWrite(ConsoleColor.White, $"");
await Task.Delay(5000);
var client = new Client(ClientSettings);
try
{
defaultDelay = Int32.Parse(ClientSettings.requestsDelay);
Client.requestDelay = defaultDelay;
await Task.Delay(defaultDelay);
if (ClientSettings.AuthType == AuthType.Ptc)
await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword);
else if (ClientSettings.AuthType == AuthType.Google)
await client.DoGoogleLogin(ClientSettings.GoogleEmail, ClientSettings.GooglePassword);
await Task.Delay(defaultDelay); //ColoredConsoleWrite(ConsoleColor.White, $"SetServer");
await client.SetServer();
await Task.Delay(defaultDelay); //ColoredConsoleWrite(ConsoleColor.White, $"GetProfile");
var profile = await client.GetProfile();
userName = profile.Profile.Username;
await Task.Delay(defaultDelay); //ColoredConsoleWrite(ConsoleColor.White, $"GetSettings");
var settings = await client.GetSettings();
await Task.Delay(defaultDelay); //ColoredConsoleWrite(ConsoleColor.White, $"GetMapObjects");
var mapObjects = await client.GetMapObjects();
await Task.Delay(defaultDelay); //ColoredConsoleWrite(ConsoleColor.White, $"GetInventory");
var inventory = await client.GetInventory();
var pokemons = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon).Where(p => p != null && p?.PokemonId > 0);
await Task.Delay(defaultDelay); //ColoredConsoleWrite(ConsoleColor.White, $"Transfer PK");
await TransferDuplicatePokemon(client);
//ColoredConsoleWrite(ConsoleColor.Red, "Recycling Items");
await Task.Delay(defaultDelay); //ColoredConsoleWrite(ConsoleColor.White, $"client.RecycleItems(client)");
await client.RecycleItems(client);
//ColoredConsoleWrite(ConsoleColor.Red, "ExecuteFarmingPokestopsAndPokemons");
await ExecuteFarmingPokestopsAndPokemons(client);
ColoredConsoleWrite(ConsoleColor.Red, $"Finished Farming this zone. Wait 15 seconds then restart.");
await Task.Delay(15000);
Execute();
}
catch (TaskCanceledException tce) { ColoredConsoleWrite(ConsoleColor.White, $"[{DateTime.Now.ToString("HH:mm:ss")}] {Language.GetPhrases()["task_canceled_ex"]}"); Execute(); }
catch (UriFormatException ufe) { ColoredConsoleWrite(ConsoleColor.White, $"[{DateTime.Now.ToString("HH:mm:ss")}] {Language.GetPhrases()["sys_uri_format_ex"]}"); Execute(); }
catch (ArgumentOutOfRangeException aore) { ColoredConsoleWrite(ConsoleColor.White, $"[{DateTime.Now.ToString("HH:mm:ss")}] {Language.GetPhrases()["arg_out_of_range_ex"]}"); Execute(); }
catch (ArgumentNullException ane) { ColoredConsoleWrite(ConsoleColor.White, $"[{DateTime.Now.ToString("HH:mm:ss")}] {Language.GetPhrases()["arg_null_ref"]}"); Execute(); }
}
示例7: Execute
private static async void Execute()
{
var client = new Client(ClientSettings);
try
{
switch (ClientSettings.AuthType)
{
case AuthType.Ptc:
await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword);
break;
case AuthType.Google:
await client.DoGoogleLogin();
break;
}
await client.SetServer();
var profile = await client.GetProfile();
var settings = await client.GetSettings();
var mapObjects = await client.GetMapObjects();
var inventory = await client.GetInventory();
var pokemons =
inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon)
.Where(p => p != null && p?.PokemonId > 0);
ConsoleLevelTitle(profile.Profile.Username, client);
// Write the players ingame details
ColoredConsoleWrite(ConsoleColor.Yellow, "----------------------------");
if (ClientSettings.AuthType == AuthType.Ptc)
{
ColoredConsoleWrite(ConsoleColor.Cyan, "Account: " + ClientSettings.PtcUsername);
ColoredConsoleWrite(ConsoleColor.Cyan, "Password: " + ClientSettings.PtcPassword + "\n");
}
ColoredConsoleWrite(ConsoleColor.DarkGray, "Name: " + profile.Profile.Username);
ColoredConsoleWrite(ConsoleColor.DarkGray, "Team: " + profile.Profile.Team);
if (profile.Profile.Currency.ToArray()[0].Amount > 0) // If player has any pokecoins it will show how many they have.
ColoredConsoleWrite(ConsoleColor.DarkGray, "Pokecoins: " + profile.Profile.Currency.ToArray()[0].Amount);
ColoredConsoleWrite(ConsoleColor.DarkGray, "Stardust: " + profile.Profile.Currency.ToArray()[1].Amount + "\n");
ColoredConsoleWrite(ConsoleColor.DarkGray, "Latitude: " + ClientSettings.DefaultLatitude);
ColoredConsoleWrite(ConsoleColor.DarkGray, "Longitude: " + ClientSettings.DefaultLongitude);
try
{
ColoredConsoleWrite(ConsoleColor.DarkGray, "Area: " + CallAPI("place", ClientSettings.DefaultLatitude, ClientSettings.DefaultLongitude));
ColoredConsoleWrite(ConsoleColor.DarkGray, "Country: " + CallAPI("country", ClientSettings.DefaultLatitude, ClientSettings.DefaultLongitude));
}
catch (Exception)
{
ColoredConsoleWrite(ConsoleColor.DarkGray, "Unable to get Country/Place");
}
ColoredConsoleWrite(ConsoleColor.Yellow, "----------------------------");
// I believe a switch is more efficient and easier to read.
switch (ClientSettings.TransferType)
{
case "leaveStrongest":
await TransferAllButStrongestUnwantedPokemon(client);
break;
case "all":
await TransferAllGivenPokemons(client, pokemons);
break;
case "duplicate":
await TransferDuplicatePokemon(client);
break;
case "cp":
await TransferAllWeakPokemon(client, ClientSettings.TransferCPThreshold);
break;
case "iv":
await TransferAllGivenPokemons(client, pokemons, ClientSettings.TransferIVThreshold);
break;
default:
ColoredConsoleWrite(ConsoleColor.DarkGray, "Transfering pokemon disabled");
break;
}
if (ClientSettings.EvolveAllGivenPokemons)
await EvolveAllGivenPokemons(client, pokemons);
if (ClientSettings.Recycler)
client.RecycleItems(client);
await Task.Delay(5000);
PrintLevel(client);
await ExecuteFarmingPokestopsAndPokemons(client);
ColoredConsoleWrite(ConsoleColor.Red, $"No nearby useful locations found. Please wait 10 seconds.");
await Task.Delay(10000);
CheckVersion();
Execute();
}
catch (TaskCanceledException) { ColoredConsoleWrite(ConsoleColor.Red, "Task Canceled Exception - Restarting"); Execute(); }
catch (UriFormatException) { ColoredConsoleWrite(ConsoleColor.Red, "System URI Format Exception - Restarting"); Execute(); }
catch (ArgumentOutOfRangeException) { ColoredConsoleWrite(ConsoleColor.Red, "ArgumentOutOfRangeException - Restarting"); Execute(); }
catch (ArgumentNullException) { ColoredConsoleWrite(ConsoleColor.Red, "Argument Null Refference - Restarting"); Execute(); }
catch (NullReferenceException) { ColoredConsoleWrite(ConsoleColor.Red, "Null Refference - Restarting"); Execute(); }
catch (Exception ex) { ColoredConsoleWrite(ConsoleColor.Red, ex.ToString()); Execute(); }
}
示例8: Execute
private async void Execute()
{
client = new Client(ClientSettings);
this.locationManager = new LocationManager(client, ClientSettings.TravelSpeed);
try
{
switch (ClientSettings.AuthType)
{
case AuthType.Ptc:
ColoredConsoleWrite(Color.Green, "Login Type: Pokemon Trainers Club");
break;
case AuthType.Google:
ColoredConsoleWrite(Color.Green, "Login Type: Google");
break;
}
await client.Login();
await client.SetServer();
var profile = await client.GetProfile();
var settings = await client.GetSettings();
var mapObjects = await client.GetMapObjects();
var inventory = await client.GetInventory();
var pokemons =
inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon)
.Where(p => p != null && p?.PokemonId > 0);
updateUserStatusBar(client);
// Write the players ingame details
ColoredConsoleWrite(Color.Yellow, "----------------------------");
/*// dont actually want to display info but keeping here incase people want to \O_O/
* if (ClientSettings.AuthType == AuthType.Ptc)
{
ColoredConsoleWrite(Color.Cyan, "Account: " + ClientSettings.PtcUsername);
ColoredConsoleWrite(Color.Cyan, "Password: " + ClientSettings.PtcPassword + "\n");
}
else
{
ColoredConsoleWrite(Color.Cyan, "Email: " + ClientSettings.Email);
ColoredConsoleWrite(Color.Cyan, "Password: " + ClientSettings.Password + "\n");
}*/
string lat2 = System.Convert.ToString(ClientSettings.DefaultLatitude);
string longit2 = System.Convert.ToString(ClientSettings.DefaultLongitude);
ColoredConsoleWrite(Color.DarkGray, "Name: " + profile.Profile.Username);
ColoredConsoleWrite(Color.DarkGray, "Team: " + profile.Profile.Team);
if (profile.Profile.Currency.ToArray()[0].Amount > 0) // If player has any pokecoins it will show how many they have.
ColoredConsoleWrite(Color.DarkGray, "Pokecoins: " + profile.Profile.Currency.ToArray()[0].Amount);
ColoredConsoleWrite(Color.DarkGray, "Stardust: " + profile.Profile.Currency.ToArray()[1].Amount + "\n");
ColoredConsoleWrite(Color.DarkGray, "Latitude: " + ClientSettings.DefaultLatitude);
ColoredConsoleWrite(Color.DarkGray, "Longitude: " + ClientSettings.DefaultLongitude);
try
{
ColoredConsoleWrite(Color.DarkGray, "Country: " + CallAPI("country", lat2.Replace(',', '.'), longit2.Replace(',', '.')));
ColoredConsoleWrite(Color.DarkGray, "Area: " + CallAPI("place", lat2.Replace(',', '.'), longit2.Replace(',', '.')));
}
catch (Exception)
{
ColoredConsoleWrite(Color.DarkGray, "Unable to get Country/Place");
}
ColoredConsoleWrite(Color.Yellow, "----------------------------");
// I believe a switch is more efficient and easier to read.
switch (ClientSettings.TransferType)
{
case "Leave Strongest":
await TransferAllButStrongestUnwantedPokemon(client);
break;
case "All":
await TransferAllGivenPokemons(client, pokemons);
break;
case "CP Duplicate":
await TransferDuplicatePokemon(client);
break;
case "IV Duplicate":
await TransferDuplicateIVPokemon(client);
break;
case "CP/IV Duplicate":
await TransferDuplicateCPIVPokemon(client);
break;
case "CP":
await TransferAllWeakPokemon(client, ClientSettings.TransferCPThreshold);
break;
case "IV":
await TransferAllGivenPokemons(client, pokemons, ClientSettings.TransferIVThreshold);
break;
default:
ColoredConsoleWrite(Color.DarkGray, "Transfering pokemon disabled");
break;
}
if (ClientSettings.EvolveAllGivenPokemons)
await EvolveAllGivenPokemons(client, pokemons);
if (ClientSettings.Recycler)
client.RecycleItems(client);
await Task.Delay(5000);
PrintLevel(client);
//.........这里部分代码省略.........
示例9: PrintBoostrap
private static async Task PrintBoostrap(Client client)
{
var profile = await client.GetProfile();
await ConsoleLevelTitle(profile.Profile.Username, client);
ColoredConsoleWrite(ConsoleColor.Yellow, "----------------------------");
ColoredConsoleWrite(ConsoleColor.Cyan,
Language.GetPhrases()["account"].Replace("[username]", ClientSettings.PtcUsername));
ColoredConsoleWrite(ConsoleColor.Cyan,
Language.GetPhrases()["password"].Replace("[password]", ClientSettings.PtcPassword + "\n"));
ColoredConsoleWrite(ConsoleColor.DarkGray,
Language.GetPhrases()["latitude"].Replace("[latitude]", Convert.ToString(ClientSettings.DefaultLatitude)));
ColoredConsoleWrite(ConsoleColor.DarkGray,
Language.GetPhrases()["longtitude"].Replace("[longtitude]", Convert.ToString(ClientSettings.DefaultLongitude)));
ColoredConsoleWrite(ConsoleColor.Yellow, "----------------------------");
ColoredConsoleWrite(ConsoleColor.DarkGray, Language.GetPhrases()["your_account"] + "\n");
ColoredConsoleWrite(ConsoleColor.DarkGray,
Language.GetPhrases()["username"].Replace("[username]", profile.Profile.Username));
ColoredConsoleWrite(ConsoleColor.DarkGray,
Language.GetPhrases()["team"].Replace("[team]", Convert.ToString(profile.Profile.Team)));
ColoredConsoleWrite(ConsoleColor.DarkGray,
Language.GetPhrases()["stardust"].Replace("[stardust]",
Convert.ToString(profile.Profile.Currency.ToArray()[1].Amount)));
ColoredConsoleWrite(ConsoleColor.Cyan, "\n" + Language.GetPhrases()["farming_started"]);
ColoredConsoleWrite(ConsoleColor.Yellow, "----------------------------");
}
示例10: ConsoleLevelTitle
public static async Task ConsoleLevelTitle(string Username, Client client)
{
var inventory = await client.GetInventory();
var stats = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PlayerStats).ToArray();
var profile = await client.GetProfile();
foreach (var v in stats)
if (v != null)
{
int XpDiff = GetXpDiff(client, v.Level);
System.Console.Title = string.Format(Username + " | Level {0:0} - ({1:0} / {2:0}) | Stardust {3:0}", v.Level, (v.Experience - v.PrevLevelXp - XpDiff), (v.NextLevelXp - v.PrevLevelXp - XpDiff), profile.Profile.Currency.ToArray()[1].Amount);
}
await Task.Delay(1000);
ConsoleLevelTitle(Username, client);
}
示例11: loginPtc
private async Task loginPtc(string username, string password)
{
try
{
// Creating the Settings
Logger.Write("Adjusting the Settings.");
UserSettings.Default.AuthType = AuthType.Ptc.ToString();
UserSettings.Default.PtcUsername = username;
UserSettings.Default.PtcPassword = password;
this.settings = new Settings();
// Begin Login
Logger.Write("Trying to Login with PTC Credentials...");
Client client = new Client(this.settings);
await client.DoPtcLogin(this.settings.PtcUsername, this.settings.PtcPassword);
await client.SetServer();
// Server Ready
Logger.Write("Connected! Server is Ready.");
this.client = client;
Logger.Write("Attempting to Retrieve Inventory and Player Profile...");
this.inventory = new Inventory(client);
this.profile = await client.GetProfile();
enableButtons();
}
catch
{
Logger.Write("Unable to Connect using the PTC Credentials.");
MessageBox.Show("Unable to Authenticate with Login Server.", "Login Problem");
Application.Exit();
}
}
示例12: loginGoogle
private async Task loginGoogle()
{
try
{
// Creating the Settings
Logger.Write("Adjusting the Settings.");
UserSettings.Default.AuthType = AuthType.Google.ToString();
this.settings = new Settings();
// Begin Login
Logger.Write("Trying to Login with Google Token...");
Client client = new Client(this.settings);
await client.DoGoogleLogin();
await client.SetServer();
// Server Ready
Logger.Write("Connected! Server is Ready.");
this.client = client;
Logger.Write("Attempting to Retrieve Inventory and Player Profile...");
this.inventory = new Inventory(client);
this.profile = await client.GetProfile();
enableButtons();
}
catch
{
Logger.Write("Unable to Connect using the Google Token.");
MessageBox.Show("Unable to Authenticate with Login Server.", "Login Problem");
Application.Exit();
}
}
示例13: LoginPtc
private async Task LoginPtc(string username, string password)
{
try
{
// Login Method
_loginMethod = AuthType.Ptc;
_username = username;
_password = password;
// Creating the Settings
Logger.Write("Adjusting the Settings.");
UserSettings.Default.AuthType = AuthType.Ptc.ToString();
UserSettings.Default.PtcUsername = username;
UserSettings.Default.PtcPassword = password;
_settings = new Settings();
// Begin Login
Logger.Write("Trying to Login with PTC Credentials...");
Client client = new Client(_settings);
await client.DoPtcLogin(_settings.PtcUsername, _settings.PtcPassword);
await client.SetServer();
// Server Ready
Logger.Write("Connected! Server is Ready.");
_client = client;
Logger.Write("Attempting to Retrieve Inventory and Player Profile...");
_inventory = new Inventory(client);
_profile = await client.GetProfile();
EnableButtons();
_loginSuccess = true;
}
catch(Exception ex)
{
// Error Logging
ErrorReportCreator.Create("PTCLoginError", "Unable to Login with PTC", ex);
Logger.Write("Unable to Connect using the PTC Credentials.");
MessageBox.Show(@"Unable to Authenticate with Login Server.", @"Login Problem");
Application.Exit();
}
}
示例14: LoginGoogle
private async Task LoginGoogle(string username, string password)
{
try
{
// Login Method
_loginMethod = AuthType.Google;
_username = username;
_password = password;
// Creating the Settings
Logger.Write("Adjusting the Settings.");
UserSettings.Default.AuthType = AuthType.Google.ToString();
_settings = new Settings();
// Begin Login
Logger.Write("Trying to Login with Google Token...");
Client client = new Client(_settings);
client.DoGoogleLogin(username, password);
await client.SetServer();
// Server Ready
Logger.Write("Connected! Server is Ready.");
_client = client;
Logger.Write("Attempting to Retrieve Inventory and Player Profile...");
_inventory = new Inventory(client);
_profile = await client.GetProfile();
EnableButtons();
_loginSuccess = true;
}
catch (GoogleException ex)
{
if(ex.Message.Contains("NeedsBrowser"))
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("It seems you have Google 2 Factor Authentication enabled.");
sb.AppendLine("In order to enable this bot to access your Google Account you need to create an App Password and use that one instead of your Google Password.");
sb.AppendLine();
sb.AppendLine("Please go to: https://security.google.com/settings/security/apppasswords");
sb.AppendLine("In 'Select App' select 'Other' and 'on my' select 'Windows Computer'.");
sb.AppendLine();
sb.AppendLine("This will generate a random password use that password login to the bot.");
MessageBox.Show(sb.ToString(), "Google 2 Factor Authentication");
Application.Exit();
}
if(ex.Message.Contains("BadAuth"))
{
MessageBox.Show("Your Google Credentials are incorrect.", "Google Login");
Application.Exit();
}
}
catch(Exception ex)
{
// Error Logging
ErrorReportCreator.Create("GoogleLoginError", "Unable to Login with Google", ex);
Logger.Write("Unable to Connect using the Google Token.");
MessageBox.Show(@"Unable to Authenticate with Login Server.", @"Login Problem");
Application.Exit();
}
}
示例15: Execute
private async void Execute()
{
EnabledButton(false);
client = new Client(ClientSettings);
try
{
switch (ClientSettings.AuthType)
{
case AuthType.Ptc:
await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword);
break;
case AuthType.Google:
await client.DoGoogleLogin(ClientSettings.Email, ClientSettings.Password);
break;
}
//
await client.SetServer();
var profile = await client.GetProfile();
var inventory = await client.GetInventory();
var pokemons =
inventory.InventoryDelta.InventoryItems
.Select(i => i.InventoryItemData?.Pokemon)
.Where(p => p != null && p?.PokemonId > 0)
.OrderByDescending(key => key.Cp);
var families = inventory.InventoryDelta.InventoryItems
.Select(i => i.InventoryItemData?.PokemonFamily)
.Where(p => p != null && (int)p?.FamilyId > 0)
.OrderByDescending(p => (int)p.FamilyId);
var imageList = new ImageList { ImageSize = new Size(50, 50) };
listView1.ShowItemToolTips = true;
foreach (var pokemon in pokemons)
{
Bitmap pokemonImage = null;
await Task.Run(() =>
{
pokemonImage = GetPokemonImage((int)pokemon.PokemonId);
});
imageList.Images.Add(pokemon.PokemonId.ToString(), pokemonImage);
listView1.LargeImageList = imageList;
var listViewItem = new ListViewItem();
listViewItem.Tag = pokemon;
var currentCandy = families
.Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
.Select(f => f.Candy)
.First();
var currIv = Math.Round(Perfect(pokemon));
//listViewItem.SubItems.Add();
listViewItem.ImageKey = pokemon.PokemonId.ToString();
var pokemonId2 = pokemon.PokemonId;
var pokemonName = pokemon.Id;
listViewItem.Text = string.Format("{0}\n{1} CP", pokemon.PokemonId, pokemon.Cp);
listViewItem.ToolTipText = currentCandy + " Candy\n" + currIv + "% IV";
this.listView1.Items.Add(listViewItem);
}
this.Text = "PokeUi " + pokemons.Count<PokemonData>() + "/" + profile.Profile.PokeStorage;
EnabledButton(true);
}
catch (TaskCanceledException) { Execute(); }
catch (UriFormatException) { Execute(); }
catch (ArgumentOutOfRangeException) { Execute(); }
catch (ArgumentNullException) { Execute(); }
catch (NullReferenceException) { Execute(); }
catch (Exception ex) { Execute(); }
}