Skip to content

Commit

Permalink
Improve SendOnFarmingFinished + increase farming interval
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Feb 22, 2016
1 parent 25da5fb commit 6974e51
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions ArchiSteamFarm/Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ internal void Shutdown() {
Program.OnBotShutdown();
}

internal async Task OnFarmingFinished() {
if (SendOnFarmingFinished) {
await ResponseSendTrade(BotName).ConfigureAwait(false);
internal async Task OnFarmingFinished(bool farmedSomething) {
if (farmedSomething && SendOnFarmingFinished) {
await ResponseSendTrade().ConfigureAwait(false);
}
if (ShutdownOnFarmingFinished) {
Shutdown();
Expand Down
9 changes: 7 additions & 2 deletions ArchiSteamFarm/CardsFarmer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal CardsFarmer(Bot bot) {
async e => await CheckGamesForFarming().ConfigureAwait(false),
null,
TimeSpan.FromMinutes(15), // Delay
TimeSpan.FromMinutes(15) // Period
TimeSpan.FromMinutes(60) // Period
);
}

Expand Down Expand Up @@ -175,6 +175,8 @@ internal async Task StartFarming() {
NowFarming = true;
Semaphore.Release(); // From this point we allow other calls to shut us down

bool farmedSomething = false;

// Now the algorithm used for farming depends on whether account is restricted or not
if (Bot.CardDropsRestricted) { // If we have restricted card drops, we use complex algorithm
Logging.LogGenericInfo("Chosen farming algorithm: Complex", Bot.BotName);
Expand All @@ -184,6 +186,7 @@ internal async Task StartFarming() {
while (gamesToFarmSolo.Count > 0) {
uint appID = gamesToFarmSolo[0];
if (await FarmSolo(appID).ConfigureAwait(false)) {
farmedSomething = true;
Logging.LogGenericInfo("Done farming: " + appID, Bot.BotName);
gamesToFarmSolo.Remove(appID);
gamesToFarmSolo.TrimExcess();
Expand All @@ -194,6 +197,7 @@ internal async Task StartFarming() {
}
} else {
if (FarmMultiple(GamesToFarm)) {
farmedSomething = true;
Logging.LogGenericInfo("Done farming: " + string.Join(", ", GamesToFarm.Keys), Bot.BotName);
} else {
NowFarming = false;
Expand All @@ -206,6 +210,7 @@ internal async Task StartFarming() {
while (GamesToFarm.Count > 0) {
uint appID = GetAnyGameToFarm(GamesToFarm);
if (await FarmSolo(appID).ConfigureAwait(false)) {
farmedSomething = true;
Logging.LogGenericInfo("Done farming: " + appID, Bot.BotName);
} else {
NowFarming = false;
Expand All @@ -218,7 +223,7 @@ internal async Task StartFarming() {
CurrentGamesFarming.TrimExcess();
NowFarming = false;
Logging.LogGenericInfo("Farming finished!", Bot.BotName);
await Bot.OnFarmingFinished().ConfigureAwait(false);
await Bot.OnFarmingFinished(farmedSomething).ConfigureAwait(false);
}

internal async Task StopFarming() {
Expand Down

0 comments on commit 6974e51

Please sign in to comment.