Skip to content

Commit

Permalink
Add mode classic and multiLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
Svvmy committed Jan 16, 2024
1 parent 2f2d2f4 commit c67cf3b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
21 changes: 19 additions & 2 deletions src/main/java/Classes/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;


//@Scope(value = WebApplicationContext.SCOPE_SESSION)
Expand All @@ -23,9 +24,10 @@ public class Game {
List<Fruit> fruits = new ArrayList<>();
ArrayList<Integer> lastDirections = new ArrayList<>();
private boolean modeSansMur = false;

private boolean collisionEnCours = false;

private String modeJeu;


public Game() {
this.terrain = new Terrain();
Expand Down Expand Up @@ -104,7 +106,13 @@ private void preparerNouveauNiveau() {

public void verifierEtMettreAJourNiveau() {
if (toutesLesBoulesMangees()) {
preparerNouveauNiveau();
if(Objects.equals(this.modeJeu, "MULTI")){
preparerNouveauNiveau();
}else if(Objects.equals(this.modeJeu,"CLASSIC")){
this.isWin = true;
this.started =false;
this.setResult("WIN");
}
}
}
public void demarrerJeu(){
Expand Down Expand Up @@ -300,6 +308,7 @@ public void activeModeSansMur(){

// Vérifie si on a gagne la partie, on l'appel lorsqu'on prépare un nouveau niveau
public void checkWin(){ //TO DO win par niveau ?

if (this.niveauActuel == 3 && this.toutesLesBoulesMangees()){
this.isWin = true;
this.started =false;
Expand All @@ -323,6 +332,14 @@ public String getResult() { // Retouren si on a gagner ou perdu la partie
return this.result;
}

public String getModeJeu(){
return this.modeJeu;
}

public void setModeJeu(String mode){
this.modeJeu = mode;
}

public void setResult(String res){
this.result = res;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ public ResponseEntity<Game> startGame() {
}
//Pour charger la Map avant de lancer le jeu
@PostMapping("/load-map")
public ResponseEntity<Game> loadMap() {
public ResponseEntity<Game> loadMap(@RequestBody String modeJeu) {
Game currentGame = this.game;
currentGame.setModeJeu(modeJeu);
currentGame.initialiserJeu();
return ResponseEntity.ok(currentGame);
}

@GetMapping("/test-deploiement-back")
public String hello() {
return "Déploiement du back a été réalisé avec succès !";
return "Déploiement du back a été réalisé avec succès !V2";
}

// @PostMapping("/update-grid")
Expand Down

0 comments on commit c67cf3b

Please sign in to comment.