Added check to see if all players are ready before setting to inGame
This commit is contained in:
parent
5db0af5841
commit
dfd8bbfc10
@ -202,9 +202,24 @@ public class GameGroupTests
|
||||
public void SetAllInGame_SetsStateToInGame()
|
||||
{
|
||||
AddFullParty();
|
||||
Assert.That(_gameGroup.Players, Has.All.Property(nameof(IPlayer.State)).Not.EqualTo(State.Ready));
|
||||
_gameGroup.SetAllInGame();
|
||||
Assert.That(_gameGroup.Players, Has.All.Property(nameof(IPlayer.State)).EqualTo(State.InGame));
|
||||
_gameGroup.Players.ForEach(player => player.State = State.Ready);
|
||||
Assert.That(_gameGroup.Players, Has.All.Property(nameof(IPlayer.State)).EqualTo(State.Ready));
|
||||
|
||||
var allInGame = _gameGroup.SetAllInGame();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(allInGame, Is.True);
|
||||
Assert.That(_gameGroup.Players, Has.All.Property(nameof(IPlayer.State)).EqualTo(State.InGame));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetAllInGame_SetStateToInGame_WhenNotAllReady()
|
||||
{
|
||||
AddFullParty();
|
||||
var allInGame = _gameGroup.SetAllInGame();
|
||||
Assert.That(allInGame, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -32,8 +32,11 @@ public class GameGroup // TODO tests
|
||||
return Players;
|
||||
}
|
||||
|
||||
public void SetAllInGame()
|
||||
public bool SetAllInGame()
|
||||
{
|
||||
if (Players.Any(player => player.State != State.Ready)) return false;
|
||||
|
||||
foreach (var player in Players) player.State = State.InGame;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user