Project

General

Profile

Download (17.5 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / objects / RubikObjectList.java @ 7480fbab

1 a7d8c3cd Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6 f05e0259 Leszek Koltunski
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8 a7d8c3cd Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10
package org.distorted.objects;
11
12 804293f0 Leszek Koltunski
import java.util.ArrayList;
13 5e048300 Leszek Koltunski
import java.util.Locale;
14 804293f0 Leszek Koltunski
15 81493402 Leszek Koltunski
import android.content.Context;
16 400ff34d Leszek Koltunski
import android.content.SharedPreferences;
17
18 81493402 Leszek Koltunski
import org.distorted.external.RubikFiles;
19 400ff34d Leszek Koltunski
import org.distorted.main.RubikActivity;
20 e4733ed7 Leszek Koltunski
import org.distorted.objectlib.main.ObjectSignatures;
21 a7d8c3cd Leszek Koltunski
import org.distorted.objectlib.main.ObjectType;
22
23 09cf2a36 Leszek Koltunski
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
24 a7d8c3cd Leszek Koltunski
import static org.distorted.objectlib.main.ObjectType.NUM_OBJECTS;
25 e847c553 Leszek Koltunski
import static org.distorted.main.RubikActivity.SHOW_DOWNLOADED_DEBUG;
26 a7d8c3cd Leszek Koltunski
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28
29
public class RubikObjectList
30
{
31 e4733ed7 Leszek Koltunski
  public static final int DEF_OBJECT= ObjectSignatures.CUBE_3;
32 506f7ceb Leszek Koltunski
  private static RubikObjectList mThis;
33 a7d8c3cd Leszek Koltunski
  private static int mNumObjects;
34 fcf7320f Leszek Koltunski
  private static int mNumExtras;
35 a7d8c3cd Leszek Koltunski
  private static ArrayList<RubikObject> mObjects;
36 400ff34d Leszek Koltunski
  private static int mObject = DEF_OBJECT;
37 a7d8c3cd Leszek Koltunski
38 314e9ff0 Leszek Koltunski
  public static class DownloadedObject
39 506f7ceb Leszek Koltunski
    {
40
    String shortName;
41 80f574a1 Leszek Koltunski
    boolean icon,object,extras,free;
42 84d746d7 Leszek Koltunski
    int numScrambles, objectMinor, extrasMinor;
43 506f7ceb Leszek Koltunski
44 80f574a1 Leszek Koltunski
    DownloadedObject(String sName, int scrambles, boolean isFree, int oMinor, int eMinor, boolean i, boolean o, boolean e)
45 506f7ceb Leszek Koltunski
      {
46
      shortName = sName;
47 84d746d7 Leszek Koltunski
48
      numScrambles= scrambles;
49 80f574a1 Leszek Koltunski
      free        = isFree;
50 84d746d7 Leszek Koltunski
      objectMinor = oMinor;
51
      extrasMinor = eMinor;
52
53 506f7ceb Leszek Koltunski
      icon   = i;
54
      object = o;
55
      extras = e;
56
      }
57
    }
58
59
  private static ArrayList<DownloadedObject> mDownloadedObjects;
60 9b763e1c Leszek Koltunski
  private static String mFreeSolvedObjects;
61
  private static String mFreeBoughtObjects;
62 506f7ceb Leszek Koltunski
63 a7d8c3cd Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
64
65
  private RubikObjectList()
66
    {
67 fcf7320f Leszek Koltunski
    mNumObjects= 0;
68
    mNumExtras = 0;
69 804293f0 Leszek Koltunski
70 506f7ceb Leszek Koltunski
    mObjects           = new ArrayList<>();
71
    mDownloadedObjects = new ArrayList<>();
72 a7d8c3cd Leszek Koltunski
73
    createBuiltinObjects();
74
    }
75
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77
78
  private void createBuiltinObjects()
79
    {
80
    for(int i=0; i<NUM_OBJECTS; i++)
81
      {
82
      ObjectType type = ObjectType.getObject(i);
83 d433b50e Leszek Koltunski
      RubikObject obj = new RubikObject(type);
84 a7d8c3cd Leszek Koltunski
      mObjects.add(obj);
85
      mNumObjects++;
86 804293f0 Leszek Koltunski
87 e847c553 Leszek Koltunski
      if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "creating local object "+type.name() );
88 84d746d7 Leszek Koltunski
89 314e9ff0 Leszek Koltunski
      if( obj.hasExtras() )
90 804293f0 Leszek Koltunski
        {
91 e847c553 Leszek Koltunski
        if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "has extras "+mNumExtras );
92 84d746d7 Leszek Koltunski
93 fcf7320f Leszek Koltunski
        obj.setExtrasOrdinal(mNumExtras);
94
        mNumExtras++;
95 84d746d7 Leszek Koltunski
        }
96
      else
97
        {
98 e847c553 Leszek Koltunski
        if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "no extras");
99 804293f0 Leszek Koltunski
        }
100 a7d8c3cd Leszek Koltunski
      }
