-
Notifications
You must be signed in to change notification settings - Fork 73
/
ChoiceControl.java
9210 lines (8322 loc) · 344 KB
/
ChoiceControl.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package net.sourceforge.kolmafia.session;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.kolmafia.AdventureResult;
import net.sourceforge.kolmafia.AscensionClass;
import net.sourceforge.kolmafia.EdServantData;
import net.sourceforge.kolmafia.KoLAdventure;
import net.sourceforge.kolmafia.KoLCharacter;
import net.sourceforge.kolmafia.KoLConstants;
import net.sourceforge.kolmafia.KoLConstants.MafiaState;
import net.sourceforge.kolmafia.KoLmafia;
import net.sourceforge.kolmafia.Modifiers;
import net.sourceforge.kolmafia.Modifiers.Modifier;
import net.sourceforge.kolmafia.Modifiers.ModifierList;
import net.sourceforge.kolmafia.RequestLogger;
import net.sourceforge.kolmafia.RequestThread;
import net.sourceforge.kolmafia.VYKEACompanionData;
import net.sourceforge.kolmafia.combat.MonsterStatusTracker;
import net.sourceforge.kolmafia.moods.HPRestoreItemList;
import net.sourceforge.kolmafia.moods.MPRestoreItemList;
import net.sourceforge.kolmafia.objectpool.AdventurePool;
import net.sourceforge.kolmafia.objectpool.EffectPool;
import net.sourceforge.kolmafia.objectpool.FamiliarPool;
import net.sourceforge.kolmafia.objectpool.ItemPool;
import net.sourceforge.kolmafia.objectpool.OutfitPool;
import net.sourceforge.kolmafia.persistence.AdventureDatabase;
import net.sourceforge.kolmafia.persistence.ConcoctionDatabase;
import net.sourceforge.kolmafia.persistence.DateTimeManager;
import net.sourceforge.kolmafia.persistence.DebugDatabase;
import net.sourceforge.kolmafia.persistence.ItemDatabase;
import net.sourceforge.kolmafia.persistence.MonsterDatabase.Element;
import net.sourceforge.kolmafia.persistence.MonsterDatabase.Phylum;
import net.sourceforge.kolmafia.persistence.QuestDatabase;
import net.sourceforge.kolmafia.persistence.QuestDatabase.Quest;
import net.sourceforge.kolmafia.persistence.SkillDatabase;
import net.sourceforge.kolmafia.preferences.Preferences;
import net.sourceforge.kolmafia.request.AdventureRequest;
import net.sourceforge.kolmafia.request.ApiRequest;
import net.sourceforge.kolmafia.request.ArcadeRequest;
import net.sourceforge.kolmafia.request.BeachCombRequest;
import net.sourceforge.kolmafia.request.CampgroundRequest;
import net.sourceforge.kolmafia.request.CampgroundRequest.Mushroom;
import net.sourceforge.kolmafia.request.CargoCultistShortsRequest;
import net.sourceforge.kolmafia.request.DeckOfEveryCardRequest;
import net.sourceforge.kolmafia.request.DecorateTentRequest;
import net.sourceforge.kolmafia.request.EatItemRequest;
import net.sourceforge.kolmafia.request.EdBaseRequest;
import net.sourceforge.kolmafia.request.EquipmentRequest;
import net.sourceforge.kolmafia.request.FloristRequest;
import net.sourceforge.kolmafia.request.GenericRequest;
import net.sourceforge.kolmafia.request.GenieRequest;
import net.sourceforge.kolmafia.request.LatteRequest;
import net.sourceforge.kolmafia.request.LocketRequest;
import net.sourceforge.kolmafia.request.MummeryRequest;
import net.sourceforge.kolmafia.request.PantogramRequest;
import net.sourceforge.kolmafia.request.PyramidRequest;
import net.sourceforge.kolmafia.request.QuestLogRequest;
import net.sourceforge.kolmafia.request.SaberRequest;
import net.sourceforge.kolmafia.request.SpaaaceRequest;
import net.sourceforge.kolmafia.request.SpelunkyRequest;
import net.sourceforge.kolmafia.request.SweetSynthesisRequest;
import net.sourceforge.kolmafia.request.TavernRequest;
import net.sourceforge.kolmafia.request.UmbrellaRequest;
import net.sourceforge.kolmafia.request.WildfireCampRequest;
import net.sourceforge.kolmafia.session.ChoiceAdventures.Option;
import net.sourceforge.kolmafia.session.ChoiceAdventures.Spoilers;
import net.sourceforge.kolmafia.textui.command.EdPieceCommand;
import net.sourceforge.kolmafia.textui.command.JurassicParkaCommand;
import net.sourceforge.kolmafia.textui.command.SnowsuitCommand;
import net.sourceforge.kolmafia.utilities.ChoiceUtilities;
import net.sourceforge.kolmafia.utilities.StringUtilities;
public abstract class ChoiceControl {
private static int abooPeakLevel = 0;
public static final Pattern URL_IID_PATTERN = Pattern.compile("iid=(\\d+)");
public static int extractIidFromURL(final String urlString) {
Matcher matcher = URL_IID_PATTERN.matcher(urlString);
return matcher.find() ? StringUtilities.parseInt(matcher.group(1)) : -1;
}
public static final Pattern URL_QTY_PATTERN = Pattern.compile("qty=(\\d+)");
public static int extractQtyFromURL(final String urlString) {
Matcher matcher = URL_QTY_PATTERN.matcher(urlString);
return matcher.find() ? StringUtilities.parseInt(matcher.group(1)) : -1;
}
private static final Pattern TELEGRAM_PATTERN = Pattern.compile("value=\"RE: (.*?)\"");
public static final void preChoice(final GenericRequest request) {
switch (ChoiceManager.lastChoice) {
// Wheel In the Sky Keep on Turning: Muscle Position
case 9:
Preferences.setString(
"currentWheelPosition",
ChoiceManager.lastDecision == 1
? "mysticality"
: ChoiceManager.lastDecision == 2 ? "moxie" : "muscle");
break;
// Wheel In the Sky Keep on Turning: Mysticality Position
case 10:
Preferences.setString(
"currentWheelPosition",
ChoiceManager.lastDecision == 1
? "map quest"
: ChoiceManager.lastDecision == 2 ? "muscle" : "mysticality");
break;
// Wheel In the Sky Keep on Turning: Map Quest Position
case 11:
Preferences.setString(
"currentWheelPosition",
ChoiceManager.lastDecision == 1
? "moxie"
: ChoiceManager.lastDecision == 2 ? "mysticality" : "map quest");
break;
// Wheel In the Sky Keep on Turning: Moxie Position
case 12:
Preferences.setString(
"currentWheelPosition",
ChoiceManager.lastDecision == 1
? "muscle"
: ChoiceManager.lastDecision == 2 ? "map quest" : "moxie");
break;
// Maidens: disambiguate the Knights
case 89:
AdventureRequest.setNameOverride(
"Knight", ChoiceManager.lastDecision == 1 ? "Knight (Wolf)" : "Knight (Snake)");
break;
// Strung-Up Quartet
case 106:
Preferences.setInteger("lastQuartetAscension", KoLCharacter.getAscensions());
Preferences.setInteger("lastQuartetRequest", ChoiceManager.lastDecision);
if (KoLCharacter.recalculateAdjustments()) {
KoLCharacter.updateStatus();
}
break;
case 123: // At Least It's Not Full Of Trash
if (ChoiceManager.lastDecision == 2) {
// Raise your hands up towards the heavens
// This takes take a turn and advances to the tiles
ResultProcessor.processAdventuresUsed(1);
}
break;
// Start the Island War Quest
case 142:
case 146:
if (ChoiceManager.lastDecision == 3) {
QuestDatabase.setQuestProgress(Quest.ISLAND_WAR, "step1");
Preferences.setString("warProgress", "started");
if (KoLCharacter.inPokefam()) {
// The following is a guess. Since all
// sidequests are open, it is at least
// 458, and surely both sides are equal
Preferences.setInteger("hippiesDefeated", 500);
Preferences.setInteger("fratboysDefeated", 500);
}
}
break;
// The Gong Has Been Bung
case 276:
ResultProcessor.processItem(ItemPool.GONG, -1);
Preferences.setInteger("moleTunnelLevel", 0);
Preferences.setInteger("birdformCold", 0);
Preferences.setInteger("birdformHot", 0);
Preferences.setInteger("birdformRoc", 0);
Preferences.setInteger("birdformSleaze", 0);
Preferences.setInteger("birdformSpooky", 0);
Preferences.setInteger("birdformStench", 0);
break;
// The Horror...
case 611:
// To find which step we're on, look at the responseText from the _previous_ request. This
// should still be in lastResponseText.
abooPeakLevel =
findBooPeakLevel(
ChoiceUtilities.findChoiceDecisionText(1, ChoiceManager.lastResponseText));
// Handle changing the progress level in postChoice1 where we know the result.
break;
// Behind the world there is a door...
case 612:
TurnCounter.stopCounting("Silent Invasion window begin");
TurnCounter.stopCounting("Silent Invasion window end");
TurnCounter.startCounting(35, "Silent Invasion window begin loc=*", "lparen.gif");
TurnCounter.startCounting(40, "Silent Invasion window end loc=*", "rparen.gif");
break;
case 794:
ResultProcessor.removeItem(ItemPool.FUNKY_JUNK_KEY);
break;
case 931:
// Life Ain't Nothin But Witches and Mummies
QuestDatabase.setQuestIfBetter(Quest.CITADEL, "step6");
break;
case 932:
// No Whammies
QuestDatabase.setQuestIfBetter(Quest.CITADEL, "step8");
break;
case 1005: // 'Allo
case 1006: // One Small Step For Adventurer
case 1007: // Twisty Little Passages, All Hedge
case 1008: // Pooling Your Resources
case 1009: // Good Ol' 44% Duck
case 1010: // Another Day, Another Fork
case 1011: // Of Mouseholes and Manholes
case 1012: // The Last Temptation
case 1013: // Mazel Tov!
// Taking any of these takes a turn. We'll eventually
// be informed of that in a charpane/api refresh, but
// that's too late for logging.
ResultProcessor.processAdventuresUsed(1);
break;
case 1023: // Like a Bat into Hell
if (ChoiceManager.lastDecision == 2) {
int edDefeats = Preferences.getInteger("_edDefeats");
int kaCost = edDefeats > 2 ? (int) (Math.pow(2, Math.min(edDefeats - 3, 5))) : 0;
AdventureResult cost = ItemPool.get(ItemPool.KA_COIN, -kaCost);
ResultProcessor.processResult(cost);
KoLCharacter.setLimitMode(LimitMode.NONE);
}
break;
case 1024: // Like a Bat out of Hell
switch (ChoiceManager.lastDecision) {
case 2:
Preferences.setInteger("_edDefeats", 0);
Preferences.setBoolean("edUsedLash", false);
MonsterStatusTracker.reset();
KoLCharacter.setLimitMode(LimitMode.NONE);
break;
case 1:
int edDefeats = Preferences.getInteger("_edDefeats");
int kaCost = edDefeats > 2 ? (int) (Math.pow(2, Math.min(edDefeats - 3, 5))) : 0;
AdventureResult cost = ItemPool.get(ItemPool.KA_COIN, -kaCost);
ResultProcessor.processResult(cost);
KoLCharacter.setLimitMode(LimitMode.NONE);
break;
}
break;
case 1028:
// A Shop
SpelunkyRequest.logShop(ChoiceManager.lastResponseText, ChoiceManager.lastDecision);
break;
case 1085: // Deck of Every Card
if (ChoiceManager.lastDecision == 1) {
Preferences.increment("_deckCardsDrawn", 1, 15, false);
}
break;
case 1086: // Pick a Card
if (ChoiceManager.lastDecision == 1) {
// The extra 1 will be covered in choice 1085
Preferences.increment("_deckCardsDrawn", 4, 15, false);
}
break;
case 1171: // LT&T Office
if (ChoiceManager.lastDecision < 4) {
QuestDatabase.setQuestProgress(Quest.TELEGRAM, QuestDatabase.STARTED);
Preferences.setInteger("lttQuestDifficulty", ChoiceManager.lastDecision);
Preferences.setInteger("lttQuestStageCount", 0);
Matcher matcher = TELEGRAM_PATTERN.matcher(ChoiceManager.lastResponseText);
for (int i = 0; i < ChoiceManager.lastDecision; i++) {
if (!matcher.find()) {
break;
}
}
Preferences.setString("lttQuestName", matcher.group(1));
} else if (ChoiceManager.lastDecision == 5) {
QuestDatabase.setQuestProgress(Quest.TELEGRAM, QuestDatabase.UNSTARTED);
Preferences.setInteger("lttQuestDifficulty", 0);
Preferences.setInteger("lttQuestStageCount", 0);
Preferences.setString("lttQuestName", "");
}
break;
case 1197:
// Travel back to a Delicious Meal
if (ChoiceManager.lastDecision == 1 && !request.getURLString().contains("foodid=0")) {
EatItemRequest.timeSpinnerUsed = true;
}
break;
case 1261:
// Which Door?
if (ChoiceManager.lastResponseText.contains("Boris")) {
Preferences.setString("_villainLairKey", "boris");
} else if (ChoiceManager.lastResponseText.contains("Jarlsberg")) {
Preferences.setString("_villainLairKey", "jarlsberg");
} else if (ChoiceManager.lastResponseText.contains("Sneaky Pete")) {
Preferences.setString("_villainLairKey", "pete");
}
break;
case 1345:
// Blech House
Preferences.setInteger("smutOrcNoncombatProgress", 0);
break;
}
}
public static void postChoice0(int choice, final String urlString, final GenericRequest request) {
String text = request.responseText;
switch (choice) {
case 125: // No Visible Means of Support
if (ChoiceManager.lastChoice == 0) {
// If we are visiting for the first time,
// finish the tiles
DvorakManager.lastTile(text);
}
break;
case 360: // Wumpus Cave
WumpusManager.preWumpus(ChoiceManager.lastDecision);
break;
case 1019: // Bee Rewarded
if (ChoiceManager.lastDecision == 1) {
// This does not contain an "Encounter", so was
// not logged.
RequestLogger.registerLocation("The Black Forest");
}
break;
case 1308:
{
// place.php?whichplace=monorail&action=monorail_downtown
//
// On a Downtown Train
//
// Everything you do at this location uses this choice
// adventure #. As you select options, you stay in the
// same choice, but the available options change.
//
// We must deduce what is happening by looking at the
// response text
if (text.contains("muffin is not yet ready")) {
Preferences.setBoolean("_muffinOrderedToday", true);
// We submitted a choice. If we are buying a muffin,
// remove the muffin tin here, since the response is
// indistinguishable from simply visiting the Breakfast
// Counter with a muffin on order.
//
// Therefore, look at the previous response. If it is
// selling muffins and we jut bought a muffin, remove
// the muffin tin.
if (ChoiceManager.lastResponseText != null
&& ChoiceManager.lastResponseText.contains("Order a blueberry muffin")) {
ResultProcessor.processResult(ItemPool.get(ItemPool.EARTHENWARE_MUFFIN_TIN, -1));
}
}
break;
}
case 1313: // Bastille Battalion
case 1314: // Bastille Battalion (Master of None)
case 1315: // Castle vs. Castle
case 1316: // GAME OVER
case 1317: // A Hello to Arms (Battalion)
case 1318: // Defensive Posturing
case 1319: // Cheese Seeking Behavior
BastilleBattalionManager.preChoice(urlString, request);
break;
case 1451:
// Fire Captain Hagnk
WildfireCampRequest.parseCaptain(text);
break;
case 1452:
// Sprinkler Joe
if (text.contains("Thanks again for your help!")) {
Preferences.setBoolean("wildfireSprinkled", true);
}
break;
case 1453:
// Fracker Dan
if (text.contains("Thanks for the help!")) {
Preferences.setBoolean("wildfireFracked", true);
}
break;
case 1454:
// Cropduster Dusty
if (text.contains("Thanks for helping out.")) {
Preferences.setBoolean("wildfireDusted", true);
}
break;
}
}
private static final Pattern BROKEN_CHAMPAGNE_PATTERN =
Pattern.compile("Looks like it has (\\d+) ounce");
private static final Pattern DAYCARE_RECRUIT_PATTERN =
Pattern.compile("attract (.*?) new children");
private static final Pattern DAYCARE_EQUIPMENT_PATTERN =
Pattern.compile("manage to find (.*?) used");
private static final Pattern DAYCARE_ITEM_PATTERN =
Pattern.compile("<td valign=center>You lose an item: </td>.*?<b>(.*?)</b> \\((.*?)\\)</td>");
private static final Pattern DECEASED_TREE_PATTERN =
Pattern.compile("Looks like it has (.*?) needle");
private static final Pattern DESCID_PATTERN = Pattern.compile("descitem\\((.*?)\\)");
// You toss the space wine off the edge of the floating battlefield and 21 frat boys jump off
// after it.
private static final Pattern FRAT_RATIONING_PATTERN =
Pattern.compile(
"You toss the (.*?) off the edge of the floating battlefield and (\\d+) frat boys? jumps? off after it.");
private static final Pattern GARBAGE_SHIRT_PATTERN =
Pattern.compile("Looks like you can read roughly (\\d+) scrap");
private static final Pattern GERALD_PATTERN =
Pattern.compile("Gerald wants (\\d+)<table>.*?descitem\\((\\d+)\\)");
private static final Pattern GERALDINE_PATTERN =
Pattern.compile("Geraldine wants (\\d+)<table>.*?descitem\\((\\d+)\\)");
private static final Pattern HELLEVATOR_PATTERN =
Pattern.compile(
"the (lobby|first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|eleventh) (button|floor)");
// You toss the mana curds into the crowd. 10 hippies dive onto it, greedily consume it, and pass
// out.
private static final Pattern HIPPY_RATIONING_PATTERN =
Pattern.compile(
"You toss the (.*?) into the crowd. (\\d+) hippies dive onto it, greedily consume it, and pass out.");
// You select a Gold Tier client, Norma "Smelly" Jackson, a hobo from The Oasis.
private static final Pattern GUZZLR_LOCATION_PATTERN =
Pattern.compile(
"You select a (Bronze|Gold|Platinum) Tier client, (.*?), +an? (.*?) from (.*?)\\.<p>");
private static final Pattern ITEMID_PATTERN = Pattern.compile("itemid(\\d+)=(\\d+)");
private static final Pattern ORACLE_QUEST_PATTERN =
Pattern.compile("don't remember leaving any spoons in (.*?)"");
private static final Pattern QTY_PATTERN = Pattern.compile("qty(\\d+)=(\\d+)");
private static final Pattern SAFE_PATTERN = Pattern.compile("find ([\\d,]+) Meat in the safe");
private static final Pattern SKELETON_PATTERN =
Pattern.compile("You defeated <b>(\\d+)</b> skeletons");
private static final Pattern TATTOO_PATTERN =
Pattern.compile("otherimages/sigils/hobotat(\\d+).gif");
private static final Pattern TOSSID_PATTERN = Pattern.compile("tossid=(\\d+)");
private static final Pattern TRASH_PATTERN =
Pattern.compile("must have been (\\d+) pieces of trash");
private static final Pattern UNPERM_PATTERN =
Pattern.compile("Turning (.+)(?: \\(HP\\)) into (\\d+) karma.");
private static final Pattern URL_SKILLID_PATTERN = Pattern.compile("skillid=(\\d+)");
private static final Pattern URL_VOTE_PATTERN = Pattern.compile("local\\[\\]=(\\d)");
private static final Pattern YEARBOOK_TARGET_PATTERN =
Pattern.compile("<b>Results:</b>.*?<b>(.*?)</b>");
private static final String[] FLOORS =
new String[] {
"lobby",
"first",
"second",
"third",
"fourth",
"fifth",
"sixth",
"seventh",
"eighth",
"ninth",
"tenth",
"eleventh",
};
private static final AdventureResult BINDER_CLIP = ItemPool.get(ItemPool.BINDER_CLIP, 1);
private static final AdventureResult MCCLUSKY_FILE = ItemPool.get(ItemPool.MCCLUSKY_FILE, 1);
public static void postChoice1(final String urlString, final GenericRequest request) {
String text = request.responseText;
switch (ChoiceManager.lastChoice) {
case 147:
// Cornered!
int ducks1 =
switch (ChoiceManager.lastDecision) {
case 1 -> AdventurePool.THE_GRANARY;
case 2 -> AdventurePool.THE_BOG;
case 3 -> AdventurePool.THE_POND;
default -> 0;
};
Preferences.setString("duckAreasSelected", String.valueOf(ducks1));
break;
case 148:
// Cornered Again!
int ducks2 =
switch (ChoiceManager.lastDecision) {
case 1 -> AdventurePool.THE_BACK_40;
case 2 -> AdventurePool.THE_FAMILY_PLOT;
default -> 0;
};
Preferences.setString(
"duckAreasSelected", Preferences.getString("duckAreasSelected") + "," + ducks2);
break;
case 149:
// How Many Corners Does this Stupid Barn Have?
int ducks3 =
switch (ChoiceManager.lastDecision) {
case 1 -> AdventurePool.THE_SHADY_THICKET;
case 2 -> AdventurePool.THE_OTHER_BACK_40;
default -> 0;
};
Preferences.setString(
"duckAreasSelected", Preferences.getString("duckAreasSelected") + "," + ducks3);
break;
case 188:
// The Infiltrationist
// Once you're inside the frat house, it's a simple
// matter of making your way down to the basement and
// retrieving Caronch's dentures from the frat boys'
// ridiculous trophy case.
if (ChoiceManager.lastDecision == 3 && text.contains("ridiculous trophy case")) {
ResultProcessor.processResult(ItemPool.get(ItemPool.HOT_WING, -3));
}
break;
case 189:
// O Cap'm, My Cap'm
if (ChoiceManager.lastDecision == 3) {
QuestDatabase.setQuestIfBetter(Quest.NEMESIS, "step26");
}
break;
case 191:
// Chatterboxing
if (ChoiceManager.lastDecision == 2
&& text.contains("find a valuable trinket that looks promising")) {
BanishManager.banishMonster("chatty pirate", BanishManager.Banisher.CHATTERBOXING, true);
}
break;
case 237:
// Big Merv's Protein Shakes
case 238:
// Suddenly Salad!
case 239:
// Sizzling Weasel On a Stick
if (ChoiceManager.lastDecision == 1 && text.contains("You gain")) {
// You spend 20 hobo nickels
AdventureResult cost = ItemPool.get(ItemPool.HOBO_NICKEL, -20);
ResultProcessor.processResult(cost);
// You gain 5 fullness
KoLCharacter.setFullness(KoLCharacter.getFullness() + 5);
}
break;
case 242:
// Arthur Finn's World-Record Homebrew Stout
case 243:
// Mad Jack's Corn Squeezery
case 244:
// Bathtub Jimmy's Gin Mill
if (ChoiceManager.lastDecision == 1 && text.contains("You gain")) {
// You spend 20 hobo nickels
AdventureResult cost = ItemPool.get(ItemPool.HOBO_NICKEL, -20);
ResultProcessor.processResult(cost);
// You gain 5 drunkenness. This will be set
// when we refresh the charpane.
}
break;
case 271:
// Tattoo Shop
case 274:
// Tattoo Redux
if (ChoiceManager.lastDecision == 1) {
Matcher matcher = TATTOO_PATTERN.matcher(request.responseText);
if (matcher.find()) {
int tattoo = StringUtilities.parseInt(matcher.group(1));
AdventureResult cost = ItemPool.get(ItemPool.HOBO_NICKEL, -20 * tattoo);
ResultProcessor.processResult(cost);
}
}
break;
case 298:
// In the Shade
// You carefully plant the packet of seeds, sprinkle it
// with gooey green algae, wait a few days, and then
// you reap what you sow. Sowed. Sew?
if (ChoiceManager.lastDecision == 1 && text.contains("you reap what you sow")) {
ResultProcessor.processResult(ItemPool.get(ItemPool.SEED_PACKET, -1));
ResultProcessor.processResult(ItemPool.get(ItemPool.GREEN_SLIME, -1));
}
break;
case 346:
// Soup For You
case 347:
// Yes, Soup For You...
case 348:
// Souped Up
case 351:
// Beginner's Luck
QuestDatabase.setQuestIfBetter(Quest.PRIMORDIAL, QuestDatabase.STARTED);
break;
case 349:
// The Primordial Directive
// You swam upward, into a brighter and warmer part of the soup
if (ChoiceManager.lastDecision == 1
&& text.contains("a brighter and warmer part of the soup")) {
QuestDatabase.setQuestIfBetter(Quest.PRIMORDIAL, "step1");
}
break;
case 350:
// Soupercharged
if (ChoiceManager.lastDecision == 1 && text.contains("You've fixed me all up")) {
Preferences.setInteger("aminoAcidsUsed", 0);
QuestDatabase.setQuestProgress(Quest.PRIMORDIAL, QuestDatabase.FINISHED);
}
break;
case 354:
// You Can Never Be Too Rich or Too in the Future
ResultProcessor.processResult(ItemPool.get(ItemPool.INDIGO_PARTY_INVITATION, -1));
break;
case 355:
// I'm on the Hunt, I'm After You
ResultProcessor.processResult(ItemPool.get(ItemPool.VIOLET_HUNT_INVITATION, -1));
break;
case 357:
// Painful, Circuitous Logic
ResultProcessor.processResult(ItemPool.get(ItemPool.MECHA_MAYHEM_CLUB_CARD, -1));
break;
case 358:
// Brings All the Boys to the Blue Yard
ResultProcessor.processResult(ItemPool.get(ItemPool.BLUE_MILK_CLUB_CARD, -1));
break;
case 362:
// A Bridge Too Far
ResultProcessor.processResult(ItemPool.get(ItemPool.SPACEFLEET_COMMUNICATOR_BADGE, -1));
break;
case 363:
// Does This Bug You? Does This Bug You?
ResultProcessor.processResult(ItemPool.get(ItemPool.SMUGGLER_SHOT_FIRST_BUTTON, -1));
break;
case 373:
// Choice 373 is Northern Gate
// Krakrox plugged the small stone block he found in
// the basement of the abandoned building into the hole
// on the left side of the gate
if (text.contains("Krakrox plugged the small stone block")) {
ResultProcessor.processResult(ItemPool.get(ItemPool.SMALL_STONE_BLOCK, -1));
}
// Krakrox plugged the little stone block he had found
// in the belly of the giant snake into the hole on the
// right side of the gate
else if (text.contains("Krakrox plugged the little stone block")) {
ResultProcessor.processResult(ItemPool.get(ItemPool.LITTLE_STONE_BLOCK, -1));
}
break;
case 376:
// Choice 376 is Ancient Temple
// You fit the two halves of the stone circle together,
// and slot them into the depression on the door. After
// a moment's pause, a low rumbling becomes audible,
// and then the stone slab lowers into the ground. The
// temple is now open to you, if you are ready to face
// whatever lies inside.
if (text.contains("two halves of the stone circle")) {
ResultProcessor.processResult(ItemPool.get(ItemPool.HALF_STONE_CIRCLE, -1));
ResultProcessor.processResult(ItemPool.get(ItemPool.STONE_HALF_CIRCLE, -1));
}
break;
case 389:
// Choice 389 is The Unbearable Supremeness of Being
// "Of course I understand," Jill says, in fluent
// English. "I learned your language in the past five
// minutes. I know where the element is, but we'll have
// to go offworld to get it. Meet me at the Desert
// Beach Spaceport." And with that, she gives you a
// kiss and scampers off. Homina-homina.
if (text.contains("Homina-homina")) {
ResultProcessor.processResult(ItemPool.get(ItemPool.SUPREME_BEING_GLOSSARY, -1));
QuestDatabase.setQuestProgress(Quest.FUTURE, "step1");
}
break;
case 390:
// Choice 390 is A Winning Pass
// "Um, okay," you say, and stomp off to kill some more time.
if (text.contains("to kill some more time")) {
QuestDatabase.setQuestProgress(Quest.FUTURE, "step2");
}
break;
case 391:
// Choice 391 is OMG KAWAIII
// "Damn it!" you say, and chase after her.
if (text.contains("and chase after her")) {
QuestDatabase.setQuestProgress(Quest.FUTURE, "step3");
}
break;
case 392:
// Choice 392 is The Elements of Surprise . . .
// And as the two of you walk toward the bed, you sense
// your ancestral memories pulling you elsewhere, ever
// elsewhere, because your ancestral memories are
// total, absolute jerks.
if (text.contains("total, absolute jerks")) {
EquipmentManager.discardEquipment(ItemPool.RUBY_ROD);
ResultProcessor.processResult(ItemPool.get(ItemPool.ESSENCE_OF_HEAT, -1));
ResultProcessor.processResult(ItemPool.get(ItemPool.ESSENCE_OF_KINK, -1));
ResultProcessor.processResult(ItemPool.get(ItemPool.ESSENCE_OF_COLD, -1));
ResultProcessor.processResult(ItemPool.get(ItemPool.ESSENCE_OF_STENCH, -1));
ResultProcessor.processResult(ItemPool.get(ItemPool.ESSENCE_OF_FRIGHT, -1));
ResultProcessor.processResult(ItemPool.get(ItemPool.ESSENCE_OF_CUTE, -1));
ResultProcessor.processResult(ItemPool.get(ItemPool.SECRET_FROM_THE_FUTURE, 1));
QuestDatabase.setQuestProgress(Quest.FUTURE, QuestDatabase.FINISHED);
}
break;
case 393:
// The Collector
if (ChoiceManager.lastDecision == 1) {
for (int i = ItemPool.GREEN_PEAWEE_MARBLE; i <= ItemPool.BIG_BUMBOOZER_MARBLE; ++i) {
ResultProcessor.processResult(ItemPool.get(i, -1));
}
}
break;
case 394:
{
// Hellevator Music
// Parse response
Matcher matcher = HELLEVATOR_PATTERN.matcher(text);
if (!matcher.find()) {
break;
}
String floor = matcher.group(1);
for (int mcd = 0; mcd < FLOORS.length; ++mcd) {
if (floor.equals(FLOORS[mcd])) {
String message = "Setting monster level to " + mcd;
RequestLogger.printLine(message);
RequestLogger.updateSessionLog(message);
break;
}
}
break;
}
case 413:
case 414:
case 415:
case 416:
case 417:
case 418:
HaciendaManager.parseRoom(ChoiceManager.lastChoice, ChoiceManager.lastDecision, text);
break;
case 440:
// Puttin' on the Wax
if (ChoiceManager.lastDecision == 1) {
HaciendaManager.parseRecording(urlString, text);
}
break;
case 443:
// Chess Puzzle
if (ChoiceManager.lastDecision == 1) {
// Option 1 is "Play"
RabbitHoleManager.parseChessMove(urlString, text);
}
break;
case 450:
// The Duchess' Cottage
if (ChoiceManager.lastDecision == 1
&& text.contains("Delectable and pulchritudinous!")) { // Option 1 is Feed the Duchess
ResultProcessor.processItem(ItemPool.BEAUTIFUL_SOUP, -1);
ResultProcessor.processItem(ItemPool.LOBSTER_QUA_GRILL, -1);
ResultProcessor.processItem(ItemPool.MISSING_WINE, -1);
ResultProcessor.processItem(ItemPool.WALRUS_ICE_CREAM, -1);
ResultProcessor.processItem(ItemPool.HUMPTY_DUMPLINGS, -1);
}
break;
case 457:
// Oh, No! Five-Oh!
int count = InventoryManager.getCount(ItemPool.ORQUETTES_PHONE_NUMBER);
if (ChoiceManager.lastDecision == 1 && count > 0) {
ResultProcessor.processItem(ItemPool.ORQUETTES_PHONE_NUMBER, -count);
ResultProcessor.processItem(ItemPool.KEGGER_MAP, -1);
}
case 460:
case 461:
case 462:
case 463:
case 464:
case 465:
case 467:
case 468:
case 469:
case 470:
case 472:
case 473:
case 474:
case 475:
case 476:
case 477:
case 478:
case 479:
case 480:
case 481:
case 482:
case 483:
case 484:
// Space Trip
ArcadeRequest.postChoiceSpaceTrip(
request, ChoiceManager.lastChoice, ChoiceManager.lastDecision);
break;
case 471:
// DemonStar
ArcadeRequest.postChoiceDemonStar(request, ChoiceManager.lastDecision);
break;
case 485:
// Fighters Of Fighting
ArcadeRequest.postChoiceFightersOfFighting(request, ChoiceManager.lastDecision);
break;
case 486:
// Dungeon Fist!
ArcadeRequest.postChoiceDungeonFist(request, ChoiceManager.lastDecision);
break;
case 488:
case 489:
case 490:
case 491:
// Meteoid
ArcadeRequest.postChoiceMeteoid(
request, ChoiceManager.lastChoice, ChoiceManager.lastDecision);
break;
case 529:
case 531:
case 532:
case 533:
case 534:
Matcher skeletonMatcher = SKELETON_PATTERN.matcher(text);
if (skeletonMatcher.find()) {
String message = "You defeated " + skeletonMatcher.group(1) + " skeletons";
RequestLogger.printLine(message);
RequestLogger.updateSessionLog(message);
}
break;
case 539:
// Choice 539 is An E.M.U. for Y.O.U.
EquipmentManager.discardEquipment(ItemPool.SPOOKY_LITTLE_GIRL);
break;
case 540:
// Choice 540 is Big-Time Generator - game board
//
// Win:
//
// The generator starts to hum and the well above you
// begins to spin, slowly at first, then faster and
// faster. The humming becomes a deep, sternum-rattling
// thrum, a sub-audio *WHOOMP WHOOMP WHOOMPWHOOMPWHOOMP.*
// Brilliant blue light begins to fill the well, and
// you feel like your bones are turning to either
// powder, jelly, or jelly with powder in it.<p>Then
// you fall through one of those glowy-circle
// transporter things and end up back on Grimace, and
// boy, are they glad to see you! You're not sure where
// one gets ticker-tape after an alien invasion, but
// they seem to have found some.
//
// Lose 3 times:
//
// Your E.M.U.'s getting pretty beaten up from all the
// pinballing between obstacles, and you don't like
// your chances of getting back to the surface if you
// try again. You manage to blast out of the generator
// well and land safely on the surface. After that,
// though, the E.M.U. gives an all-over shudder, a sad
// little servo whine, and falls apart.
if (text.contains("WHOOMP") || text.contains("a sad little servo whine")) {
EquipmentManager.discardEquipment(ItemPool.EMU_UNIT);
QuestDatabase.setQuestIfBetter(Quest.GENERATOR, QuestDatabase.FINISHED);
}
break;
case 542:
// The Now's Your Pants! I Mean... Your Chance!
// Then you make your way back out of the Alley,
// clutching your pants triumphantly and trying really
// hard not to think about how oddly chilly it has
// suddenly become.
// When you steal your pants, they are unequipped, you
// gain a "you acquire" message", and they appear in
// inventory.
//
// Treat this is simply discarding the pants you are
// wearing
if (text.contains("oddly chilly")) {
EquipmentManager.discardEquipment(EquipmentManager.getEquipment(EquipmentManager.PANTS));
QuestDatabase.setQuestProgress(Quest.MOXIE, "step1");
}
break;
case 546:
// Interview With You
VampOutManager.postChoiceVampOut(text);
break;
case 559:
// Fudge Mountain Breakdown
if (ChoiceManager.lastDecision == 2) {
if (text.contains("but nothing comes out")) {
Preferences.setInteger("_fudgeWaspFights", 3);
} else if (text.contains("trouble has taken a holiday")) {
// The Advent Calendar hasn't been punched out enough to find fudgewasps yet
} else {
Preferences.increment("_fudgeWaspFights", 1);
}
}
break;
case 571:
// Choice 571 is Your Minstrel Vamps
QuestDatabase.setQuestProgress(Quest.CLANCY, QuestDatabase.STARTED);
break;
case 572:
// Choice 572 is Your Minstrel Clamps
QuestDatabase.setQuestProgress(Quest.CLANCY, "step2");
break;
case 573:
// Choice 573 is Your Minstrel Stamps
QuestDatabase.setQuestProgress(Quest.CLANCY, "step4");
break;
case 576:
// Choice 576 is Your Minstrel Camps