-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
c519ef6
commit 1ae837f
Showing
12 changed files
with
262 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace PugSharp.Config; | ||
|
||
public class ConfigCreator | ||
{ | ||
public ConfigCreator() | ||
{ | ||
Config = new MatchConfig | ||
{ | ||
// TODO Maybe use guid for demo, ... | ||
MatchId = "CustomMatch", | ||
Team1 = new Team | ||
{ | ||
Name = "Team 1", | ||
|
||
}, | ||
Team2 = new Team | ||
{ | ||
Name = "Team 2", | ||
}, | ||
TeamMode = TeamMode.Scramble, | ||
}; | ||
} | ||
|
||
public MatchConfig Config { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace PugSharp.Config; | ||
|
||
public enum TeamMode | ||
{ | ||
// Take Teams as they are | ||
Default, | ||
|
||
// Scramble Teams afte all players are joined | ||
Scramble, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,5 @@ public enum MatchCommand | |
CompleteMap, | ||
Pause, | ||
Unpause, | ||
TeamsDefined, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,5 @@ public enum MatchState | |
MapCompleted, | ||
MatchCompleted, | ||
RestoreMatch, | ||
DefineTeams, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace PugSharp.Shared | ||
{ | ||
public static class EnumerableExtensions | ||
{ | ||
public static IEnumerable<T> Randomize<T>(this IEnumerable<T> source) | ||
{ | ||
if (source == null) throw new ArgumentNullException(nameof(source)); | ||
|
||
return source.RandomizeInternal(); | ||
} | ||
|
||
private static IEnumerable<T> RandomizeInternal<T>( | ||
this IEnumerable<T> source) | ||
{ | ||
var buffer = source.ToList(); | ||
for (int i = 0; i < buffer.Count; i++) | ||
{ | ||
int j = Random.Shared.Next(i, buffer.Count); | ||
yield return buffer[j]; | ||
|
||
buffer[j] = buffer[i]; | ||
} | ||
} | ||
|
||
public static void AddRange<T>(this IList<T> items, IEnumerable<T> itemsToAdd) | ||
{ | ||
foreach (var item in itemsToAdd) | ||
{ | ||
items.Add(item); | ||
} | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
PugSharp/NumericExtensions.cs → PugSharp.Shared/NumericExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.