-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathis-seedfinder.patch
2263 lines (2087 loc) · 84.6 KB
/
is-seedfinder.patch
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
From 562456c218412c8f3a6b5821a7a817e5f92de21e Mon Sep 17 00:00:00 2001
From: ifritdiezel <[email protected]>
Date: Wed, 1 Feb 2023 16:50:11 +0500
Subject: [PATCH 1/9] initial
---
.../java/com/watabou/utils/DeviceCompat.java | 4 +-
.../shatteredpixeldungeon/SeedFinder.java | 394 ++++++++++++++++++
.../ShatteredPixelDungeon.java | 13 +-
.../actors/mobs/ArmoredStatue.java | 2 +-
.../actors/mobs/Statue.java | 2 +-
.../actors/mobs/npcs/Wandmaker.java | 2 +-
.../shatteredpixeldungeon/items/Heap.java | 15 +-
.../shatteredpixeldungeon/levels/Level.java | 2 +-
.../messages/Languages.java | 4 -
.../desktop/DesktopLauncher.java | 7 +-
10 files changed, 417 insertions(+), 28 deletions(-)
create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SeedFinder.java
diff --git a/SPD-classes/src/main/java/com/watabou/utils/DeviceCompat.java b/SPD-classes/src/main/java/com/watabou/utils/DeviceCompat.java
index 5deeeab25..c872ffbff 100644
--- a/SPD-classes/src/main/java/com/watabou/utils/DeviceCompat.java
+++ b/SPD-classes/src/main/java/com/watabou/utils/DeviceCompat.java
@@ -21,11 +21,9 @@
package com.watabou.utils;
-import com.badlogic.gdx.Application;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.utils.SharedLibraryLoader;
-import com.watabou.noosa.Game;
//TODO migrate to platformSupport class
public class DeviceCompat {
@@ -61,7 +59,7 @@ public class DeviceCompat {
}
public static boolean isDebug(){
- return Game.version.contains("INDEV");
+ return true;
}
public static void log( String tag, String message ){
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SeedFinder.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SeedFinder.java
new file mode 100644
index 000000000..cdc314583
--- /dev/null
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SeedFinder.java
@@ -0,0 +1,394 @@
+package com.shatteredpixel.shatteredpixeldungeon;
+
+import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
+import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.ArmoredStatue;
+import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.CrystalMimic;
+import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.GoldenMimic;
+import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic;
+import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
+import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue;
+import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Ghost;
+import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Imp;
+import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker;
+import com.shatteredpixel.shatteredpixeldungeon.items.Dewdrop;
+import com.shatteredpixel.shatteredpixeldungeon.items.EnergyCrystal;
+import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
+import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
+import com.shatteredpixel.shatteredpixeldungeon.items.Heap.Type;
+import com.shatteredpixel.shatteredpixeldungeon.items.Item;
+import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
+import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact;
+import com.shatteredpixel.shatteredpixeldungeon.items.keys.CrystalKey;
+import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey;
+import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
+import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
+import com.shatteredpixel.shatteredpixeldungeon.items.quest.CeremonialCandle;
+import com.shatteredpixel.shatteredpixeldungeon.items.quest.CorpseDust;
+import com.shatteredpixel.shatteredpixeldungeon.items.quest.Embers;
+import com.shatteredpixel.shatteredpixeldungeon.items.quest.Pickaxe;
+import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
+import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
+import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
+import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
+import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
+import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
+import com.shatteredpixel.shatteredpixeldungeon.utils.DungeonSeed;
+import com.watabou.noosa.Game;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Scanner;
+
+public class SeedFinder {
+ enum Condition {ANY, ALL};
+
+ public static class Options {
+ public static int floors;
+ public static Condition condition;
+ public static String itemListFile;
+ public static String ouputFile;
+ public static long seed;
+ public static int startingSeed;
+ public static long endingSeed;
+ }
+
+ public class HeapItem {
+ public Item item;
+ public Heap heap;
+
+ public HeapItem(Item item, Heap heap) {
+ this.item = item;
+ this.heap = heap;
+ }
+ }
+
+ List<Class<? extends Item>> blacklist;
+ ArrayList<String> itemList;
+
+ // TODO: make it parse the item list directly from the arguments
+ private void parseArgs(String[] args) {
+ if (args.length == 2) {
+ Options.ouputFile = "stdout";
+ Options.floors = Integer.parseInt(args[0]);
+ Options.seed = DungeonSeed.convertFromText(args[1]);
+
+ return;
+ }
+
+ Options.floors = Integer.parseInt(args[0]);
+ Options.condition = args[1].equals("any") ? Condition.ANY : Condition.ALL;
+ Options.itemListFile = args[2];
+ Options.ouputFile = args[3];
+
+ if (args.length < 5)
+ Options.startingSeed = 0;
+ else
+ Options.startingSeed = Integer.parseInt((args[4]));
+
+ if (args.length < 6)
+ Options.endingSeed = DungeonSeed.TOTAL_SEEDS;
+ else
+ Options.endingSeed = Integer.parseInt((args[5]));
+
+ }
+
+ private ArrayList<String> getItemList() {
+ ArrayList<String> itemList = new ArrayList<>();
+
+ try {
+ Scanner scanner = new Scanner(new File(Options.itemListFile));
+
+ while (scanner.hasNextLine()) {
+ itemList.add(scanner.nextLine());
+ }
+
+ scanner.close();
+
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+
+ return itemList;
+ }
+
+ private void addTextItems(String caption, ArrayList<HeapItem> items, StringBuilder builder) {
+ if (!items.isEmpty()) {
+ builder.append(caption + ":\n");
+
+ for (HeapItem item : items) {
+ Item i = item.item;
+ Heap h = item.heap;
+
+ if (((i instanceof Armor && ((Armor) i).hasGoodGlyph()) ||
+ (i instanceof Weapon && ((Weapon) i).hasGoodEnchant()) ||
+ (i instanceof Ring) || (i instanceof Wand)) && i.cursed)
+ builder.append("- cursed " + i.title().toLowerCase());
+
+ else
+ builder.append("- " + i.title().toLowerCase());
+
+ if (h.type != Type.HEAP)
+ builder.append(" (" + h.title().toLowerCase() + ")");
+
+ builder.append("\n");
+ }
+
+ builder.append("\n");
+ }
+ }
+
+ private void addTextQuest(String caption, ArrayList<Item> items, StringBuilder builder) {
+ if (!items.isEmpty()) {
+ builder.append(caption + ":\n");
+
+ for (Item i : items) {
+ if (i.cursed)
+ builder.append("- cursed " + i.title().toLowerCase() + "\n");
+
+ else
+ builder.append("- " + i.title().toLowerCase() + "\n");
+ }
+
+ builder.append("\n");
+ }
+ }
+
+ public SeedFinder(String[] args) {
+ System.out.printf("Starting IS-Seedfinder, game version: " + Game.version + "\n");
+ parseArgs(args);
+
+ if (args.length == 2) {
+ logSeedItems(Long.toString(Options.seed), Options.floors);
+
+ return;
+ }
+
+ itemList = getItemList();
+
+ try {
+ Writer outputFile = new FileWriter(Options.ouputFile);
+ outputFile.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ for (int i = Options.startingSeed; i < Options.endingSeed; i++) {
+ if (testSeed(Integer.toString(i), Options.floors)) {
+ System.out.printf("Found valid seed %s (%d)\n", DungeonSeed.convertToCode(Dungeon.seed), Dungeon.seed);
+ logSeedItems(Integer.toString(i), Options.floors);
+ }
+ }
+ }
+
+ private ArrayList<Heap> getMobDrops(Level l) {
+ ArrayList<Heap> heaps = new ArrayList<>();
+
+ for (Mob m : l.mobs) {
+ if (m instanceof Statue) {
+ Heap h = new Heap();
+ h.items = new LinkedList<>();
+ h.items.add(((Statue) m).weapon.identify());
+ h.type = Type.STATUE;
+ heaps.add(h);
+ }
+
+ else if (m instanceof ArmoredStatue) {
+ Heap h = new Heap();
+ h.items = new LinkedList<>();
+ h.items.add(((ArmoredStatue) m).armor.identify());
+ h.items.add(((ArmoredStatue) m).weapon.identify());
+ h.type = Type.STATUE;
+ heaps.add(h);
+ }
+
+ else if (m instanceof Mimic) {
+ Heap h = new Heap();
+ h.items = new LinkedList<>();
+
+ for (Item item : ((Mimic) m).items)
+ h.items.add(item.identify());
+
+ if (m instanceof GoldenMimic) h.type = Type.GOLDEN_MIMIC;
+ else if (m instanceof CrystalMimic) h.type = Type.CRYSTAL_MIMIC;
+ else h.type = Type.MIMIC;
+ heaps.add(h);
+ }
+ }
+
+ return heaps;
+ }
+
+ private boolean testSeed(String seed, int floors) {
+ SPDSettings.customSeed(seed);
+ GamesInProgress.selectedClass = HeroClass.WARRIOR;
+ Dungeon.init();
+
+ boolean[] itemsFound = new boolean[itemList.size()];
+
+ for (int i = 0; i < floors; i++) {
+ Level l = Dungeon.newLevel();
+
+ if(Dungeon.depth % 5 != 0) {
+ ArrayList<Heap> heaps = new ArrayList<>(l.heaps.valueList());
+ heaps.addAll(getMobDrops(l));
+
+ for (Heap h : heaps) {
+ for (Item item : h.items) {
+ item.identify();
+
+ for (int j = 0; j < itemList.size(); j++) {
+ if (item.title().toLowerCase().contains(itemList.get(j))) {
+ if (itemsFound[j] == false) {
+ itemsFound[j] = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ Dungeon.depth++;
+ }
+
+ if (Options.condition == Condition.ANY) {
+ for (int i = 0; i < itemList.size(); i++) {
+ if (itemsFound[i] == true)
+ return true;
+ }
+
+ return false;
+ }
+
+ else {
+ for (int i = 0; i < itemList.size(); i++) {
+ if (itemsFound[i] == false)
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ private void logSeedItems(String seed, int floors) {
+ PrintWriter out = null;
+ OutputStream out_fd = System.out;
+
+ try {
+ if (Options.ouputFile != "stdout")
+ out_fd = new FileOutputStream(Options.ouputFile, true);
+
+ out = new PrintWriter(out_fd);
+ } catch (FileNotFoundException e) { // gotta love Java mandatory exceptions
+ e.printStackTrace();
+ }
+
+ SPDSettings.customSeed(seed);
+ GamesInProgress.selectedClass = HeroClass.WARRIOR;
+ Dungeon.init();
+
+ blacklist = Arrays.asList(Gold.class, Dewdrop.class, IronKey.class, GoldenKey.class, CrystalKey.class, EnergyCrystal.class,
+ CorpseDust.class, Embers.class, CeremonialCandle.class, Pickaxe.class);
+
+ out.printf("Items for seed %s (%d):\n\n", DungeonSeed.convertToCode(Dungeon.seed), Dungeon.seed);
+
+ for (int i = 0; i < floors; i++) {
+ out.printf("--- floor %d ---\n\n", Dungeon.depth);
+
+ Level l = Dungeon.newLevel();
+ ArrayList<Heap> heaps = new ArrayList<>(l.heaps.valueList());
+ StringBuilder builder = new StringBuilder();
+ ArrayList<HeapItem> scrolls = new ArrayList<>();
+ ArrayList<HeapItem> potions = new ArrayList<>();
+ ArrayList<HeapItem> equipment = new ArrayList<>();
+ ArrayList<HeapItem> rings = new ArrayList<>();
+ ArrayList<HeapItem> artifacts = new ArrayList<>();
+ ArrayList<HeapItem> wands = new ArrayList<>();
+ ArrayList<HeapItem> others = new ArrayList<>();
+
+ // list quest rewards
+ if (Ghost.Quest.armor != null) {
+ ArrayList<Item> rewards = new ArrayList<>();
+ rewards.add(Ghost.Quest.armor.identify());
+ rewards.add(Ghost.Quest.weapon.identify());
+ Ghost.Quest.complete();
+
+ addTextQuest("Ghost quest rewards", rewards, builder);
+ }
+
+ if (Wandmaker.Quest.wand1 != null) {
+ ArrayList<Item> rewards = new ArrayList<>();
+ rewards.add(Wandmaker.Quest.wand1.identify());
+ rewards.add(Wandmaker.Quest.wand2.identify());
+ Wandmaker.Quest.complete();
+
+ builder.append("Wandmaker quest item: ");
+
+ switch (Wandmaker.Quest.type) {
+ case 1: default:
+ builder.append("corpse dust\n\n");
+ break;
+ case 2:
+ builder.append("fresh embers\n\n");
+ break;
+ case 3:
+ builder.append("rotberry seed\n\n");
+ }
+
+ addTextQuest("Wandmaker quest rewards", rewards, builder);
+ }
+
+ if (Imp.Quest.reward != null) {
+ ArrayList<Item> rewards = new ArrayList<>();
+ rewards.add(Imp.Quest.reward.identify());
+ Imp.Quest.complete();
+
+ addTextQuest("Imp quest reward", rewards, builder);
+ }
+
+ heaps.addAll(getMobDrops(l));
+
+ // list items
+ for (Heap h : heaps) {
+ for (Item item : h.items) {
+ item.identify();
+
+ if (h.type == Type.FOR_SALE) continue;
+ else if (blacklist.contains(item.getClass())) continue;
+ else if (item instanceof Scroll) scrolls.add(new HeapItem(item, h));
+ else if (item instanceof Potion) potions.add(new HeapItem(item, h));
+ else if (item instanceof MeleeWeapon || item instanceof Armor) equipment.add(new HeapItem(item, h));
+ else if (item instanceof Ring) rings.add(new HeapItem(item, h));
+ else if (item instanceof Artifact) artifacts.add(new HeapItem(item, h));
+ else if (item instanceof Wand) wands.add(new HeapItem(item, h));
+ else others.add(new HeapItem(item, h));
+ }
+ }
+
+ addTextItems("Scrolls", scrolls, builder);
+ addTextItems("Potions", potions, builder);
+ addTextItems("Equipment", equipment, builder);
+ addTextItems("Rings", rings, builder);
+ addTextItems("Artifacts", artifacts, builder);
+ addTextItems("Wands", wands, builder);
+ addTextItems("Other", others, builder);
+
+ out.print(builder.toString());
+
+ Dungeon.depth++;
+ }
+
+ out.close();
+ }
+
+}
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java
index 3568af8b4..74a368403 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java
@@ -27,8 +27,6 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.TitleScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.WelcomeScene;
import com.watabou.noosa.Game;
-import com.watabou.noosa.audio.Music;
-import com.watabou.noosa.audio.Sample;
import com.watabou.utils.DeviceCompat;
import com.watabou.utils.PlatformSupport;
@@ -97,17 +95,8 @@ public class ShatteredPixelDungeon extends Game {
@Override
public void create() {
super.create();
+ finish();
- updateSystemUI();
- SPDAction.loadBindings();
-
- Music.INSTANCE.enable( SPDSettings.music() );
- Music.INSTANCE.volume( SPDSettings.musicVol()*SPDSettings.musicVol()/100f );
- Sample.INSTANCE.enable( SPDSettings.soundFx() );
- Sample.INSTANCE.volume( SPDSettings.SFXVol()*SPDSettings.SFXVol()/100f );
-
- Sample.INSTANCE.load( Assets.Sounds.all );
-
}
@Override
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/ArmoredStatue.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/ArmoredStatue.java
index 8c2683a8a..96e7c1b37 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/ArmoredStatue.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/ArmoredStatue.java
@@ -41,7 +41,7 @@ public class ArmoredStatue extends Statue {
spriteClass = StatueSprite.class;
}
- protected Armor armor;
+ public Armor armor;
public ArmoredStatue(){
super();
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Statue.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Statue.java
index db91b0654..8992eaaae 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Statue.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Statue.java
@@ -47,7 +47,7 @@ public class Statue extends Mob {
properties.add(Property.INORGANIC);
}
- protected Weapon weapon;
+ public Weapon weapon;
public boolean levelGenStatue = true;
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java
index 740aa90b0..f3023f6b0 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java
@@ -201,7 +201,7 @@ public class Wandmaker extends NPC {
public static class Quest {
- private static int type;
+ public static int type;
// 1 = corpse dust quest
// 2 = elemental embers quest
// 3 = rotberry quest
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java
index 5a3730dba..328dbce50 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java
@@ -45,7 +45,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
-import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundlable;
import com.watabou.utils.Bundle;
@@ -65,7 +64,11 @@ public class Heap implements Bundlable {
CRYSTAL_CHEST,
TOMB,
SKELETON,
- REMAINS
+ REMAINS,
+ MIMIC,
+ GOLDEN_MIMIC,
+ CRYSTAL_MIMIC,
+ STATUE
}
public Type type = Type.HEAP;
@@ -369,6 +372,14 @@ public class Heap implements Bundlable {
return Messages.get(this, "skeleton");
case REMAINS:
return Messages.get(this, "remains");
+ case MIMIC:
+ return "mimic";
+ case GOLDEN_MIMIC:
+ return "golden mimic";
+ case CRYSTAL_MIMIC:
+ return "crystal mimic";
+ case STATUE:
+ return "statue";
default:
return peek().title();
}
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java
index 28ba04179..5fe06b44f 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java
@@ -100,7 +100,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
-public abstract class Level implements Bundlable {
+public abstract class Level implements Bundlable {
public static enum Feeling {
NONE,
diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/messages/Languages.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/messages/Languages.java
index 5f3c81211..0a4eeb7fe 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/messages/Languages.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/messages/Languages.java
@@ -96,10 +96,6 @@ public enum Languages {
}
public static Languages matchCode(String code){
- for (Languages lang : Languages.values()){
- if (lang.code().equals(code))
- return lang;
- }
return ENGLISH;
}
diff --git a/desktop/src/main/java/com/shatteredpixel/shatteredpixeldungeon/desktop/DesktopLauncher.java b/desktop/src/main/java/com/shatteredpixel/shatteredpixeldungeon/desktop/DesktopLauncher.java
index d4d20997a..b53df27ba 100644
--- a/desktop/src/main/java/com/shatteredpixel/shatteredpixeldungeon/desktop/DesktopLauncher.java
+++ b/desktop/src/main/java/com/shatteredpixel/shatteredpixeldungeon/desktop/DesktopLauncher.java
@@ -22,16 +22,14 @@
package com.shatteredpixel.shatteredpixeldungeon.desktop;
import com.badlogic.gdx.Files;
-import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3FileHandle;
-import com.badlogic.gdx.backends.lwjgl3.Lwjgl3NativesLoader;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Preferences;
import com.badlogic.gdx.files.FileHandle;
-import com.badlogic.gdx.utils.GdxNativesLoader;
import com.badlogic.gdx.utils.SharedLibraryLoader;
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
+import com.shatteredpixel.shatteredpixeldungeon.SeedFinder;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.services.news.News;
import com.shatteredpixel.shatteredpixeldungeon.services.news.NewsImpl;
@@ -196,6 +194,9 @@ public class DesktopLauncher {
config.setWindowIcon("icons/icon_16.png", "icons/icon_32.png", "icons/icon_48.png",
"icons/icon_64.png", "icons/icon_128.png", "icons/icon_256.png");
+ config.setInitialVisible(false);
new Lwjgl3Application(new ShatteredPixelDungeon(new DesktopPlatformSupport()), config);
+
+ new SeedFinder(args);
}
}
--
2.34.1
From 822185c09086b605e9994e59c0fc49cc61795b42 Mon Sep 17 00:00:00 2001
From: ifritdiezel <[email protected]>
Date: Wed, 1 Feb 2023 17:06:02 +0500
Subject: [PATCH 2/9] Update README.md
---
README.md | 52 +++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 39 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index 420aed93d..ae8f06b92 100644
--- a/README.md
+++ b/README.md
@@ -1,20 +1,46 @@
-# Shattered Pixel Dungeon
+# IS-Seedfinder (cloned from [alessiomarotta/shpd-seed-finder](https://github.com/alessiomarotta/shpd-seed-finder))
-A Roguelike RPG, with randomly generated levels, items, enemies, and traps! Based on the [source code of Pixel Dungeon](https://github.com/00-Evan/pixel-dungeon-gradle), by [Watabou](https://www.watabou.ru).
+Application to find seeds for Shattered Pixel Dungeon given constraints (e.g. wand of disintegration +2 and ring of evasion in the first 4 floors).
+It can also display items found on a specific seed.
-Shattered Pixel Dungeon currently compiles for Android, iOS and Desktop platforms. It is available from [Google Play](https://play.google.com/store/apps/details?id=com.shatteredpixel.shatteredpixeldungeon), [the App Store](https://apps.apple.com/app/shattered-pixel-dungeon/id1563121109), and right here on [GitHub](https://github.com/00-Evan/shattered-pixel-dungeon/releases).
+New feature summary:
+- Specify the seed to start scanning with. Can be used to continue scanning after terminating the application or to run multiple instances to make use of multiple threads
+- Specify final seed to stop at, useful for running multiple instances
+- Skips every boss floor to slightly improve performance
-If you like this game, please consider [supporting me on Patreon](https://www.patreon.com/ShatteredPixel)!
+# How to use
-There is an official blog for this project at [ShatteredPixel.com](https://www.shatteredpixel.com).
+## Seed display mode
-The game also has a translation project hosted on [Transifex](https://www.transifex.com/shattered-pixel/shattered-pixel-dungeon/).
+If no more than two arguments are provided, the items found in a given seed will be printed on the screen:
-Note that **this repository does not accept pull requests!** The code here is provided in hopes that others may find it useful for their own projects, not to allow community contribution. Issue reports of all kinds (bug reports, feature requests, etc.) are welcome.
+```
+java -jar seed-finder.jar floors seed
+```
-If you'd like to work with the code, you can find the following guides in `/docs`:
-- [Compiling for Android.](docs/getting-started-android.md)
- - **[If you plan to distribute on Google Play please read the end of this guide.](docs/getting-started-android.md#distributing-your-apk)**
-- [Compiling for desktop platforms.](docs/getting-started-desktop.md)
-- [Compiling for iOS.](docs/getting-started-ios.md)
-- [Recommended changes for making your own mod.](docs/recommended-changes.md)
\ No newline at end of file
+- **floors**: maximum depth to display
+- **seed**: dungeon seed to analyze
+
+## Finder mode
+
+If al least 3 arguments are provided, the application will try to find a specific seed:
+
+```
+java -jar seed-finder.jar floors condition item_list output_file [starting_seed] [ending seed]
+```
+
+- **floors**: maximum depth to look for the items
+- **condition**: can be either `any` or `all`: the first will consider a seed valid if any of the specified items has been found, the second one requires _all_ of the items to spawn instead
+- **item_list**: file name containing a list of items, one item per line
+- **output_file**: file name to save the item list for each seed
+- **starting_seed**: the first seed the script scans. useful for running multiple instances to utilize more threads, stays at 0 if unspecified
+- **ending_seed**: the script terminates upon reaching this seed, the last possible seed by default
+
+The entries in the item list need to be in english, all lowercase and can optionally specify the enchantement and the upgrade level, so both `projecting crossbow +3` and `sword` are valid item names.
+
+The application will run until the set final seed is scanned or all the seeds have been tested by default (virtually indefinitely), so stop it using ctrl-C when you have found enough seeds for your needs.
+
+Any valid seeds will be printed during the execution in the 9 letter code and numeric format.
+
+# How to build
+The patch is already applied, see [Shattered PD desktop building instructions](https://github.com/00-Evan/shattered-pixel-dungeon/blob/master/docs/getting-started-desktop.md) to generate a release
--
2.34.1
From 2725be2881c1e72a8df5dbbcd6461a081e801ed8 Mon Sep 17 00:00:00 2001
From: ifritdiezel <[email protected]>
Date: Wed, 1 Feb 2023 17:12:10 +0500
Subject: [PATCH 3/9] added patch file
---
README.md | 3 +-
is-seedfinder.patch | 637 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 639 insertions(+), 1 deletion(-)
create mode 100644 is-seedfinder.patch
diff --git a/README.md b/README.md
index ae8f06b92..2c18feea2 100644
--- a/README.md
+++ b/README.md
@@ -43,4 +43,5 @@ The application will run until the set final seed is scanned or all the seeds ha
Any valid seeds will be printed during the execution in the 9 letter code and numeric format.
# How to build
-The patch is already applied, see [Shattered PD desktop building instructions](https://github.com/00-Evan/shattered-pixel-dungeon/blob/master/docs/getting-started-desktop.md) to generate a release
+The patch is already applied, see [Shattered PD desktop building instructions](https://github.com/00-Evan/shattered-pixel-dungeon/blob/master/docs/getting-started-desktop.md) to generate a release.
+A modified [patch](https://github.com/ifritdiezel/is-seedfinder/blob/master/is-seedfinder.patch) to apply to an existing project is also available in the root directory.
diff --git a/is-seedfinder.patch b/is-seedfinder.patch
new file mode 100644
index 000000000..7d98c9a9c
--- /dev/null
+++ b/is-seedfinder.patch
@@ -0,0 +1,637 @@
+Index: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java
+--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java (revision a96d62f6bfb1ef79b0ee93f2f0632beb6bad8ef8)
++++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java (date 1675245846839)
+@@ -100,7 +100,7 @@
+ import java.util.HashMap;
+ import java.util.HashSet;
+
+-public abstract class Level implements Bundlable {
++public abstract class Level implements Bundlable {
+
+ public static enum Feeling {
+ NONE,
+Index: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SeedFinder.java
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SeedFinder.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SeedFinder.java
+new file mode 100644
+--- /dev/null (date 1675247499129)
++++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SeedFinder.java (date 1675247499129)
+@@ -0,0 +1,394 @@
++package com.shatteredpixel.shatteredpixeldungeon;
++
++import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
++import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.ArmoredStatue;
++import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.CrystalMimic;
++import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.GoldenMimic;
++import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic;
++import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
++import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue;
++import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Ghost;
++import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Imp;
++import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker;
++import com.shatteredpixel.shatteredpixeldungeon.items.Dewdrop;
++import com.shatteredpixel.shatteredpixeldungeon.items.EnergyCrystal;
++import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
++import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
++import com.shatteredpixel.shatteredpixeldungeon.items.Heap.Type;
++import com.shatteredpixel.shatteredpixeldungeon.items.Item;
++import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
++import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact;
++import com.shatteredpixel.shatteredpixeldungeon.items.keys.CrystalKey;
++import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey;
++import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
++import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
++import com.shatteredpixel.shatteredpixeldungeon.items.quest.CeremonialCandle;
++import com.shatteredpixel.shatteredpixeldungeon.items.quest.CorpseDust;
++import com.shatteredpixel.shatteredpixeldungeon.items.quest.Embers;
++import com.shatteredpixel.shatteredpixeldungeon.items.quest.Pickaxe;
++import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
++import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
++import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
++import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
++import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
++import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
++import com.shatteredpixel.shatteredpixeldungeon.utils.DungeonSeed;
++import com.watabou.noosa.Game;
++
++import java.io.File;
++import java.io.FileNotFoundException;
++import java.io.FileOutputStream;
++import java.io.FileWriter;
++import java.io.IOException;
++import java.io.OutputStream;
++import java.io.PrintWriter;
++import java.io.Writer;
++import java.util.ArrayList;
++import java.util.Arrays;
++import java.util.LinkedList;
++import java.util.List;
++import java.util.Scanner;
++
++public class SeedFinder {
++ enum Condition {ANY, ALL};
++
++ public static class Options {
++ public static int floors;
++ public static Condition condition;
++ public static String itemListFile;
++ public static String ouputFile;
++ public static long seed;
++ public static int startingSeed;
++ public static long endingSeed;
++ }
++
++ public class HeapItem {
++ public Item item;
++ public Heap heap;
++
++ public HeapItem(Item item, Heap heap) {
++ this.item = item;
++ this.heap = heap;
++ }
++ }
++
++ List<Class<? extends Item>> blacklist;
++ ArrayList<String> itemList;
++
++ // TODO: make it parse the item list directly from the arguments
++ private void parseArgs(String[] args) {
++ if (args.length == 2) {
++ Options.ouputFile = "stdout";
++ Options.floors = Integer.parseInt(args[0]);
++ Options.seed = DungeonSeed.convertFromText(args[1]);
++
++ return;
++ }
++
++ Options.floors = Integer.parseInt(args[0]);
++ Options.condition = args[1].equals("any") ? Condition.ANY : Condition.ALL;
++ Options.itemListFile = args[2];
++ Options.ouputFile = args[3];
++
++ if (args.length < 5)
++ Options.startingSeed = 0;
++ else
++ Options.startingSeed = Integer.parseInt((args[4]));
++
++ if (args.length < 6)
++ Options.endingSeed = DungeonSeed.TOTAL_SEEDS;
++ else
++ Options.endingSeed = Integer.parseInt((args[5]));
++
++ }
++
++ private ArrayList<String> getItemList() {
++ ArrayList<String> itemList = new ArrayList<>();
++
++ try {
++ Scanner scanner = new Scanner(new File(Options.itemListFile));
++
++ while (scanner.hasNextLine()) {
++ itemList.add(scanner.nextLine());
++ }
++
++ scanner.close();
++
++ } catch (FileNotFoundException e) {
++ e.printStackTrace();
++ }
++
++ return itemList;
++ }
++
++ private void addTextItems(String caption, ArrayList<HeapItem> items, StringBuilder builder) {
++ if (!items.isEmpty()) {
++ builder.append(caption + ":\n");
++
++ for (HeapItem item : items) {
++ Item i = item.item;
++ Heap h = item.heap;
++
++ if (((i instanceof Armor && ((Armor) i).hasGoodGlyph()) ||
++ (i instanceof Weapon && ((Weapon) i).hasGoodEnchant()) ||
++ (i instanceof Ring) || (i instanceof Wand)) && i.cursed)
++ builder.append("- cursed " + i.title().toLowerCase());
++
++ else
++ builder.append("- " + i.title().toLowerCase());
++
++ if (h.type != Type.HEAP)
++ builder.append(" (" + h.title().toLowerCase() + ")");
++
++ builder.append("\n");
++ }
++
++ builder.append("\n");
++ }
++ }
++
++ private void addTextQuest(String caption, ArrayList<Item> items, StringBuilder builder) {
++ if (!items.isEmpty()) {
++ builder.append(caption + ":\n");
++
++ for (Item i : items) {
++ if (i.cursed)
++ builder.append("- cursed " + i.title().toLowerCase() + "\n");
++
++ else
++ builder.append("- " + i.title().toLowerCase() + "\n");
++ }
++
++ builder.append("\n");
++ }
++ }
++
++ public SeedFinder(String[] args) {
++ System.out.printf("Starting IS-Seedfinder, game version: " + Game.version + "\n");
++ parseArgs(args);
++
++ if (args.length == 2) {
++ logSeedItems(Long.toString(Options.seed), Options.floors);
++
++ return;
++ }
++
++ itemList = getItemList();
++
++ try {
++ Writer outputFile = new FileWriter(Options.ouputFile);
++ outputFile.close();
++ } catch (IOException e) {
++ e.printStackTrace();
++ }
++
++ for (int i = Options.startingSeed; i < Options.endingSeed; i++) {
++ if (testSeed(Integer.toString(i), Options.floors)) {
++ System.out.printf("Found valid seed %s (%d)\n", DungeonSeed.convertToCode(Dungeon.seed), Dungeon.seed);
++ logSeedItems(Integer.toString(i), Options.floors);
++ }
++ }
++ }
++
++ private ArrayList<Heap> getMobDrops(Level l) {
++ ArrayList<Heap> heaps = new ArrayList<>();
++
++ for (Mob m : l.mobs) {
++ if (m instanceof Statue) {
++ Heap h = new Heap();
++ h.items = new LinkedList<>();
++ h.items.add(((Statue) m).weapon.identify());
++ h.type = Type.STATUE;
++ heaps.add(h);
++ }
++
++ else if (m instanceof ArmoredStatue) {
++ Heap h = new Heap();
++ h.items = new LinkedList<>();
++ h.items.add(((ArmoredStatue) m).armor.identify());
++ h.items.add(((ArmoredStatue) m).weapon.identify());
++ h.type = Type.STATUE;
++ heaps.add(h);
++ }
++
++ else if (m instanceof Mimic) {
++ Heap h = new Heap();
++ h.items = new LinkedList<>();
++
++ for (Item item : ((Mimic) m).items)
++ h.items.add(item.identify());
++
++ if (m instanceof GoldenMimic) h.type = Type.GOLDEN_MIMIC;
++ else if (m instanceof CrystalMimic) h.type = Type.CRYSTAL_MIMIC;
++ else h.type = Type.MIMIC;
++ heaps.add(h);
++ }
++ }
++
++ return heaps;
++ }
++
++ private boolean testSeed(String seed, int floors) {
++ SPDSettings.customSeed(seed);
++ GamesInProgress.selectedClass = HeroClass.WARRIOR;
++ Dungeon.init();
++
++ boolean[] itemsFound = new boolean[itemList.size()];
++
++ for (int i = 0; i < floors; i++) {
++ Level l = Dungeon.newLevel();
++
++ if(Dungeon.depth % 5 != 0) {
++ ArrayList<Heap> heaps = new ArrayList<>(l.heaps.valueList());
++ heaps.addAll(getMobDrops(l));
++
++ for (Heap h : heaps) {
++ for (Item item : h.items) {
++ item.identify();
++