Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / RubikObject.java @ a7d8c3cd

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 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.objects;
21

    
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23

    
24
import org.distorted.dmesh.ObjectMesh;
25
import org.distorted.jsons.ObjectJson;
26
import org.distorted.objectlib.main.ObjectType;
27
import org.distorted.patterns.RubikPatternList;
28

    
29
public class RubikObject
30
{
31
  private static final int NUM = 4;
32

    
33
  private final String mName;
34
  private final int mNumScramble;
35
  private final int mOrdinal;
36
  private final int mJsonID, mMeshID;
37
  private final int[] mIconID;
38
  private final String[][] mPatterns;
39

    
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41

    
42
  RubikObject(int ordinal, ObjectType type)
43
    {
44
    mIconID = new int[NUM];
45
    for(int i=0; i<NUM; i++) mIconID[i] = type.getIconID(i);
46

    
47
    mName        = type.name();
48
    mNumScramble = type.getNumScramble();
49
    mOrdinal     = ordinal;
50
    mJsonID      = ObjectJson.getJsonID(type);
51
    mMeshID      = ObjectMesh.getMeshID(type);
52

    
53
    int patternOrdinal  = RubikPatternList.getOrdinal(type);
54
    mPatterns = RubikPatternList.getPatterns(patternOrdinal);
55
    }
56

    
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58
// PUBLIC API
59

    
60
  public String getName()
61
    {
62
    return mName;
63
    }
64

    
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66

    
67
  public int getIconID(int size)
68
    {
69
    return size>=0 && size<NUM ? mIconID[size] : 0;
70
    }
71

    
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73

    
74
  public int getNumScramble()
75
    {
76
    return mNumScramble;
77
    }
78

    
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80

    
81
  public int getOrdinal()
82
    {
83
    return mOrdinal;
84
    }
85

    
86
///////////////////////////////////////////////////////////////////////////////////////////////////
87

    
88
  public int getJsonID()
89
    {
90
    return mJsonID;
91
    }
92

    
93
///////////////////////////////////////////////////////////////////////////////////////////////////
94

    
95
  public int getMeshID()
96
    {
97
    return mMeshID;
98
    }
99

    
100
///////////////////////////////////////////////////////////////////////////////////////////////////
101

    
102
  public String[][] getPatterns()
103
    {
104
    return mPatterns;
105
    }
106
}
(1-1/2)