101
    }
102
103 506f7ceb Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
104
105 84d746d7 Leszek Koltunski
  private static boolean internalAddDownloadedObject(DownloadedObject object)
106 506f7ceb Leszek Koltunski
    {
107 314e9ff0 Leszek Koltunski
    String name = object.shortName;
108
109
    for(RubikObject ro : mObjects )
110 84d746d7 Leszek Koltunski
      if( ro.getLowerName().equals(name) )
111 314e9ff0 Leszek Koltunski
        {
112 84d746d7 Leszek Koltunski
        return ro.updateObject(object);
113 314e9ff0 Leszek Koltunski
        }
114
115 84d746d7 Leszek Koltunski
    RubikObject obj = new RubikObject(object);
116
    mObjects.add(obj);
117
    mNumObjects++;
118
119 e847c553 Leszek Koltunski
    if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "creating downloaded object "+obj.getUpperName() );
120 84d746d7 Leszek Koltunski
121
    if( obj.hasExtras() )
122 314e9ff0 Leszek Koltunski
      {
123 e847c553 Leszek Koltunski
      if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "has extras "+mNumExtras );
124 506f7ceb Leszek Koltunski
125 84d746d7 Leszek Koltunski
      obj.setExtrasOrdinal(mNumExtras);
126
      mNumExtras++;
127
      }
128
    else
129
      {
130 e847c553 Leszek Koltunski
      if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "no extras");
131 314e9ff0 Leszek Koltunski
      }
132 84d746d7 Leszek Koltunski
133
    return true;
134 506f7ceb Leszek Koltunski
    }
135
136 a7d8c3cd Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
137
// PUBLIC API
138 806329e3 Leszek Koltunski
139 80f574a1 Leszek Koltunski
  public static boolean addDownloadedObject(Context context, String shortName, int numScrambles, boolean isFree, int objectMinor,
140 81493402 Leszek Koltunski
                                         int extrasMinor, boolean icon, boolean object, boolean extras)
141 806329e3 Leszek Koltunski
    {
142 c89c3b1b Leszek Koltunski
    if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "New downloaded object "+shortName+" icon="+icon+" object="+object+" extras="+extras);
143
144 506f7ceb Leszek Koltunski
    for( DownloadedObject obj : mDownloadedObjects )
145
      {
146
      if( obj.shortName.equals(shortName) )
147
        {
148
        obj.icon  |= icon;
149
        obj.object|= object;
150
        obj.extras|= extras;
151
152 c89c3b1b Leszek Koltunski
        if( !obj.object ) objectMinor=-1;
153
        if( !obj.extras ) extrasMinor=-1;
154
155
        obj.objectMinor = objectMinor;
156
        obj.extrasMinor = extrasMinor;
157
158
        if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Updating downloaded object "+shortName+" icon="+obj.icon+" object="+obj.object+" extras="+obj.extras);
159 506f7ceb Leszek Koltunski
160 41a5dd89 Leszek Koltunski
        try
161
          {
162
          RubikActivity ract = (RubikActivity)context;
163
          ract.reloadObject(shortName);
164
          }
165
        catch(Exception ex)
166
          {
167
          android.util.Log.e("D", "exception trying to reload object: "+ex.getMessage() );
168
          }
169
170 ac1900c3 Leszek Koltunski
        return false;
171 506f7ceb Leszek Koltunski
        }
172
      }
