Changeset 217:fcc5eca8eaca


Ignore:
Timestamp:
04/06/11 22:59:08 (12 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Children:
218:7ee5bd883d62, 220:2d5dfec4cd11
Phase:
public
Message:

Add explicit starting state to avoid it magically appearing later.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • data/game.json

    r206 r217  
    1414    },
    1515    "npcs": {
    16         "monk": { "type": "Monk", "level": "level1", "pos": [15, 16], "dsm": "npcs/monk.json" },
    17         "guard": { "type": "Guard", "level": "level2", "pos": [10, 3], "dsm": "npcs/guard.json" }
     16        "monk": { "type": "Monk", "level": "level1", "pos": [15, 16], "dsm": "npcs/monk.json", "state": "start" },
     17        "guard": { "type": "Guard", "level": "level2", "pos": [10, 3], "dsm": "npcs/guard.json", "state": "start" }
    1818    },
    1919    "levels": {
  • skaapsteker/dialogue.py

    r216 r217  
    1616       """
    1717
    18     def __init__(self, name, world, json_filename):
    19         me = getattr(world.npcs, name)
    20         self.state = getattr(me, 'state', 'start')
    21         me.state = self.state
     18    def __init__(self, name, world, json_filename, state):
     19        self.state = state
    2220        self.world = world
    2321        self.states = AttrDict()
     
    2624            pseudo_path = [json_filename, state]
    2725            self.states[state] = DsmState(state, state_src, pseudo_path)
    28         assert self.state in self.states, "DSM must have start state"
     26        assert self.state in self.states, "DSM must have start state %r" % (self.state,)
    2927
    3028    def get_state(self):
     
    4341            self.states[self.state].leave(my_locals)
    4442            self.state = next_state.name
     43            # TODO: update self.world to reflect new state?
    4544            self.states[self.state].enter(my_locals)
    4645
  • skaapsteker/sprites/base.py

    r214 r217  
    137137        self._layer = Layers.PLAYER
    138138
    139     def setup(self, name, world, dsm):
    140         self.dsm = dialogue.DSM(name, world, dsm)
     139    def setup(self, name, world, dsm, state):
     140        self.dsm = dialogue.DSM(name, world, dsm, state)
    141141
    142142
Note: See TracChangeset for help on using the changeset viewer.