Files
ArchiSteamFarm/ArchiSteamFarm/Statistics.cs

794 lines
32 KiB
C#
Raw Normal View History

2019-02-16 17:34:17 +01:00
// _ _ _ ____ _ _____
2017-11-18 17:27:06 +01:00
// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
2019-01-14 19:11:17 +01:00
// |
2019-01-02 16:32:53 +01:00
// Copyright 2015-2019 Łukasz "JustArchi" Domeradzki
2018-07-27 04:52:14 +02:00
// Contact: JustArchi@JustArchi.net
2019-01-14 19:11:17 +01:00
// |
2018-07-27 04:52:14 +02:00
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
2019-01-14 19:11:17 +01:00
// |
2018-07-27 04:52:14 +02:00
// http://www.apache.org/licenses/LICENSE-2.0
2019-01-14 19:11:17 +01:00
// |
2018-07-27 04:52:14 +02:00
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using System.Collections.Generic;
2018-12-14 16:07:46 +01:00
using System.Collections.Immutable;
2018-12-03 00:45:09 +01:00
using System.Diagnostics.CodeAnalysis;
2018-02-21 17:44:06 +01:00
using System.Linq;
2016-12-04 02:49:56 +01:00
using System.Threading;
using System.Threading.Tasks;
2017-12-14 08:23:17 +01:00
using ArchiSteamFarm.Json;
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
using ArchiSteamFarm.Localization;
2019-01-10 23:44:32 +01:00
using JetBrains.Annotations;
2017-07-10 23:04:33 +02:00
using Newtonsoft.Json;
namespace ArchiSteamFarm {
2016-12-04 02:49:56 +01:00
internal sealed class Statistics : IDisposable {
2018-11-29 18:56:28 +01:00
private const byte MaxMatchedBotsHard = 40;
2019-04-05 14:29:35 +02:00
private const byte MaxMatchedBotsSoft = 20;
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
private const byte MaxMatchingRounds = 10;
2017-03-20 17:21:56 +01:00
private const byte MinAnnouncementCheckTTL = 6; // Minimum amount of hours we must wait before checking eligibility for Announcement, should be lower than MinPersonaStateTTL
2017-02-08 14:55:40 +01:00
private const byte MinHeartBeatTTL = 10; // Minimum amount of minutes we must wait before sending next HeartBeat
2017-07-10 23:04:33 +02:00
private const byte MinItemsCount = 100; // Minimum amount of items to be eligible for public listing
2017-03-20 17:21:56 +01:00
private const byte MinPersonaStateTTL = 8; // Minimum amount of hours we must wait before requesting persona state update
2017-06-26 03:36:51 +02:00
private const string URL = "https://" + SharedInfo.StatisticsServer;
2018-12-14 16:07:46 +01:00
private static readonly ImmutableHashSet<Steam.Asset.EType> AcceptedMatchableTypes = ImmutableHashSet.Create(
2018-09-08 00:46:40 +02:00
Steam.Asset.EType.Emoticon,
Steam.Asset.EType.FoilTradingCard,
Steam.Asset.EType.ProfileBackground,
Steam.Asset.EType.TradingCard
2018-12-14 16:07:46 +01:00
);
2018-03-24 17:14:01 +01:00
2016-12-04 02:08:45 +01:00
private readonly Bot Bot;
private readonly SemaphoreSlim MatchActivelySemaphore = new SemaphoreSlim(1, 1);
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
private readonly Timer MatchActivelyTimer;
2017-08-04 19:26:37 +02:00
private readonly SemaphoreSlim RequestsSemaphore = new SemaphoreSlim(1, 1);
2017-07-13 06:08:52 +02:00
private DateTime LastAnnouncementCheck;
private DateTime LastHeartBeat;
private DateTime LastPersonaStateRequest;
private bool ShouldSendHeartBeats;
2016-12-04 02:08:45 +01:00
2019-01-10 23:44:32 +01:00
internal Statistics([NotNull] Bot bot) {
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
Bot = bot ?? throw new ArgumentNullException(nameof(bot));
2016-12-04 02:08:45 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
MatchActivelyTimer = new Timer(
async e => await MatchActively().ConfigureAwait(false),
null,
2019-03-03 16:22:25 +01:00
TimeSpan.FromHours(1) + TimeSpan.FromSeconds(ASF.LoadBalancingDelay * Bot.Bots.Count), // Delay
2018-12-03 00:59:01 +01:00
TimeSpan.FromHours(8) // Period
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
);
}
public void Dispose() {
MatchActivelySemaphore.Dispose();
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
MatchActivelyTimer.Dispose();
RequestsSemaphore.Dispose();
}
2016-12-04 02:49:56 +01:00
2016-12-04 02:08:45 +01:00
internal async Task OnHeartBeat() {
// Request persona update if needed
if ((DateTime.UtcNow > LastPersonaStateRequest.AddHours(MinPersonaStateTTL)) && (DateTime.UtcNow > LastAnnouncementCheck.AddHours(MinAnnouncementCheckTTL))) {
LastPersonaStateRequest = DateTime.UtcNow;
Bot.RequestPersonaStateUpdate();
}
if (!ShouldSendHeartBeats || (DateTime.UtcNow < LastHeartBeat.AddMinutes(MinHeartBeatTTL))) {
return;
}
2017-08-04 19:26:37 +02:00
await RequestsSemaphore.WaitAsync().ConfigureAwait(false);
2016-12-04 02:49:56 +01:00
try {
if (!ShouldSendHeartBeats || (DateTime.UtcNow < LastHeartBeat.AddMinutes(MinHeartBeatTTL))) {
2016-12-04 02:49:56 +01:00
return;
}
2018-02-21 17:47:17 +01:00
const string request = URL + "/Api/HeartBeat";
2018-12-15 00:27:15 +01:00
2019-04-02 20:43:17 +02:00
Dictionary<string, string> data = new Dictionary<string, string>(2, StringComparer.Ordinal) {
{ "Guid", ASF.GlobalDatabase.Guid.ToString("N") },
{ "SteamID", Bot.SteamID.ToString() }
2016-12-04 02:49:56 +01:00
};
WebBrowser.BasicResponse response = await Bot.ArchiWebHandler.WebBrowser.UrlPost(request, data, requestOptions: WebBrowser.ERequestOptions.ReturnClientErrors).ConfigureAwait(false);
if (response == null) {
return;
}
if (response.StatusCode.IsClientErrorCode()) {
LastHeartBeat = DateTime.MinValue;
ShouldSendHeartBeats = false;
2019-04-05 14:29:35 +02:00
return;
2016-12-04 02:49:56 +01:00
}
2019-04-05 14:29:35 +02:00
LastHeartBeat = DateTime.UtcNow;
2016-12-04 02:49:56 +01:00
} finally {
2017-08-04 19:26:37 +02:00
RequestsSemaphore.Release();
}
2016-12-04 02:08:45 +01:00
}
2019-05-19 15:38:06 +02:00
internal async Task OnLoggedOn() {
if (!await Bot.ArchiWebHandler.JoinGroup(SharedInfo.ASFGroupSteamID).ConfigureAwait(false)) {
Bot.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningFailedWithError, nameof(ArchiWebHandler.JoinGroup)));
}
}
2018-02-01 00:46:18 +01:00
internal async Task OnPersonaState(string nickname = null, string avatarHash = null) {
2019-04-05 15:12:54 +02:00
if ((DateTime.UtcNow < LastAnnouncementCheck.AddHours(MinAnnouncementCheckTTL)) && (ShouldSendHeartBeats || (LastHeartBeat == DateTime.MinValue))) {
return;
}
2017-08-04 19:26:37 +02:00
await RequestsSemaphore.WaitAsync().ConfigureAwait(false);
2016-12-04 02:49:56 +01:00
try {
2019-04-05 15:12:54 +02:00
if ((DateTime.UtcNow < LastAnnouncementCheck.AddHours(MinAnnouncementCheckTTL)) && (ShouldSendHeartBeats || (LastHeartBeat == DateTime.MinValue))) {
return;
}
2018-03-24 17:14:01 +01:00
// Don't announce if we don't meet conditions
2019-06-19 18:50:26 +02:00
bool? eligible = await IsEligibleForListing().ConfigureAwait(false);
2018-12-15 00:27:15 +01:00
2019-04-05 15:12:54 +02:00
if (!eligible.HasValue) {
// This is actually network failure, so we'll stop sending heartbeats but not record it as valid check
ShouldSendHeartBeats = false;
return;
}
if (!eligible.Value) {
2018-03-24 17:14:01 +01:00
LastAnnouncementCheck = DateTime.UtcNow;
ShouldSendHeartBeats = false;
2018-12-15 00:27:15 +01:00
2018-03-24 17:14:01 +01:00
return;
}
2019-04-05 15:12:54 +02:00
string tradeToken = await Bot.ArchiHandler.GetTradeToken().ConfigureAwait(false);
if (string.IsNullOrEmpty(tradeToken)) {
// This is actually network failure, so we'll stop sending heartbeats but not record it as valid check
ShouldSendHeartBeats = false;
return;
}
2018-06-09 00:45:15 +02:00
HashSet<Steam.Asset.EType> acceptedMatchableTypes = Bot.BotConfig.MatchableTypes.Where(type => AcceptedMatchableTypes.Contains(type)).ToHashSet();
2018-12-15 00:27:15 +01:00
2018-03-24 17:14:01 +01:00
if (acceptedMatchableTypes.Count == 0) {
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
Bot.ArchiLogger.LogNullError(nameof(acceptedMatchableTypes));
2018-03-24 17:14:01 +01:00
LastAnnouncementCheck = DateTime.UtcNow;
ShouldSendHeartBeats = false;
2018-12-15 00:27:15 +01:00
2018-03-24 17:14:01 +01:00
return;
}
2019-04-10 23:15:34 +02:00
HashSet<Steam.Asset> inventory = await Bot.ArchiWebHandler.GetInventory(tradable: true, wantedTypes: acceptedMatchableTypes).ConfigureAwait(false);
if (inventory == null) {
2019-04-05 15:12:54 +02:00
// This is actually inventory failure, so we'll stop sending heartbeats but not record it as valid check
ShouldSendHeartBeats = false;
2018-12-15 00:27:15 +01:00
2016-12-04 02:49:56 +01:00
return;
}
2018-12-20 17:40:51 +01:00
LastAnnouncementCheck = DateTime.UtcNow;
// This is actual inventory
2017-07-10 23:04:33 +02:00
if (inventory.Count < MinItemsCount) {
ShouldSendHeartBeats = false;
2018-12-15 00:27:15 +01:00
return;
}
2018-02-21 17:47:17 +01:00
const string request = URL + "/Api/Announce";
2018-12-15 00:27:15 +01:00
2019-04-02 20:43:17 +02:00
Dictionary<string, string> data = new Dictionary<string, string>(9, StringComparer.Ordinal) {
2018-02-01 00:46:18 +01:00
{ "AvatarHash", avatarHash ?? "" },
2018-03-24 17:14:01 +01:00
{ "GamesCount", inventory.Select(item => item.RealAppID).Distinct().Count().ToString() },
2019-04-02 20:43:17 +02:00
{ "Guid", ASF.GlobalDatabase.Guid.ToString("N") },
2018-02-21 17:44:06 +01:00
{ "ItemsCount", inventory.Count.ToString() },
2018-03-24 17:14:01 +01:00
{ "MatchableTypes", JsonConvert.SerializeObject(acceptedMatchableTypes) },
{ "MatchEverything", Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.MatchEverything) ? "1" : "0" },
2019-04-02 20:43:17 +02:00
{ "Nickname", nickname ?? "" },
{ "SteamID", Bot.SteamID.ToString() },
2018-03-24 17:14:01 +01:00
{ "TradeToken", tradeToken }
2016-12-04 02:49:56 +01:00
};
WebBrowser.BasicResponse response = await Bot.ArchiWebHandler.WebBrowser.UrlPost(request, data, requestOptions: WebBrowser.ERequestOptions.ReturnClientErrors).ConfigureAwait(false);
if (response == null) {
return;
}
if (response.StatusCode.IsClientErrorCode()) {
LastHeartBeat = DateTime.MinValue;
ShouldSendHeartBeats = false;
2019-04-05 16:25:44 +02:00
return;
}
2019-04-05 14:29:35 +02:00
LastHeartBeat = DateTime.UtcNow;
ShouldSendHeartBeats = true;
2016-12-04 02:49:56 +01:00
} finally {
2017-08-04 19:26:37 +02:00
RequestsSemaphore.Release();
2016-12-04 02:49:56 +01:00
}
}
2018-03-24 17:14:01 +01:00
2019-01-10 23:44:32 +01:00
[ItemCanBeNull]
2019-02-02 22:54:23 +01:00
private async Task<ImmutableHashSet<ListedUser>> GetListedUsers() {
const string request = URL + "/Api/Bots";
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
2019-02-02 22:54:23 +01:00
WebBrowser.ObjectResponse<ImmutableHashSet<ListedUser>> objectResponse = await Bot.ArchiWebHandler.WebBrowser.UrlGetToJsonObject<ImmutableHashSet<ListedUser>>(request).ConfigureAwait(false);
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
return objectResponse?.Content;
}
2019-06-19 18:50:26 +02:00
private async Task<bool?> IsEligibleForListing() {
bool? isEligibleForMatching = await IsEligibleForMatching().ConfigureAwait(false);
if (isEligibleForMatching != true) {
return isEligibleForMatching;
}
// Bot must have public inventory
bool? hasPublicInventory = await Bot.ArchiWebHandler.HasPublicInventory().ConfigureAwait(false);
if (hasPublicInventory != true) {
Bot.ArchiLogger.LogGenericTrace(string.Format(Strings.WarningFailedWithError, nameof(Bot.ArchiWebHandler.HasPublicInventory) + ": " + (hasPublicInventory?.ToString() ?? "null")));
return hasPublicInventory;
}
return true;
}
2019-04-05 15:12:54 +02:00
private async Task<bool?> IsEligibleForMatching() {
2018-03-24 17:14:01 +01:00
// Bot must have ASF 2FA
if (!Bot.HasMobileAuthenticator) {
2018-12-08 01:45:13 +01:00
Bot.ArchiLogger.LogGenericTrace(string.Format(Strings.WarningFailedWithError, nameof(Bot.HasMobileAuthenticator) + ": " + Bot.HasMobileAuthenticator));
2018-12-15 00:27:15 +01:00
2018-03-24 17:14:01 +01:00
return false;
}
// Bot must have STM enable in TradingPreferences
if (!Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.SteamTradeMatcher)) {
2018-12-08 01:45:13 +01:00
Bot.ArchiLogger.LogGenericTrace(string.Format(Strings.WarningFailedWithError, nameof(Bot.BotConfig.TradingPreferences) + ": " + Bot.BotConfig.TradingPreferences));
2018-12-15 00:27:15 +01:00
2018-03-24 17:14:01 +01:00
return false;
}
// Bot must have at least one accepted matchable type set
if ((Bot.BotConfig.MatchableTypes.Count == 0) || Bot.BotConfig.MatchableTypes.All(type => !AcceptedMatchableTypes.Contains(type))) {
2018-12-08 01:45:13 +01:00
Bot.ArchiLogger.LogGenericTrace(string.Format(Strings.WarningFailedWithError, nameof(Bot.BotConfig.MatchableTypes) + ": " + Bot.BotConfig.MatchableTypes));
2018-12-15 00:27:15 +01:00
2018-03-24 17:14:01 +01:00
return false;
}
// Bot must have valid API key (e.g. not being restricted account)
2019-04-05 15:12:54 +02:00
bool? hasValidApiKey = await Bot.ArchiWebHandler.HasValidApiKey().ConfigureAwait(false);
2018-12-15 00:27:15 +01:00
2019-06-19 18:50:26 +02:00
if (hasValidApiKey != true) {
2019-04-06 11:05:51 +02:00
Bot.ArchiLogger.LogGenericTrace(string.Format(Strings.WarningFailedWithError, nameof(Bot.ArchiWebHandler.HasValidApiKey) + ": " + (hasValidApiKey?.ToString() ?? "null")));
2019-04-05 15:12:54 +02:00
return hasValidApiKey;
2018-12-08 01:45:13 +01:00
}
return true;
2018-03-24 17:14:01 +01:00
}
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
private async Task MatchActively() {
2019-04-05 15:12:54 +02:00
if (!Bot.IsConnectedAndLoggedOn || Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.MatchEverything) || !Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.MatchActively) || (await IsEligibleForMatching().ConfigureAwait(false) != true)) {
Bot.ArchiLogger.LogGenericTrace(Strings.ErrorAborted);
2018-12-15 00:27:15 +01:00
return;
}
2019-06-19 18:52:30 +02:00
HashSet<Steam.Asset.EType> acceptedMatchableTypes = Bot.BotConfig.MatchableTypes.Where(AcceptedMatchableTypes.Contains).ToHashSet();
2018-12-15 00:27:15 +01:00
if (acceptedMatchableTypes.Count == 0) {
Bot.ArchiLogger.LogGenericTrace(Strings.ErrorAborted);
2018-12-15 00:27:15 +01:00
return;
}
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
if (!await MatchActivelySemaphore.WaitAsync(0).ConfigureAwait(false)) {
Bot.ArchiLogger.LogGenericTrace(Strings.ErrorAborted);
2018-12-15 00:27:15 +01:00
return;
}
try {
Bot.ArchiLogger.LogGenericTrace(Strings.Starting);
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
Dictionary<ulong, (byte Tries, ISet<ulong> GivenAssetIDs, ISet<ulong> ReceivedAssetIDs)> triedSteamIDs = new Dictionary<ulong, (byte Tries, ISet<ulong> GivenAssetIDs, ISet<ulong> ReceivedAssetIDs)>();
bool match = true;
for (byte i = 0; (i < MaxMatchingRounds) && match; i++) {
if (i > 0) {
// After each round we wait at least 5 minutes for all bots to react
await Task.Delay(5 * 60 * 1000).ConfigureAwait(false);
}
2019-04-05 15:12:54 +02:00
if (!Bot.IsConnectedAndLoggedOn || Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.MatchEverything) || !Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.MatchActively) || (await IsEligibleForMatching().ConfigureAwait(false) != true)) {
2018-12-03 05:21:12 +01:00
Bot.ArchiLogger.LogGenericTrace(Strings.ErrorAborted);
2018-12-15 00:27:15 +01:00
2018-12-03 05:21:12 +01:00
break;
}
using (await Bot.Actions.GetTradingLock().ConfigureAwait(false)) {
Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.ActivelyMatchingItems, i));
match = await MatchActivelyRound(acceptedMatchableTypes, triedSteamIDs).ConfigureAwait(false);
Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.DoneActivelyMatchingItems, i));
}
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
}
Bot.ArchiLogger.LogGenericTrace(Strings.Done);
} finally {
MatchActivelySemaphore.Release();
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
}
}
2018-12-03 00:45:09 +01:00
[SuppressMessage("ReSharper", "FunctionComplexityOverflow")]
private async Task<bool> MatchActivelyRound(IReadOnlyCollection<Steam.Asset.EType> acceptedMatchableTypes, IDictionary<ulong, (byte Tries, ISet<ulong> GivenAssetIDs, ISet<ulong> ReceivedAssetIDs)> triedSteamIDs) {
if ((acceptedMatchableTypes == null) || (acceptedMatchableTypes.Count == 0) || (triedSteamIDs == null)) {
Bot.ArchiLogger.LogNullError(nameof(acceptedMatchableTypes) + " || " + nameof(triedSteamIDs));
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
return false;
}
2019-04-10 23:15:34 +02:00
HashSet<Steam.Asset> ourInventory = await Bot.ArchiWebHandler.GetInventory(wantedTypes: acceptedMatchableTypes).ConfigureAwait(false);
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
if ((ourInventory == null) || (ourInventory.Count == 0)) {
2018-12-02 06:28:03 +01:00
Bot.ArchiLogger.LogGenericTrace(string.Format(Strings.ErrorIsEmpty, nameof(ourInventory)));
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
return false;
}
(Dictionary<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity), Dictionary<ulong, uint>> ourFullState, Dictionary<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity), Dictionary<ulong, uint>> ourTradableState) = Trading.GetDividedInventoryState(ourInventory);
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
if (Trading.IsEmptyForMatching(ourFullState, ourTradableState)) {
2018-11-29 19:21:41 +01:00
// User doesn't have any more dupes in the inventory
Bot.ArchiLogger.LogGenericTrace(string.Format(Strings.ErrorIsEmpty, nameof(ourFullState) + " || " + nameof(ourTradableState)));
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
return false;
}
2019-02-02 22:54:23 +01:00
ImmutableHashSet<ListedUser> listedUsers = await GetListedUsers().ConfigureAwait(false);
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
if ((listedUsers == null) || (listedUsers.Count == 0)) {
2018-12-02 06:28:03 +01:00
Bot.ArchiLogger.LogGenericTrace(string.Format(Strings.ErrorIsEmpty, nameof(listedUsers)));
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
return false;
}
byte emptyMatches = 0;
2019-02-02 22:54:23 +01:00
HashSet<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity)> skippedSetsThisRound = new HashSet<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity)>();
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
foreach (ListedUser listedUser in listedUsers.Where(listedUser => acceptedMatchableTypes.Any(listedUser.MatchableTypes.Contains) && (!triedSteamIDs.TryGetValue(listedUser.SteamID, out (byte Tries, ISet<ulong> GivenAssetIDs, ISet<ulong> ReceivedAssetIDs) attempt) || (attempt.Tries < byte.MaxValue)) && !Bot.IsBlacklistedFromTrades(listedUser.SteamID)).OrderBy(listedUser => triedSteamIDs.TryGetValue(listedUser.SteamID, out (byte Tries, ISet<ulong> GivenAssetIDs, ISet<ulong> ReceivedAssetIDs) attempt) ? attempt.Tries : 0).ThenByDescending(listedUser => listedUser.MatchEverything).ThenByDescending(listedUser => listedUser.Score).Take(MaxMatchedBotsHard)) {
HashSet<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity)> wantedSets = ourTradableState.Keys.Where(set => !skippedSetsThisRound.Contains(set) && listedUser.MatchableTypes.Contains(set.Type)).ToHashSet();
2019-02-04 03:09:20 +01:00
if (wantedSets.Count == 0) {
continue;
}
Bot.ArchiLogger.LogGenericTrace(listedUser.SteamID + "...");
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
HashSet<Steam.Asset> theirInventory = await Bot.ArchiWebHandler.GetInventory(listedUser.SteamID, tradable: listedUser.MatchEverything ? true : (bool?) null, wantedSets: wantedSets).ConfigureAwait(false);
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
if ((theirInventory == null) || (theirInventory.Count == 0)) {
2018-12-02 06:28:03 +01:00
Bot.ArchiLogger.LogGenericTrace(string.Format(Strings.ErrorIsEmpty, nameof(theirInventory)));
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
continue;
}
2019-02-02 22:54:23 +01:00
HashSet<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity)> skippedSetsThisUser = new HashSet<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity)>();
Dictionary<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity), Dictionary<ulong, uint>> theirTradableState = Trading.GetTradableInventoryState(theirInventory);
2019-02-02 22:54:23 +01:00
Dictionary<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity), Dictionary<ulong, uint>> inventoryStateChanges = new Dictionary<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity), Dictionary<ulong, uint>>();
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
for (byte i = 0; i < Trading.MaxTradesPerAccount; i++) {
byte itemsInTrade = 0;
2019-02-02 22:54:23 +01:00
HashSet<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity)> skippedSetsThisTrade = new HashSet<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity)>();
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
Dictionary<ulong, uint> classIDsToGive = new Dictionary<ulong, uint>();
Dictionary<ulong, uint> classIDsToReceive = new Dictionary<ulong, uint>();
Dictionary<ulong, uint> fairClassIDsToGive = new Dictionary<ulong, uint>();
Dictionary<ulong, uint> fairClassIDsToReceive = new Dictionary<ulong, uint>();
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
foreach (((uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity) set, Dictionary<ulong, uint> ourFullItems) in ourFullState.Where(set => !skippedSetsThisUser.Contains(set.Key) && listedUser.MatchableTypes.Contains(set.Key.Type) && set.Value.Values.Any(count => count > 1))) {
if (!ourTradableState.TryGetValue(set, out Dictionary<ulong, uint> ourTradableItems) || (ourTradableItems.Count == 0)) {
continue;
}
if (!theirTradableState.TryGetValue(set, out Dictionary<ulong, uint> theirTradableItems) || (theirTradableItems.Count == 0)) {
continue;
}
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
2018-12-09 21:26:22 +01:00
// Those 2 collections are on user-basis since we can't be sure that the trade passes through (and therefore we need to keep original state in case of failure)
Dictionary<ulong, uint> ourFullSet = new Dictionary<ulong, uint>(ourFullItems);
2018-12-09 21:26:22 +01:00
Dictionary<ulong, uint> ourTradableSet = new Dictionary<ulong, uint>(ourTradableItems);
// We also have to take into account changes that happened in previous trades with this user, so this block will adapt to that
if (inventoryStateChanges.TryGetValue(set, out Dictionary<ulong, uint> pastChanges) && (pastChanges.Count > 0)) {
foreach ((ulong classID, uint amount) in pastChanges) {
if (!ourFullSet.TryGetValue(classID, out uint fullAmount) || (fullAmount == 0) || (fullAmount < amount)) {
2018-12-09 21:26:22 +01:00
Bot.ArchiLogger.LogNullError(nameof(fullAmount));
2018-12-15 00:27:15 +01:00
2018-12-09 21:26:22 +01:00
return false;
}
if (fullAmount > amount) {
ourFullSet[classID] = fullAmount - amount;
2018-12-09 21:26:22 +01:00
} else {
ourFullSet.Remove(classID);
2018-12-09 21:26:22 +01:00
}
if (!ourTradableSet.TryGetValue(classID, out uint tradableAmount) || (tradableAmount == 0) || (tradableAmount < amount)) {
2018-12-09 21:26:22 +01:00
Bot.ArchiLogger.LogNullError(nameof(tradableAmount));
2018-12-15 00:27:15 +01:00
2018-12-09 21:26:22 +01:00
return false;
}
if (fullAmount > amount) {
ourTradableSet[classID] = fullAmount - amount;
2018-12-09 21:26:22 +01:00
} else {
ourTradableSet.Remove(classID);
2018-12-09 21:26:22 +01:00
}
}
if (Trading.IsEmptyForMatching(ourFullSet, ourTradableSet)) {
continue;
}
}
bool match;
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
do {
match = false;
foreach ((ulong ourItem, uint ourFullAmount) in ourFullSet.Where(item => item.Value > 1).OrderByDescending(item => item.Value)) {
if (!ourTradableSet.TryGetValue(ourItem, out uint ourTradableAmount) || (ourTradableAmount == 0)) {
continue;
}
foreach ((ulong theirItem, uint theirTradableAmount) in theirTradableItems.OrderBy(item => ourFullSet.TryGetValue(item.Key, out uint ourAmountOfTheirItem) ? ourAmountOfTheirItem : 0)) {
if (ourFullSet.TryGetValue(theirItem, out uint ourAmountOfTheirItem) && (ourFullAmount <= ourAmountOfTheirItem + 1)) {
continue;
}
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
if (!listedUser.MatchEverything) {
// We have a potential match, let's check fairness for them
fairClassIDsToGive.TryGetValue(ourItem, out uint fairGivenAmount);
fairClassIDsToReceive.TryGetValue(theirItem, out uint fairReceivedAmount);
fairClassIDsToGive[ourItem] = ++fairGivenAmount;
fairClassIDsToReceive[theirItem] = ++fairReceivedAmount;
2019-08-26 00:30:00 +02:00
// Filter their inventory for the sets we're trading or have traded with this user
2019-08-26 00:30:00 +02:00
HashSet<Steam.Asset> fairFiltered = theirInventory.Where(item => ((item.RealAppID == set.RealAppID) && (item.Type == set.Type) && (item.Rarity == set.Rarity)) || skippedSetsThisTrade.Any(skippedSets => (skippedSets.RealAppID == item.RealAppID) && (skippedSets.Type == item.Type) && (skippedSets.Rarity == item.Rarity))).Select(item => item.CreateShallowCopy()).ToHashSet();
// Copy list to HashSet<Steam.Asset>
2019-08-26 00:30:00 +02:00
HashSet<Steam.Asset> fairItemsToGive = Trading.GetTradableItemsFromInventory(ourInventory.Where(item => ((item.RealAppID == set.RealAppID) && (item.Type == set.Type) && (item.Rarity == set.Rarity)) || skippedSetsThisTrade.Any(skippedSets => (skippedSets.RealAppID == item.RealAppID) && (skippedSets.Type == item.Type) && (skippedSets.Rarity == item.Rarity))).Select(item => item.CreateShallowCopy()).ToHashSet(), fairClassIDsToGive.ToDictionary(classID => classID.Key, classID => classID.Value));
HashSet<Steam.Asset> fairItemsToReceive = Trading.GetTradableItemsFromInventory(fairFiltered.Select(item => item.CreateShallowCopy()).ToHashSet(), fairClassIDsToReceive.ToDictionary(classID => classID.Key, classID => classID.Value));
// Actual check:
if (!Trading.IsTradeNeutralOrBetter(fairFiltered, fairItemsToReceive, fairItemsToGive)) {
if (fairGivenAmount > 1) {
fairClassIDsToGive[ourItem] = fairGivenAmount - 1;
} else {
fairClassIDsToGive.Remove(ourItem);
}
if (fairReceivedAmount > 1) {
fairClassIDsToReceive[theirItem] = fairReceivedAmount - 1;
} else {
fairClassIDsToReceive.Remove(theirItem);
}
continue;
}
}
// Skip this set from the remaining of this round
skippedSetsThisTrade.Add(set);
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
// Update our state based on given items
classIDsToGive[ourItem] = classIDsToGive.TryGetValue(ourItem, out uint ourGivenAmount) ? ourGivenAmount + 1 : 1;
ourFullSet[ourItem] = ourFullAmount - 1; // We don't need to remove anything here because we can guarantee that ourItem.Value is at least 2
2018-12-09 21:26:22 +01:00
if (inventoryStateChanges.TryGetValue(set, out Dictionary<ulong, uint> currentChanges)) {
2019-02-16 17:34:17 +01:00
currentChanges[ourItem] = currentChanges.TryGetValue(ourItem, out uint amount) ? amount + 1 : 1;
2018-12-09 21:26:22 +01:00
} else {
inventoryStateChanges[set] = new Dictionary<ulong, uint> {
{ ourItem, 1 }
2018-12-09 21:26:22 +01:00
};
}
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
// Update our state based on received items
classIDsToReceive[theirItem] = classIDsToReceive.TryGetValue(theirItem, out uint ourReceivedAmount) ? ourReceivedAmount + 1 : 1;
ourFullSet[theirItem] = ourAmountOfTheirItem + 1;
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
if (ourTradableAmount > 1) {
ourTradableSet[ourItem] = ourTradableAmount - 1;
} else {
ourTradableSet.Remove(ourItem);
}
2018-12-09 21:26:22 +01:00
// Update their state based on taken items
if (theirTradableAmount > 1) {
theirTradableItems[theirItem] = theirTradableAmount - 1;
2018-12-09 21:26:22 +01:00
} else {
theirTradableItems.Remove(theirItem);
2018-12-09 21:26:22 +01:00
}
itemsInTrade += 2;
match = true;
2018-12-15 00:27:15 +01:00
break;
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
}
if (match) {
break;
}
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
}
} while (match && (itemsInTrade < Trading.MaxItemsPerTrade - 1));
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
if (itemsInTrade >= Trading.MaxItemsPerTrade - 1) {
break;
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
}
}
if (skippedSetsThisTrade.Count == 0) {
Bot.ArchiLogger.LogGenericTrace(string.Format(Strings.ErrorIsEmpty, nameof(skippedSetsThisTrade)));
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
break;
}
// Remove the items from inventories
HashSet<Steam.Asset> itemsToGive = Trading.GetTradableItemsFromInventory(ourInventory, classIDsToGive);
HashSet<Steam.Asset> itemsToReceive = Trading.GetTradableItemsFromInventory(theirInventory, classIDsToReceive);
2019-02-02 22:54:23 +01:00
if ((itemsToGive.Count != itemsToReceive.Count) || !Trading.IsFairExchange(itemsToGive, itemsToReceive)) {
// Failsafe
Bot.ArchiLogger.LogGenericError(string.Format(Strings.WarningFailedWithError, Strings.ErrorAborted));
2018-12-15 00:27:15 +01:00
return false;
}
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
if (triedSteamIDs.TryGetValue(listedUser.SteamID, out (byte Tries, ISet<ulong> GivenAssetIDs, ISet<ulong> ReceivedAssetIDs) previousAttempt)) {
if (itemsToGive.Select(item => item.AssetID).All(previousAttempt.GivenAssetIDs.Contains) && itemsToReceive.Select(item => item.AssetID).All(previousAttempt.ReceivedAssetIDs.Contains)) {
// This user didn't respond in our previous round, avoid him for remaining ones
triedSteamIDs[listedUser.SteamID] = (byte.MaxValue, previousAttempt.GivenAssetIDs, previousAttempt.ReceivedAssetIDs);
2018-12-15 00:27:15 +01:00
break;
}
previousAttempt.GivenAssetIDs.UnionWith(itemsToGive.Select(item => item.AssetID));
previousAttempt.ReceivedAssetIDs.UnionWith(itemsToReceive.Select(item => item.AssetID));
} else {
previousAttempt.GivenAssetIDs = new HashSet<ulong>(itemsToGive.Select(item => item.AssetID));
previousAttempt.ReceivedAssetIDs = new HashSet<ulong>(itemsToReceive.Select(item => item.AssetID));
}
triedSteamIDs[listedUser.SteamID] = (++previousAttempt.Tries, previousAttempt.GivenAssetIDs, previousAttempt.ReceivedAssetIDs);
emptyMatches = 0;
Bot.ArchiLogger.LogGenericTrace(Bot.SteamID + " <- " + string.Join(", ", itemsToReceive.Select(item => item.RealAppID + "/" + item.Type + "-" + item.ClassID + " #" + item.Amount)) + " | " + string.Join(", ", itemsToGive.Select(item => item.RealAppID + "/" + item.Type + "-" + item.ClassID + " #" + item.Amount)) + " -> " + listedUser.SteamID);
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
(bool success, HashSet<ulong> mobileTradeOfferIDs) = await Bot.ArchiWebHandler.SendTradeOffer(listedUser.SteamID, itemsToGive, itemsToReceive, listedUser.TradeToken, true).ConfigureAwait(false);
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
if ((mobileTradeOfferIDs != null) && (mobileTradeOfferIDs.Count > 0) && Bot.HasMobileAuthenticator) {
2019-01-23 17:58:37 +01:00
(bool twoFactorSuccess, _) = await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, Steam.ConfirmationDetails.EType.Trade, mobileTradeOfferIDs, true).ConfigureAwait(false);
if (!twoFactorSuccess) {
Bot.ArchiLogger.LogGenericTrace(Strings.WarningFailed);
2018-12-15 00:27:15 +01:00
return false;
}
}
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
if (!success) {
Bot.ArchiLogger.LogGenericTrace(Strings.WarningFailed);
2018-12-15 00:27:15 +01:00
break;
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
}
// Add itemsToGive to theirInventory to reflect their current state if we're over MaxItemsPerTrade
theirInventory.UnionWith(itemsToGive);
skippedSetsThisUser.UnionWith(skippedSetsThisTrade);
Bot.ArchiLogger.LogGenericTrace(Strings.Success);
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
}
if (skippedSetsThisUser.Count == 0) {
if (skippedSetsThisRound.Count == 0) {
// If we didn't find any match on clean round, this user isn't going to have anything interesting for us anytime soon
triedSteamIDs[listedUser.SteamID] = (byte.MaxValue, null, null);
}
2019-04-05 14:29:35 +02:00
if (++emptyMatches >= MaxMatchedBotsSoft) {
2018-12-05 22:16:38 +01:00
break;
}
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
continue;
}
skippedSetsThisRound.UnionWith(skippedSetsThisUser);
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
2019-02-02 22:54:23 +01:00
foreach ((uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity) skippedSet in skippedSetsThisUser) {
ourFullState.Remove(skippedSet);
ourTradableState.Remove(skippedSet);
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
}
if (Trading.IsEmptyForMatching(ourFullState, ourTradableState)) {
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
// User doesn't have any more dupes in the inventory
2018-11-29 19:21:41 +01:00
break;
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
}
ourFullState.TrimExcess();
ourTradableState.TrimExcess();
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
}
Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.ActivelyMatchingItemsRound, skippedSetsThisRound.Count));
2018-12-15 00:27:15 +01:00
return skippedSetsThisRound.Count > 0;
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
}
2019-04-04 17:56:38 +02:00
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
private sealed class ListedUser {
internal readonly HashSet<Steam.Asset.EType> MatchableTypes = new HashSet<Steam.Asset.EType>();
2018-11-29 18:47:53 +01:00
#pragma warning disable 649
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
[JsonProperty(PropertyName = "steam_id", Required = Required.Always)]
internal readonly ulong SteamID;
2018-11-29 18:47:53 +01:00
#pragma warning restore 649
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
2018-11-29 18:47:53 +01:00
#pragma warning disable 649
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
[JsonProperty(PropertyName = "trade_token", Required = Required.Always)]
internal readonly string TradeToken;
2018-11-29 18:47:53 +01:00
#pragma warning restore 649
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
internal float Score => GamesCount / (float) ItemsCount;
#pragma warning disable 649
[JsonProperty(PropertyName = "games_count", Required = Required.Always)]
private readonly ushort GamesCount;
#pragma warning restore 649
#pragma warning disable 649
[JsonProperty(PropertyName = "items_count", Required = Required.Always)]
private readonly ushort ItemsCount;
#pragma warning restore 649
internal bool MatchEverything { get; private set; }
2019-06-29 15:59:38 +02:00
#pragma warning disable IDE0051
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
[JsonProperty(PropertyName = "matchable_backgrounds", Required = Required.Always)]
private byte MatchableBackgroundsNumber {
set {
switch (value) {
case 0:
MatchableTypes.Remove(Steam.Asset.EType.ProfileBackground);
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
break;
case 1:
MatchableTypes.Add(Steam.Asset.EType.ProfileBackground);
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
break;
default:
ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(value), value));
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
return;
}
}
}
2019-06-29 15:59:38 +02:00
#pragma warning restore IDE0051
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
2019-06-29 15:59:38 +02:00
#pragma warning disable IDE0051
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
[JsonProperty(PropertyName = "matchable_cards", Required = Required.Always)]
private byte MatchableCardsNumber {
set {
switch (value) {
case 0:
MatchableTypes.Remove(Steam.Asset.EType.TradingCard);
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
break;
case 1:
MatchableTypes.Add(Steam.Asset.EType.TradingCard);
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
break;
default:
ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(value), value));
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
return;
}
}
}
2019-06-29 15:59:38 +02:00
#pragma warning restore IDE0051
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
2019-06-29 15:59:38 +02:00
#pragma warning disable IDE0051
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
[JsonProperty(PropertyName = "matchable_emoticons", Required = Required.Always)]
private byte MatchableEmoticonsNumber {
set {
switch (value) {
case 0:
MatchableTypes.Remove(Steam.Asset.EType.Emoticon);
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
break;
case 1:
MatchableTypes.Add(Steam.Asset.EType.Emoticon);
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
break;
default:
ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(value), value));
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
return;
}
}
}
2019-06-29 15:59:38 +02:00
#pragma warning restore IDE0051
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
2019-06-29 15:59:38 +02:00
#pragma warning disable IDE0051
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
[JsonProperty(PropertyName = "matchable_foil_cards", Required = Required.Always)]
private byte MatchableFoilCardsNumber {
set {
switch (value) {
case 0:
MatchableTypes.Remove(Steam.Asset.EType.FoilTradingCard);
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
break;
case 1:
MatchableTypes.Add(Steam.Asset.EType.FoilTradingCard);
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
break;
default:
ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(value), value));
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
return;
}
}
}
2019-06-29 15:59:38 +02:00
#pragma warning restore IDE0051
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
2019-06-29 15:59:38 +02:00
#pragma warning disable IDE0051
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
[JsonProperty(PropertyName = "match_everything", Required = Required.Always)]
private byte MatchEverythingNumber {
set {
switch (value) {
case 0:
MatchEverything = false;
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
break;
case 1:
MatchEverything = true;
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
break;
default:
ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(value), value));
2018-12-15 00:27:15 +01:00
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
return;
}
}
}
2019-06-29 15:59:38 +02:00
#pragma warning restore IDE0051
2019-04-04 17:56:38 +02:00
[JsonConstructor]
private ListedUser() { }
Implement ETradingPreferences.MatchActively This will probably need a lot more tests, tweaking and bugfixing, but basic logic is: - MatchActively added to TradingPreferences with value of 16 - User must also use SteamTradeMatcher, can't use MatchEverything - User must have statistics enabled and be eligible for being listed (no requirement of having 100 items minimum) Once all requirements are passed, statistics module will communicate with the listing and fetch match everything bots: - The matching will start in 1h since ASF start and will repeat every day (right now it starts in 1 minute to aid debugging). - Each matching is composed of up to 10 rounds maximum. - In each round ASF will fetch our inventory and inventory of listed bots in order to find MatchableTypes items to be matched. If match is found, offer is being sent and confirmed automatically. - Each set (composition of item type + appID it's from) can be matched in a single round only once, this is to minimize "items no longer available" as much as possible and also avoid a need to wait for each bot to react before sending all trades. - Round ends when we try to match a total of 20 bots, or we hit no items to match in consecutive 10 tries with 10 different bots. - If last round resulted in at least a single trade being sent, next round starts within 5 minutes since last one, otherwise matching ends and repeats the next day. We'll see how it works in practice, expect a lot of follow-up commits, unless I won't have anything to fix or improve.
2018-11-29 18:35:58 +01:00
}
}
2018-09-08 00:46:40 +02:00
}