annotate src/parpg/bGrease/__init__.py @ 173:fadc02e77ae1

get_equipable now checks if wearer is valid and returns None if it is not. This will fix a falsely raised SlotInvalidError.
author KarstenBock@gmx.net
date Sun, 09 Oct 2011 19:23:59 +0200
parents 96af64cf3b81
children
rev   line source
27
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
1 #############################################################################
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
2 #
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
3 # Copyright (c) 2010 by Casey Duncan and contributors
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
4 # All Rights Reserved.
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
5 #
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
6 # This software is subject to the provisions of the MIT License
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
7 # A copy of the license should accompany this distribution.
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
8 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
9 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
10 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
11 #
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
12 #############################################################################
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
13
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
14 __versioninfo__ = (0, 3, 0)
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
15 __version__ = '.'.join(str(n) for n in __versioninfo__)
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
16
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
17 __all__ = ('BaseWorld', 'Entity', 'System', 'Renderer')
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
18
29
ad18c3f912c5 Made sure that the modules in the current directory are imported, and not those
KarstenBock@gmx.net
parents: 27
diff changeset
19 import component
ad18c3f912c5 Made sure that the modules in the current directory are imported, and not those
KarstenBock@gmx.net
parents: 27
diff changeset
20 import geometry
ad18c3f912c5 Made sure that the modules in the current directory are imported, and not those
KarstenBock@gmx.net
parents: 27
diff changeset
21 import collision
ad18c3f912c5 Made sure that the modules in the current directory are imported, and not those
KarstenBock@gmx.net
parents: 27
diff changeset
22 from entity import Entity
ad18c3f912c5 Made sure that the modules in the current directory are imported, and not those
KarstenBock@gmx.net
parents: 27
diff changeset
23 from world import BaseWorld
27
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
24
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
25 import abc
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
26
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
27 class System(object):
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
28 """Grease system abstract base class. Systems define behaviorial aspects
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
29 of a |World|. All systems must define a :meth:`step`
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
30 method that is invoked by the world each timestep. User-defined systems
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
31 are not required to subclass this class.
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
32
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
33 See :ref:`an example system from the tutorial <tut-system-example>`.
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
34 """
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
35 __metaclass__ = abc.ABCMeta
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
36
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
37 world = None
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
38 """The |World| this system belongs to"""
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
39
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
40 def set_world(self, world):
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
41 """Bind the system to a world"""
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
42 self.world = world
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
43
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
44 @abc.abstractmethod
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
45 def step(self, dt):
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
46 """Execute a time step for the system. Must be defined
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
47 by all system classes.
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
48
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
49 :param dt: Time since last step invocation
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
50 :type dt: float
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
51 """
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
52
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
53 class Renderer(object):
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
54 """Grease renderer abstract base class. Renderers define the presentation
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
55 of a |World|. All renderers must define a :meth:`draw`
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
56 method that is invoked by the world when the display needs to be redrawn.
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
57 User-defined renderers are not required to subclass this class.
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
58
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
59 See :ref:`an example renderer from the tutorial <tut-renderer-example>`.
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
60 """
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
61 __metaclass__ = abc.ABCMeta
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
62
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
63 world = None
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
64 """The |World| this renderer belongs to"""
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
65
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
66 def set_world(self, world):
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
67 """Bind the system to a world"""
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
68 self.world = world
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
69
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
70 @abc.abstractmethod
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
71 def draw(self):
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
72 """Issue drawing commands for this renderer. Must be defined
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
73 for all renderer classes.
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
74 """
09b581087d68 Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
75