173
174 c89c3b1b Leszek Koltunski
    if( !object ) objectMinor=-1;
175
    if( !extras ) extrasMinor=-1;
176
177 80f574a1 Leszek Koltunski
    DownloadedObject obj = new DownloadedObject(shortName,numScrambles,isFree,objectMinor,extrasMinor,icon,object,extras);
178 c89c3b1b Leszek Koltunski
    if ( internalAddDownloadedObject(obj) )
179 84d746d7 Leszek Koltunski
      {
180 c89c3b1b Leszek Koltunski
      if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Adding new downloaded object "+shortName+" icon="+obj.icon+" object="+obj.object+" extras="+obj.extras);
181
      mDownloadedObjects.add(obj);
182 ac1900c3 Leszek Koltunski
      return true;
183 84d746d7 Leszek Koltunski
      }
184 81493402 Leszek Koltunski
    else
185
      {
186
      if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "New downloaded object "+shortName+" is already built-in, deleting");
187
      RubikFiles files = RubikFiles.getInstance();
188
      files.deleteIcon(context,shortName);
189
      files.deleteJsonObject(context,shortName);
190
      files.deleteJsonExtras(context,shortName);
191 ac1900c3 Leszek Koltunski
      return false;
192 81493402 Leszek Koltunski
      }
193 806329e3 Leszek Koltunski
    }
194
195 f12e4de9 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
196
197
  public static void setMeshState(int ordinal, int state)
198
    {
199
    if( ordinal>=0 && ordinal<mNumObjects ) mObjects.get(ordinal).setMeshState(state);
200
    }
201
202
///////////////////////////////////////////////////////////////////////////////////////////////////
203
204
  public static int getMeshState(int ordinal)
205
    {
206
    return (ordinal>=0 && ordinal<mNumObjects) ? mObjects.get(ordinal).getMeshState() : MESH_NICE;
207
    }
208
209 9b763e1c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
210
211
  public static void saveMeshState(SharedPreferences.Editor editor)
212
    {
213
    for(int i=0; i<mNumObjects; i++)
214
      {
215
      RubikObject obj = getObject(i);
216
217
      if( obj!=null )
218
        {
219
        String name = obj.getUpperName();
220
        editor.putInt("rol_"+name, obj.getMeshState() );
221
        }
222
      }
223
    }
224
225 7480fbab Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
226
227
  public static boolean allAlreadyBought()
228
    {
229
    return mFreeBoughtObjects.equals("*");
230
    }
231
232
///////////////////////////////////////////////////////////////////////////////////////////////////
233
234
  public static boolean objectAlreadyBought(String shortName)
235
    {
236
    RubikObject o = getObject(shortName);
237
    return ( o!=null && o.isFree() );
238
    }
239
240 9b763e1c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
241
242
  public static void buyAll()
243
    {
244
    mFreeBoughtObjects = "*";
245
246
    for(int i=0; i<mNumObjects; i++)
247
      {
248
      RubikObject o = mObjects.get(i);
249
      o.markFree();
250
      }
251
    }
252
253
///////////////////////////////////////////////////////////////////////////////////////////////////
254
255
  public static boolean buyObject(String shortName)
256
    {
257
    RubikObject o = getObject(shortName);
258
259
    if( o!=null && !o.isFree() )
260
      {
261
      o.markFree();
262 7480fbab Leszek Koltunski
      String add = mFreeBoughtObjects.length()==0 ? shortName : (","+shortName);
263
      mFreeBoughtObjects += add;
264 9b763e1c Leszek Koltunski
      return true;
265
      }
266
267
    return false;
268
    }
269
270
///////////////////////////////////////////////////////////////////////////////////////////////////
271
272
  public static boolean solveObject(String shortName)
273
    {
274
    RubikObject o = getObject(shortName);
275
276
    if( o!=null && !o.isFree() )
277
      {
278
      o.markFree();
279 7480fbab Leszek Koltunski
      String add = mFreeSolvedObjects.length()==0 ? shortName : (","+shortName);
280
      mFreeSolvedObjects += add;
281 9b763e1c Leszek Koltunski
      return true;
282
      }
283
284
    return false;
285
    }
