mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-04 16:10:08 +00:00
Add CustomGamePlayedWhileFarming
Also make it possible for CustomGamePlayedWhileIdle and GamesPlayedWhileIdle to coexist
This commit is contained in:
@@ -215,34 +215,15 @@ namespace ArchiSteamFarm {
|
||||
Client.Send(logon);
|
||||
}
|
||||
|
||||
internal void PlayGame(string gameName) {
|
||||
internal void PlayGame(uint gameID, string gameName = null) {
|
||||
if (!Client.IsConnected) {
|
||||
return;
|
||||
}
|
||||
|
||||
ClientMsgProtobuf<CMsgClientGamesPlayed> request = new ClientMsgProtobuf<CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);
|
||||
if (!string.IsNullOrEmpty(gameName)) {
|
||||
request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed {
|
||||
game_extra_info = gameName,
|
||||
game_id = new GameID {
|
||||
AppType = GameID.GameType.Shortcut,
|
||||
ModID = uint.MaxValue
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Client.Send(request);
|
||||
PlayGames(new List<uint> { gameID }, gameName);
|
||||
}
|
||||
|
||||
internal void PlayGames(uint gameID) {
|
||||
if (!Client.IsConnected) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayGames(new HashSet<uint> { gameID });
|
||||
}
|
||||
|
||||
internal void PlayGames(ICollection<uint> gameIDs) {
|
||||
internal void PlayGames(ICollection<uint> gameIDs, string gameName = null) {
|
||||
if (gameIDs == null) {
|
||||
Logging.LogNullError(nameof(gameIDs), Bot.BotName);
|
||||
return;
|
||||
@@ -253,6 +234,17 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
ClientMsgProtobuf<CMsgClientGamesPlayed> request = new ClientMsgProtobuf<CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);
|
||||
|
||||
if (!string.IsNullOrEmpty(gameName)) {
|
||||
request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed {
|
||||
game_extra_info = gameName,
|
||||
game_id = new GameID {
|
||||
AppType = GameID.GameType.Shortcut,
|
||||
ModID = uint.MaxValue
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
foreach (uint gameID in gameIDs.Where(gameID => gameID != 0)) {
|
||||
request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed {
|
||||
game_id = new GameID(gameID)
|
||||
|
||||
@@ -1473,11 +1473,7 @@ namespace ArchiSteamFarm {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(BotConfig.CustomGamePlayedWhileIdle)) {
|
||||
ArchiHandler.PlayGame(BotConfig.CustomGamePlayedWhileIdle);
|
||||
} else {
|
||||
ArchiHandler.PlayGames(BotConfig.GamesPlayedWhileIdle);
|
||||
}
|
||||
ArchiHandler.PlayGames(BotConfig.GamesPlayedWhileIdle, BotConfig.CustomGamePlayedWhileIdle);
|
||||
}
|
||||
|
||||
private async void OnConnected(SteamClient.ConnectedCallback callback) {
|
||||
|
||||
@@ -103,11 +103,14 @@ namespace ArchiSteamFarm {
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
internal byte AcceptConfirmationsPeriod { get; private set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
internal string CustomGamePlayedWhileFarming { get; private set; } = null;
|
||||
|
||||
[JsonProperty]
|
||||
internal string CustomGamePlayedWhileIdle { get; private set; } = null;
|
||||
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
internal HashSet<uint> GamesPlayedWhileIdle { get; private set; } = new HashSet<uint> { 0 };
|
||||
internal HashSet<uint> GamesPlayedWhileIdle { get; private set; } = new HashSet<uint>();
|
||||
|
||||
|
||||
internal static BotConfig Load(string filePath) {
|
||||
|
||||
@@ -480,7 +480,7 @@ namespace ArchiSteamFarm {
|
||||
return false;
|
||||
}
|
||||
|
||||
Bot.ArchiHandler.PlayGames(appID);
|
||||
Bot.ArchiHandler.PlayGame(appID, Bot.BotConfig.CustomGamePlayedWhileFarming);
|
||||
DateTime endFarmingDate = DateTime.Now.AddHours(Program.GlobalConfig.MaxFarmingTime);
|
||||
|
||||
bool success = true;
|
||||
@@ -515,7 +515,7 @@ namespace ArchiSteamFarm {
|
||||
return false;
|
||||
}
|
||||
|
||||
Bot.ArchiHandler.PlayGames(appIDs);
|
||||
Bot.ArchiHandler.PlayGames(appIDs, Bot.BotConfig.CustomGamePlayedWhileFarming);
|
||||
|
||||
bool success = true;
|
||||
while (maxHour < 2) {
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
"SteamTradeToken": null,
|
||||
"SendTradePeriod": 0,
|
||||
"AcceptConfirmationsPeriod": 0,
|
||||
"CustomGamePlayedWhileFarming": null,
|
||||
"CustomGamePlayedWhileIdle": null,
|
||||
"GamesPlayedWhileIdle": [
|
||||
0
|
||||
]
|
||||
"GamesPlayedWhileIdle": [ ]
|
||||
}
|
||||
@@ -111,6 +111,9 @@ namespace ConfigGenerator {
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
public byte AcceptConfirmationsPeriod { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public string CustomGamePlayedWhileFarming { get; set; } = null;
|
||||
|
||||
[JsonProperty]
|
||||
public string CustomGamePlayedWhileIdle { get; set; } = null;
|
||||
|
||||
@@ -153,7 +156,6 @@ namespace ConfigGenerator {
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
}
|
||||
|
||||
GamesPlayedWhileIdle.Add(0);
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user