-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfakeCube.js
33 lines (28 loc) · 867 Bytes
/
fakeCube.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* @typedef {Object} FakeCubeFace
* @property {number} color - The color of the object.
* @property {number} positionInFace - The position of the object in face.
* @property {number} parentFaceId - The ID of the parent face of the object.
*/
export default class FakeCube {
/** @type FakeCubeFace[] */
faces = [];
constructor(faces) {
this.faces = faces;
}
/** @type FakeCubeFace */
getFace(color) {
return this.faces.find(face => face.color === color);
}
/** @type FakeCubeFace */
getFaceByParentFaceId(parentFaceId) {
return this.faces.find(face => face.parentFaceId === parentFaceId);
}
getColors() {
return this.faces.map(face => face.color);
}
/** @type FakeCubeFace */
getOtherFace(color) {
return this.faces.find(face => face.color !== color);
}
}