286
287 400ff34d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
288
289
  public static void savePreferences(SharedPreferences.Editor editor)
290
    {
291 f12e4de9 Leszek Koltunski
    RubikObject obj = getObject(mObject);
292 84d746d7 Leszek Koltunski
    if( obj!=null ) editor.putString("rol_objName", obj.getUpperName() );
293 506f7ceb Leszek Koltunski
294
    int numDownloaded = mDownloadedObjects.size();
295
296
    if( numDownloaded>0 )
297
      {
298
      StringBuilder downloadedObjects = new StringBuilder();
299
300
      for(int i=0; i<numDownloaded; i++)
301
        {
302
        if( i>0 ) downloadedObjects.append(',');
303
304
        DownloadedObject object = mDownloadedObjects.get(i);
305
        downloadedObjects.append(object.shortName);
306
        downloadedObjects.append(' ');
307 84d746d7 Leszek Koltunski
        downloadedObjects.append(object.numScrambles);
308
        downloadedObjects.append(' ');
309
        downloadedObjects.append(object.objectMinor);
310
        downloadedObjects.append(' ');
311
        downloadedObjects.append(object.extrasMinor);
312
        downloadedObjects.append(' ');
313 506f7ceb Leszek Koltunski
        downloadedObjects.append(object.icon   ? "1":"0");
314
        downloadedObjects.append(' ');
315
        downloadedObjects.append(object.object ? "1":"0");
316
        downloadedObjects.append(' ');
317
        downloadedObjects.append(object.extras ? "1":"0");
318 80f574a1 Leszek Koltunski
        downloadedObjects.append(' ');
319
        downloadedObjects.append(object.free ? "true":"false");
320 506f7ceb Leszek Koltunski
        }
321
322 84d746d7 Leszek Koltunski
      String objects = downloadedObjects.toString();
323 e847c553 Leszek Koltunski
      if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "saving: "+objects);
324 84d746d7 Leszek Koltunski
      editor.putString("rol_downloaded", objects );
325 506f7ceb Leszek Koltunski
      }
326 7e9139c1 Leszek Koltunski
    else
327
      {
328
      editor.putString("rol_downloaded", "" );
329
      }
330 f12e4de9 Leszek Koltunski
331 9b763e1c Leszek Koltunski
    editor.putString("rol_freeSolved", mFreeSolvedObjects);
332
    editor.putString("rol_freeBought", mFreeBoughtObjects);
333 400ff34d Leszek Koltunski
    }
334
335
///////////////////////////////////////////////////////////////////////////////////////////////////
336
337 7480fbab Leszek Koltunski
  public static void restorePreferences(Context context, SharedPreferences preferences, boolean justStarted)
