Skip to content

Commit

Permalink
makes the tutorial more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
hneemann committed Aug 22, 2019
1 parent fb0b0e4 commit bc3770b
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class InitialTutorial extends JDialog implements CircuitComponent.Tutoria
STEPS.add(new Step("tutorial2", (cc, mod, t) -> contains(cc, In.DESCRIPTION, In.DESCRIPTION)));
STEPS.add(new Step("tutorial3", (cc, mod, t) -> contains(cc, In.DESCRIPTION, In.DESCRIPTION, XOr.DESCRIPTION)));
STEPS.add(new Step("tutorial4", (cc, mod, t) -> contains(cc, In.DESCRIPTION, In.DESCRIPTION, XOr.DESCRIPTION, Out.DESCRIPTION)));
STEPS.add(new Step("tutorial5", (cc, mod, t) -> contains(mod, ModifyInsertWire.class)));
STEPS.add(new Step("tutorial5", (cc, mod, t) -> contains(mod, ModifyInsertWire.class) || isWorking(cc)));
STEPS.add(new Step("tutorial6", (cc, mod, t) -> isWorking(cc)));
STEPS.add(new Step("tutorial7", (cc, mod, t) -> t.main.getModel() != null));
STEPS.add(new Step("tutorial8", (cc, mod, t) -> outputIsHigh(t)));
Expand Down Expand Up @@ -99,10 +99,12 @@ private static boolean isIONamed(CircuitComponent cc, int expected, InitialTutor
}
}
}
return num == expected;
return num >= expected;
}

private static boolean isWorking(CircuitComponent cc) {
if (cc.getCircuit().getElements().size() < 4)
return false;
try {
new ModelCreator(cc.getCircuit(), cc.getLibrary()).createModel(false);
return true;
Expand All @@ -127,7 +129,7 @@ private static boolean contains(Modification<Circuit> mod, Class<? extends Modif

private static boolean contains(CircuitComponent cc, ElementTypeDescription... descriptions) {
ArrayList<VisualElement> el = new ArrayList<>(cc.getCircuit().getElements());
if (el.size() != descriptions.length)
if (el.size() < descriptions.length)
return false;
for (ElementTypeDescription d : descriptions) {
Iterator<VisualElement> it = el.iterator();
Expand Down Expand Up @@ -195,7 +197,10 @@ private void disableTutorial() {
}

private void incIndex() {
stepIndex++;
do {
stepIndex++;
} while (stepIndex < STEPS.size()
&& STEPS.get(stepIndex).getChecker().accomplished(circuitComponent, null, this));
if (stepIndex == STEPS.size()) {
disableTutorial();
} else {
Expand Down

0 comments on commit bc3770b

Please sign in to comment.