Project

General

Profile

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

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

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
import org.distorted.dmesh.ObjectMesh;
23
import org.distorted.jsons.ObjectJson;
24
import org.distorted.objectlib.json.JsonWriter;
25
import org.distorted.objectlib.main.ObjectType;
26
import org.distorted.patterns.RubikPatternList;
27

    
28
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
29

    
30
///////////////////////////////////////////////////////////////////////////////////////////////////
31

    
32
public class RubikObject
33
{
34
  private final String mName;
35
  private final int mNumScramble;
36
  private final int mOrdinal;
37
  private final int mJsonID, mMeshID, mExtrasID;
38
  private final int mIconID;
39
  private final String[][] mPatterns;
40

    
41
  private int mMeshState;
42
  private int mExtrasOrdinal;
43
  private int mObjectMinor, mExtrasMinor;
44

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

    
47
  RubikObject(ObjectType type)
48
    {
49
    mIconID      = type.getIconID();
50
    mName        = type.name();
51
    mNumScramble = type.getNumScramble();
52
    mOrdinal     = type.ordinal();
53
    mJsonID      = ObjectJson.getObjectJsonID(mOrdinal);
54
    mMeshID      = ObjectMesh.getMeshID(mOrdinal);
55
    mExtrasID    = ObjectJson.getExtrasJsonID(mOrdinal);
56

    
57
    int patternOrdinal  = RubikPatternList.getOrdinal(mOrdinal);
58
    mPatterns = RubikPatternList.getPatterns(patternOrdinal);
59

    
60
    mMeshState = MESH_NICE;
61
    mExtrasOrdinal = -1;
62

    
63
    mObjectMinor = JsonWriter.VERSION_OBJECT_MINOR;
64
    mExtrasMinor = JsonWriter.VERSION_EXTRAS_MINOR;
65
    }
66

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

    
69
  public void setExtrasOrdinal(int ordinal)
70
    {
71
    mExtrasOrdinal = ordinal;
72
    }
73

    
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75

    
76
  public int getExtrasOrdinal()
77
    {
78
    return mExtrasOrdinal;
79
    }
80

    
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82

    
83
  public void setMeshState(int state)
84
    {
85
    mMeshState = state;
86
    }
87

    
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

    
90
  public int getMeshState()
91
    {
92
    return mMeshState;
93
    }
94

    
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96
// PUBLIC API
97

    
98
  public String getName()
99
    {
100
    return mName;
101
    }
102

    
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104

    
105
  public int getNumScramble()
106
    {
107
    return mNumScramble;
108
    }
109

    
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

    
112
  public int getOrdinal()
113
    {
114
    return mOrdinal;
115
    }
116

    
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118

    
119
  public int getIconID()
120
    {
121
    return mIconID;
122
    }
123

    
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125

    
126
  public int getJsonID()
127
    {
128
    return mJsonID;
129
    }
130

    
131
///////////////////////////////////////////////////////////////////////////////////////////////////
132

    
133
  public int getMeshID()
134
    {
135
    return mMeshID;
136
    }
137

    
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139

    
140
  public int getExtrasJsonID()
141
    {
142
    return mExtrasID;
143
    }
144

    
145
///////////////////////////////////////////////////////////////////////////////////////////////////
146

    
147
  public String[][] getPatterns()
148
    {
149
    return mPatterns;
150
    }
151

    
152
///////////////////////////////////////////////////////////////////////////////////////////////////
153

    
154
  public int getObjectMinor()
155
    {
156
    return mObjectMinor;
157
    }
158

    
159
///////////////////////////////////////////////////////////////////////////////////////////////////
160

    
161
  public int getExtrasMinor()
162
    {
163
    return mExtrasMinor;
164
    }
165
}
(1-1/2)