-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSelectionData.cs
66 lines (54 loc) · 1.69 KB
/
SelectionData.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using PlayerRoles;
using PluginAPI.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SCPSelector
{
public class SelectionData
{
private Dictionary<int, int> PlayerSelections;
private Dictionary<int, RoleTypeId> PlayerRoles;
public SelectionData()
{
PlayerSelections = new Dictionary<int, int>();
PlayerRoles = new Dictionary<int, RoleTypeId>();
}
public void Reset()
{
PlayerSelections = new Dictionary<int, int>();
PlayerRoles = new Dictionary<int, RoleTypeId>();
}
public void RegisterSCPPlayer(Player player, RoleTypeId role)
{
int id = player.PlayerId;
if (PlayerSelections.ContainsKey(id)) return;
PlayerSelections[id] = 0;
PlayerRoles[id] = role;
}
public bool ReachedMaxChanges(Player player)
{
int id = player.PlayerId;
if (!PlayerSelections.ContainsKey(id))
PlayerSelections[id] = 0;
if (PlayerSelections[id] >= Plugin.Instance.Config.MaxChanges)
return false;
return true;
}
public bool IsDuplicate(RoleTypeId role)
{
return PlayerRoles.ContainsValue(role);
}
public void ChangeRole(Player player, RoleTypeId role)
{
int id = player.PlayerId;
if (!PlayerSelections.ContainsKey(id))
PlayerSelections[id] = 0;
PlayerSelections[id]++;
PlayerRoles[id] = role;
player.SetRole(role);
}
}
}