Package horizons :: Package world :: Module ingametype :: Class IngameType
[hide private]
[frames] | no frames]

Type IngameType

source code

object --+    
         |    
      type --+
             |
            IngameType

Class that is used to create Ingame-Type-Classes from yaml data.

Instance Methods [hide private]
a new object with type S, a subtype of T
__new__(self, id, yaml_data) source code
 
_strip_translation_marks(self, string)
Converts object translation `string` to translated object for in-game display.
source code
the object's type
__init__(self, id, yaml_data)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
_parse_component_templates(self)
Prepares misc data in self.component_templates
source code
 
_fife_object(self) source code
 
_loadObject(self)
Inits self._real_object
source code
 
name(self) source code

Inherited from type: __call__, __delattr__, __eq__, __ge__, __getattribute__, __gt__, __hash__, __instancecheck__, __le__, __lt__, __ne__, __repr__, __setattr__, __subclasscheck__, __subclasses__, mro

Inherited from object: __format__, __reduce__, __reduce_ex__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  basepackage = 'horizons.world.building.'
  classstring = 'Type[{id}]'
Instance Variables [hide private]
  additional_provided_resources
TUTORIAL: Now you know the basic attributes each type has.
Properties [hide private]

Inherited from type: __abstractmethods__, __base__, __bases__, __basicsize__, __dictoffset__, __flags__, __itemsize__, __mro__, __name__, __weakrefoffset__

Inherited from object: __class__

Method Details [hide private]

__new__(self, id, yaml_data)

source code 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__
(inherited documentation)

_strip_translation_marks(self, string)

source code 

Converts object translation `string` to translated object for in-game display.

Object properties supposed to be translated are recognized by the (subsequently stripped) leading `_ `. If `string` is supposed to be translated, returns lazy translation object of `string`. If `string` is not supposed to be translated, returns `string` unchanged. If `string` is None (not defined or empty in yaml), returns empty unicode.

__init__(self, id, yaml_data)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • id - building or unit type id
  • yaml_data - a dict containing all the data read from yaml files

    Note this creates class types, NOT instances. These types are created at the beginning of a session and are later used to create instances, when buildings are built. The __new__() function uses quite some python magic to construct the new class.

    TUTORIAL: Check out the __new__() function if you feel you're pretty good with python and are interested in how it all works. Otherwise, continue to the __init__() function.

Returns: the object's type
Overrides: object.__init__
(inherited documentation)

_fife_object(self)

source code 
Decorators:
  • @property

name(self)

source code 
Decorators:
  • @property

Instance Variable Details [hide private]

additional_provided_resources

TUTORIAL: Now you know the basic attributes each type has.
Further attributes specific to buildings and units can be found in
horizons/world/{building,units}/__init__.py
which contains the unit and building specific attributes and loading.

By now you should know the basic constructs used in UH, so we feel
comfortable stopping the tutorial here. Be sure to join our IRC
channel and idle around there, ask us if you're stuck and so on.

You'll find tasks for getting into the code in our issue tracker at
https://github.com/unknown-horizons/unknown-horizons/issues
Especially look for issues with the 'starter' label attached!

Other relevant parts of the code you might be interested in are:
* commands: horizons/commands. Abstracts all user interactions.
* scheduler: horizons/scheduler.py. Manages ingame time.
* extscheduler: horizons/extscheduler.py. Manages wall clock time.
* scenario: horizons/scenario. Condition-action system for scenarios
* automatic tests: tests/. Contains unit tests, gui tests and game (system) tests
* networking: horizons/network. Sending stuff over the wire
* concreteobject: horizons/world/concreteobject.py. Things with graphical representations
* gui: horizons/gui. The ugly parts. IngameGui and Gui, tabs and widgets.
* production: horizons/world/production
** Producer: producer component, manages everything
** ProductionLine: keeps data about the different production lines.
** Production: the alive version of the production line. Used when a building
               actually produces something, stores progress and the like.
* engine: horizons/engine. Direct interface to fife.
* ai: horizons/ai/aiplayer. Way too big to describe here.