Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #374 from Necrobot-Private/feature/multibot-fixes
Browse files Browse the repository at this point in the history
Feature/multibot fixes
  • Loading branch information
jjskuld authored Nov 18, 2016
2 parents be73d92 + f9677df commit a46fd75
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,5 @@ public interface ILogicSettings
MultipleBotConfig MultipleBotConfig { get; }
int GymCollectRewardAfter { get; }
List<AuthConfig> Bots { get; }
bool AllowMultipleBot { get; }
}
}
6 changes: 3 additions & 3 deletions PoGo.NecroBot.Logic/Model/Settings/AuthSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ public class AuthSettings
[JsonProperty(Required = Required.DisallowNull, DefaultValueHandling = DefaultValueHandling.Ignore, Order = 3)]
public DeviceConfig DeviceConfig = new DeviceConfig();

[JsonProperty(Required = Required.DisallowNull, DefaultValueHandling = DefaultValueHandling.Ignore, Order = 4)]
public bool AllowMultipleBot = false;

[JsonProperty(Required = Required.Default, DefaultValueHandling = DefaultValueHandling.Ignore, Order = 5)]
public List<AuthConfig> Bots= new List<AuthConfig>();

Expand Down Expand Up @@ -306,6 +303,9 @@ private static void MigrateSettings(int schemaVersion, JObject settings, string
settings["DeviceConfig"]["FirmwareFingerprint"] = null;
break;

case 4:
((JObject)settings).Remove("AllowMultipleBot");
break;
// Add more here.
}
}
Expand Down
1 change: 0 additions & 1 deletion PoGo.NecroBot.Logic/Model/Settings/LogicSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ public LogicSettings(GlobalSettings settings)

public MultipleBotConfig MultipleBotConfig => _settings.MultipleBotConfig;
public List<AuthConfig> Bots => _settings.Auth.Bots;
public bool AllowMultipleBot => _settings.Auth.AllowMultipleBot;
public int MinIVForAutoSnipe => _settings.SnipeConfig.MinIVForAutoSnipe;
public Dictionary<PokemonId, BotSwitchPokemonFilter> BotSwitchPokemonFilters => _settings.BotSwitchPokemonFilters;

Expand Down
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/Model/Settings/MultipleBotConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public static MultipleBotConfig Default()

public static bool IsMultiBotActive(ILogicSettings logicSettings)
{
return logicSettings.AllowMultipleBot && logicSettings.Bots != null && logicSettings.Bots.Count > 1;
return logicSettings.Bots != null && logicSettings.Bots.Count > 1;
}
}
}
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/Model/Settings/UpdateConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace PoGo.NecroBot.Logic.Model.Settings
[JsonObject(Title = "Update Config", Description = "Set your update settings.", ItemRequired = Required.DisallowNull)]
public class UpdateConfig
{
public const int CURRENT_SCHEMA_VERSION = 4;
public const int CURRENT_SCHEMA_VERSION = 5;

[DefaultValue(CURRENT_SCHEMA_VERSION)]
[JsonProperty(Required = Required.DisallowNull, DefaultValueHandling = DefaultValueHandling.Populate, Order = 1)]
Expand Down
25 changes: 14 additions & 11 deletions PoGo.NecroBot.Logic/Tasks/CatchPokemonTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,30 +412,33 @@ encounter is EncounterResponse || encounter is IncenseEncounterResponse
} while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed ||
caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchEscape);

if(caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchFlee)
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
{
CatchFleeContinuouslyCount++;
if(CatchFleeContinuouslyCount > 10)
if (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchFlee)
{
CatchFleeContinuouslyCount = 0;
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
CatchFleeContinuouslyCount++;
if (CatchFleeContinuouslyCount > 10)
{
CatchFleeContinuouslyCount = 0;

throw new ActiveSwitchByRuleException()
{
MatchedRule = SwitchRules.CatchFlee,
ReachedValue = 10
};
}
}
else
{
//reset if not catch flee.
CatchFleeContinuouslyCount = 0;
}
}
else
{
//reset if not catch flee.
CatchFleeContinuouslyCount = 0;
}

