Skip to content

Commit

Permalink
StartTeam
Browse files Browse the repository at this point in the history
  • Loading branch information
TheR00st3r committed Nov 2, 2023
1 parent ab934d7 commit 27ef48b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
17 changes: 5 additions & 12 deletions PugSharp.Match/Match.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,21 +268,13 @@ private void SetSelectedTeamSite()

if (_CurrentMatchTeamToVote!.Team == Team.Terrorist)
{
_MatchInfo.StartTeam1 = _TeamVotes.MaxBy(m => m.Votes.Count)!.Name;
_MatchInfo.StartTeam1 = _TeamVotes.MaxBy(m => m.Votes.Count)!.Name.Equals("T") ? Team.Terrorist : Team.CounterTerrorist;
_Logger.LogInformation("StartTeam is {team}", _MatchInfo.StartTeam1);
if (_MatchInfo.StartTeam1.Equals("CT", StringComparison.OrdinalIgnoreCase))
{
_MatchCallback.SwapTeams();
}
}
else
{
_MatchInfo.StartTeam1 = _TeamVotes.MinBy(m => m.Votes.Count)!.Name;
_MatchInfo.StartTeam1 = _TeamVotes.MinBy(m => m.Votes.Count)!.Name.Equals("T") ? Team.Terrorist : Team.CounterTerrorist;
_Logger.LogInformation("StartTeam is {team}", _MatchInfo.StartTeam1);
if (_MatchInfo.StartTeam1.Equals("T", StringComparison.OrdinalIgnoreCase))
{
_MatchCallback.SwapTeams();
}
}

_MatchCallback.SendMessage($"{_CurrentMatchTeamToVote!.Team} selected {_MatchInfo.StartTeam1} as startside!");
Expand Down Expand Up @@ -438,6 +430,7 @@ public void SetPlayerDisconnected(IPlayer player)
return;
}

// TODO Error when Player was not ready
var matchPlayer = GetMatchPlayer(player.SteamID);
TryFireState(MatchCommand.DisconnectPlayer);

Expand Down Expand Up @@ -492,11 +485,11 @@ public Team GetPlayerTeam(ulong steamID)
{
if (Config.Team1.Players.ContainsKey(steamID))
{
return Team.Terrorist;
return _MatchInfo.StartTeam1 ?? Team.Terrorist;
}
else if (Config.Team2.Players.ContainsKey(steamID))
{
return Team.CounterTerrorist;
return _MatchInfo.StartTeam1 == Team.CounterTerrorist ? Team.Terrorist : Team.CounterTerrorist;
}

return Team.None;
Expand Down
6 changes: 4 additions & 2 deletions PugSharp.Match/MatchInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
namespace PugSharp.Match;
using PugSharp.Match.Contract;

namespace PugSharp.Match;

public class MatchInfo
{
public string SelectedMap { get; set; }
public string StartTeam1 { get; set; }
public Team? StartTeam1 { get; set; }
}

0 comments on commit 27ef48b

Please sign in to comment.