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

Commit a46fd75

Browse files
authored
Merge pull request #374 from Necrobot-Private/feature/multibot-fixes
Feature/multibot fixes
2 parents be73d92 + f9677df commit a46fd75

File tree

8 files changed

+48
-56
lines changed

8 files changed

+48
-56
lines changed

PoGo.NecroBot.Logic/Interfaces/Configuration/ILogicSettings.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,5 @@ public interface ILogicSettings
230230
MultipleBotConfig MultipleBotConfig { get; }
231231
int GymCollectRewardAfter { get; }
232232
List<AuthConfig> Bots { get; }
233-
bool AllowMultipleBot { get; }
234233
}
235234
}

PoGo.NecroBot.Logic/Model/Settings/AuthSettings.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ public class AuthSettings
3737
[JsonProperty(Required = Required.DisallowNull, DefaultValueHandling = DefaultValueHandling.Ignore, Order = 3)]
3838
public DeviceConfig DeviceConfig = new DeviceConfig();
3939

40-
[JsonProperty(Required = Required.DisallowNull, DefaultValueHandling = DefaultValueHandling.Ignore, Order = 4)]
41-
public bool AllowMultipleBot = false;
42-
4340
[JsonProperty(Required = Required.Default, DefaultValueHandling = DefaultValueHandling.Ignore, Order = 5)]
4441
public List<AuthConfig> Bots= new List<AuthConfig>();
4542

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

306+
case 4:
307+
((JObject)settings).Remove("AllowMultipleBot");
308+
break;
309309
// Add more here.
310310
}
311311
}

PoGo.NecroBot.Logic/Model/Settings/LogicSettings.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ public LogicSettings(GlobalSettings settings)
232232

233233
public MultipleBotConfig MultipleBotConfig => _settings.MultipleBotConfig;
234234
public List<AuthConfig> Bots => _settings.Auth.Bots;
235-
public bool AllowMultipleBot => _settings.Auth.AllowMultipleBot;
236235
public int MinIVForAutoSnipe => _settings.SnipeConfig.MinIVForAutoSnipe;
237236
public Dictionary<PokemonId, BotSwitchPokemonFilter> BotSwitchPokemonFilters => _settings.BotSwitchPokemonFilters;
238237

PoGo.NecroBot.Logic/Model/Settings/MultipleBotConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public static MultipleBotConfig Default()
132132

133133
public static bool IsMultiBotActive(ILogicSettings logicSettings)
134134
{
135-
return logicSettings.AllowMultipleBot && logicSettings.Bots != null && logicSettings.Bots.Count > 1;
135+
return logicSettings.Bots != null && logicSettings.Bots.Count > 1;
136136
}
137137
}
138138
}

PoGo.NecroBot.Logic/Model/Settings/UpdateConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace PoGo.NecroBot.Logic.Model.Settings
66
[JsonObject(Title = "Update Config", Description = "Set your update settings.", ItemRequired = Required.DisallowNull)]
77
public class UpdateConfig
88
{
9-
public const int CURRENT_SCHEMA_VERSION = 4;
9+
public const int CURRENT_SCHEMA_VERSION = 5;
1010

1111
[DefaultValue(CURRENT_SCHEMA_VERSION)]
1212
[JsonProperty(Required = Required.DisallowNull, DefaultValueHandling = DefaultValueHandling.Populate, Order = 1)]

PoGo.NecroBot.Logic/Tasks/CatchPokemonTask.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -412,30 +412,33 @@ encounter is EncounterResponse || encounter is IncenseEncounterResponse
412412
} while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed ||
413413
caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchEscape);
414414

415-
if(caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchFlee)
415+
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
416416
{
417-
CatchFleeContinuouslyCount++;
418-
if(CatchFleeContinuouslyCount > 10)
417+
if (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchFlee)
419418
{
420-
CatchFleeContinuouslyCount = 0;
421-
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
419+
CatchFleeContinuouslyCount++;
420+
if (CatchFleeContinuouslyCount > 10)
422421
{
422+
CatchFleeContinuouslyCount = 0;
423+
423424
throw new ActiveSwitchByRuleException()
424425
{
425426
MatchedRule = SwitchRules.CatchFlee,
426427
ReachedValue = 10
427428
};
428429
}
429430
}
431+
else
432+
{
433+
//reset if not catch flee.
434+
CatchFleeContinuouslyCount = 0;
435+
}
430436
}
431-
else
432-
{
433-
//reset if not catch flee.
434-
CatchFleeContinuouslyCount = 0;
435-
}
437+
436438
session.Actions.RemoveAll(x => x == Model.BotActions.Catch);
437439

