Merge branch 'MapEdits' into dev
continuous-integration/drone/push Build is failing Details

pull/108/head
Rémi LAVERGNE 11 months ago
commit fc8a7b7994

@ -24,7 +24,7 @@ class Program
IPersistence persistence = new DataContractXml(); IPersistence persistence = new DataContractXml();
Player player = new Player(pseudo, "test.png"); Player player = new Player(pseudo, "test.png");
Map map = new Map("background"); Map map = new Map("Dunai","background");
Game game = new Game(persistence); Game game = new Game(persistence);
// Abonnement aux événements // Abonnement aux événements

@ -197,7 +197,7 @@ namespace Models.Game
BestScores = new ObservableCollection<BestScore>(); BestScores = new ObservableCollection<BestScore>();
GameRules = new Rules.Rules(); GameRules = new Rules.Rules();
UsedMap = new Map("test"); UsedMap = new Map("temp","test");
IsRunning = false; IsRunning = false;
} }

@ -17,6 +17,12 @@ namespace Models.Game
public ReadOnlyObservableCollection<Cell> Boards { get; private set; } public ReadOnlyObservableCollection<Cell> Boards { get; private set; }
ObservableCollection<Cell> board = new ObservableCollection<Cell>(); ObservableCollection<Cell> board = new ObservableCollection<Cell>();
/// <summary>
/// The displaying name of the map
/// </summary>
[DataMember]
public string Name { get; private set; }
/// <summary> /// <summary>
/// It is the backgrond image of the map /// It is the backgrond image of the map
/// </summary> /// </summary>
@ -46,11 +52,12 @@ namespace Models.Game
/// Initializes a new instance of the Map class. /// Initializes a new instance of the Map class.
/// </summary> /// </summary>
/// <param name="background">The background of the map.</param> /// <param name="background">The background of the map.</param>
public Map(string background) public Map(string name, string background)
{ {
Name = name;
Background = background;
Boards = new ReadOnlyObservableCollection<Cell>(board); Boards = new ReadOnlyObservableCollection<Cell>(board);
InitializeBoards(board); InitializeBoards(board);
Background = background;
OperationGrid = new ReadOnlyObservableCollection<OperationCell>(operationGrid); OperationGrid = new ReadOnlyObservableCollection<OperationCell>(operationGrid);
InitializeOperationGrid(operationGrid); InitializeOperationGrid(operationGrid);
RopePaths = new List<List<Cell>>(); RopePaths = new List<List<Cell>>();

@ -33,9 +33,9 @@ namespace Stub
public void LoadMap() public void LoadMap()
{ {
listmap.Add(new Map("profile.jpg")); listmap.Add(new Map("Dunai","profile.jpg"));
listmap.Add(new Map("montagne1.png")); listmap.Add(new Map("Kagkot","montagne1.png"));
listmap.Add(new Map("tmp1.jpeg")); listmap.Add(new Map("Dhaulagiri","tmp1.jpeg"));
} }
public void Add(string pseudo, string profilePicture) public void Add(string pseudo, string profilePicture)

@ -68,7 +68,7 @@ public class GameTests
[Fact] [Fact]
public void AddMap_ShouldAddMapToList() public void AddMap_ShouldAddMapToList()
{ {
var map = new Map("test_background.png"); var map = new Map("test_name", "test_background.png");
_game.AddMap(map); _game.AddMap(map);
@ -90,7 +90,7 @@ public class GameTests
{ {
var players = new ObservableCollection<Player> { new Player("test", "DefaultProfilePicture") }; var players = new ObservableCollection<Player> { new Player("test", "DefaultProfilePicture") };
var games = new ObservableCollection<Game> { new Game(_mockPersistence.Object) }; var games = new ObservableCollection<Game> { new Game(_mockPersistence.Object) };
var maps = new ObservableCollection<Map> { new Map("test_background") }; var maps = new ObservableCollection<Map> { new Map("test_name", "test_background.png") };
var bestScores = new ObservableCollection<BestScore> { new BestScore(1, 26) }; var bestScores = new ObservableCollection<BestScore> { new BestScore(1, 26) };
_mockPersistence.Setup(p => p.LoadData()).Returns((players, games, maps, bestScores)); _mockPersistence.Setup(p => p.LoadData()).Returns((players, games, maps, bestScores));
@ -115,7 +115,7 @@ public class GameTests
public void InitializeGame_ShouldInitializeGameAndNotTriggerEventWhenNotStarted() public void InitializeGame_ShouldInitializeGameAndNotTriggerEventWhenNotStarted()
{ {
var player = new Player("test_player", "DefaultProfilePicture"); var player = new Player("test_player", "DefaultProfilePicture");
var map = new Map("test_background"); var map = new Map("test_name", "test_background.png");
bool eventTriggered = false; bool eventTriggered = false;
_game.GameStarted += (sender, args) => _game.GameStarted += (sender, args) =>
@ -134,7 +134,7 @@ public class GameTests
public void InitializeGame_ShouldInitializeGameAndTriggerEventWhenStarted() public void InitializeGame_ShouldInitializeGameAndTriggerEventWhenStarted()
{ {
var player = new Player("test_player", "DefaultProfilePicture"); var player = new Player("test_player", "DefaultProfilePicture");
var map = new Map("test_background"); var map = new Map("test_name", "test_background.png");
bool eventTriggered = false; bool eventTriggered = false;
_game.GameEnded += (sender, args) => _game.GameEnded += (sender, args) =>
@ -158,7 +158,7 @@ public class GameTests
public void HandlePlayerOperation_ShouldPerformCorrectOperationAndTriggerEvent(Operation operation, int value1, int value2, int expectedResult) public void HandlePlayerOperation_ShouldPerformCorrectOperationAndTriggerEvent(Operation operation, int value1, int value2, int expectedResult)
{ {
var player = new Player("test_player", "DefaultProfilePicture"); var player = new Player("test_player", "DefaultProfilePicture");
var map = new Map("background"); var map = new Map("test_name", "test_background.png");
_game.InitializeGame(map, player, false); _game.InitializeGame(map, player, false);
bool eventTriggered = false; bool eventTriggered = false;
@ -184,7 +184,7 @@ public class GameTests
public void Game_Initialization_SetsMap() public void Game_Initialization_SetsMap()
{ {
var player = new Player("test_player", "DefaultProfilePicture"); var player = new Player("test_player", "DefaultProfilePicture");
var map = new Map("background"); var map = new Map("test_name", "test_background.png");
_game.InitializeGame(map, player); _game.InitializeGame(map, player);
@ -195,7 +195,7 @@ public class GameTests
public void Game_Initialization_SetsPlayer() public void Game_Initialization_SetsPlayer()
{ {
var player = new Player("test_player", "DefaultProfilePicture"); var player = new Player("test_player", "DefaultProfilePicture");
var map = new Map("background"); var map = new Map("test_name", "test_background.png");
_game.InitializeGame(map, player); _game.InitializeGame(map, player);
@ -206,7 +206,7 @@ public class GameTests
public void Game_Initialization_SetsDice() public void Game_Initialization_SetsDice()
{ {
Player player = new Player("test_player", "DefaultProfilePicture"); Player player = new Player("test_player", "DefaultProfilePicture");
Map map = new Map("test_background"); Map map = new Map("test_name", "test_background.png");
_game.InitializeGame(map, player); _game.InitializeGame(map, player);
@ -226,7 +226,7 @@ public class GameTests
public void MarkOperationAsChecked_Check_Well() public void MarkOperationAsChecked_Check_Well()
{ {
var player = new Player("test_player", "DefaultProfilePicture"); var player = new Player("test_player", "DefaultProfilePicture");
var map = new Map("test_background"); var map = new Map("test_name", "test_background.png");
_game.InitializeGame(map, player); _game.InitializeGame(map, player);
@ -260,7 +260,7 @@ public class GameTests
public void IsPlaceOperationCorrect() public void IsPlaceOperationCorrect()
{ {
var player = new Player("test_player", "DefaultProfilePicture"); var player = new Player("test_player", "DefaultProfilePicture");
var map = new Map("test_background"); var map = new Map("test_name", "test_background.png");
_game.InitializeGame(map, player); _game.InitializeGame(map, player);
Assert.NotNull(_game.GameRules); Assert.NotNull(_game.GameRules);
@ -281,7 +281,7 @@ public class GameTests
public void IsHandlePlayerChoice_Handling() public void IsHandlePlayerChoice_Handling()
{ {
var player = new Player("test_player", "DefaultProfilePicture"); var player = new Player("test_player", "DefaultProfilePicture");
var map = new Map("test_background"); var map = new Map("test_name", "test_background.png");
_game.InitializeGame(map, player); _game.InitializeGame(map, player);
@ -295,7 +295,7 @@ public class GameTests
public void IsHandlePlayerChoice_InvalidCell() public void IsHandlePlayerChoice_InvalidCell()
{ {
var player = new Player("test_player", "DefaultProfilePicture"); var player = new Player("test_player", "DefaultProfilePicture");
var map = new Map("test_background"); var map = new Map("test_name", "test_background.png");
_game.InitializeGame(map, player); _game.InitializeGame(map, player);
@ -309,7 +309,7 @@ public class GameTests
public void IsHandlePlayerChoice_InvalidPlace() public void IsHandlePlayerChoice_InvalidPlace()
{ {
var player = new Player("test_player", "DefaultProfilePicture"); var player = new Player("test_player", "DefaultProfilePicture");
var map = new Map("test_background"); var map = new Map("test_name", "test_background.png");
_game.InitializeGame(map, player); _game.InitializeGame(map, player);
@ -324,7 +324,7 @@ public class GameTests
public void ShouldTriggerEventWhenEnded() public void ShouldTriggerEventWhenEnded()
{ {
var player = new Player("test_player", "DefaultProfilePicture"); var player = new Player("test_player", "DefaultProfilePicture");
var map = new Map("test_background"); var map = new Map("test_name", "test_background.png");
bool eventTriggered = false; bool eventTriggered = false;
_game.GameEnded += (sender, args) => _game.GameEnded += (sender, args) =>

@ -8,9 +8,10 @@ public class MapTests
[Fact] [Fact]
public void Map_Initialization_SetsBackground() public void Map_Initialization_SetsBackground()
{ {
string name = "test_name";
string background = "test_background"; string background = "test_background";
var map = new Map(background); var map = new Map(name,background);
Assert.Equal(background, map.Background); Assert.Equal(background, map.Background);
} }
@ -18,10 +19,11 @@ public class MapTests
[Fact] [Fact]
public void Map_Initialization_InitializesBoards() public void Map_Initialization_InitializesBoards()
{ {
string name = "test_name";
string background = "test_background"; string background = "test_background";
var map = new Map(background); var map = new Map(name, background);
Assert.Equal(49, map.Boards.Count); Assert.Equal(49, map.Boards.Count);
for (int i = 0; i < 36; i++) for (int i = 0; i < 36; i++)
{ {
@ -32,10 +34,11 @@ public class MapTests
[Fact] [Fact]
public void Map_Initialization_InitializesRopePathsAndZones() public void Map_Initialization_InitializesRopePathsAndZones()
{ {
string name = "test_name";
string background = "test_background"; string background = "test_background";
var map = new Map(background); var map = new Map(name, background);
Assert.NotNull(map.RopePaths); Assert.NotNull(map.RopePaths);
Assert.NotNull(map.Zones); Assert.NotNull(map.Zones);
Assert.Empty(map.RopePaths); Assert.Empty(map.RopePaths);

@ -33,7 +33,7 @@ public class RulesTests
public void IsCellValid_ReturnsFalse_WhenCellIsNotEmptyAndHasAdjacentCells() public void IsCellValid_ReturnsFalse_WhenCellIsNotEmptyAndHasAdjacentCells()
{ {
Rules rules = new Rules(); Rules rules = new Rules();
Map map = new Map("background"); Map map = new Map("test", "background");
Cell selectedCell = map.Boards[0]; Cell selectedCell = map.Boards[0];
selectedCell.Value = 5; selectedCell.Value = 5;
Assert.False(rules.IsCellValid(selectedCell, map.Boards.ToList())); Assert.False(rules.IsCellValid(selectedCell, map.Boards.ToList()));
@ -43,7 +43,7 @@ public class RulesTests
public void IsCellValid_ReturnsTrue_WhenCellIsEmptyAndHasAdjacentCells() public void IsCellValid_ReturnsTrue_WhenCellIsEmptyAndHasAdjacentCells()
{ {
Rules rules = new Rules(); Rules rules = new Rules();
Map map = new Map("background"); Map map = new Map("test", "background");
Cell selectedCell = map.Boards[0]; Cell selectedCell = map.Boards[0];
Assert.True(rules.IsCellValid(selectedCell, map.Boards.ToList())); Assert.True(rules.IsCellValid(selectedCell, map.Boards.ToList()));
} }
@ -81,7 +81,7 @@ public class RulesTests
Rules rules = new Rules(); Rules rules = new Rules();
Cell cell1 = new Cell(0, 0); Cell cell1 = new Cell(0, 0);
Cell cell2 = new Cell(0, 1); Cell cell2 = new Cell(0, 1);
Map map = new Map("background"); Map map = new Map("test", "background");
map.RopePaths.Add(new List<Cell> { cell1, cell2 }); map.RopePaths.Add(new List<Cell> { cell1, cell2 });
Assert.True(rules.IsInRopePaths(cell2, map.RopePaths, 0)); Assert.True(rules.IsInRopePaths(cell2, map.RopePaths, 0));
} }
@ -92,7 +92,7 @@ public class RulesTests
Rules rules = new Rules(); Rules rules = new Rules();
Cell cell1 = new Cell(0, 0); Cell cell1 = new Cell(0, 0);
Cell cell2 = new Cell(0, 1); Cell cell2 = new Cell(0, 1);
Map map = new Map("background"); Map map = new Map("test", "background");
map.RopePaths.Add(new List<Cell> { cell1 }); map.RopePaths.Add(new List<Cell> { cell1 });
Assert.False(rules.IsInRopePaths(cell2, map.RopePaths, 0)); Assert.False(rules.IsInRopePaths(cell2, map.RopePaths, 0));
} }
@ -103,7 +103,7 @@ public class RulesTests
Rules rules = new Rules(); Rules rules = new Rules();
Cell cell1 = new Cell(0, 0); Cell cell1 = new Cell(0, 0);
Cell cell2 = new Cell(0, 1); Cell cell2 = new Cell(0, 1);
Map map = new Map("background"); Map map = new Map("test", "background");
map.RopePaths.Add(new List<Cell> { cell1 }); map.RopePaths.Add(new List<Cell> { cell1 });
map.RopePaths.Add(new List<Cell> { cell2 }); map.RopePaths.Add(new List<Cell> { cell2 });
Assert.True(rules.IsInRopePaths(cell2, map.RopePaths, 0)); Assert.True(rules.IsInRopePaths(cell2, map.RopePaths, 0));
@ -117,7 +117,7 @@ public class RulesTests
Cell cell2 = new Cell(0, 1); Cell cell2 = new Cell(0, 1);
cell1.Value = 5; cell1.Value = 5;
cell2.Value = 5; cell2.Value = 5;
Map map = new Map("background"); Map map = new Map("test", "background");
map.RopePaths.Add(new List<Cell> { cell1, cell2 }); map.RopePaths.Add(new List<Cell> { cell1, cell2 });
Assert.True(rules.AsValue(cell2, map.RopePaths, 0)); Assert.True(rules.AsValue(cell2, map.RopePaths, 0));
} }
@ -130,7 +130,7 @@ public class RulesTests
Cell cell2 = new Cell(0, 1); Cell cell2 = new Cell(0, 1);
cell1.Value = 5; cell1.Value = 5;
cell2.Value = 5; cell2.Value = 5;
Map map = new Map("background"); Map map = new Map("test", "background");
map.RopePaths.Add(new List<Cell> { cell1 }); map.RopePaths.Add(new List<Cell> { cell1 });
Assert.True(rules.AsValue(cell2, map.RopePaths, 0)); Assert.True(rules.AsValue(cell2, map.RopePaths, 0));
} }
@ -143,7 +143,7 @@ public class RulesTests
Cell cell2 = new Cell(0, 1); Cell cell2 = new Cell(0, 1);
cell1.Value = 5; cell1.Value = 5;
cell2.Value = 6; cell2.Value = 6;
Map map = new Map("background"); Map map = new Map("test", "background");
map.RopePaths.Add(new List<Cell> { cell1 }); map.RopePaths.Add(new List<Cell> { cell1 });
Assert.False(rules.AsValue(cell2, map.RopePaths, 0)); Assert.False(rules.AsValue(cell2, map.RopePaths, 0));
} }
@ -187,7 +187,7 @@ public class RulesTests
public void IsZoneValidAndAddToZones_DoesNothing_WhenCellIsNull() public void IsZoneValidAndAddToZones_DoesNothing_WhenCellIsNull()
{ {
Rules rules = new Rules(); Rules rules = new Rules();
Map map = new Map("background"); Map map = new Map("test", "background");
rules.IsZoneValidAndAddToZones(null, map); rules.IsZoneValidAndAddToZones(null, map);
Assert.Empty(map.Zones); Assert.Empty(map.Zones);
} }
@ -196,7 +196,7 @@ public class RulesTests
public void IsZoneValidAndAddToZones_DoesNothing_WhenCellValueIsNull() public void IsZoneValidAndAddToZones_DoesNothing_WhenCellValueIsNull()
{ {
Rules rules = new Rules(); Rules rules = new Rules();
Map map = new Map("background"); Map map = new Map("test", "background");
Cell cell = new Cell(0, 0); Cell cell = new Cell(0, 0);
rules.IsZoneValidAndAddToZones(cell, map); rules.IsZoneValidAndAddToZones(cell, map);
Assert.Empty(map.Zones); Assert.Empty(map.Zones);
@ -375,7 +375,7 @@ public class RulesTests
public void NewZoneIsCreated_DoesNothing_WhenFirstCellIsNull() public void NewZoneIsCreated_DoesNothing_WhenFirstCellIsNull()
{ {
Rules rules = new Rules(); Rules rules = new Rules();
Map map = new Map("background"); Map map = new Map("test", "background");
rules.NewZoneIsCreated(null, new Cell(0, 0), map); rules.NewZoneIsCreated(null, new Cell(0, 0), map);
Assert.Empty(map.Zones); Assert.Empty(map.Zones);
} }
@ -384,7 +384,7 @@ public class RulesTests
public void NewZoneIsCreated_DoesNothing_WhenSecondCellIsNull() public void NewZoneIsCreated_DoesNothing_WhenSecondCellIsNull()
{ {
Rules rules = new Rules(); Rules rules = new Rules();
Map map = new Map("background"); Map map = new Map("test", "background");
rules.NewZoneIsCreated(new Cell(0, 0), null, map); rules.NewZoneIsCreated(new Cell(0, 0), null, map);
Assert.Empty(map.Zones); Assert.Empty(map.Zones);
} }
@ -393,7 +393,7 @@ public class RulesTests
public void NewZoneIsCreated_DoesNothing_WhenFirstCellValueIsNull() public void NewZoneIsCreated_DoesNothing_WhenFirstCellValueIsNull()
{ {
Rules rules = new Rules(); Rules rules = new Rules();
Map map = new Map("background"); Map map = new Map("test", "background");
Cell firstCell = new Cell(0, 0); Cell firstCell = new Cell(0, 0);
rules.NewZoneIsCreated(firstCell, new Cell(0, 1), map); rules.NewZoneIsCreated(firstCell, new Cell(0, 1), map);
Assert.Empty(map.Zones); Assert.Empty(map.Zones);
@ -403,7 +403,7 @@ public class RulesTests
public void NewZoneIsCreated_DoesNothing_WhenSecondCellValueIsNull() public void NewZoneIsCreated_DoesNothing_WhenSecondCellValueIsNull()
{ {
Rules rules = new Rules(); Rules rules = new Rules();
Map map = new Map("background"); Map map = new Map("test", "background");
Cell secondCell = new Cell(0, 0); Cell secondCell = new Cell(0, 0);
rules.NewZoneIsCreated(new Cell(0, 1), secondCell, map); rules.NewZoneIsCreated(new Cell(0, 1), secondCell, map);
Assert.Empty(map.Zones); Assert.Empty(map.Zones);
@ -413,7 +413,7 @@ public class RulesTests
public void NewZoneIsCreated_CreatesNewZone_WhenBothCellsAreNotNullAndHaveValues() public void NewZoneIsCreated_CreatesNewZone_WhenBothCellsAreNotNullAndHaveValues()
{ {
Rules rules = new Rules(); Rules rules = new Rules();
Map map = new Map("background"); Map map = new Map("test", "background");
Cell firstCell = new Cell(0, 0); Cell firstCell = new Cell(0, 0);
firstCell.Value = 1; firstCell.Value = 1;
Cell secondCell = new Cell(0, 1); Cell secondCell = new Cell(0, 1);

@ -37,9 +37,9 @@ namespace Trek_12
/* Add the permanent maps if they are not already in the game */ /* Add the permanent maps if they are not already in the game */
if (Manager.Maps.Count == 0) if (Manager.Maps.Count == 0)
{ {
Manager.AddMap(new Map("profile.jpg")); Manager.AddMap(new Map("Dunai","profile.jpg"));
Manager.AddMap(new Map("montagne1.png")); Manager.AddMap(new Map("Kagkot","montagne1.png"));
Manager.AddMap(new Map("tmp1.jpeg")); Manager.AddMap(new Map("Dhaulagiri","tmp1.jpeg"));
} }

@ -26,7 +26,7 @@
VerticalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"
x:Name="Frame"> x:Name="Frame">
<Grid RowDefinitions="auto,*"> <Grid RowDefinitions="auto,*">
<Label Text="{Binding Background}" <Label Text="{Binding Name}"
FontAttributes="Bold" FontAttributes="Bold"
FontSize="18" FontSize="18"
HorizontalOptions="Center" HorizontalOptions="Center"

Loading…
Cancel
Save