338 400ff34d Leszek Koltunski
    {
339 526a5906 Leszek Koltunski
    if( mThis==null ) mThis = new RubikObjectList();
340
341 506f7ceb Leszek Koltunski
    String downloaded = preferences.getString("rol_downloaded","");
342
343 e847c553 Leszek Koltunski
    if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", downloaded);
344 506f7ceb Leszek Koltunski
345
    if( !downloaded.equals(""))
346
      {
347
      String[] dObjects = downloaded.split(",");
348
349
      for(String dObj : dObjects)
350
        {
351
        String[] parts = dObj.split(" ");
352 80f574a1 Leszek Koltunski
        int length = parts.length;
353 506f7ceb Leszek Koltunski
354 80f574a1 Leszek Koltunski
        if( length==7 || length==8 )
355 506f7ceb Leszek Koltunski
          {
356
          String name = parts[0];
357 84d746d7 Leszek Koltunski
          String scra = parts[1];
358
          String objM = parts[2];
359
          String extM = parts[3];
360
          String icon = parts[4];
361
          String obje = parts[5];
362
          String extr = parts[6];
363 80f574a1 Leszek Koltunski
          boolean isFree = (length==7 || Boolean.parseBoolean(parts[7]));
364 84d746d7 Leszek Koltunski
365
          int scrambles = Integer.parseInt(scra);
366
          int oMinor    = Integer.parseInt(objM);
367
          int eMinor    = Integer.parseInt(extM);
368 506f7ceb Leszek Koltunski
369
          boolean bIcon = icon.equals("1");
370
          boolean bObje = obje.equals("1");
371
          boolean bExtr = extr.equals("1");
372
373 80f574a1 Leszek Koltunski
          addDownloadedObject(context,name,scrambles,isFree,oMinor,eMinor,bIcon,bObje,bExtr);
374 506f7ceb Leszek Koltunski
          }
375
        }
376
      }
377 d9d2c5fb Leszek Koltunski
378
    RubikObject object = getObject(DEF_OBJECT);
379
    String defName = object==null ? "CUBE_3" : object.getUpperName();
380
    String objName= preferences.getString("rol_objName",defName);
381
    mObject = getOrdinal(objName);
382
    if( mObject<0 || mObject>=mNumObjects ) mObject = DEF_OBJECT;
383 9b763e1c Leszek Koltunski
384 7480fbab Leszek Koltunski
    if( justStarted )
385 9b763e1c Leszek Koltunski
      {
386 7480fbab Leszek Koltunski
      mFreeSolvedObjects = preferences.getString("rol_freeSolved", "");
387
      mFreeBoughtObjects = preferences.getString("rol_freeBought", "");
388
389
      if( mFreeBoughtObjects.length()>0 )
390 9b763e1c Leszek Koltunski
        {
391 7480fbab Leszek Koltunski
        if( mFreeBoughtObjects.charAt(0)=='*' )
392
          {
393
          for(int i=0; i<mNumObjects; i++)
394
            {
395
            RubikObject o = mObjects.get(i);
396
            o.markFree();
397
            }
398
          }
399
        else
400 9b763e1c Leszek Koltunski
          {
401 7480fbab Leszek Koltunski
          String[] objs = mFreeBoughtObjects.split(",");
402
403
          for( String obj : objs )
404
            {
405
            RubikObject o = getObject(obj);
406
            if( o!=null ) o.markFree();
407
            }
408 9b763e1c Leszek Koltunski
          }
409
        }
410 7480fbab Leszek Koltunski
411
      if( mFreeSolvedObjects.length()>0 )
412 9b763e1c Leszek Koltunski
        {
413 7480fbab Leszek Koltunski
        String[] objs = mFreeSolvedObjects.split(",");
414 9b763e1c Leszek Koltunski
415
        for( String obj : objs )
416
          {
417
          RubikObject o = getObject(obj);
418
          if( o!=null ) o.markFree();
419
          }
420
        }
421
      }
422 400ff34d Leszek Koltunski
    }
423
424 f12e4de9 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
425
426
  public static void restoreMeshState(SharedPreferences preferences)
427
    {
428
    for(int i=0; i<mNumObjects; i++)
429
      {
430
      RubikObject obj = getObject(i);
431
432
      if( obj!=null )
433
        {
434 84d746d7 Leszek Koltunski
        String name  = obj.getUpperName();
435 f12e4de9 Leszek Koltunski
        int meshState= preferences.getInt("rol_"+name,MESH_NICE);
436
        obj.setMeshState(meshState);
437
        }
438
      }
439
    }
440
441 400ff34d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
442
443 1088a219 Leszek Koltunski
  public static boolean setCurrObject(int ordinal)
444 400ff34d Leszek Koltunski
    {
445
    if( mObject!=ordinal )
446
      {
447
      mObject = ordinal;
448
      return true;
449
      }
450
451
    return false;
452
    }
453
454
///////////////////////////////////////////////////////////////////////////////////////////////////
455
456
  public static int getCurrObject()
457
    {
458
    return mObject;
459
    }
460
461 69b66386 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
462
463
  public static String getCurrentName()
464
    {
465
    RubikObject object = mObjects.get(mObject);
466
    return object==null ? "" : object.getUpperName();
467
    }
468
469 d433b50e Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
470 a7d8c3cd Leszek Koltunski
471
  public static RubikObject getObject(int ordinal)
