Add GamesPlayedWhileIdle, closes #121

This commit is contained in:
JustArchi
2016-02-28 04:15:52 +01:00
parent 335044e38a
commit 6bc715575f
3 changed files with 26 additions and 3 deletions

View File

@@ -85,6 +85,7 @@ namespace ArchiSteamFarm {
internal string SteamTradeToken { get; private set; } = "null";
internal byte SendTradePeriod { get; private set; } = 0;
internal HashSet<uint> Blacklist { get; } = new HashSet<uint>();
internal HashSet<uint> GamesPlayedWhileIdle { get; } = new HashSet<uint>() { 0 };
internal bool Statistics { get; private set; } = true;
private bool InvalidPassword = false;
@@ -245,6 +246,14 @@ namespace ArchiSteamFarm {
}
}
internal void ResetGamesPlayed() {
if (GamesPlayedWhileIdle.Contains(0)) {
ArchiHandler.PlayGames(0);
} else {
ArchiHandler.PlayGames(GamesPlayedWhileIdle);
}
}
internal async Task Restart() {
Stop();
await Utilities.SleepAsync(500).ConfigureAwait(false);
@@ -710,7 +719,7 @@ namespace ArchiSteamFarm {
if (gameIDs.Contains(0)) {
if (await CardsFarmer.SwitchToManualMode(false).ConfigureAwait(false)) {
ArchiHandler.PlayGames(0);
ResetGamesPlayed();
}
} else {
await CardsFarmer.SwitchToManualMode(true).ConfigureAwait(false);
@@ -1173,6 +1182,8 @@ namespace ArchiSteamFarm {
await SteamFriends.SetPersonaName(SteamNickname);
}
ResetGamesPlayed();
if (SteamParentalPIN.Equals("null")) {
SteamParentalPIN = Program.GetUserInput(BotName, Program.EUserInputType.SteamParentalPIN);
}
@@ -1396,6 +1407,12 @@ namespace ArchiSteamFarm {
Blacklist.Add(uint.Parse(appID));
}
break;
case "GamesPlayedWhileIdle":
GamesPlayedWhileIdle.Clear();
foreach (string appID in value.Split(',')) {
GamesPlayedWhileIdle.Add(uint.Parse(appID));
}
break;
case "Statistics":
Statistics = bool.Parse(value);
break;

View File

@@ -426,7 +426,7 @@ namespace ArchiSteamFarm {
keepFarming = await ShouldFarm(appID).ConfigureAwait(false);
}
Bot.ArchiHandler.PlayGames(0);
Bot.ResetGamesPlayed();
Logging.LogGenericInfo("Stopped farming: " + appID, Bot.BotName);
return success;
}
@@ -459,7 +459,7 @@ namespace ArchiSteamFarm {
maxHour += timePlayed;
}
Bot.ArchiHandler.PlayGames(0);
Bot.ResetGamesPlayed();
Logging.LogGenericInfo("Stopped farming: " + string.Join(", ", appIDs), Bot.BotName);
return success;
}

View File

@@ -144,6 +144,12 @@
<!-- You probably don't want to change anything here -->
<Blacklist type="HashSet(uint)" value="303700,335590,368020,425280"/>
<!-- This is comma-separated list of IDs that should be played when ASF is idle -->
<!-- Idle ASF means that ASF is currently not doing anything - account has nothing to farm, it's only periodically checked for new cards available for dropping -->
<!-- If you want from ASF to be "playing" specific game(s) instead, you can specify them here. Remember that given account should already own specified appIDs -->
<!-- By default ASF is not playing any games when in idle state. You can change it below, remember to remove "0" appID from the collection -->
<GamesPlayedWhileIdle type="HashSet(uint)" value="0"/>
<!-- This switch enables statistics for me - bot will join Archi's SC Farm group and chat on steam -->
<!-- Consider leaving it at "true", this way I can check how many running bots are active -->
<!-- Such information directly affects my willings to work on the project, as I can see how many users are actually using it -->