requriments dellete and new

jimFirstDesign
jim 6 years ago
parent 5a0d937158
commit 3465f1852b

@ -1,8 +1,8 @@
package de.banananetwork.dsa.characters;
import de.banananetwork.dsa.Regulations;
import de.banananetwork.dsa.aspects.Aspect;
import de.banananetwork.dsa.cultures.Culture;
import de.banananetwork.dsa.modifications.Modification;
import de.banananetwork.dsa.professions.Profession;
import de.banananetwork.dsa.species.Species;
@ -17,7 +17,7 @@ public class Character {
Species species;
Culture culture;
Profession profession;
List<Modification> modifications;
List<Aspect> modifications;
// TODO Skills
// TODO Zauber
// TODO Liturgen

@ -1,78 +1,5 @@
package de.banananetwork.dsa.requirements;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Supplier;
public abstract class Requirement {
public abstract RequirementCheckResult checkOn(Character character);
private static class SingleRequirement extends Requirement {
}
private static class CombinedRequirement extends Requirement {
private final RequirementLink requirementLink;
private final Requirement[] requirements;
private CombinedRequirement(RequirementLink requirementLink, Requirement[] requirements) {
this.requirementLink = requirementLink;
this.requirements = requirements;
}
@Override
public RequirementCheckResult checkOn(Character character) {
return null;
}
}
public static class Builder {
private final List<Supplier<Requirement>> requirements = new ArrayList<>();
private RequirementLink requirementLink;
public Builder(RequirementLink requirementLink) {
this.requirementLink = requirementLink;
}
Builder add(Supplier<Requirement> requirementSupplier) {
this.requirements.add(requirementSupplier);
return this;
}
public Builder add(Requirement requirement) {
return this.add(() -> requirement);
}
public Builder add(Builder requirement) {
return this.add(requirement::create);
}
private Builder addAll(Collection<Supplier<Requirement>> requirements) {
this.requirements.addAll(requirements);
return this;
}
public Builder addAll(Builder requirements) {
return this.addAll(requirements.requirements);
}
private Requirement create() {
switch (this.requirements.size()) {
case 0:
throw new IllegalStateException();
case 1:
return this.requirements.get(0).get();
default:
return new CombinedRequirement(this.requirementLink, this.requirements.stream().map(Supplier::get).toArray(Requirement[]::new));
}
}
}
public interface Requirement {
boolean checkCorrect();
}

@ -1,43 +0,0 @@
package de.banananetwork.dsa.requirements;
public abstract class RequirementCheckResult {
private final Requirement requirement;
private RequirementCheckResult(Requirement requirement) {
this.requirement = requirement;
}
public Requirement getRequirement() {
return requirement;
}
public enum State {
ACCEPTED(0), WARNING(1), ERROR(2);
private final int priority;
State(int priority) {
this.priority = priority;
}
public State combine(State state) {
return state.priority > this.priority ? state : this;
}
}
private static class SingleResult extends RequirementCheckResult {
}
private static class CombinedResult extends RequirementCheckResult {
RequirementCheckResult[] results;
}
}

@ -1,5 +0,0 @@
package de.banananetwork.dsa.requirements;
public enum RequirementLink {
AND, OR
}
Loading…
Cancel
Save