Exemple #1
0
    def __init__(self):
        """ Initializes Rpg3 instance.

        Creates a valid table board and all required widgets and resources for
        the game.
        """
        super(Rpg3, self).__init__()

        self.size = 8
        self.user = User('USERNAME')
        self.createTableBoard(self.size)
        self.logger = loggerator.getLoggerator('rpg3')
        self.statsDict = tablecell.TableCell.createAttrsDict()

        labelAttrs = {'font_name': 'Times New Roman',
                      'font_size': 12,
                      'anchor_x': 'left',
                      'anchor_y': 'top', }
        x, y = 32, 460
        self.createCommandLine()

        for stat, value in self.user.stats.getStatsData().iteritems():
            label = cocos.text.Label('%s: %s' % (stat, value['count']), **labelAttrs)
            label.position = x, y
            self.add(label, name=stat)
            x, y = x, y - 16

        self.engine = engine.Engine(self.tableboard, None, self, self.user)

        self.add(SkillMenu())
Exemple #2
0
    def __init__(self, priorities, defaultPriority):
        """Notificator constructor.

        It create a Notificator instance. Initialize Id to zero.

        >>> nt = Notificator((1, 2, 3), 2)

        >>> nt.logger # doctest: +ELLIPSIS
        <loggerator.Loggerator object at 0x...>

        >>> nt.priorityValues # doctest: +ELLIPSIS
        <plist.PValuesList object at 0x...>

        >>> nt.id
        0

        >>> nt.triggerInfo
        {}

        :type priorities: list
        :param priorities:
            It is the list of priorities to be used in the priority list.

        :type defaultPriority: object
        :param defaultPriority:
            It is the default priority that will be used for any other method
            when no priority value is provided.

        :raise plist.PriorityListException:
            No list of priorities is provided.

        :raise plist.DefaultPriorityException:
            Default priority does not belong to the list of priorities provided.
        """
        self.logger = loggerator.getLoggerator('notificator',
                                               color=(loggerator.FG_YELLOW))
        """
            :type: loggerator.Loggerator

            Variable for local logger. Disable debug logs by default.
        """

        self.priorityValues = plist.PValuesList(priorities, defaultPriority)
        """
            :type: PValuesList

            PValuesList with the list with all possible priorites and the
            default one.
        """

        self.id          = 0
        """
            :type: int

            Identification for every function registered to the notify manager.
        """

        self.triggerInfo = {}
        """
Exemple #3
0
    def __init__(self, priorities, defaultPriority):
        """Notificator constructor.

        It create a Notificator instance. Initialize Id to zero.

        >>> nt = Notificator((1, 2, 3), 2)

        >>> nt.logger # doctest: +ELLIPSIS
        <loggerator.Loggerator object at 0x...>

        >>> nt.priorityValues # doctest: +ELLIPSIS
        <plist.PValuesList object at 0x...>

        >>> nt.id
        0

        >>> nt.triggerInfo
        {}

        :type priorities: list
        :param priorities:
            It is the list of priorities to be used in the priority list.

        :type defaultPriority: object
        :param defaultPriority:
            It is the default priority that will be used for any other method
            when no priority value is provided.

        :raise plist.PriorityListException:
            No list of priorities is provided.

        :raise plist.DefaultPriorityException:
            Default priority does not belong to the list of priorities provided.
        """
        self.logger = loggerator.getLoggerator('notificator',
                                               color=(loggerator.FG_YELLOW))
        """
            :type: loggerator.Loggerator

            Variable for local logger. Disable debug logs by default.
        """

        self.priorityValues = plist.PValuesList(priorities, defaultPriority)
        """
            :type: PValuesList

            PValuesList with the list with all possible priorites and the
            default one.
        """

        self.id = 0
        """
            :type: int

            Identification for every function registered to the notify manager.
        """

        self.triggerInfo = {}
        """
Exemple #4
0
 def __init__(self, name, time):
     self.name = name
     self.time = time
     self.stats = {'pushedAt': None,
                   'popedAt': None,
                   'tasksAtPush': None,
                   'tasksAtPop': None}
     self.logger = loggerator.getLoggerator('TASKER')
Exemple #5
0
 def __init__(self):
     self._cmdDict = {'exit': self.do_exit,
                      'start': self.do_start,
                      'move': self.do_move,
                      'next': self.do_next,
                      'status': self.do_status, }
     self._toolbarMessage = 'The Road Game'
     self._game = None
     self._logger = loggerator.getLoggerator('PLAY')
Exemple #6
0
    def __init__(self):
        """ Engine initialization method.

        >>> eng = Engine()
        >>> eng.simTime
        0
        >>> eng.runQ
        defaultdict(<type 'list'>, {})
        >>> eng.waitQ
        defaultdict(<type 'list'>, {})
        >>> eng.runEv
        """
        self.simTime = 0
        self.runQ    = collections.defaultdict(list)
        self.waitQ   = collections.defaultdict(list)
        self.runEv   = None
        self.logger  = loggerator.getLoggerator('ENGINE')
