-
Notifications
You must be signed in to change notification settings - Fork 73
/
KoLCharacter.java
5663 lines (4835 loc) · 190 KB
/
KoLCharacter.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;
import java.awt.Taskbar;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.IntStream;
import net.java.dev.spellcast.utilities.LockableListModel;
import net.java.dev.spellcast.utilities.SortedListModel;
import net.sourceforge.kolmafia.AscensionPath.Path;
import net.sourceforge.kolmafia.KoLConstants.Stat;
import net.sourceforge.kolmafia.KoLConstants.WeaponType;
import net.sourceforge.kolmafia.KoLConstants.ZodiacType;
import net.sourceforge.kolmafia.KoLConstants.ZodiacZone;
import net.sourceforge.kolmafia.chat.ChatManager;
import net.sourceforge.kolmafia.listener.CharacterListenerRegistry;
import net.sourceforge.kolmafia.listener.NamedListenerRegistry;
import net.sourceforge.kolmafia.listener.PreferenceListenerRegistry;
import net.sourceforge.kolmafia.moods.HPRestoreItemList;
import net.sourceforge.kolmafia.moods.MPRestoreItemList;
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.objectpool.SkillPool;
import net.sourceforge.kolmafia.persistence.*;
import net.sourceforge.kolmafia.persistence.MonsterDatabase.Element;
import net.sourceforge.kolmafia.persistence.QuestDatabase.Quest;
import net.sourceforge.kolmafia.preferences.Preferences;
import net.sourceforge.kolmafia.request.CampgroundRequest;
import net.sourceforge.kolmafia.request.CharPaneRequest;
import net.sourceforge.kolmafia.request.CharPaneRequest.Companion;
import net.sourceforge.kolmafia.request.CharSheetRequest;
import net.sourceforge.kolmafia.request.ChateauRequest;
import net.sourceforge.kolmafia.request.ChezSnooteeRequest;
import net.sourceforge.kolmafia.request.ClanLoungeRequest;
import net.sourceforge.kolmafia.request.DwarfFactoryRequest;
import net.sourceforge.kolmafia.request.EquipmentRequest;
import net.sourceforge.kolmafia.request.FamiliarRequest;
import net.sourceforge.kolmafia.request.FightRequest;
import net.sourceforge.kolmafia.request.FloristRequest;
import net.sourceforge.kolmafia.request.GenericRequest;
import net.sourceforge.kolmafia.request.GuildRequest;
import net.sourceforge.kolmafia.request.HellKitchenRequest;
import net.sourceforge.kolmafia.request.HermitRequest;
import net.sourceforge.kolmafia.request.MicroBreweryRequest;
import net.sourceforge.kolmafia.request.QuantumTerrariumRequest;
import net.sourceforge.kolmafia.request.RelayRequest;
import net.sourceforge.kolmafia.request.SpelunkyRequest;
import net.sourceforge.kolmafia.request.StandardRequest;
import net.sourceforge.kolmafia.request.StorageRequest;
import net.sourceforge.kolmafia.request.TelescopeRequest;
import net.sourceforge.kolmafia.request.UseItemRequest;
import net.sourceforge.kolmafia.request.UseSkillRequest;
import net.sourceforge.kolmafia.session.BanishManager;
import net.sourceforge.kolmafia.session.BatManager;
import net.sourceforge.kolmafia.session.ChoiceManager;
import net.sourceforge.kolmafia.session.ClanManager;
import net.sourceforge.kolmafia.session.ContactManager;
import net.sourceforge.kolmafia.session.CrystalBallManager;
import net.sourceforge.kolmafia.session.DisplayCaseManager;
import net.sourceforge.kolmafia.session.EquipmentManager;
import net.sourceforge.kolmafia.session.EventManager;
import net.sourceforge.kolmafia.session.GoalManager;
import net.sourceforge.kolmafia.session.InventoryManager;
import net.sourceforge.kolmafia.session.Limitmode;
import net.sourceforge.kolmafia.session.LocketManager;
import net.sourceforge.kolmafia.session.ResultProcessor;
import net.sourceforge.kolmafia.session.StoreManager;
import net.sourceforge.kolmafia.session.TurnCounter;
import net.sourceforge.kolmafia.session.VioletFogManager;
import net.sourceforge.kolmafia.session.VolcanoMazeManager;
import net.sourceforge.kolmafia.session.WumpusManager;
import net.sourceforge.kolmafia.session.YouRobotManager;
import net.sourceforge.kolmafia.swingui.AdventureFrame;
import net.sourceforge.kolmafia.swingui.GearChangeFrame;
import net.sourceforge.kolmafia.swingui.MallSearchFrame;
import net.sourceforge.kolmafia.swingui.SkillBuffFrame;
import net.sourceforge.kolmafia.textui.DataFileCache;
import net.sourceforge.kolmafia.textui.command.EudoraCommand.Correspondent;
import net.sourceforge.kolmafia.utilities.FileUtilities;
import net.sourceforge.kolmafia.utilities.LockableListFactory;
import net.sourceforge.kolmafia.webui.DiscoCombatHelper;
/**
* A container class representing the <code>KoLCharacter</code>. This class also allows for data
* listeners that are updated whenever the character changes; ultimately, the purpose of this class
* is to shift away from the centralized-notification paradigm (inefficient) towards a listener
* paradigm, which is both cleaner and easier to manage with regards to extensions. In addition, it
* loosens the coupling between the various aspects of <code>KoLmafia</code>, leading to
* extensibility.
*/
public abstract class KoLCharacter {
public static final String WAR_BLESSING = "War";
public static final String STORM_BLESSING = "Storm";
public static final String SHE_WHO_WAS_BLESSING = "She-who-was";
public static final int MALE = -1;
public static final int FEMALE = 1;
// Create this early before subsequent initializers want to look at it.
private static final Modifiers currentModifiers = new Modifiers();
// Things that cannot be changed
private static String username = "";
private static int userId = 0;
private static String playerId = "0";
// Ascension-related variables
private static boolean isHardcore = false;
private static boolean isCasual = false;
private static boolean inRonin = true;
private static boolean skillsRecalled = false;
private static boolean restricted = false;
private static int ascensions = 0;
private static ZodiacSign ascensionSign = ZodiacSign.NONE;
private static Path ascensionPath = Path.NONE;
// Things which can change over the course of playing
private static List<String> avatar = Collections.emptyList();
private static AscensionClass ascensionClass = null;
private static int gender = 0;
public static int AWOLtattoo = 0;
private static int currentLevel = 1;
private static long decrementPrime = 0;
private static long incrementPrime = 25;
private static long currentHP, maximumHP, baseMaxHP;
private static long currentMP, maximumMP, baseMaxMP;
// Plumbers only
private static int currentPP, maximumPP;
// Robots only
private static int youRobotEnergy, youRobotScraps;
// Wildfire only
private static int wildfireWater;
private static int[] adjustedStats = new int[3];
private static long[] totalSubpoints = new long[3];
private static final long[] triggerSubpoints = new long[3];
private static final int[] triggerItem = new int[3];
private static int fury = 0;
private static int soulsauce = 0;
private static int disco_momentum = 0;
private static int audience = 0;
private static int absorbs = 0;
private static int thunder = 0;
private static int rain = 0;
private static int lightning = 0;
private static String mask = null;
private static String limitmode = null;
public static final int MAX_BASEPOINTS = 65535;
static {
resetTriggers();
}
public static final SortedListModel<String> battleSkillNames = new SortedListModel<>();
// Status pane data which is rendered whenever
// the user issues a "status" type command.
private static int attacksLeft = 0;
private static long availableMeat = 0;
private static long storageMeat = 0;
private static long closetMeat = 0;
private static long sessionMeat = 0;
private static int inebriety = 0;
private static int fullness = 0;
private static int spleenUse = 0;
private static int adventuresLeft = 0;
private static int daycount = 0;
private static int turnsPlayed = 0;
private static int currentRun = 0;
private static long rollover = 0;
private static boolean isFullnessIncreased = false;
private static int holidayManaCostReduction = 0;
// Travel information
private static boolean hasStore = true;
private static boolean hasDisplayCase = true;
private static boolean hasClan = true;
// Campground information
private static boolean hasBookshelf = false;
private static int telescopeUpgrades = 0;
private static boolean hippyStoneBroken = false;
// Familiar data
public static final SortedListModel<FamiliarData> familiars = new SortedListModel<>();
public static FamiliarData currentFamiliar = FamiliarData.NO_FAMILIAR;
public static FamiliarData effectiveFamiliar = FamiliarData.NO_FAMILIAR;
public static String currentFamiliarImage = null;
public static FamiliarData currentEnthroned = FamiliarData.NO_FAMILIAR;
public static FamiliarData currentBjorned = FamiliarData.NO_FAMILIAR;
private static int arenaWins = 0;
private static boolean isUsingStabBat = false;
public static FamiliarData[] currentPokeFam =
new FamiliarData[] {
FamiliarData.NO_FAMILIAR, FamiliarData.NO_FAMILIAR, FamiliarData.NO_FAMILIAR
};
// Minstrel data (Avatar of Boris)
public static AdventureResult currentInstrument = null;
public static int minstrelLevel = 0;
public static boolean minstrelAttention = false;
// Companion data (Avatar of Jarlsberg)
private static Companion companion = null;
// Pastamancer Pasta Thralls
public static final LockableListModel<PastaThrallData> pastaThralls = new LockableListModel<>();
public static PastaThrallData currentPastaThrall = PastaThrallData.NO_THRALL;
private static int stillsAvailable = 0;
private static boolean tripleReagent = false;
private static boolean guildStoreStateKnown = false;
private static KoLAdventure selectedLocation;
private static int mindControlLevel = 0;
private static int radSickness = 0;
private static int autoAttackAction = 0;
private static String autosellMode = "";
private static boolean ignoreZoneWarnings = false;
private static boolean lazyInventory = false;
private static boolean unequipFamiliar = false;
private static Correspondent eudora = Correspondent.NONE;
// Put things that allocate AdventureResult objects AFTER previous
// static data has been initialized.
private static final AdventureResult[] WANDS =
new AdventureResult[] {
ItemPool.get(ItemPool.PINE_WAND, 1),
ItemPool.get(ItemPool.EBONY_WAND, 1),
ItemPool.get(ItemPool.HEXAGONAL_WAND, 1),
ItemPool.get(ItemPool.ALUMINUM_WAND, 1),
ItemPool.get(ItemPool.MARBLE_WAND, 1)
};
// Status pane data which is rendered whenever
// the user changes equipment, effects, and familiar
public static final void reset(final String newUserName) {
if (newUserName.equals(KoLCharacter.username)) {
return;
}
// Check that character names contain a narrow range of characters. Note
// that we explicitly allow empty usernames so we can revert to the initial
// not-logged-in state.
if (!newUserName.matches("^[a-zA-Z_ 0-9]{3,30}$") && !newUserName.isEmpty()) {
return;
}
// Apparently the CodeQL security scan requires this as a fix...
if (newUserName.contains("..")) {
return;
}
KoLCharacter.username = newUserName;
Preferences.reset(KoLCharacter.username);
KoLCharacter.reset(true);
}
public static final void reset(boolean newCharacter) {
KoLCharacter.ascensionClass = null;
KoLCharacter.gender = 0;
KoLCharacter.currentLevel = 1;
KoLCharacter.decrementPrime = 0L;
KoLCharacter.incrementPrime = 25L;
KoLCharacter.fury = 0;
KoLCharacter.soulsauce = 0;
KoLCharacter.disco_momentum = 0;
KoLCharacter.thunder = 0;
KoLCharacter.rain = 0;
KoLCharacter.lightning = 0;
KoLCharacter.absorbs = 0;
KoLCharacter.mask = null;
KoLCharacter.adventuresLeft = 0;
KoLCharacter.attacksLeft = 0;
KoLCharacter.adjustedStats = new int[3];
KoLCharacter.totalSubpoints = new long[3];
KoLCharacter.resetTriggers();
KoLCharacter.currentModifiers.reset();
KoLCharacter.currentModifiers.resetModifiers();
KoLConstants.inventory.clear();
KoLConstants.closet.clear();
KoLConstants.storage.clear();
KoLCharacter.storageMeat = 0;
KoLConstants.freepulls.clear();
KoLConstants.collection.clear();
KoLConstants.pulverizeQueue.clear();
KoLCharacter.sessionMeat = 0;
KoLCharacter.resetSkills();
KoLCharacter.isHardcore = false;
KoLCharacter.isCasual = false;
KoLCharacter.inRonin = true;
KoLCharacter.restricted = false;
KoLCharacter.inebriety = 0;
KoLCharacter.skillsRecalled = false;
KoLCharacter.hasStore = false;
KoLCharacter.hasDisplayCase = false;
KoLCharacter.hasClan = false;
KoLCharacter.hasBookshelf = false;
KoLCharacter.telescopeUpgrades = 0;
KoLCharacter.hippyStoneBroken = false;
KoLCharacter.familiars.clear();
KoLCharacter.familiars.add(FamiliarData.NO_FAMILIAR);
KoLCharacter.currentFamiliar = FamiliarData.NO_FAMILIAR;
KoLCharacter.effectiveFamiliar = FamiliarData.NO_FAMILIAR;
KoLCharacter.currentEnthroned = FamiliarData.NO_FAMILIAR;
KoLCharacter.currentBjorned = FamiliarData.NO_FAMILIAR;
KoLCharacter.arenaWins = 0;
KoLCharacter.isUsingStabBat = false;
KoLCharacter.companion = null;
KoLCharacter.currentPastaThrall = PastaThrallData.NO_THRALL;
KoLCharacter.pastaThralls.clear();
KoLCharacter.pastaThralls.add(PastaThrallData.NO_THRALL);
KoLCharacter.stillsAvailable = -1;
KoLCharacter.tripleReagent = false;
KoLCharacter.guildStoreStateKnown = false;
KoLCharacter.AWOLtattoo = 0;
KoLCharacter.ascensions = 0;
KoLCharacter.ascensionSign = ZodiacSign.NONE;
KoLCharacter.ascensionPath = Path.NONE;
KoLCharacter.mindControlLevel = 0;
KoLCharacter.radSickness = 0;
KoLCharacter.autosellMode = "";
KoLCharacter.lazyInventory = false;
KoLCharacter.unequipFamiliar = false;
KoLCharacter.eudora = Correspondent.NONE;
// Clear some of the standard lists so they don't
// carry over from player to player.
GoalManager.clearGoals();
KoLConstants.recentEffects.clear();
KoLConstants.activeEffects.clear();
// Don't reuse NPC food & drink from a previous login
ChezSnooteeRequest.reset();
MicroBreweryRequest.reset();
HellKitchenRequest.reset();
CrystalBallManager.reset();
DisplayCaseManager.clearCache();
DwarfFactoryRequest.reset();
EquipmentManager.resetEquipment();
EquipmentManager.resetCustomOutfits();
GearChangeFrame.clearFamiliarList();
InventoryManager.resetInventory();
LocketManager.clear();
SkillDatabase.resetCasts();
SpecialOutfit.forgetCheckpoints();
StorageRequest.resetRoninStoragePulls();
VolcanoMazeManager.reset();
VYKEACompanionData.initialize(true);
WumpusManager.reset();
CoinmasterRegistry.reset();
ConcoctionDatabase.resetQueue();
ConcoctionDatabase.refreshConcoctions();
ConsumablesDatabase.setSmoresData();
ConsumablesDatabase.setAffirmationCookieData();
ConsumablesDatabase.setVariableConsumables();
ConsumablesDatabase.calculateAdventureRanges();
DailyLimitDatabase.reset();
RelayRequest.reset();
Modifiers.overrideModifier("Generated:_userMods", Preferences.getString("_userMods"));
// Things that don't need to be reset when you ascend
if (newCharacter) {
ContactManager.clearMailContacts();
DataFileCache.clearCache();
EventManager.clearEventHistory();
ChatManager.resetChatLiteracy();
ClanManager.clearCache(true);
StoreManager.clearCache();
}
}
public static final void resetSkills() {
KoLConstants.usableSkills.clear();
KoLConstants.summoningSkills.clear();
KoLConstants.remedySkills.clear();
KoLConstants.selfOnlySkills.clear();
KoLConstants.buffSkills.clear();
KoLConstants.songSkills.clear();
KoLConstants.expressionSkills.clear();
KoLConstants.walkSkills.clear();
KoLConstants.availableSkills.clear();
KoLConstants.availableSkillsSet.clear();
KoLConstants.availableCombatSkillsSet.clear();
KoLConstants.combatSkills.clear();
// All characters get the option to
// attack something.
KoLCharacter.battleSkillNames.clear();
KoLCharacter.battleSkillNames.add("attack with weapon");
KoLCharacter.battleSkillNames.add("custom combat script");
KoLCharacter.battleSkillNames.add("delevel and plink");
FightRequest.addItemActionsWithNoCost();
KoLCharacter.battleSkillNames.add("try to run away");
int battleIndex = KoLCharacter.battleSkillNames.indexOf(Preferences.getString("battleAction"));
KoLCharacter.battleSkillNames.setSelectedIndex(battleIndex == -1 ? 0 : battleIndex);
SkillBuffFrame.update();
}
static final void resetPerAscensionData() {
// This is called after we have read the Charsheet and know how
// many ascensions the character has completed.
// Update all data which changes each ascension
VioletFogManager.reset();
KoLCharacter.ensureUpdatedAscensionCounters();
KoLCharacter.ensureUpdatedDwarfFactory();
KoLCharacter.ensureUpdatedGuyMadeOfBees();
KoLCharacter.ensureUpdatedPirateInsults();
KoLCharacter.ensureUpdatedPotionEffects();
KoLCharacter.ensureUpdatedSkatePark();
KoLCharacter.ensureUpdatedCellar();
}
public static final void setHoliday(final String holiday) {
KoLCharacter.isFullnessIncreased =
holiday.contains("Feast of Boris") || holiday.contains("Drunksgiving");
KoLCharacter.holidayManaCostReduction = holiday.contains("Festival of Jarlsberg") ? 3 : 0;
KoLmafia.statDay = HolidayDatabase.currentStatDay();
}
public static final void setFullness(final int fullness) {
KoLCharacter.fullness = Math.max(0, fullness);
}
public static final int getFullness() {
return KoLCharacter.fullness;
}
public static final int getFullnessLimit() {
if (!KoLCharacter.canEat()) {
return 0;
}
if (KoLCharacter.inRobocore()) {
// Robots can eat size-0 magical sausages but have no fullness
return 0;
} else if (KoLCharacter.isGreyGoo()) {
// Grey Goo can "eat" things but they don't go into a stomach.
return 0;
}
// Default stomach size, overridden below for various paths
int limit = 15;
if (KoLCharacter.isAWoLClass()) {
limit = 10;
if (KoLCharacter.hasSkill("Prodigious Appetite")) {
limit += 5;
}
} else if (KoLCharacter.isEd()) {
limit = 0;
if (KoLCharacter.hasSkill("Replacement Stomach")) {
limit += 5;
}
} else if (KoLCharacter.inZombiecore()) {
if (KoLCharacter.hasSkill("Insatiable Hunger")) {
limit += 5;
}
if (KoLCharacter.hasSkill("Ravenous Pounce")) {
limit += 5;
}
}
// If you are an Avatar of Boris, you are a hearty eater
else if (KoLCharacter.inAxecore()) {
limit = 20;
if (KoLCharacter.hasSkill("Legendary Appetite")) {
limit += 5;
}
} else if (KoLCharacter.isJarlsberg()) {
limit = 10;
if (KoLCharacter.hasSkill("Lunch Like a King")) {
limit += 5;
}
} else if (KoLCharacter.isSneakyPete()) {
limit = 5;
} else if (KoLCharacter.inNuclearAutumn()) {
limit = 3;
} else if (KoLCharacter.isVampyre()) {
limit = 5;
} else if (KoLCharacter.isPlumber()) {
limit = 20;
} else if (KoLCharacter.inBadMoon()) {
if (KoLCharacter.hasSkill("Pride")) {
limit -= 1;
}
if (KoLCharacter.hasSkill("Gluttony")) {
limit += 2;
}
}
// yojimbos_law sez:
//
// "The path sets your max fullness to 5, regardless of other modifiers.
// Spice melanges and sour balls each clear 3 fullness (and dieting pills
// have no interaction with your fullness), so those work.
// Pantsgiving increases your max fullness, which is then set to 5,
// so it doesn't work. If you somehow got liver or stomach of steel,
// those would similarly not work."
if (!KoLCharacter.isVampyre()) {
if (KoLCharacter.hasSkill("Stomach of Steel")) {
limit += 5;
}
if (Preferences.getBoolean("_distentionPillUsed")) {
limit += 1;
}
if (Preferences.getBoolean("_lupineHormonesUsed")) {
limit += 3;
}
if (Preferences.getBoolean("_sweetToothUsed")) {
limit += 1;
}
if (Preferences.getBoolean("_voraciTeaUsed")) {
limit += 1;
}
// Pantsgiving
limit += Preferences.getInteger("_pantsgivingFullness");
}
if (KoLCharacter.inBeecore()
|| KoLCharacter.isTrendy()
|| KoLCharacter.inBugcore()
|| KoLCharacter.inClasscore()) {
// No bonus fullness is available in these paths
return limit;
}
if (KoLCharacter.isAWoLClass()) {
// No bonus fullness even in aftercore for these classes
return limit;
}
if (KoLCharacter.isFullnessIncreased
&& (KoLCharacter.getPath() == Path.NONE || KoLCharacter.getPath() == Path.TEETOTALER)) {
// Challenge paths do not give bonus fullness for Feast of Boris.
// Check for paths that give bonus fullness instead of excluding all other paths.
limit += 15;
}
return limit;
}
public static final void setInebriety(final int inebriety) {
KoLCharacter.inebriety = inebriety;
}
public static final int getInebriety() {
return KoLCharacter.inebriety;
}
public static final int getInebrietyLimit() {
if (!KoLCharacter.canDrink()) {
return 0;
}
if (KoLCharacter.isGreyGoo()) {
// Grey Goo can "drink" things but they don't go into a liver.
return 0;
}
// Default liver size, overridden below for various paths
int limit = 14;
if (KoLCharacter.isAWoLClass()) {
limit = 9;
if (KoLCharacter.hasSkill(SkillPool.HARD_DRINKER__COW_PUNCHER)) {
limit += 5;
}
} else if (KoLCharacter.isJarlsberg()) {
limit = 9;
if (KoLCharacter.hasSkill("Nightcap")) {
limit += 5;
}
} else if (KoLCharacter.isSneakyPete()) {
limit = 19;
if (KoLCharacter.hasSkill(SkillPool.HARD_DRINKER__AVATAR_OF_SNEAKY_PETE)) {
limit += 10;
}
} else if (KoLCharacter.isEd()) {
limit = 0;
if (KoLCharacter.hasSkill("Replacement Liver")) {
limit += 4;
}
} else if (KoLCharacter.inAxecore() || KoLCharacter.inZombiecore()) {
limit = 4;
} else if (KoLCharacter.inNuclearAutumn()) {
limit = 2;
} else if (KoLCharacter.inBondcore()) {
limit = Math.min(KoLCharacter.getLevel(), 11) + 2;
if (Preferences.getBoolean("bondDrunk1")) {
limit += 1;
}
if (Preferences.getBoolean("bondDrunk2")) {
limit += 2;
}
} else if (KoLCharacter.isVampyre()) {
limit = 4;
}
if (KoLCharacter.hasSkill("Liver of Steel")) {
limit += 5;
}
if (KoLCharacter.hasSkill("Hollow Leg")) {
limit += 1;
}
if (KoLCharacter.hasSkill("Drinking to Drink")) {
limit += 1;
}
if (KoLCharacter.getFamiliar().getId() == FamiliarPool.STOOPER) {
limit += 1;
}
return limit;
}
public static final boolean isFallingDown() {
return KoLCharacter.getInebriety() > KoLCharacter.getInebrietyLimit();
}
public static final void setSpleenUse(int spleenUse) {
int value = Math.max(0, spleenUse);
if (KoLCharacter.spleenUse != value) {
KoLCharacter.spleenUse = value;
KoLCharacter.updateStatus();
}
}
public static final int getSpleenUse() {
return KoLCharacter.spleenUse;
}
public static final int getSpleenLimit() {
if (Limitmode.limitSpleening()) {
return 0;
}
if (KoLCharacter.inNoobcore()) {
return 0;
} else if (KoLCharacter.inRobocore()) {
return 0;
} else if (KoLCharacter.isGreyGoo()) {
// Grey Goo can "chew" things but they don't go into a spleen.
return 0;
}
// Default spleen size, overridden below for various paths
int limit = 15;
if (KoLCharacter.isAWoLClass()) {
limit = 10;
if (KoLCharacter.hasSkill("Tolerant Constitution")) {
limit += 5;
}
} else if (KoLCharacter.isEd()) {
limit = 5;
if (KoLCharacter.hasSkill("Okay Seriously, This is the Last Spleen")) {
limit += 5;
}
if (KoLCharacter.hasSkill("Just One More Extra Spleen")) {
limit += 5;
}
if (KoLCharacter.hasSkill("Still Another Extra Spleen")) {
limit += 5;
}
if (KoLCharacter.hasSkill("Yet Another Extra Spleen")) {
limit += 5;
}
if (KoLCharacter.hasSkill("Another Extra Spleen")) {
limit += 5;
}
if (KoLCharacter.hasSkill("Extra Spleen")) {
limit += 5;
}
} else if (KoLCharacter.inNuclearAutumn()) {
limit = 3;
} else if (KoLCharacter.isPlumber()) {
limit = 5;
} else if (KoLCharacter.inBondcore() && Preferences.getBoolean("bondSpleen")) {
limit += 2;
}
if (KoLCharacter.hasSkill("Spleen of Steel")) {
limit += 5;
}
if (Preferences.getInteger("lastStillBeatingSpleen") == KoLCharacter.getAscensions()) {
limit += 1;
}
return limit;
}
/**
* Accessor method to retrieve the name of this character.
*
* @return The name of this character
*/
public static final String getUserName() {
return KoLCharacter.username;
}
public static final String baseUserName() {
return Preferences.baseUserName(KoLCharacter.username);
}
/**
* Accessor method to set the user Id associated with this character.
*
* @param userId The user Id associated with this character
*/
public static final void setUserId(final int userId) {
KoLCharacter.userId = userId;
KoLCharacter.playerId = String.valueOf(userId);
ContactManager.registerPlayerId(KoLCharacter.username, String.valueOf(userId));
}
/**
* Accessor method to retrieve the user Id associated with this character.
*
* @return The user Id associated with this character
*/
public static final String getPlayerId() {
return KoLCharacter.playerId;
}
/**
* Accessor method to retrieve the user Id associated with this character.
*
* @return The user Id associated with this character
*/
public static final int getUserId() {
return KoLCharacter.userId;
}
/**
* Accessor method to get the avatar associated with this character.
*
* @param avatar The avatar for this character
*/
public static final void setAvatar(final String avatar) {
KoLCharacter.setAvatar(Collections.singletonList(avatar));
}
public static final void setAvatar(final List<String> images) {
// Only set the avatar if the set of images has changed.
//
// Note that we assume that a "set" will do; the images will be overlaid
// upon each other, rather than being arranged in a specific order.
if (KoLCharacter.avatar.size() == images.size()) {
boolean changed = false;
Set<String> currentImages = new HashSet<>(KoLCharacter.avatar);
for (String image : images) {
if (!currentImages.contains(image)) {
changed = true;
break;
}
}
if (!changed) {
return;
}
}
KoLCharacter.avatar = images;
String prefix = KoLmafia.imageServerPath();
boolean female = false;
for (String image : images) {
if (image.endsWith("_f.gif")) {
female = true;
}
FileUtilities.downloadImage(prefix + image);
}
if (female) {
KoLCharacter.setGender(KoLCharacter.FEMALE);
} else {
// Unfortunately, lack of '_f' in the avatar doesn't
// necessarily indicate a male character - it could be a custom
// avatar, or a special avatar such as Birdform that's unisex.
KoLCharacter.setGender();
}
NamedListenerRegistry.fireChange("(avatar)");
}
/**
* Accessor method to get the avatar associated with this character.
*
* @return The avatar for this character
*/
public static final List<String> getAvatar() {
return KoLCharacter.avatar;
}
private static int setGender() {
// If we already know our gender, are in Valhalla (where gender
// is meaningless), or are not logged in (ditto), nothing to do
if (KoLCharacter.gender != 0
|| CharPaneRequest.inValhalla()
|| GenericRequest.passwordHash.isEmpty()) {
return KoLCharacter.gender;
}
// Can't tell? Look at their vinyl boots!
String descId = ItemDatabase.getDescriptionId(ItemPool.VINYL_BOOTS);
GenericRequest req = new GenericRequest("desc_item.php?whichitem=" + descId);
RequestThread.postRequest(req);
if (req.responseText != null) {
KoLCharacter.gender =
req.responseText.contains("+15%") ? KoLCharacter.FEMALE : KoLCharacter.MALE;
}
return KoLCharacter.gender;
}
public static final void setGender(final int gender) {
KoLCharacter.gender = gender;
}
public static final int getGender() {
return KoLCharacter.setGender();
}
/**
* Accessor method to retrieve the index of the prime stat.
*
* @return The index of the prime stat
*/
public static final int getPrimeIndex() {
return ascensionClass == null ? 0 : ascensionClass.getPrimeStatIndex();
}
/**
* Accessor method to retrieve the level of this character.
*
* @return The level of this character
*/
public static final int getLevel() {
long totalPrime = KoLCharacter.getTotalPrime();
if (totalPrime < KoLCharacter.decrementPrime || totalPrime >= KoLCharacter.incrementPrime) {
int previousLevel = KoLCharacter.currentLevel;
KoLCharacter.currentLevel = KoLCharacter.calculateSubpointLevels(totalPrime);
KoLCharacter.decrementPrime = KoLCharacter.calculateLastLevel();
KoLCharacter.incrementPrime = KoLCharacter.calculateNextLevel();
if (KoLCharacter.incrementPrime < 0) {
// this will overflow at level 216
KoLCharacter.incrementPrime = Long.MAX_VALUE;
}
if (previousLevel != KoLCharacter.currentLevel) {
HPRestoreItemList.updateHealthRestored();
MPRestoreItemList.updateManaRestored();
ConsumablesDatabase.setVariableConsumables();
}
}
return KoLCharacter.currentLevel;
}
public static final int getFury() {
return KoLCharacter.fury;
}
public static final int getFuryLimit() {
// 0 if not Seal Clubber, 3 with only Wrath of the Wolverine, 5 with Ire of the Orca in addition
return (ascensionClass != AscensionClass.SEAL_CLUBBER
|| !KoLCharacter.hasSkill("Wrath of the Wolverine"))
? 0
: KoLCharacter.hasSkill("Ire of the Orca") ? 5 : 3;
}
public static final void setFury(final int newFury) {
int furyLimit = KoLCharacter.getFuryLimit();
KoLCharacter.fury = newFury > furyLimit ? furyLimit : Math.max(newFury, 0);
}
public static final void setFuryNoCheck(final int newFury) {
KoLCharacter.fury = newFury;
}
public static final void resetFury() {
fury = 0;
}
public static final void incrementFury(final int incFury) {
KoLCharacter.setFury(KoLCharacter.fury + incFury);
}
public static final void decrementFury(final int decFury) {
KoLCharacter.setFury(KoLCharacter.fury - decFury);
}
public static final String getBlessingType() {
if (KoLConstants.activeEffects.contains(EffectPool.get(EffectPool.BLESSING_OF_THE_WAR_SNAPPER))
|| KoLConstants.activeEffects.contains(
EffectPool.get(EffectPool.GRAND_BLESSING_OF_THE_WAR_SNAPPER))
|| KoLConstants.activeEffects.contains(
EffectPool.get(EffectPool.GLORIOUS_BLESSING_OF_THE_WAR_SNAPPER))
|| KoLConstants.activeEffects.contains(
EffectPool.get(EffectPool.AVATAR_OF_THE_WAR_SNAPPER))) {
return KoLCharacter.WAR_BLESSING;
}
if (KoLConstants.activeEffects.contains(EffectPool.get(EffectPool.BLESSING_OF_SHE_WHO_WAS))
|| KoLConstants.activeEffects.contains(
EffectPool.get(EffectPool.GRAND_BLESSING_OF_SHE_WHO_WAS))
|| KoLConstants.activeEffects.contains(
EffectPool.get(EffectPool.GLORIOUS_BLESSING_OF_SHE_WHO_WAS))
|| KoLConstants.activeEffects.contains(EffectPool.get(EffectPool.AVATAR_OF_SHE_WHO_WAS))) {
return KoLCharacter.SHE_WHO_WAS_BLESSING;
}
if (KoLConstants.activeEffects.contains(
EffectPool.get(EffectPool.BLESSING_OF_THE_STORM_TORTOISE))
|| KoLConstants.activeEffects.contains(
EffectPool.get(EffectPool.GRAND_BLESSING_OF_THE_STORM_TORTOISE))
|| KoLConstants.activeEffects.contains(
EffectPool.get(EffectPool.GLORIOUS_BLESSING_OF_THE_STORM_TORTOISE))
|| KoLConstants.activeEffects.contains(
EffectPool.get(EffectPool.AVATAR_OF_THE_STORM_TORTOISE))) {
return KoLCharacter.STORM_BLESSING;
}
return null;
}
public static final int getBlessingLevel() {
if (KoLConstants.activeEffects.contains(EffectPool.get(EffectPool.BLESSING_OF_THE_WAR_SNAPPER))