projet-genie-logiciel-systeme/runtime-workspace/fr.n7.game.examples/src-gen/Action.java

58 lines
1.6 KiB
Java
Raw Normal View History

2021-12-09 17:54:08 +00:00
import java.util.List;
public class Action {
2022-01-18 18:49:37 +00:00
String nom;
2021-12-09 17:54:08 +00:00
Condition visible;
List<Connaissance> connaissances;
List<Objet> objetsRecus;
List<Objet> objetsConso;
Condition finInterraction;
List<Description> descriptions;
public Action(
2022-01-18 18:49:37 +00:00
String nom,
2021-12-09 17:54:08 +00:00
Condition visible,
Condition finInterraction,
2021-12-09 17:54:08 +00:00
List<Connaissance> connaissances,
List<Objet> objetsRecus,
List<Objet> objetsConso,
List<Description> descriptions) {
2022-01-18 18:49:37 +00:00
this.nom = nom;
2021-12-09 17:54:08 +00:00
this.visible = visible;
this.connaissances = connaissances;
this.objetsRecus = objetsRecus;
this.objetsConso = objetsConso;
this.finInterraction = finInterraction;
this.descriptions = descriptions;
}
void actionner() {
for (Connaissance c : this.connaissances) {
if (!Jeu.explorateur.connaissances.contains(c)) {
Jeu.explorateur.connaissances.add(c);
}
}
for (Objet o : this.objetsRecus) {
Jeu.explorateur.objets.add(o);
}
for (Objet o : this.objetsConso) {
Jeu.explorateur.objets.remove(o);
}
}
@Override
public String toString() {
for (Description d : this.descriptions) {
if (d.condition.evaluer()) {
return d.toString();
}
}
return "No desc";
}
2022-01-18 18:49:37 +00:00
public static Action search(List<Action> list, String name) {
return list.stream().filter(o -> o.nom.equals(name)).findFirst()
.orElseThrow(() -> new IllegalArgumentException("No data found"));
}
2021-12-09 17:54:08 +00:00
}