Skip to content

Commit

Permalink
Merge pull request #34 from Lan2Play/feature/ReadyTag
Browse files Browse the repository at this point in the history
Add ReadyTag #31
  • Loading branch information
TheR00st3r authored Jan 7, 2025
2 parents af09d0a + 001af69 commit 350af39
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 21 deletions.
1 change: 1 addition & 0 deletions PugSharp.Match.Contract/IPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public interface IPlayer
string PlayerName { get; }

Team Team { get; }
string Clan { get; set; }

void PrintToChat(string message);

Expand Down
5 changes: 5 additions & 0 deletions PugSharp.Match/Match.cs
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ private void ReadyReminderTimer_Elapsed(object? sender, System.Timers.ElapsedEve
foreach (var player in notReadyPlayers)
{
player.PrintToChat(remindMessage);
player.Clan = _TextHelper.GetText(nameof(Resources.PugSharp_Match_NotReadyTag));
}
}
catch (Exception ex)
Expand Down Expand Up @@ -1034,6 +1035,7 @@ public bool TryAddPlayer(IPlayer player)
return false;
}

player.Clan = _TextHelper.GetText(nameof(Resources.PugSharp_Match_NotReadyTag));
if (MatchInfo.Config.TeamMode == Config.TeamMode.PlayerSelect)
{
// Quicker to just remove them and add them back, rather than check whether they are already in the match
Expand Down Expand Up @@ -1144,13 +1146,16 @@ public void TogglePlayerIsReady(IPlayer player)

if (matchPlayer.IsReady)
{
player.Clan = _TextHelper.GetText(nameof(Resources.PugSharp_Match_ReadyTag));
_CsServer.PrintToChatAll(_TextHelper.GetText(nameof(Resources.PugSharp_Match_Info_Ready), player.PlayerName, readyPlayers, requiredPlayers));
TryFireState(MatchCommand.PlayerReady);
}
else
{
player.Clan = _TextHelper.GetText(nameof(Resources.PugSharp_Match_NotReadyTag));
_CsServer.PrintToChatAll(_TextHelper.GetText(nameof(Resources.PugSharp_Match_Info_NotReady), player.PlayerName, readyPlayers, requiredPlayers));
}

}

public Team GetPlayerTeam(ulong steamID)
Expand Down
48 changes: 33 additions & 15 deletions PugSharp.Translation/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion PugSharp.Translation/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
Expand Down Expand Up @@ -297,6 +297,12 @@
<data name="PugSharp.Match.Info.WaitingForAllPlayers" xml:space="preserve">
<value>Waiting for all players to be ready.</value>
</data>
<data name="PugSharp.Match.NotReadyTag" xml:space="preserve">
<value>[Not Ready] </value>
</data>
<data name="PugSharp.Match.ReadyTag" xml:space="preserve">
<value>[Ready] </value>
</data>
<data name="PugSharp.Match.TeamReminder" xml:space="preserve">
<value>You are currently on Team: **{0:teamName}**.</value>
</data>
Expand Down
17 changes: 12 additions & 5 deletions PugSharp/Models/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Menu;

using CSSharpUtils.Extensions;

using PugSharp.Match.Contract;

namespace PugSharp.Models;
Expand Down Expand Up @@ -86,23 +88,28 @@ public int? Money
}
}

public string? Clan
public string Clan
{
get
{
if (TryGetPlayerController(out var playerController))
{
return playerController?.Clan;
return playerController?.ClanName ?? string.Empty;
}

return null;
return string.Empty;
}

set
{
if (TryGetPlayerController(out var playerController) && playerController?.InGameMoneyServices != null && value != null)
if (TryGetPlayerController(out var playerController)
&& value != null
&& !string.Equals(playerController!.Clan, value, StringComparison.Ordinal))
{
playerController.Clan = value;
playerController.SetClantag(value);

// Fire Event to synchronize all clients
new EventNextlevelChanged(force: false).FireEvent(false);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions PugSharp/PugSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CSSharpUtils" Version="1.0.5" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.10" />
<PackageReference Include="OneOf" Version="3.0.271" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
Expand Down

0 comments on commit 350af39

Please sign in to comment.