|
|
|
@ -397,4 +397,110 @@ public class GameTests
|
|
|
|
|
Assert.True(_game.UsedMap.Boards[2].Penalty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void PutPenaltyForLostCells_ReallyPutPenalty_ForZones()
|
|
|
|
|
{
|
|
|
|
|
var player = new Player("test_player", "DefaultProfilePicture");
|
|
|
|
|
var map = new Map("test_name", "test_background.png");
|
|
|
|
|
_game.InitializeGame(map, player);
|
|
|
|
|
|
|
|
|
|
_game.UsedMap.Boards[1].Value = 5;
|
|
|
|
|
_game.UsedMap.Boards[2].Value = 5;
|
|
|
|
|
_game.UsedMap.Boards[3].Value = 5;
|
|
|
|
|
_game.UsedMap.Boards[0].Value = 0;
|
|
|
|
|
|
|
|
|
|
foreach (var cells in _game.UsedMap.Boards.ToList())
|
|
|
|
|
{
|
|
|
|
|
_game.GameRules.IsZoneValidAndAddToZones(cells, _game.UsedMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_game.PutPenaltyForLostCells(_game.UsedMap.Boards);
|
|
|
|
|
|
|
|
|
|
Assert.True(_game.UsedMap.Boards[0].Penalty);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void PutPenaltyForLostCells_ReallyPutPenalty_ForRopePathes()
|
|
|
|
|
{
|
|
|
|
|
var player = new Player("test_player", "DefaultProfilePicture");
|
|
|
|
|
var map = new Map("test_name", "test_background.png");
|
|
|
|
|
_game.InitializeGame(map, player);
|
|
|
|
|
|
|
|
|
|
_game.UsedMap.Boards[1].Value = 1;
|
|
|
|
|
_game.UsedMap.Boards[2].Value = 2;
|
|
|
|
|
_game.UsedMap.Boards[3].Value = 5;
|
|
|
|
|
_game.UsedMap.Boards[0].Value = 0;
|
|
|
|
|
|
|
|
|
|
var methodInfo = typeof(Game).GetMethod("AddToRopePath", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
Assert.NotNull(methodInfo);
|
|
|
|
|
|
|
|
|
|
foreach (var cells in _game.UsedMap.Boards.ToList())
|
|
|
|
|
{
|
|
|
|
|
methodInfo.Invoke(_game, new object[] { cells, _game.UsedMap.Boards.ToList() });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_game.PutPenaltyForLostCells(_game.UsedMap.Boards);
|
|
|
|
|
|
|
|
|
|
Assert.True(_game.UsedMap.Boards[3].Penalty);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CalculusOfPenalty_ReallyCalculusPenalty()
|
|
|
|
|
{
|
|
|
|
|
var player = new Player("test_player", "DefaultProfilePicture");
|
|
|
|
|
var map = new Map("test_name", "test_background.png");
|
|
|
|
|
_game.InitializeGame(map, player);
|
|
|
|
|
|
|
|
|
|
_game.UsedMap.Boards[0].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[1].Valid = true;
|
|
|
|
|
_game.UsedMap.Boards[2].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[13].Valid = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_game.UsedMap.Boards[0].Value = 0;
|
|
|
|
|
_game.UsedMap.Boards[1].Value = 1;
|
|
|
|
|
_game.UsedMap.Boards[2].Value = 2;
|
|
|
|
|
_game.UsedMap.Boards[8].Value = 5;
|
|
|
|
|
_game.UsedMap.Boards[7].Value = 5;
|
|
|
|
|
_game.UsedMap.Boards[9].Value = 5;
|
|
|
|
|
_game.UsedMap.Boards[10].Value = 6;
|
|
|
|
|
_game.UsedMap.Boards[11].IsDangerous = true;
|
|
|
|
|
_game.UsedMap.Boards[12].Value = 13; //One penalty because it is over 12
|
|
|
|
|
_game.UsedMap.Boards[13].Value = 9; //One penalty because it is lost
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
var methodInfo = typeof(Game).GetMethod("AddToRopePath", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
Assert.NotNull(methodInfo);
|
|
|
|
|
|
|
|
|
|
foreach (var cells in _game.UsedMap.Boards.ToList())
|
|
|
|
|
{
|
|
|
|
|
_game.GameRules.IsZoneValidAndAddToZones(cells, _game.UsedMap);
|
|
|
|
|
methodInfo.Invoke(_game, new object[] { cells, _game.GameRules.EveryAdjacentCells(cells, _game.UsedMap.Boards.ToList()) });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_game.PutPenaltyForLostCells(_game.UsedMap.Boards);
|
|
|
|
|
|
|
|
|
|
Assert.True(_game.UsedMap.Boards[10].Penalty);
|
|
|
|
|
Assert.True(_game.UsedMap.Boards[11].Penalty);
|
|
|
|
|
Assert.True(_game.UsedMap.Boards[12].Penalty);
|
|
|
|
|
|
|
|
|
|
Assert.Equal(9, _game.CalculusOfPenalty(_game.UsedMap.Boards));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|