~divmod-dev/divmod.org/empty-host-header-2936

« back to all changes in this revision

Viewing changes to Imaginary/ExampleGame/examplegame/mice.py

  • Committer: glyph
  • Date: 2009-06-29 04:03:17 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:17590
Remove all usage of `installOn()` from Imaginary.

This change replaces the undocumented `ThingMixin`, and the unfortunately-named, poorly-considered idiom of using `installOn` with its subclasses, with a new, thoroughly documented and better-named mixin, `imaginary.enhancement.Enhancement`.

Furthermore, this updates `createCreator` to use `Enhancement`s rather than arbitrary powerups.

The tests and included systems now also provide a good example of how Imaginary application / game code should idiomatically fit into the framework.

Author: glyph

Reviewer: exarkun

Fixes #2558

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- test-case-name: imaginary.test.test_npc,imaginary.test.test_japanese -*-
 
1
# -*- test-case-name: examplegame.test.test_mice,examplegame.test.test_japanese -*-
2
2
 
3
3
import random
4
4
 
5
5
from zope.interface import implements
6
6
 
7
7
from axiom import item, attributes
8
 
from axiom.dependency import installOn
9
8
 
10
9
from imaginary import iimaginary, events, objects, action, language
11
10
from examplegame import japanese
255
254
    def createMouse(**kw):
256
255
        store = kw['store']
257
256
        mouse = objects.Thing(**kw)
258
 
        mouseActor = objects.Actor(store=store)
259
 
        installOn(mouseActor, mouse)
 
257
        mouseActor = objects.Actor.createFor(mouse)
260
258
        mousehood = mouseIntelligenceFactory(store=store)
261
259
        mouseActor.setEnduringIntelligence(mousehood)
262
260
        return mouse