Exemple #7
0
    def __init__(self, theSize, theBoard=None, theNewCellCb=None):
        """ TableBoard initialization method.

        :type theSize: int
        :param theSize: Size of the board (size x size).

        :type theBoard: list
        :param theBoard: board to be used for the tableboard

        :type theNewCellCb: func
        :param theNewCellCb: Function to be called to create a new cell
        """
        super(TableBoard, self).__init__('tableboard')
        self.size      = theSize
        self.newCellCb = theNewCellCb
        self.board     = theBoard if theBoard else self._createDefaultTableBoard()
        self.logger    = loggerator.getLoggerator('tableboard')
Exemple #8
0
    def __init__(self, theName):
        """ Initialize Player instance

        >>> u = Player('my name')
        >>> u.name
        'my name'
        >>> u.stats # doctest: +ELLIPSIS
        <stats.Stats object at 0x...>

        :type theName: str
        :param theName: Player name
        """
        super(Player, self).__init__(theName)
        self.stats = stats.Stats()
        self.attrs = attrs.Attrs()
        self.logger = loggerator.getLoggerator(utilator.getClass(self))
        self.dungeonpath = None
Exemple #9
0
 def __init__(self,
              engine,
              name,
              cb=None,
              cbArgs=None,
              timeStart=1.0,
              timeEnd=100.0,
              limit=None):
     """ Generator initialization method.
     """
     self.engine    = engine
     self.counter   = 0
     self.name      = name
     self.timeStart = timeStart
     self.timeEnd   = timeEnd
     self.limit     = limit
     self.cb        = cb
     self.cbArgs    = cbArgs if cbArgs else ()
     self.logger    = loggerator.getLoggerator('GENERATOR')
Exemple #10
0
    def __init__(self):
        """ Initialize Stats instance

        >>> s = Stats()
        >>> s.level, s.exp
        (0, 0)
        >>> s.coin.value
        {'count': 0, 'value': 0}
        >>> s.axe
        {'count': 0, 'value': 0}

        """
        self.level  = 0
        self.exp    = 0
        statsStream = open('config/stats.yaml', 'r')
        self.stdict = yaml.load(statsStream)
        for key, val in self.stdict.iteritems():
            self.stdict[key] = self._initStat(val)
        self.logger = loggerator.getLoggerator('stat')
Exemple #11
0
    def __init__(self, thePosition, **kwargs):
        """ Cell initialization method.

        :type thePosition: tuple
        :param thePosition: Tuple with x and y coordinates.

        :type theName: str
        :param theName: Sword name

        :type kwargs: dict
        :param kwargs: Dictionary with sword attributes.
        """
        super(Cell, self).__init__(kwargs.get('theName', None))
        self.logger     = loggerator.getLoggerator(self.getClass())
        self.position   = thePosition
        self.data       = kwargs.get('theData', None)
        self.sprite     = kwargs.get('theSprite', None)
        self.spriteName = kwargs.get('theSpriteName', None)
        self.selected   = False
        self.createSprite()
 def __init__(self,
              engine,
              name,
              queue,
              timeStart=1.0,
              timeEnd=100.0,
              limit=None,
              taskStart=1.0,
              taskEnd=100.0):
     """ Generator initialization method.
     """
     super(TaskerGenerator, self).__init__(engine,
                                           name,
                                           cb=self._taskerEvent,
                                           timeStart=timeStart,
                                           timeEnd=timeEnd,
                                           limit=limit)
     self.queue     = queue
     self.taskStart = taskStart
     self.taskEnd   = taskEnd
     self.taskId    = 0
     self.logger    = loggerator.getLoggerator('TASK_GEN')
Exemple #13
0
from gear import Gear
import loggerator

logger = loggerator.getLoggerator('ROAD')


class Segment(object):
    def __init__(self, theLength, **kwargs):
        self._length = theLength
        self._width = kwargs.get("theWidth", 2)
        self._height = kwargs.get("theHeight", 0)
        self._gear = kwargs.get("theGear", Gear.DIRECT)
        self._startAt = None
        self._endAt = None

    def placeInRoad(self, theStartAt, theEndAt):
        assert theEndAt - theStartAt == self.Len
        self._startAt = theStartAt
        self._endAt = theEndAt

    @property
    def Len(self):
        return self._length

    @property
    def Width(self):
        return self._width

    @property
    def Height(self):
        return self._height
Exemple #14
0
    def __init__(self):
        """ Initialize dependator

        >>> dep = Dependator()

        >>> dep.instances
        {}

        >>> dep.instDependencies
        {}

        >>> dep.attrDependencies
        {}

        >>> dep.instID
        0

        >>> dep.attrID
        0

        >>> dep.logger # doctest: +ELLIPSIS
        <loggerator.Loggerator object at 0x...>


        :raise plist.PriorityListException:
            No list of priorities is provided.

        :raise plist.DefaultPriorityException:
            Default priority does not belong to the list of priorities provided.
        """
        self.instances = {}
        """
        :type: dict

        It stores all instances registered to the dependator
        """

        self.instDependencies = {}
        """
        :type: dict

        It stores all instance dependencies entries
        """

        self.attrDependencies = {}
        """
        :type: dict

        It stores all attribute dependencies entries
        """

        self.instID = 0
        """
        :type: int

        It is the id for any new instance dependency
        """

        self.attrID = 0
        """
        :type: int

        It is the id for any new attribute dependency
        """

        self.notificator = notificator.Notificator(Priority.PRIOS, Priority.DEFAULT)
        """
        :type: notificator.Notificator

        Notificator instance for handling all notification callbacks
        """

        self.logger = loggerator.getLoggerator('dependator',
                                               color=(loggerator.FG_CYAN))
        """
Exemple #15
0
:type: str

Pattern used to store method traced return values. This are stored in the mock
instances as calls just after the method being traced, so it is easy to keep
tracking that information. Return value is passed as the only parameter for
that call. This call has to be removed when method calls are returned.
"""

