Skip to content

Commit

Permalink
fix bug api upgrade-grid
Browse files Browse the repository at this point in the history
  • Loading branch information
Svvmy committed Jan 7, 2024
1 parent bc5c30c commit 3f0f075
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
4 changes: 4 additions & 0 deletions src/main/java/Classes/DirectionWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
public class DirectionWrapper{
private String direction;


public DirectionWrapper(String direction){
this.direction = direction;
}
public int getDirection() {
return convertStringToInt(direction);
}
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/Classes/Terrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ public class Terrain {
public Terrain() {

grille = new char[][] {
{'P', 'o', 'O', 'F', 'M', '.', '.', '.', '.', '.', '.', '.', '.', 'O', '.'},
{'K', 'M', '.', 'M', 'M', '.', '.', '.', 'M', 'M', '.', 'o', 'M', '.', '.'},
{'K', 'M', 'M', 'O', 'M', 'M', '.', 'M', '.', 'C', '.', '.', '.', 'K', '.'},
{'P', 'o', 'O', 'F', 'M', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
{'.', 'M', '.', 'M', 'M', '.', '.', '.', 'M', 'M', '.', 'o', 'M', '.', '.'},
{'.', 'M', 'M', 'O', 'M', 'M', '.', 'M', '.', '.', '.', '.', '.', '.', '.'},
{'O', '.', 'M', '.', '.', 'M', '.', 'M', '.', '.', 'O', 'M', 'M', 'M', '.'},
{'.', '.', '.', 'B', '.', '.', '.', 'M', 'M', 'M', '.', '.', 'K', 'M', 'M'},
{'B', 'C', 'M', '.', '.', 'M', '.', 'O', 'M', '.', '.', 'M', '.', 'K', 'C'},
{'K', '.', '.', 'O', '.', '.', '.', 'M', '.', 'M', '.', 'M', 'M', 'M', '.'},
{'M', 'M', 'M', '.', 'M', 'B', 'M', 'K', 'M', '.', 'M', 'K', 'M', '.', 'o'},
{'.', '.', 'M', '.', 'M', '.', 'M', '.', 'M', 'o', 'M', '.', '.', 'B', '.'},
{'M', 'M', 'M', '.', '.', '.', 'M', 'M', 'M', '.', '.', 'C', 'M', 'M', '.'},
{'K', 'o', '.', '.', '.', 'B', 'C', '.', 'M', '.', 'O', '.', 'M', '.', '.'},
{'M', 'M', 'M', 'M', 'M', 'M', 'M', 'K', '.', 'C', '.', 'O', 'M', '.', '.'},
{'.', '.', '.', 'M', '.', 'C', '.', '.', '.', 'M', '.', 'M', 'M', 'O', 'C'},
{'C', 'O', '.', 'M', '.', '.', '.', 'B', '.', '.', 'B', 'M', '.', '.', '.'},
{'F', '.', '.', '.', '.', 'M', 'M', 'M', '.', '.', '.', 'o', 'K', 'M', '.'},
{'.', '.', '.', '.', '.', '.', '.', 'M', 'M', 'M', '.', '.', '.', 'M', 'M'},
{'.', '.', 'M', '.', '.', 'M', '.', 'O', 'M', '.', '.', 'M', '.', '.', '.'},
{'.', '.', '.', 'O', '.', '.', '.', 'M', '.', 'M', '.', 'M', 'M', 'M', '.'},
{'M', 'M', 'M', '.', 'M', '.', 'M', '.', 'M', '.', 'M', '.', 'M', '.', 'o'},
{'.', '.', 'M', '.', 'M', '.', 'M', '.', 'M', 'o', 'M', '.', '.', '.', '.'},
{'M', 'M', 'M', '.', '.', '.', 'M', 'M', 'M', '.', '.', '.', 'M', 'M', '.'},
{'.', 'o', '.', '.', '.', '.', '.', '.', 'M', '.', 'O', '.', 'M', '.', '.'},
{'M', 'M', 'M', 'M', 'M', 'M', 'M', '.', '.', '.', '.', 'O', 'M', '.', '.'},
{'.', '.', '.', 'M', '.', '.', '.', '.', '.', 'M', '.', 'M', 'M', 'O', '.'},
{'.', 'O', '.', 'M', '.', '.', '.', '.', '.', '.', '.', 'M', '.', '.', '.'},
{'F', '.', '.', '.', '.', 'M', 'M', 'M', '.', '.', '.', 'o', '.', 'M', '.'},
};

grilleInit = new char[][] {
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/pacman/pacman/controller/GameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ public ResponseEntity<Game> startGame() {
}

@PostMapping("/update-grid")
public ResponseEntity<Game> updateGrid(@RequestBody DirectionWrapper direction) {
public ResponseEntity<Game> updateGrid(@RequestBody String directionData) {
Game currentGame = this.game;

// Mettre à jour la grille avec la nouvelle direction
System.out.println("direction "+direction);
currentGame.updateGrid(direction.getDirection());
DirectionWrapper directionConverter = new DirectionWrapper(directionData);

System.out.println("direction data "+directionData);
// Mettre à jour la grille avec la nouvelle direction
currentGame.updateGrid(directionConverter.getDirection());
System.out.println("direction recu convertit "+directionConverter.getDirection());
return ResponseEntity.ok(currentGame);
}

Expand Down

0 comments on commit 3f0f075

Please sign in to comment.