|
|
|
@ -251,13 +251,17 @@ public class GameTests
|
|
|
|
|
Assert.NotNull(_game.GameRules);
|
|
|
|
|
_game.UsedMap.Boards[0].Value = 1;
|
|
|
|
|
_game.UsedMap.Boards[1].Value = 2;
|
|
|
|
|
_game.UsedMap.Boards[0].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[1].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[2].Valid = true;
|
|
|
|
|
|
|
|
|
|
var methodInfo = typeof(Game).GetMethod("PlaceResult", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
Assert.NotNull(methodInfo);
|
|
|
|
|
|
|
|
|
|
var cell = new Cell(0, 2);
|
|
|
|
|
cell.Value = 3;
|
|
|
|
|
methodInfo.Invoke(_game, new object[] { cell, 3 });
|
|
|
|
|
_game.PlayerCell = new Cell(2, 0);
|
|
|
|
|
_game.PlayerCell.Value = 3;
|
|
|
|
|
methodInfo.Invoke(_game, new object[] { _game.PlayerCell, 3 });
|
|
|
|
|
//_game.UsedMap.Boards[2].Value = _game.PlayerCell.Value;
|
|
|
|
|
|
|
|
|
|
Assert.Equal(3, _game.UsedMap.Boards[2].Value);
|
|
|
|
|
}
|
|
|
|
@ -270,8 +274,11 @@ public class GameTests
|
|
|
|
|
|
|
|
|
|
_game.InitializeGame(map, player, false);
|
|
|
|
|
|
|
|
|
|
var cell = new Cell(0, 1);
|
|
|
|
|
var cell = new Cell(1, 0);
|
|
|
|
|
cell.Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[0].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[0].Value = 1;
|
|
|
|
|
_game.UsedMap.Boards[1].Valid = true;
|
|
|
|
|
bool result = _game.HandlePlayerChoice(cell, 1);
|
|
|
|
|
Assert.True(result);
|
|
|
|
|
}
|
|
|
|
@ -329,14 +336,16 @@ public class GameTests
|
|
|
|
|
var player = new Player("test_player", "DefaultProfilePicture");
|
|
|
|
|
var map = new Map("test_name", "test_background.png");
|
|
|
|
|
_game.InitializeGame(map, player, false);
|
|
|
|
|
_game.UsedMap.Boards[1].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[2].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[1].Value = 5;
|
|
|
|
|
|
|
|
|
|
var methodInfo = typeof(Game).GetMethod("PlaceResult", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
Assert.NotNull(methodInfo);
|
|
|
|
|
|
|
|
|
|
var cell = new Cell(0, 2);
|
|
|
|
|
cell.Value = 14;
|
|
|
|
|
methodInfo.Invoke(_game, new object[] { cell, 14 });
|
|
|
|
|
_game.PlayerCell = new Cell(2, 0);
|
|
|
|
|
_game.PlayerCell.Value = 14;
|
|
|
|
|
methodInfo.Invoke(_game, new object[] { _game.PlayerCell, 14 });
|
|
|
|
|
|
|
|
|
|
Assert.True(_game.UsedMap.Boards[2].Penalty);
|
|
|
|
|
}
|
|
|
|
@ -347,15 +356,19 @@ public class GameTests
|
|
|
|
|
var player = new Player("test_player", "DefaultProfilePicture");
|
|
|
|
|
var map = new Map("test_name", "test_background.png");
|
|
|
|
|
_game.InitializeGame(map, player, false);
|
|
|
|
|
|
|
|
|
|
_game.UsedMap.Boards[1].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[2].Valid = true;
|
|
|
|
|
|
|
|
|
|
_game.UsedMap.Boards[1].Value = 5;
|
|
|
|
|
_game.UsedMap.Boards[2].IsDangerous = true;
|
|
|
|
|
|
|
|
|
|
var methodInfo = typeof(Game).GetMethod("PlaceResult", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
Assert.NotNull(methodInfo);
|
|
|
|
|
|
|
|
|
|
var cell = new Cell(0, 2);
|
|
|
|
|
cell.Value = 7;
|
|
|
|
|
methodInfo.Invoke(_game, new object[] { cell, 7 });
|
|
|
|
|
_game.PlayerCell = new Cell(2, 0);
|
|
|
|
|
_game.PlayerCell.Value = 7;
|
|
|
|
|
methodInfo.Invoke(_game, new object[] { _game.PlayerCell, 7 });
|
|
|
|
|
|
|
|
|
|
Assert.True(_game.UsedMap.Boards[2].Penalty);
|
|
|
|
|
}
|
|
|
|
@ -415,42 +428,133 @@ public class GameTests
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CalculusOfPenalty_ReallyCalculusPenalty()
|
|
|
|
|
public void CalculusOfPenalty_ReallyCalculusPenalty_ForZonesAndDangerousCellsAndOverTwelve()
|
|
|
|
|
{
|
|
|
|
|
var player = new Player("test_player", "DefaultProfilePicture");
|
|
|
|
|
var map = new Map("test_name", "test_background.png");
|
|
|
|
|
_game.InitializeGame(map, player, false);
|
|
|
|
|
var methodInfo = typeof(Game).GetMethod("AddToRopePath", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
Assert.NotNull(methodInfo);
|
|
|
|
|
|
|
|
|
|
_game.UsedMap.Boards[0].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[1].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[2].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[3].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[7].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[8].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[9].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[10].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[11].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[12].Valid = true;
|
|
|
|
|
|
|
|
|
|
_game.UsedMap.Boards[10].Value = 2; // 1,3 // penalty
|
|
|
|
|
_game.UsedMap.Boards[7].Value = 5; // 1,0
|
|
|
|
|
_game.UsedMap.Boards[8].Value = 5; // 1,1
|
|
|
|
|
_game.UsedMap.Boards[9].Value = 5; // 1,2
|
|
|
|
|
|
|
|
|
|
var place = typeof(Game).GetMethod("PlaceResult", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
Assert.NotNull(place);
|
|
|
|
|
|
|
|
|
|
_game.PlayerCell = new Cell(4, 1);
|
|
|
|
|
_game.PlayerCell.Value = 7;
|
|
|
|
|
_game.PlayerCell.Valid = true;
|
|
|
|
|
_game.PlayerCell.IsDangerous = true;
|
|
|
|
|
place.Invoke(_game, new object[] { _game.PlayerCell, 7 }); //One penalty
|
|
|
|
|
|
|
|
|
|
_game.PlayerCell = new Cell(5, 1);
|
|
|
|
|
_game.PlayerCell.Value = 14;
|
|
|
|
|
_game.PlayerCell.Valid = true;
|
|
|
|
|
place.Invoke(_game, new object[] { _game.PlayerCell, 14 });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var cells in _game.UsedMap.Boards.ToList())
|
|
|
|
|
{
|
|
|
|
|
_game.GameRules.IsZoneValidAndAddToZones(cells, _game.UsedMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_game.UsedMap.Boards[0].Value = 0;
|
|
|
|
|
methodInfo.Invoke(_game, new object[] { _game.UsedMap.Boards[0], _game.GameRules.EveryAdjacentCells(_game.UsedMap.Boards[0], _game.UsedMap.Boards.ToList()) });
|
|
|
|
|
_game.UsedMap.Boards[1].Value = 1;
|
|
|
|
|
methodInfo.Invoke(_game, new object[] { _game.UsedMap.Boards[1], _game.GameRules.EveryAdjacentCells(_game.UsedMap.Boards[1], _game.UsedMap.Boards.ToList()) });
|
|
|
|
|
_game.UsedMap.Boards[2].Value = 2;
|
|
|
|
|
methodInfo.Invoke(_game, new object[] { _game.UsedMap.Boards[2], _game.GameRules.EveryAdjacentCells(_game.UsedMap.Boards[2], _game.UsedMap.Boards.ToList()) });
|
|
|
|
|
_game.UsedMap.Boards[3].Value = 5;
|
|
|
|
|
|
|
|
|
|
_game.PutPenaltyForLostCells(_game.UsedMap.Boards);
|
|
|
|
|
|
|
|
|
|
Assert.True(_game.UsedMap.Boards[3].Penalty);
|
|
|
|
|
Assert.True(_game.UsedMap.Boards[11].Penalty);
|
|
|
|
|
Assert.Equal(9, _game.CalculusOfPenalty(_game.UsedMap.Boards));
|
|
|
|
|
|
|
|
|
|
Assert.Equal(3, _game.CalculusOfPenalty(_game.UsedMap.Boards));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void DoesDeleteGame_ReallyDeleteGame()
|
|
|
|
|
{
|
|
|
|
|
Game game = new Game();
|
|
|
|
|
Game game1 = new Game();
|
|
|
|
|
game.AddGame(game);
|
|
|
|
|
game.AddGame(game1);
|
|
|
|
|
game.DeleteGame();
|
|
|
|
|
Assert.DoesNotContain(game1, game.Games);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CalculusOfPenalty_ReallyCalculusPenalty_ForZonesAndDangerousCellsAndOverTwelve()
|
|
|
|
|
public void DoesDeleteGame_DoNotDeleteNoGame()
|
|
|
|
|
{
|
|
|
|
|
var player = new Player("test_player", "DefaultProfilePicture");
|
|
|
|
|
var map = new Map("test_name", "test_background.png");
|
|
|
|
|
_game.InitializeGame(map, player, false);
|
|
|
|
|
bool res = _game.DeleteGame();
|
|
|
|
|
Assert.False(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CanIModifyAPlayer()
|
|
|
|
|
{
|
|
|
|
|
Game game = new Game();
|
|
|
|
|
Player player = new Player("test", "DefaultProfilePicture");
|
|
|
|
|
game.AddPlayer(player);
|
|
|
|
|
game.ModifyPlayer("test", "newName");
|
|
|
|
|
Assert.Equal("newName", game.Players[0].Pseudo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CanIModifyANonExistentPlayer()
|
|
|
|
|
{
|
|
|
|
|
Game game = new Game();
|
|
|
|
|
var res = game.ModifyPlayer("nope", "newName");
|
|
|
|
|
Assert.False(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CanIRollDice()
|
|
|
|
|
{
|
|
|
|
|
_game.InitializeGame(new Map("test", "test.png"), new Player("test", "test.png"), false);
|
|
|
|
|
_game.RollAllDice();
|
|
|
|
|
Assert.NotNull(_game.Dice1);
|
|
|
|
|
Assert.NotNull(_game.Dice2);
|
|
|
|
|
Assert.True(_game.Dice1.Value >= 0 && _game.Dice1.Value <= 5 );
|
|
|
|
|
Assert.True(_game.Dice2.Value >= 1 && _game.Dice2.Value <= 6 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CanIStartGame()
|
|
|
|
|
{
|
|
|
|
|
_game.InitializeGame(new Map("test", "test.png"), new Player("test", "test.png"), false);
|
|
|
|
|
|
|
|
|
|
var start = typeof(Game).GetMethod("StartGame", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
Assert.NotNull(start);
|
|
|
|
|
|
|
|
|
|
start.Invoke(_game, null);
|
|
|
|
|
|
|
|
|
|
Assert.True(_game.IsRunning);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CanIEndGame()
|
|
|
|
|
{
|
|
|
|
|
_game.InitializeGame(new Map("test", "test.png"), new Player("test", "test.png"), false);
|
|
|
|
|
|
|
|
|
|
var start = typeof(Game).GetMethod("StartGame", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
Assert.NotNull(start);
|
|
|
|
|
|
|
|
|
|
start.Invoke(_game, null);
|
|
|
|
|
var end = typeof(Game).GetMethod("EndGame", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
Assert.NotNull(end);
|
|
|
|
|
|
|
|
|
|
end.Invoke(_game, new object[] { 14 } );
|
|
|
|
|
|
|
|
|
|
Assert.False(_game.IsRunning);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CalculusOfPointsWorksWellOrNot()
|
|
|
|
|
{
|
|
|
|
|
_game.InitializeGame(new Map("test", "test.png"), new Player("test", "test.png"), false);
|
|
|
|
|
|
|
|
|
|
_game.UsedMap.Boards[7].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[8].Valid = true;
|
|
|
|
@ -459,24 +563,20 @@ public class GameTests
|
|
|
|
|
_game.UsedMap.Boards[11].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[12].Valid = true;
|
|
|
|
|
|
|
|
|
|
_game.UsedMap.Boards[10].Value = 2; // 1,3 // penalty
|
|
|
|
|
_game.UsedMap.Boards[7].Value = 5; // 1,0
|
|
|
|
|
_game.UsedMap.Boards[8].Value = 5; // 1,1
|
|
|
|
|
_game.UsedMap.Boards[9].Value = 5; // 1,2
|
|
|
|
|
_game.UsedMap.Boards[10].Value = 2; // penalty (- 3)
|
|
|
|
|
_game.UsedMap.Boards[7].Value = 5; //5 + 2 = 7
|
|
|
|
|
_game.UsedMap.Boards[8].Value = 5;
|
|
|
|
|
_game.UsedMap.Boards[9].Value = 5;
|
|
|
|
|
|
|
|
|
|
var place = typeof(Game).GetMethod("PlaceResult", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
Assert.NotNull(place);
|
|
|
|
|
|
|
|
|
|
var cell = new Cell(1, 4);
|
|
|
|
|
cell.Value = 7;
|
|
|
|
|
cell.Valid = true;
|
|
|
|
|
cell.IsDangerous = true;
|
|
|
|
|
place.Invoke(_game, new object[] { cell, 7 }); //One penalty
|
|
|
|
|
_game.PlayerCell = new Cell(4, 1);
|
|
|
|
|
_game.PlayerCell.Value = 7;
|
|
|
|
|
_game.PlayerCell.Valid = true;
|
|
|
|
|
_game.PlayerCell.IsDangerous = true;
|
|
|
|
|
place.Invoke(_game, new object[] { _game.PlayerCell, 7 }); //One penalty
|
|
|
|
|
|
|
|
|
|
var othercell = new Cell(1, 5);
|
|
|
|
|
cell.Value = 14;
|
|
|
|
|
cell.Valid = true;
|
|
|
|
|
place.Invoke(_game, new object[] { othercell, 14 });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var cells in _game.UsedMap.Boards.ToList())
|
|
|
|
@ -487,7 +587,39 @@ public class GameTests
|
|
|
|
|
_game.PutPenaltyForLostCells(_game.UsedMap.Boards);
|
|
|
|
|
|
|
|
|
|
Assert.True(_game.UsedMap.Boards[11].Penalty);
|
|
|
|
|
Assert.Equal(9, _game.CalculusOfPenalty(_game.UsedMap.Boards));
|
|
|
|
|
|
|
|
|
|
Assert.Equal(1, _game.FinalCalculusOfPoints());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CalculusOfPointsWorksWellOrNotForRopePathes()
|
|
|
|
|
{
|
|
|
|
|
_game.InitializeGame(new Map("test", "test.png"), new Player("test", "test.png"), false);
|
|
|
|
|
|
|
|
|
|
var methodInfo = typeof(Game).GetMethod("AddToRopePath", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
Assert.NotNull(methodInfo);
|
|
|
|
|
_game.Turn = 2;
|
|
|
|
|
_game.UsedMap.Boards[7].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[8].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[9].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[10].Valid = true;
|
|
|
|
|
|
|
|
|
|
_game.UsedMap.Boards[7].Value = 5; //7 + 2 = 9
|
|
|
|
|
methodInfo.Invoke(_game, new object[] { _game.UsedMap.Boards[7], _game.UsedMap.Boards.ToList() });
|
|
|
|
|
_game.UsedMap.Boards[8].Value = 6;
|
|
|
|
|
methodInfo.Invoke(_game, new object[] { _game.UsedMap.Boards[8], _game.UsedMap.Boards.ToList() });
|
|
|
|
|
_game.UsedMap.Boards[9].Value = 7;
|
|
|
|
|
methodInfo.Invoke(_game, new object[] { _game.UsedMap.Boards[9], _game.UsedMap.Boards.ToList() });
|
|
|
|
|
_game.UsedMap.Boards[10].Value = 2; // penalty (- 3)
|
|
|
|
|
methodInfo.Invoke(_game, new object[] { _game.UsedMap.Boards[10], _game.UsedMap.Boards.ToList() });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_game.PutPenaltyForLostCells(_game.UsedMap.Boards);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.True(_game.UsedMap.Boards[10].Penalty);
|
|
|
|
|
|
|
|
|
|
Assert.Equal(6, _game.FinalCalculusOfPoints());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|