示例#1
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
示例#2
0
 def __get_middle_cube_id() -> int:
     mat_positions = CubeMat.get_positions()
     return mat_positions[1]