Source code for src.resource_

# pylint: disable=missing-module-docstring
# pylint: disable=unnecessary-pass
import abc
from enum import Enum

from src.utils import RESOURCE_CARDS_DIR, Abstract


[docs]class ResourceCard(Abstract): """Abstract class template for Resource cards and controls behaviour for all resource card types, also inherits behaviour from abstract class so that the correct image files are retrieved for each resource card :param Abstract: abstract base class in utils.py :type Abstract: type """
[docs] @abc.abstractmethod def name(self): """ Abstract method representing description of a resource card and the outcome Should be implemented by derived classes to return card's description :return: A String representing the description of a resource card """ pass
[docs] def asset(self): """Returns resource card asset :return: Resource Card asset :rtype: str """ return self.get_asset(RESOURCE_CARDS_DIR)
[docs]class Lumber(ResourceCard): """Derived Class from ResourceCard abstract class"""
[docs] def name(self): """Displays a string indicating the Name of the resource card - Lumber :return: A string displaying the resource card name :rtype: str """ return "Lumber"
[docs]class Wool(ResourceCard): """Derived Class from ResourceCard abstract class"""
[docs] def name(self): """Displays a string indicating the Name of the resource card - Wool :return: A string displaying the resource card name :rtype: str """ return "Wool"
[docs]class Grain(ResourceCard): """Derived Class from ResourceCard abstract class"""
[docs] def name(self): """Displays a string indicating the Name of the resource card - Grain :return: A string displaying the resource card name :rtype: str """ return "Grain"
[docs]class Brick(ResourceCard): """Derived Class from ResourceCard abstract class"""
[docs] def name(self): """Displays a string indicating the Name of the resource card - Brick :return: A string displaying the resource card name :rtype: str """ return "Brick"
[docs]class Ore(ResourceCard): """Derived Class from ResourceCard abstract class"""
[docs] def name(self): """Displays a string indicating the Name of the resource card - Brick :return: A string displaying the resource card name :rtype: Ore """ return "Ore"
[docs]class Null(ResourceCard): """ A class representing a null resource card. """
[docs] def name(self): """ Returns None, since a null resource card has no name. :return: None """ return None
# pylint: disable=function-redefined
[docs]class Resource(Enum): """Class representing a Settlers of Catan resource. :param card: The corresponding ResourceCard object for this resource. :type card: ResourceCard """ WOOD = Lumber() WOOL = Wool() GRAIN = Grain() BRICK = Brick() ORE = Ore() NONE = Null() def __init__(self, card): """Constructor class""" self.card = card def name(self): """Get the name of the resource. :return: The name of the resource. :rtype: str """ return self.card.name()
[docs] def asset(self): """Get the asset representing the resource. :return: The asset representing the resource. :rtype: str """ return self.card.asset()