-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShuffler.java
More file actions
40 lines (33 loc) · 1.26 KB
/
Shuffler.java
File metadata and controls
40 lines (33 loc) · 1.26 KB
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
import java.util.ArrayList;
import java.util.Random;
public class Shuffler {
public Shuffler(int civilCount,
int mafiaCount,
int comissarCount,
int hoeCount,
int doctorCount,
int maniacCount)
{
m_slots = new ArrayList<>();
m_random = new Random();
m_slots.add(new ShufflerSlot(civilCount, new Role(MafiaClass.MafiaClassCivil)));
m_slots.add(new ShufflerSlot(mafiaCount, new Role(MafiaClass.MafiaClassGang)));
m_slots.add(new ShufflerSlot(comissarCount, new Role(MafiaClass.MafiaClassComissar)));
m_slots.add(new ShufflerSlot(hoeCount, new Role(MafiaClass.MafiaClassHoe)));
m_slots.add(new ShufflerSlot(doctorCount, new Role(MafiaClass.MafiaClassDoctor)));
m_slots.add(new ShufflerSlot(maniacCount, new Role(MafiaClass.MafiaClassManiac)));
}
public Role getRole()
{
int index = m_random.nextInt(m_slots.size());
Role role = m_slots.get(index).getRole();
boolean dec = m_slots.get(index).decreaseCount();
if (!dec)
{
m_slots.remove(index);
}
return role;
}
private ArrayList<ShufflerSlot> m_slots;
private Random m_random;
}