Skip to content
Snippets Groups Projects
Commit 0566941c authored by rosier8u's avatar rosier8u
Browse files

implementation de supprimer la dernière commande et de refaire la dernière comm

parent d83fdf93
No related branches found
No related tags found
No related merge requests found
...@@ -18,13 +18,13 @@ public class Invoker { ...@@ -18,13 +18,13 @@ public class Invoker {
} }
public void executeLastCommand(){ public void executeLastCommand(){
commandHistory.get(commandHistory.size()).execute(jeu); commandHistory.get(commandHistory.size()-1).execute(jeu);
} }
public void undoLastCommand() { public void undoLastCommand() {
if (!commandHistory.isEmpty()) { if (!commandHistory.isEmpty()) {
Command lastCommand = commandHistory.remove(commandHistory.size() - 1); commandHistory.remove(commandHistory.size() - 1);
jeu.getEquipe().supprimerLast();
} }
} }
} }
......
...@@ -73,11 +73,20 @@ public class DialogueTerminal { ...@@ -73,11 +73,20 @@ public class DialogueTerminal {
System.out.println("Vous pouvez encore ajouter maximum : "+ System.out.println("Vous pouvez encore ajouter maximum : "+
(Configuration.getInstance().getTailleMaxEquipe()-tailleActuelle)+" personneges."); (Configuration.getInstance().getTailleMaxEquipe()-tailleActuelle)+" personneges.");
System.out.println("Choisissez un personnage à ajouter à l'équipe :"); System.out.println("Choisissez un personnage à ajouter à l'équipe :");
System.out.println("0 : Terminé\n1 : Guerrier\n2 : Roi\n3 : Guerisseur\n4 : Sorcier\n"); if (tailleActuelle == 0){
System.out.println("0 : Terminé\n1 : Guerrier\n2 : Roi\n3 : Guerisseur\n4 : Sorcier\n");
}else {
System.out.println("0 : Terminé\n1 : Guerrier\n2 : Roi\n3 : Guerisseur\n4 : Sorcier\n" +
"5: Le même que précédemment\n6: Supprimer le dernier personnage ajouté\n");
}
choix = Integer.parseInt(scan.nextLine()); choix = Integer.parseInt(scan.nextLine());
if (choix != 0){ if (choix != 0){
ajouterPersonnage(choix); ajouterPersonnage(choix);
tailleActuelle++; if (choix == 6){
tailleActuelle--;
}else {
tailleActuelle++;
}
} }
} }
} }
...@@ -115,6 +124,12 @@ public class DialogueTerminal { ...@@ -115,6 +124,12 @@ public class DialogueTerminal {
case 4: case 4:
invoker.executeCommand(new CommandCreerSorcier()); invoker.executeCommand(new CommandCreerSorcier());
break; break;
case 5:
invoker.executeLastCommand();
break;
case 6:
invoker.undoLastCommand();
break;
} }
} }
......
...@@ -34,6 +34,9 @@ public class Equipe implements Groupe{ ...@@ -34,6 +34,9 @@ public class Equipe implements Groupe{
public void supprimer(Personnage personnage){ public void supprimer(Personnage personnage){
this.equipe.remove(personnage); this.equipe.remove(personnage);
} }
public void supprimerLast(){
this.equipe.remove(equipe.size()-1);
}
public void ajouter(Equipe equipe){ public void ajouter(Equipe equipe){
this.equipe.addAll(equipe.getEquipe()); this.equipe.addAll(equipe.getEquipe());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment