Пример #1
0
    def get_cube_id(self, note: Note) -> int:
        """Get the Cube ID for a corresponding note.

        :param note: The :class:`~song_match.song.note.Note` of the song.
        :return: :attr:`~cozmo.objects.LightCube.cube_id`
        """
        cube_id = self._notes.index(note) + 1
        return CubeMat.cube_id_to_position(cube_id)
Пример #2
0
    def __get_tap_animation_lookup() -> dict:
        """Build a tap animation lookup dictionary.

        The key is (cube_id, prev_cube_id),
        where cube_id is the ID of the cube Cozmo is tapping,
        and prev_cube_id is the ID of the previously tapped cube.

        There are 5 animations:
        1. center
        2. small right
        3. big right
        4. small left
        5. big left

        :return: The animation to tap the cube.
        """
        mat_positions = CubeMat.get_positions()

        # Build center animations
        keys = [(LightCube1Id, LightCube1Id), (LightCube2Id, LightCube2Id),
                (LightCube3Id, LightCube3Id)]
        center = 'anim_memorymatch_pointcenter_01'
        animations = [center, center, center]

        # Build small right animations
        first_two_elements = tuple(mat_positions[:-1])
        last_two_elements = tuple(mat_positions[-2:])
        keys.append(first_two_elements)
        keys.append(last_two_elements)
        small_right = 'anim_memorymatch_pointsmallright_fast_01'
        animations.append(small_right)
        animations.append(small_right)

        # Build big right animations
        first_and_last_elements = tuple([mat_positions[0], mat_positions[-1]])
        keys.append(first_and_last_elements)
        big_right = 'anim_memorymatch_pointbigright_01'
        animations.append(big_right)

        # Build small left animations
        first_two_elements_reversed = tuple(
            mat_positions[:-1][::-1])  # ::-1 reverses the order
        last_two_elements_reversed = tuple(mat_positions[-2:][::-1])
        keys.append(first_two_elements_reversed)
        keys.append(last_two_elements_reversed)
        small_left = 'anim_memorymatch_pointsmallleft_fast_01'
        animations.append(small_left)
        animations.append(small_left)

        # Build big left animations
        first_and_last_elements_reversed = tuple(
            [mat_positions[0], mat_positions[-1]][::-1])
        keys.append(first_and_last_elements_reversed)
        big_left = 'anim_memorymatch_pointbigleft_01'
        animations.append(big_left)

        animation_lookup = dict(zip(keys, animations))
        return animation_lookup
Пример #3
0
    def get_note(self, cube_id: int) -> Note:
        """Get the :class:`~song_match.song.note.Note` for a corresponding cube.

        :param cube_id: :attr:`~cozmo.objects.LightCube.cube_id`
        :return: The :class:`~song_match.song.note.Note` of the cube.
        """
        mat_position = CubeMat.cube_id_to_position(cube_id)
        index = self._get_index(mat_position)
        return self._notes[index]
Пример #4
0
 def _get_index_from_mat_position(cls, cube_id: int):
     mat_position = CubeMat.cube_id_to_position(cube_id)
     return cls._get_index(mat_position)
Пример #5
0
 def __get_middle_cube_id() -> int:
     mat_positions = CubeMat.get_positions()
     return mat_positions[1]