|
9 | 9 | import util.event.ConfigureClientEvent;
|
10 | 10 | import util.event.DisableAudioEvent;
|
11 | 11 | import util.widget.CachedWidget;
|
| 12 | +import util.widget.filters.WidgetActionFilter; |
12 | 13 |
|
13 | 14 | import java.util.Arrays;
|
14 | 15 | import java.util.Collections;
|
15 | 16 | import java.util.Optional;
|
16 | 17 | import java.util.Random;
|
17 | 18 | import java.util.stream.Collectors;
|
| 19 | +import java.util.stream.Stream; |
18 | 20 |
|
19 | 21 | public final class RuneScapeGuideSection extends TutorialSection {
|
20 | 22 | private enum UsernameCheckStatus {
|
@@ -84,7 +86,7 @@ public final void onLoop() throws InterruptedException {
|
84 | 86 | break;
|
85 | 87 | case 10:
|
86 | 88 | if (!isConfigured) {
|
87 |
| - execute(new ConfigureClientEvent()); |
| 89 | + isConfigured = execute(new ConfigureClientEvent()).hasFinished(); |
88 | 90 | } else if (getObjects().closest("Door").interact("Open")) {
|
89 | 91 | Sleep.sleepUntil(() -> getProgress() != 10, 5000, 600);
|
90 | 92 | }
|
@@ -147,18 +149,20 @@ private void createRandomCharacter() throws InterruptedException {
|
147 | 149 | }
|
148 | 150 |
|
149 | 151 | final RS2Widget[] childWidgets = getWidgets().getWidgets(creationScreenWidget.get(getWidgets()).get().getRootId());
|
150 |
| - Collections.shuffle(Arrays.asList(childWidgets)); |
151 | 152 |
|
152 |
| - for (final RS2Widget childWidget : childWidgets) { |
153 |
| - if (childWidget.getToolTip() == null) { |
154 |
| - continue; |
155 |
| - } |
156 |
| - if (childWidget.getToolTip().contains("Change") || childWidget.getToolTip().contains("Recolour")) { |
157 |
| - clickRandomTimes(childWidget); |
158 |
| - } |
| 153 | + final WidgetActionFilter selectableWidgetActionFilter = new WidgetActionFilter("Select"); |
| 154 | + |
| 155 | + final RS2Widget[] selectableWidgets = Stream.of(childWidgets).filter(selectableWidgetActionFilter::match).toArray(RS2Widget[]::new); |
| 156 | + |
| 157 | + Collections.shuffle(Arrays.asList(selectableWidgets)); |
| 158 | + |
| 159 | + int maxSelection = new Random().nextInt(Math.min(selectableWidgets.length, 15)); |
| 160 | + |
| 161 | + for (int i = 0; i < maxSelection; i ++) { |
| 162 | + clickRandomTimes(selectableWidgets[i]); |
159 | 163 | }
|
160 | 164 |
|
161 |
| - if (getWidgets().getWidgetContainingText("Accept").interact()) { |
| 165 | + if (getWidgets().getWidgetContainingText("Confirm").interact()) { |
162 | 166 | Sleep.sleepUntil(() -> !creationScreenWidget.isVisible(getWidgets()), 3000, 600);
|
163 | 167 | }
|
164 | 168 | }
|
|
0 commit comments