Revision d433b50e
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/RubikObjectList.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.objects; |
21 | 21 |
|
22 |
import org.distorted.objectlib.main.ObjectConstants; |
|
22 | 23 |
import org.distorted.objectlib.main.ObjectType; |
23 | 24 |
|
24 | 25 |
import java.util.ArrayList; |
... | ... | |
28 | 29 |
|
29 | 30 |
public class RubikObjectList |
30 | 31 |
{ |
32 |
public static int MAX_LEVEL; |
|
33 |
|
|
31 | 34 |
private static RubikObjectList mType; |
32 | 35 |
private static int mNumObjects; |
33 | 36 |
private static ArrayList<RubikObject> mObjects; |
34 | 37 |
|
38 |
static |
|
39 |
{ |
|
40 |
int max = Integer.MIN_VALUE; |
|
41 |
|
|
42 |
for (int i=0; i<NUM_OBJECTS; i++) |
|
43 |
{ |
|
44 |
int cur = getDBLevel(i); |
|
45 |
if( cur>max ) max = cur; |
|
46 |
} |
|
47 |
|
|
48 |
MAX_LEVEL = max; |
|
49 |
} |
|
50 |
|
|
35 | 51 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
36 | 52 |
|
37 | 53 |
private RubikObjectList() |
... | ... | |
49 | 65 |
for(int i=0; i<NUM_OBJECTS; i++) |
50 | 66 |
{ |
51 | 67 |
ObjectType type = ObjectType.getObject(i); |
52 |
RubikObject obj = new RubikObject(i,type);
|
|
68 |
RubikObject obj = new RubikObject(type); |
|
53 | 69 |
mObjects.add(obj); |
54 | 70 |
mNumObjects++; |
55 | 71 |
} |
... | ... | |
57 | 73 |
|
58 | 74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
59 | 75 |
// PUBLIC API |
76 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
77 |
// historically older versions of the app had lower 'maxScrambles' in case of several objects and |
|
78 |
// those got remembered in the server-side DB already, so we need to keep using them. This function |
|
79 |
// provides a map between 'maxScramble' of an object and its 'dbLevel'. All new objects will have |
|
80 |
// those two values the same. |
|
81 |
|
|
82 |
public static int getDBLevel(int ordinal) |
|
83 |
{ |
|
84 |
if( ordinal==ObjectConstants.CUBE_3 ) return 16; |
|
85 |
if( ordinal==ObjectConstants.CUBE_4 ) return 20; |
|
86 |
if( ordinal==ObjectConstants.CUBE_5 ) return 24; |
|
87 |
if( ordinal==ObjectConstants.PYRA_4 ) return 15; |
|
88 |
if( ordinal==ObjectConstants.PYRA_5 ) return 20; |
|
89 |
if( ordinal==ObjectConstants.MEGA_5 ) return 35; |
|
90 |
if( ordinal==ObjectConstants.DIAM_2 ) return 10; |
|
91 |
if( ordinal==ObjectConstants.DIAM_3 ) return 18; |
|
92 |
if( ordinal==ObjectConstants.REDI_3 ) return 14; |
|
93 |
if( ordinal==ObjectConstants.HELI_3 ) return 18; |
|
94 |
if( ordinal==ObjectConstants.SKEW_3 ) return 17; |
|
95 |
if( ordinal==ObjectConstants.REX_3 ) return 16; |
|
96 |
if( ordinal==ObjectConstants.MIRR_3 ) return 16; |
|
97 |
|
|
98 |
ObjectType type = ObjectType.getObject(ordinal); |
|
99 |
return type.getNumScramble(); |
|
100 |
} |
|
101 |
|
|
102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
60 | 103 |
|
61 | 104 |
public static RubikObject getObject(int ordinal) |
62 | 105 |
{ |
Also available in: Unified diff
In the 'magic' app, ObjectType is now only used in RubikObject and RubikObjectList classes and nowhere else.
This is a major step towards being able to download objects from an online repository.