verbose = False
"""
:type: bool

Flag to display log information.
"""

logger = loggerator.getLoggerator('mockerator')
"""
:type: loggerator.Loggerator

Variable for local logger. Disable debug logs by default.
"""

###############################################################################
##            _                     _   _
##  ___ _   _| |__  _ __ ___  _   _| |_(_)_ __   ___  ___
## / __| | | | '_ \| '__/ _ \| | | | __| | '_ \ / _ \/ __|
## \__ \ |_| | |_) | | | (_) | |_| | |_| | | | |  __/\__ \
## |___/\__,_|_.__/|_|  \___/ \__,_|\__|_|_| |_|\___||___/
##
###############################################################################
#
Exemple #16
0
:type: str

Pattern used to store method traced return values. This are stored in the mock
instances as calls just after the method being traced, so it is easy to keep
tracking that information. Return value is passed as the only parameter for
that call. This call has to be removed when method calls are returned.
"""

verbose = False
"""
:type: bool

Flag to display log information.
"""

logger = loggerator.getLoggerator('mockerator')
"""
:type: loggerator.Loggerator

Variable for local logger. Disable debug logs by default.
"""


###############################################################################
##            _                     _   _
##  ___ _   _| |__  _ __ ___  _   _| |_(_)_ __   ___  ___
## / __| | | | '_ \| '__/ _ \| | | | __| | '_ \ / _ \/ __|
## \__ \ |_| | |_) | | | (_) | |_| | |_| | | | |  __/\__ \
## |___/\__,_|_.__/|_|  \___/ \__,_|\__|_|_| |_|\___||___/
##
###############################################################################
Exemple #17
0
 def __init__(self):
     """ Initialize Attrs instance
     """
     self.logger   = loggerator.getLoggerator('attrs')
     for attr in Attrs.getAttrs():
         setattr(self, attr, 0)
Exemple #18
0
    def __init__(self):
        """ Initialize dependator

        >>> dep = Dependator()

        >>> dep.instances
        {}

        >>> dep.instDependencies
        {}

        >>> dep.attrDependencies
        {}

        >>> dep.instID
        0

        >>> dep.attrID
        0

        >>> dep.logger # doctest: +ELLIPSIS
        <loggerator.Loggerator object at 0x...>


        :raise plist.PriorityListException:
            No list of priorities is provided.

        :raise plist.DefaultPriorityException:
            Default priority does not belong to the list of priorities provided.
        """
        self.instances = {}
        """
        :type: dict

        It stores all instances registered to the dependator
        """

        self.instDependencies = {}
        """
        :type: dict

        It stores all instance dependencies entries
        """

        self.attrDependencies = {}
        """
        :type: dict

        It stores all attribute dependencies entries
        """

        self.instID = 0
        """
        :type: int

        It is the id for any new instance dependency
        """

        self.attrID = 0
        """
        :type: int

        It is the id for any new attribute dependency
        """

        self.notificator = notificator.Notificator(Priority.PRIOS,
                                                   Priority.DEFAULT)
        """
        :type: notificator.Notificator

        Notificator instance for handling all notification callbacks
        """

        self.logger = loggerator.getLoggerator('dependator',
                                               color=(loggerator.FG_CYAN))
        """
Exemple #19
0
import random
from gear import Gear
import loggerator

logger = loggerator.getLoggerator('DICE')


class Face(object):
    def __init__(self, theValue, theGas=0, theTire=0):
        self._value = theValue
        self._gas = theGas
        self._tire = theTire

    @property
    def Value(self):
        return self._value

    @property
    def Gas(self):
        return self._gas

    @property
    def Tire(self):
        return self._tire


class Dice(object):
    def __init__(self, theFaces, theGear=Gear.DIRECT):
        assert type(theFaces) in (list, tuple)
        self._faces = theFaces
        self._faceUp = None
Exemple #20
0
 def __init__(self, theRoad, theCars):
     self._road = theRoad
     self._cars = {}
     self._logger = loggerator.getLoggerator('ROAD-HANDLER')
     for p in theCars:
         self.addCar(p)
Exemple #21
0
 def __init__(self, queue, engine):
     self.queue  = queue
     self.engine = engine
     self.busy   = False
     self.logger = loggerator.getLoggerator('SERVICER')
     self.stats  = {'waitTime': [], 'waitQueue': []}