Auto cleanup of party modes
This commit is contained in:
1 parent
91e6d4901b
commit
cd62c3cd88
16 files changed
+497
-595
No files matched your search
@@ -5,15 +5,15 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
public class ChallengeRounds
|
||||
{
|
||||
private Random _Rand;
|
||||
private int _NumPlayer;
|
||||
private readonly Random _Rand;
|
||||
private readonly int _NumPlayer;
|
||||
|
||||
public List<Combination> Rounds;
|
||||
|
||||
public ChallengeRounds(int NumRounds, int NumPlayer, int NumPlayerAtOnce)
|
||||
{
|
||||
Rounds = new List<Combination>();
|
||||
_Rand = new Random(System.DateTime.Now.Millisecond);
|
||||
_Rand = new Random(DateTime.Now.Millisecond);
|
||||
|
||||
if (NumPlayerAtOnce < 1 || NumRounds < 1 || NumPlayer == 0)
|
||||
_NumPlayer = 0;
|
||||
@@ -38,26 +38,19 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
Rounds.Add(Combinations.GetNextCombination(null));
|
||||
|
||||
for (int i = 1; i < NumRounds; i++)
|
||||
{
|
||||
|
||||
Rounds.Add(Combinations.GetNextCombination(GetPlayerDemand(i)));
|
||||
}
|
||||
}
|
||||
|
||||
private List<int> GetPlayerDemand(int RoundIndex)
|
||||
{
|
||||
List<int> NumPlayed = new List<int>(_NumPlayer);
|
||||
for (int i = 0; i < _NumPlayer; i++)
|
||||
{
|
||||
NumPlayed.Add(0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < RoundIndex; i++)
|
||||
{
|
||||
foreach (int PlayerIndex in Rounds[i].Player)
|
||||
{
|
||||
NumPlayed[PlayerIndex]++;
|
||||
}
|
||||
}
|
||||
|
||||
int max = 0;
|
||||
@@ -92,7 +85,6 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
}
|
||||
else
|
||||
last.Add(i);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,17 +118,17 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
class Combinations
|
||||
{
|
||||
private List<Combination> _Combs;
|
||||
private Random _Rand;
|
||||
private int _NumPlayer;
|
||||
private int _NumMics;
|
||||
private readonly List<Combination> _Combs;
|
||||
private readonly Random _Rand;
|
||||
private readonly int _NumPlayer;
|
||||
private readonly int _NumMics;
|
||||
|
||||
public Combinations(int NumPlayer, int NumMics, Random Rand)
|
||||
{
|
||||
_Combs = new List<Combination>();
|
||||
_NumMics = NumMics;
|
||||
_NumPlayer = NumPlayer;
|
||||
_Rand = Rand;
|
||||
_Rand = Rand;
|
||||
}
|
||||
|
||||
public Combination GetNextCombination(List<int> PlayerNrDemand)
|
||||
@@ -147,9 +139,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
Combination combs = new Combination();
|
||||
|
||||
if (_NumPlayer == _NumMics)
|
||||
{
|
||||
return _Combs[0];
|
||||
}
|
||||
|
||||
//filter against PlayerNrDemand
|
||||
List<Combination> combsFiltered = new List<Combination>();
|
||||
@@ -176,18 +166,14 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
if (combsFiltered.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < _Combs.Count; i++)
|
||||
{
|
||||
combsFiltered.Add(_Combs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int num = combsFiltered.Count;
|
||||
int rand = _Rand.Next(num);
|
||||
Combination c = new Combination();
|
||||
for (int i = 0; i < combsFiltered[rand].Player.Count; i++)
|
||||
{
|
||||
c.Player.Add(combsFiltered[rand].Player[i]);
|
||||
}
|
||||
_Combs.Remove(combsFiltered[rand]);
|
||||
|
||||
return combsFiltered[rand];
|
||||
@@ -206,9 +192,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
for (int j = 0; j < _NumPlayer; j++)
|
||||
{
|
||||
if ((i & (1 << j)) > 0)
|
||||
{
|
||||
c.Player.Add(j);
|
||||
}
|
||||
}
|
||||
|
||||
if (c.Player.Count == _NumMics)
|
||||
@@ -240,9 +224,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
bool result = true;
|
||||
foreach (int p in PlayerIndices)
|
||||
{
|
||||
result &= IsAvailable(p);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -250,10 +232,8 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
bool result = false;
|
||||
foreach (int p in PlayerIndices)
|
||||
{
|
||||
result |= IsAvailable(p);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user