472
    {
473 506f7ceb Leszek Koltunski
    if( mThis==null ) mThis = new RubikObjectList();
474 a7d8c3cd Leszek Koltunski
    return ordinal>=0 && ordinal<mNumObjects ? mObjects.get(ordinal) : null;
475
    }
476
477 41a5dd89 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
478
479
  public static RubikObject getObject(String shortUpperName)
480
    {
481
    if( mThis==null ) mThis = new RubikObjectList();
482
483
    for(int i=0; i<mNumObjects; i++)
484
      {
485
      RubikObject object = mObjects.get(i);
486
      if( object.getUpperName().equals(shortUpperName) )
487
        {
488
        return object;
489
        }
490
      }
491
492
    return null;
493
    }
494
495 a7d8c3cd Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
496
497
  public static int getNumObjects()
498
    {
499 506f7ceb Leszek Koltunski
    if( mThis==null ) mThis = new RubikObjectList();
500 a7d8c3cd Leszek Koltunski
    return mNumObjects;
501
    }
502
503
///////////////////////////////////////////////////////////////////////////////////////////////////
504
505
  public static int getOrdinal(String name)
506
    {
507 506f7ceb Leszek Koltunski
    if( mThis==null ) mThis = new RubikObjectList();
508 a7d8c3cd Leszek Koltunski
509 5e048300 Leszek Koltunski
    String lowerName = name.toLowerCase(Locale.ENGLISH);
510 84d746d7 Leszek Koltunski
511 a7d8c3cd Leszek Koltunski
    for(int i=0; i<mNumObjects; i++)
512
      {
513
      RubikObject obj = mObjects.get(i);
514 84d746d7 Leszek Koltunski
      if( obj.getLowerName().equals(lowerName) ) return i;
515 a7d8c3cd Leszek Koltunski
      }
516
517
    return -1;
518
    }
519 804293f0 Leszek Koltunski
520 fcf7320f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
521
522
  public static int getNumExtrasObjects()
523
    {
524
    return mNumExtras;
525
    }
526
527 804293f0 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
528
529
  public static int getNumTutorialObjects()
530
    {
531 fcf7320f Leszek Koltunski
    return mNumExtras;
532 804293f0 Leszek Koltunski
    }
533
534
///////////////////////////////////////////////////////////////////////////////////////////////////
535
536 fcf7320f Leszek Koltunski
  public static int getObjectOrdinal(int extrasOrdinal)
537 804293f0 Leszek Koltunski
    {
538 fcf7320f Leszek Koltunski
    for(int i=extrasOrdinal; i<mNumObjects; i++)
539 804293f0 Leszek Koltunski
      {
540
      RubikObject object = getObject(i);
541 fcf7320f Leszek Koltunski
      int extOrd = object!=null ? object.getExtrasOrdinal() : -1;
542
      if( extOrd==extrasOrdinal ) return i;
543 804293f0 Leszek Koltunski
      }
544
545
    return -1;
546
    }
547
548 fcf7320f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
549
550
  public static int getExtrasOrdinal(int objectOrdinal)
551
    {
552
    RubikObject object = getObject(objectOrdinal);
553
    return object!=null ? object.getExtrasOrdinal() : -1;
554
    }
555
556 804293f0 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
557
558
  public static int getTutorialOrdinal(int objectOrdinal)
559
    {
560
    RubikObject object = getObject(objectOrdinal);
561 fcf7320f Leszek Koltunski
    return object!=null ? object.getExtrasOrdinal() : -1;
562
    }
563
564
///////////////////////////////////////////////////////////////////////////////////////////////////
565
566
  public static int getLocalObjectMinor(int objectOrdinal)
567
    {
568
    RubikObject object = getObject(objectOrdinal);
569
    return object!=null ? object.getObjectMinor() : -1;
570
    }
571
572
///////////////////////////////////////////////////////////////////////////////////////////////////
573
574
  public static int getLocalExtrasMinor(int objectOrdinal)
575
    {
576
    RubikObject object = getObject(objectOrdinal);
577
    return object!=null ? object.getExtrasMinor() : -1;
578 804293f0 Leszek Koltunski
    }
579 a7d8c3cd Leszek Koltunski
}