Module chillow.model.direction

Expand source code
from enum import Enum
import random


class Direction(Enum):
    """Enum to represent all possible directions in which a player can be directed to in a game."""
    left, right, up, down = range(4)

    @staticmethod
    def get_random_direction():
        """Randomly chooses one of the defined directions in this enum.

        Returns:
            A random direction.
        """
        return random.choice(list(Direction))

Classes

class Direction (value, names=None, *, module=None, qualname=None, type=None, start=1)

Enum to represent all possible directions in which a player can be directed to in a game.

Expand source code
class Direction(Enum):
    """Enum to represent all possible directions in which a player can be directed to in a game."""
    left, right, up, down = range(4)

    @staticmethod
    def get_random_direction():
        """Randomly chooses one of the defined directions in this enum.

        Returns:
            A random direction.
        """
        return random.choice(list(Direction))

Ancestors

  • enum.Enum

Class variables

var down
var left
var right
var up

Static methods

def get_random_direction()

Randomly chooses one of the defined directions in this enum.

Returns

A random direction.

Expand source code
@staticmethod
def get_random_direction():
    """Randomly chooses one of the defined directions in this enum.

    Returns:
        A random direction.
    """
    return random.choice(list(Direction))