3
3
public class ImagePair {
4
4
String image1 ;
5
5
String image2 ;
6
- int number ;
6
+ String number ;
7
+ Type type = Type .UNKNOWN ;
7
8
boolean left = true ;
8
- boolean isNTR = false ;
9
- boolean init = false ;
10
- public ImagePair (String image1 , String image2 ) throws UnmatchedException , NumberFormatException {
9
+
10
+ enum Type {
11
+ UNKNOWN ,
12
+ NINJAHAX ,
13
+ NTR ,
14
+ TESTMENU
15
+ }
16
+
17
+ public ImagePair (String image1 , String image2 ) throws UnmatchedException , IndexOutOfBoundsException {
11
18
if (image1 == null || image2 == null || image1 .equals ("null" ) || image2 .equals ("null" )) {
12
19
System .out .println ("Trying to trick me with null images?!" );
13
20
throw new UnmatchedException ();
14
21
}
15
- if (image1 .substring (0 ,4 ).equals ("scr_" ) && image2 .substring (0 ,4 ).equals ("scr_" )) {
16
- //We are now in Ninjahax Mode.
17
- if (image1 .substring (0 ,image1 .indexOf ("_" , 4 )).equals (image2 .substring (0 ,image2 .indexOf ("_" , 4 ))) &&
18
- !image1 .substring (image1 .indexOf ("_" ,4 )).equals (image2 .substring (image2 .indexOf ("_" ,4 )))){
22
+
23
+ //Check if NINJAHAX
24
+ String img1pre , img2pre ;
25
+ img1pre = image1 .substring (0 ,4 );
26
+ img2pre = image2 .substring (0 ,4 );
27
+ if (img1pre .equals ("scr_" ) && img2pre .equals ("scr_" )) { //NINJAHAX universal prefix
28
+ if (image1 .substring (0 ,image1 .indexOf ("_" , 4 )).equals (image2 .substring (0 ,image2 .indexOf ("_" , 4 ))) && //Check if number matches
29
+ !image1 .substring (image1 .indexOf ("_" ,4 )).equals (image2 .substring (image2 .indexOf ("_" ,4 )))){ //And that types are different
19
30
this .image1 = image1 ;
20
31
this .image2 = image2 ;
21
- try {
22
- number = Integer .parseInt (image1 .substring (image1 .indexOf ("_" ) + 1 ,image1 .indexOf ("_" , 4 )));
23
- } catch (NumberFormatException e ) {
24
- throw e ;
25
- }
26
- if (image1 .contains ("RIGHT" ) || image2 .contains ("RIGHT" )) {
27
- left = false ;
28
- }
29
- init = true ; //nice.
32
+ this .number = image1 .substring (image1 .indexOf ("_" ) + 1 ,image1 .indexOf ("_" , 4 ));
33
+ this .left = image1 .contains ("LEFT" ) || image2 .contains ("LEFT" );
34
+ if (this .left && image1 .contains ("RIGHT" ) || image2 .contains ("RIGHT" )) throw new UnmatchedException (); //Other image cannot be right if one is left!
35
+ this .type = Type .NINJAHAX ;
36
+ return ;
30
37
}
31
- } else if
38
+ }
32
39
33
- //Find NTR in English first
34
- (((image1 .substring (0 ,3 ).equals ("top" ) || image1 .substring (0 ,3 ).equals ("bot" )) &&
35
- (image2 .substring (0 ,3 ).equals ("top" ) || image2 .substring (0 ,3 ).equals ("bot" ))) ||
36
-
37
- //Or spanish I guess?
38
- ((image1 .substring (0 ,3 ).equals ("sup" ) || image1 .substring (0 ,3 ).equals ("inf" )) &&
39
- (image2 .substring (0 ,3 ).equals ("sup" ) || image2 .substring (0 ,3 ).equals ("inf" ))))
40
-
41
- { //extra check for ntr since I don't want it matching ninjahax ones.
42
- if (image1 .substring (4 ,8 )
43
- .equals (image2 .substring (4 ,8 )) &&
44
- !image1 .substring (0 ,image1 .indexOf ("_" ))
45
- .equals (image2 .substring (0 ,image2 .indexOf ("_" )))) {
46
- this .isNTR = true ;
40
+ //Check if NTR
41
+ img1pre = image1 .substring (0 ,3 );
42
+ img2pre = image2 .substring (0 ,3 );
43
+ if (((img1pre .equals ("top" ) || img1pre .equals ("bot" )) && (img2pre .equals ("top" ) || img2pre .equals ("bot" ))) || //NTR English prefix
44
+ ((img1pre .equals ("sup" ) || img1pre .equals ("inf" )) && (img2pre .equals ("sup" ) || img2pre .equals ("inf" ))) ) { //NTR Spanish prefix
45
+ if (image1 .substring (4 ,8 ).equals (image2 .substring (4 ,8 )) && //Check if number matches
46
+ !image1 .substring (0 ,image1 .indexOf ("_" )).equals (image2 .substring (0 ,image2 .indexOf ("_" )))) {
47
47
this .image1 = image1 ;
48
48
this .image2 = image2 ;
49
- try {
50
- number = Integer .parseInt (image1 .substring (4 ,8 ));
51
- } catch (NumberFormatException e ) {
52
- throw e ;
53
- }
54
- init = true ; //nice.
49
+ this .number = image1 .substring (4 ,8 );
50
+ this .type = Type .NTR ;
51
+ return ;
55
52
}
56
- } else {
57
- throw new UnmatchedException ();
58
53
}
54
+
55
+ //check if TESTMENU
56
+ String date1 = image1 .substring (0 , 8 ); //The date part (first 8 letters)
57
+ String date2 = image2 .substring (0 , 8 );
58
+ String time1 = image1 .substring (9 , 13 ); //The time part (After first _, 4 letters)
59
+ String time2 = image2 .substring (9 , 13 );
60
+ String number1 = image1 .substring (17 , 22 ); //The number part (After _UL_, _UR_, or _LO_, 5 letters)
61
+ String number2 = image2 .substring (17 , 22 );
62
+
63
+ //If any of this fails, an exception will be thrown.
64
+ Integer .parseInt (date1 );
65
+ Integer .parseInt (date2 );
66
+ Integer .parseInt (time1 );
67
+ Integer .parseInt (time2 );
68
+ Integer .parseInt (number1 );
69
+ Integer .parseInt (number2 );
70
+ if (date1 .equals (date2 ) && time1 .equals (time2 ) && number1 .equals (number2 )) {
71
+ if (!image1 .substring (13 , 17 ).equals (image2 .substring (13 , 17 ))) {
72
+ this .image1 = image1 ;
73
+ this .image2 = image2 ;
74
+ this .number = date1 + "_" + time1 + "_" + number1 ;
75
+ this .left = image1 .contains ("UL" ) || image2 .contains ("UL" );
76
+ if (this .left && image1 .contains ("UR" ) || image2 .contains ("UR" )) throw new UnmatchedException ();
77
+ this .type = Type .TESTMENU ;
78
+ return ;
79
+ }
80
+ }
81
+
82
+ throw new UnmatchedException ();
59
83
}
60
84
61
85
public String toString () {
62
- return (isNTR ? "NTR image," : "Ninjahax image," ) + " First: " + image1 + ", Second: " + image2 + ", Number: " + number ;
86
+ return type .toString () + " image, First: " + image1 + ", Second: " + image2 + ", Number: " + number ;
87
+ }
88
+
89
+ public String getName () {
90
+ return type .toString ().toLowerCase () + "_" + number + (left ? "" : "_RIGHT" ) + ".png" ;
63
91
}
64
92
65
93
public boolean equals (ImagePair pair2 ) {
66
- return this .number == pair2 .getNumber () && this .left == pair2 .isLeft () && this .isNTR == pair2 .isNTR ( );
94
+ return this .number . equals ( pair2 .getNumber ()) && this .left == pair2 .isLeft () && this .type . equals ( pair2 .getType () );
67
95
}
68
96
69
- public int getNumber () {
97
+ public String getNumber () {
70
98
return number ;
71
99
}
72
100
@@ -82,11 +110,7 @@ public boolean isLeft() {
82
110
return left ;
83
111
}
84
112
85
- public boolean isNTR () {
86
- return isNTR ;
87
- }
88
-
89
- public boolean isReal () {
90
- return init ; //not quite sure how one can get through without being real but...
113
+ public Type getType () {
114
+ return type ;
91
115
}
92
116
}
0 commit comments