implement team tracking via game interface (EFClient.Team and EFClient.TeamName)

This commit is contained in:
RaidMax
2022-03-12 13:38:33 -06:00
parent 1b6d8107ae
commit f567a03fa7
7 changed files with 82 additions and 4 deletions

View File

@ -18,6 +18,11 @@ namespace SharedLibraryCore.Interfaces
/// stores the regex information for a join event printed in the game log
/// </summary>
ParserRegex Join { get; set; }
/// <summary>
/// stores the regex information for a join team event printed in the game log
/// </summary>
ParserRegex JoinTeam { get; set; }
/// <summary>
/// stores the regex information for a quit event printed in the game log
@ -59,4 +64,4 @@ namespace SharedLibraryCore.Interfaces
/// </summary>
NumberStyles GuidNumberStyle { get; set; }
}
}
}

View File

@ -39,6 +39,14 @@ namespace SharedLibraryCore.Database.Models
Disconnecting
}
public enum TeamType
{
Unknown,
Spectator,
Allies,
Axis
}
[NotMapped] private readonly SemaphoreSlim _processingEvent;
public EFClient()
@ -101,6 +109,9 @@ namespace SharedLibraryCore.Database.Models
[NotMapped] public string GuidString => NetworkId.ToString("x");
[NotMapped] public ClientState State { get; set; }
[NotMapped] public TeamType Team { get; set; }
[NotMapped] public string TeamName { get; set; }
[NotMapped]
// this is kinda dirty, but I need localizable level names
@ -710,6 +721,17 @@ namespace SharedLibraryCore.Database.Models
return true;
}
public void UpdateTeam(string newTeam)
{
if (string.IsNullOrEmpty(newTeam))
{
return;
}
Team = Enum.TryParse(newTeam, true, out TeamType team) ? team : TeamType.Unknown;
TeamName = newTeam;
}
public async Task Lock()
{
var result = await _processingEvent.WaitAsync(Utilities.DefaultCommandTimeout);