session.Actions.RemoveAll(x => x == Model.BotActions.Catch);

ExecuteSwitcher(session, encounterEV);
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
ExecuteSwitcher(session, encounterEV);

if (session.LogicSettings.TransferDuplicatePokemonOnCapture &&
session.LogicSettings.TransferDuplicatePokemon &&
Expand Down
8 changes: 5 additions & 3 deletions PoGo.NecroBot.Logic/Tasks/UseNearbyPokestopsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,12 @@ private static async Task FarmPokestop(ISession session, FortData pokeStop, Fort
} while (fortTry < retryNumber - zeroCheck);
//Stop trying if softban is cleaned earlier or if 40 times fort looting failed.

if(fortTry >= retryNumber - zeroCheck)
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
{
session.CancellationTokenSource.Cancel();
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
if (fortTry >= retryNumber - zeroCheck)
{
session.CancellationTokenSource.Cancel();

//Activate switcher by pokestop
throw new ActiveSwitchByRuleException()
{
Expand All @@ -422,6 +423,7 @@ private static async Task FarmPokestop(ISession session, FortData pokeStop, Fort
};
}
}

if (session.LogicSettings.RandomlyPauseAtStops && !doNotRetry)
{
if (++_randomStop >= _randomNumber)
Expand Down
59 changes: 24 additions & 35 deletions PoGo.NecroBot.Logic/Utils/Statistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,65 +46,54 @@ public void Dirty(Inventory inventory, ISession session)

public void OnStatisticChanged(ISession session)
{

var config = session.LogicSettings.MultipleBotConfig;
if (session.LogicSettings.AllowMultipleBot)
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
{
var config = session.LogicSettings.MultipleBotConfig;

if (config.PokestopSwitch > 0 && config.PokestopSwitch <= this.TotalPokestops)
{
session.CancellationTokenSource.Cancel();
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))

//Activate switcher by pokestop
throw new ActiveSwitchByRuleException()
{
//Activate switcher by pokestop
throw new ActiveSwitchByRuleException()
{
MatchedRule = SwitchRules.Pokestop,
ReachedValue = this.TotalPokestops
};
}
MatchedRule = SwitchRules.Pokestop,
ReachedValue = this.TotalPokestops
};
}

if (config.PokemonSwitch > 0 && config.PokemonSwitch <= this.TotalPokemons)
{
session.CancellationTokenSource.Cancel();
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
//Activate switcher by pokestop
throw new ActiveSwitchByRuleException()
{
//Activate switcher by pokestop
throw new ActiveSwitchByRuleException()
{
MatchedRule = SwitchRules.Pokemon,
ReachedValue = this.TotalPokemons
};
}
MatchedRule = SwitchRules.Pokemon,
ReachedValue = this.TotalPokemons
};
}

if (config.EXPSwitch > 0 && config.EXPSwitch <= this.TotalExperience)
{
session.CancellationTokenSource.Cancel();
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
//Activate switcher by pokestop
throw new ActiveSwitchByRuleException()
{
//Activate switcher by pokestop
throw new ActiveSwitchByRuleException()
{
MatchedRule = SwitchRules.EXP,
ReachedValue = this.TotalExperience
};
}
MatchedRule = SwitchRules.EXP,
ReachedValue = this.TotalExperience
};
}

var totalMin = (DateTime.Now - _initSessionDateTime).TotalMinutes;
if (config.RuntimeSwitch> 0 && config.RuntimeSwitch <= totalMin)
{
session.CancellationTokenSource.Cancel();
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
//Activate switcher by pokestop
throw new ActiveSwitchByRuleException()
{
//Activate switcher by pokestop
throw new ActiveSwitchByRuleException()
{
MatchedRule = SwitchRules.Runtime,
ReachedValue = Math.Round(totalMin, 1)
};
}
MatchedRule = SwitchRules.Runtime,
ReachedValue = Math.Round(totalMin, 1)
};
}
}

Expand Down

0 comments on commit a46fd75

Please sign in to comment.