Changeset 234:a661b6621ec4


Ignore:
Timestamp:
04/07/11 09:05:54 (12 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Phase:
public
Message:

Add testing of triggers and entry / exit functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • scripts/npc-test

    r227 r234  
    5151        npc = getattr(game.world.npcs, npc_name)
    5252        dsm = DSM(npc_name, game.world, npc.dsm, npc.state)
     53        print "  Loaded %s." % (npc.dsm)
     54
     55        my_locals = { "world": dsm.world, "state": dsm.states, "npcs": dsm.world.npcs }
     56        my_locals.update(DsmEvent().items)
     57        for state_name, state in dsm.states.items():
     58            print "  Testing triggers for state %s" % state_name
     59            for trigger in state.triggers:
     60                eval(trigger._matches, {}, my_locals.copy())
     61                eval(trigger._next_state, {}, my_locals.copy())
     62            print "  Test on_entry and on_exit for state %s" % state_name
     63            state.enter(my_locals)
     64            state.leave(my_locals)
    5365        print "ok"
    5466    print
Note: See TracChangeset for help on using the changeset viewer.