438-
ExecuteSwitcher(session, encounterEV);
440+
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
441+
ExecuteSwitcher(session, encounterEV);
439442

440443
if (session.LogicSettings.TransferDuplicatePokemonOnCapture &&
441444
session.LogicSettings.TransferDuplicatePokemon &&

PoGo.NecroBot.Logic/Tasks/UseNearbyPokestopsTask.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,12 @@ private static async Task FarmPokestop(ISession session, FortData pokeStop, Fort
409409
} while (fortTry < retryNumber - zeroCheck);
410410
//Stop trying if softban is cleaned earlier or if 40 times fort looting failed.
411411

412-
if(fortTry >= retryNumber - zeroCheck)
412+
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
413413
{
414-
session.CancellationTokenSource.Cancel();
415-
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
414+
if (fortTry >= retryNumber - zeroCheck)
416415
{
416+
session.CancellationTokenSource.Cancel();
417+
417418
//Activate switcher by pokestop
418419
throw new ActiveSwitchByRuleException()
419420
{
@@ -422,6 +423,7 @@ private static async Task FarmPokestop(ISession session, FortData pokeStop, Fort
422423
};
423424
}
424425
}
426+
425427
if (session.LogicSettings.RandomlyPauseAtStops && !doNotRetry)
426428
{
427429
if (++_randomStop >= _randomNumber)

PoGo.NecroBot.Logic/Utils/Statistics.cs

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -46,65 +46,54 @@ public void Dirty(Inventory inventory, ISession session)
4646

4747
public void OnStatisticChanged(ISession session)
4848
{
49-
50-
var config = session.LogicSettings.MultipleBotConfig;
51-
if (session.LogicSettings.AllowMultipleBot)
49+
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
5250
{
51+
var config = session.LogicSettings.MultipleBotConfig;
52+
5353
if (config.PokestopSwitch > 0 && config.PokestopSwitch <= this.TotalPokestops)
5454
{
5555
session.CancellationTokenSource.Cancel();
56-
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
56+
57+
//Activate switcher by pokestop
58+
throw new ActiveSwitchByRuleException()
5759
{
58-
//Activate switcher by pokestop
59-
throw new ActiveSwitchByRuleException()
60-
{
61-
MatchedRule = SwitchRules.Pokestop,
62-
ReachedValue = this.TotalPokestops
63-
};
64-
}
60+
MatchedRule = SwitchRules.Pokestop,
61+
ReachedValue = this.TotalPokestops
62+
};
6563
}
6664

6765
if (config.PokemonSwitch > 0 && config.PokemonSwitch <= this.TotalPokemons)
6866
{
6967
session.CancellationTokenSource.Cancel();
70-
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
68+
//Activate switcher by pokestop
69+
throw new ActiveSwitchByRuleException()
7170
{
72-
//Activate switcher by pokestop
73-
throw new ActiveSwitchByRuleException()
74-
{
75-
MatchedRule = SwitchRules.Pokemon,
76-
ReachedValue = this.TotalPokemons
77-
};
78-
}
71+
MatchedRule = SwitchRules.Pokemon,
72+
ReachedValue = this.TotalPokemons
73+
};
7974
}
8075

8176
if (config.EXPSwitch > 0 && config.EXPSwitch <= this.TotalExperience)
8277
{
8378
session.CancellationTokenSource.Cancel();
84-
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
79+
//Activate switcher by pokestop
80+
throw new ActiveSwitchByRuleException()
8581
{
86-
//Activate switcher by pokestop
87-
throw new ActiveSwitchByRuleException()
88-
{
89-
MatchedRule = SwitchRules.EXP,
90-
ReachedValue = this.TotalExperience
91-
};
92-
}
82+
MatchedRule = SwitchRules.EXP,
83+
ReachedValue = this.TotalExperience
84+
};
9385
}
9486

9587
var totalMin = (DateTime.Now - _initSessionDateTime).TotalMinutes;
9688
if (config.RuntimeSwitch> 0 && config.RuntimeSwitch <= totalMin)
9789
{
9890
session.CancellationTokenSource.Cancel();
99-
if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings))
91+
//Activate switcher by pokestop
92+
throw new ActiveSwitchByRuleException()
10093
{
101-
//Activate switcher by pokestop
102-
throw new ActiveSwitchByRuleException()
103-
{
104-
MatchedRule = SwitchRules.Runtime,
105-
ReachedValue = Math.Round(totalMin, 1)
106-
};
107-
}
94+
MatchedRule = SwitchRules.Runtime,
95+
ReachedValue = Math.Round(totalMin, 1)
96+
};
10897
}
10998
}
11099

0 commit comments

Comments
 (0)