1 |
b498f3f6
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2020 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
|
|
// Magic Cube is free software: you can redistribute it and/or modify //
|
7 |
|
|
// it under the terms of the GNU General Public License as published by //
|
8 |
|
|
// the Free Software Foundation, either version 2 of the License, or //
|
9 |
|
|
// (at your option) any later version. //
|
10 |
|
|
// //
|
11 |
|
|
// Magic Cube is distributed in the hope that it will be useful, //
|
12 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14 |
|
|
// GNU General Public License for more details. //
|
15 |
|
|
// //
|
16 |
|
|
// You should have received a copy of the GNU General Public License //
|
17 |
|
|
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. //
|
18 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
|
|
|
20 |
|
|
package org.distorted.patterns;
|
21 |
|
|
|
22 |
e4733ed7
|
Leszek Koltunski
|
import org.distorted.objectlib.main.ObjectSignatures;
|
23 |
b498f3f6
|
Leszek Koltunski
|
|
24 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
25 |
|
|
|
26 |
|
|
public enum RubikPatternList
|
27 |
|
|
{
|
28 |
e4733ed7
|
Leszek Koltunski
|
CUBE2 (ObjectSignatures.CUBE_2, PatternCube2.patterns),
|
29 |
|
|
CUBE3 (ObjectSignatures.CUBE_3, PatternCube3.patterns),
|
30 |
|
|
CUBE4 (ObjectSignatures.CUBE_4, PatternCube4.patterns),
|
31 |
|
|
CUBE5 (ObjectSignatures.CUBE_5, PatternCube5.patterns),
|
32 |
|
|
PYRA3 (ObjectSignatures.PYRA_3, PatternPyraminx3.patterns),
|
33 |
|
|
PYRA4 (ObjectSignatures.PYRA_4, PatternPyraminx4.patterns),
|
34 |
|
|
PYRA5 (ObjectSignatures.PYRA_5, PatternPyraminx5.patterns),
|
35 |
|
|
MEGA3 (ObjectSignatures.MEGA_3, PatternMegaminx.patterns),
|
36 |
|
|
MEGA5 (ObjectSignatures.MEGA_5, PatternGigaminx.patterns),
|
37 |
b498f3f6
|
Leszek Koltunski
|
;
|
38 |
|
|
|
39 |
|
|
public static final int NUM_OBJECTS = values().length;
|
40 |
d433b50e
|
Leszek Koltunski
|
private final int mObject;
|
41 |
3c4495ac
|
Leszek Koltunski
|
private final String[][] mPatterns;
|
42 |
b498f3f6
|
Leszek Koltunski
|
|
43 |
|
|
private static final RubikPatternList[] objects;
|
44 |
|
|
|
45 |
|
|
static
|
46 |
|
|
{
|
47 |
|
|
objects = new RubikPatternList[NUM_OBJECTS];
|
48 |
|
|
int i=0;
|
49 |
|
|
|
50 |
|
|
for(RubikPatternList object: RubikPatternList.values())
|
51 |
|
|
{
|
52 |
|
|
objects[i++] = object;
|
53 |
|
|
}
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
57 |
|
|
|
58 |
d433b50e
|
Leszek Koltunski
|
RubikPatternList(int object, String[][] patterns)
|
59 |
b498f3f6
|
Leszek Koltunski
|
{
|
60 |
d433b50e
|
Leszek Koltunski
|
mObject = object;
|
61 |
|
|
mPatterns = patterns;
|
62 |
b498f3f6
|
Leszek Koltunski
|
}
|
63 |
|
|
|
64 |
d433b50e
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
65 |
|
|
// PUBLIC API
|
66 |
b498f3f6
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
67 |
|
|
|
68 |
d433b50e
|
Leszek Koltunski
|
public static String[][] getPatterns(int ordinal)
|
69 |
b498f3f6
|
Leszek Koltunski
|
{
|
70 |
d433b50e
|
Leszek Koltunski
|
return ordinal>=0 && ordinal<NUM_OBJECTS ? objects[ordinal].mPatterns : null;
|
71 |
b498f3f6
|
Leszek Koltunski
|
}
|
72 |
|
|
|
73 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
74 |
|
|
|
75 |
d433b50e
|
Leszek Koltunski
|
public static int getOrdinal(int objectOrdinal)
|
76 |
b498f3f6
|
Leszek Koltunski
|
{
|
77 |
|
|
for(int i=0; i<NUM_OBJECTS; i++)
|
78 |
|
|
{
|
79 |
d433b50e
|
Leszek Koltunski
|
if( objects[i].mObject == objectOrdinal )
|
80 |
b498f3f6
|
Leszek Koltunski
|
{
|
81 |
|
|
return i;
|
82 |
|
|
}
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
return -1;
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
89 |
|
|
|
90 |
d433b50e
|
Leszek Koltunski
|
public static int getObject(int ordinal)
|
91 |
b498f3f6
|
Leszek Koltunski
|
{
|
92 |
|
|
return objects[ordinal].mObject;
|
93 |
|
|
}
|
94 |
|
|
}
|