Skip to content

Commit b54c855

Browse files
authored
Merge pull request #16 from id-rotatcepS/develop
bot kicker Develop to Master
2 parents 884f9a3 + 8e46005 commit b54c855

70 files changed

Lines changed: 3038 additions & 32 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

TF2FrameworkInterface/BotHandling.cs

Lines changed: 779 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
using System.ComponentModel;
2+
using System.Linq;
3+
4+
namespace TF2FrameworkInterface
5+
{
6+
public class LobbyPlayer : INotifyPropertyChanged
7+
{
8+
public event PropertyChangedEventHandler PropertyChanged;
9+
public void ViewNotification(string propertyName)
10+
{
11+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
12+
}
13+
14+
private TF2DebugLobby lobbyInfo;
15+
private StatusCommandLogOutput status;
16+
public LobbyPlayer(TF2DebugLobby l, StatusCommandLogOutput status)
17+
{
18+
this.lobbyInfo = l;
19+
this.status = status;
20+
}
21+
22+
private bool isMuted;
23+
public bool IsMuted
24+
{
25+
get => isMuted;
26+
set
27+
{
28+
isMuted = value;
29+
ViewNotification(nameof(TextIcon));
30+
}
31+
}
32+
33+
private bool isBanned;
34+
public bool IsBanned
35+
{
36+
get => isBanned;
37+
set
38+
{
39+
isBanned = value;
40+
ViewNotification(nameof(TextIcon));
41+
}
42+
}
43+
private bool isUserBanned;
44+
public bool IsUserBanned
45+
{
46+
get => isUserBanned;
47+
set
48+
{
49+
isUserBanned = value;
50+
ViewNotification(nameof(TextIcon));
51+
}
52+
}
53+
private bool isFriend;
54+
public bool IsFriend
55+
{
56+
get => isFriend;
57+
set
58+
{
59+
isFriend = value;
60+
ViewNotification(nameof(TextIcon));
61+
}
62+
}
63+
private bool isMe;
64+
public bool IsMe
65+
{
66+
get => isMe;
67+
set
68+
{
69+
isMe = value;
70+
ViewNotification(nameof(TextIcon));
71+
}
72+
}
73+
74+
public string TextIcon
75+
=> (IsMuted ? "🔇" : " ")
76+
+ (IsUserBanned ? "👎"
77+
: IsBanned ? "☠"
78+
: IsMe ? "👉"
79+
: IsFriend ? "💚"
80+
: " ");
81+
82+
public string TextTime
83+
=> IsMissing ? "--"
84+
: StatusConnectedSeconds == 0
85+
? ""
86+
: new System.TimeSpan(0, 0, StatusConnectedSeconds).TotalMinutes.ToString("N0");
87+
//ToString(@"hh\:mm\:ss");
88+
89+
private TF2Status _lastGoodStatus;
90+
91+
private TF2Status StatusInfo
92+
{
93+
get
94+
{
95+
TF2Status liveStatus = status.LogStatus
96+
.FirstOrDefault(s => s.SteamUniqueID == lobbyInfo.SteamUniqueID);
97+
98+
if (liveStatus != null && liveStatus.IsDifferent(_lastGoodStatus))
99+
{
100+
_lastGoodStatus = liveStatus;
101+
NotifyStatusChanged();
102+
}
103+
104+
return _lastGoodStatus;
105+
}
106+
}
107+
108+
public bool IsRED => lobbyInfo.Team == TF2DebugLobby.TF_GC_TEAM_DEFENDERS;
109+
public bool IsBLU => lobbyInfo.Team == TF2DebugLobby.TF_GC_TEAM_INVADERS;
110+
111+
public string SteamID => lobbyInfo.SteamUniqueID;
112+
113+
private void NotifyStatusChanged()
114+
{
115+
ViewNotification(nameof(HaveStatus));
116+
ViewNotification(nameof(HaveKickInfo));
117+
ViewNotification(nameof(StatusName));
118+
ViewNotification(nameof(StatusConnectedSeconds));
119+
ViewNotification(nameof(TextTime));
120+
ViewNotification(nameof(StatusPing));
121+
ViewNotification(nameof(StatusState));
122+
}
123+
124+
internal void Update(TF2DebugLobby updatedLobby)
125+
{
126+
lobbyInfo.Team = updatedLobby.Team;
127+
ViewNotification(nameof(IsRED));
128+
ViewNotification(nameof(IsBLU));
129+
//lobbyInfo.MemberNumber
130+
//lobbyInfo.PlayerType
131+
}
132+
133+
public bool HaveStatus => StatusInfo != null;
134+
public bool HaveKickInfo => StatusInfo?.GameUserID != null;
135+
136+
public string StatusName => StatusInfo?.UserName
137+
?? " -❓" + lobbyInfo.SteamUniqueID + "❔- ";
138+
public int StatusConnectedSeconds => StatusInfo?.ConnectedSeconds
139+
?? 0;
140+
public int StatusPing => StatusInfo?.Ping
141+
?? 0;
142+
/// <summary>
143+
/// invalid, challenging, connecting, spawning, active
144+
/// </summary>
145+
public string StatusState
146+
=> IsMissing ? "--"
147+
: StatusInfo?.UserState
148+
?? "";
149+
150+
public bool IsMissing => RemoveCounter > 0;
151+
152+
private int removeCounter;
153+
/// <summary>
154+
/// track how many times we tried to remove this player
155+
/// - they can accidentally show as removed for a while,
156+
/// also useful so they stick around a little while for marking after another player kicks them.
157+
/// </summary>
158+
public int RemoveCounter
159+
{
160+
get => removeCounter;
161+
internal set
162+
{
163+
removeCounter = value;
164+
ViewNotification(nameof(TextTime));
165+
ViewNotification(nameof(StatusState));
166+
ViewNotification(nameof(IsMissing));
167+
}
168+
}
169+
}
170+
}

0 commit comments

Comments
 (0)