/// <summary> /// Effectuer le mouvement d'un aventurier sur la carte /// </summary> /// <param name="adventurer">Aventurier</param> /// <param name="map">Carte aux trésors</param> /// <param name="moveToProcess">Mouvement à traiter</param> public static void ProcessAdventurerMove(Adventurer adventurer, Map map, char moveToProcess) { switch (moveToProcess) { case 'A': if (AdventurerCanMoveForward(adventurer, map)) { adventurer.MoveForward(); Cell currentCell = map?.Cells.FirstOrDefault(c => c.X == adventurer.X && c.Y == adventurer.Y); if (currentCell?.Type == CellType.Treasure) { adventurer.PickTreasure(); currentCell.DecrementTreasure(); } } break; case 'D': adventurer.TurnRight(); break; case 'G': adventurer.TurnLeft(); break; } }
public void TestPickTreasure() { Adventurer adventurer = new Adventurer(); adventurer.PickTreasure(); Assert.AreEqual(1, adventurer?.CollectedTreasure); }