comparison scripts/npc-test @ 234:a661b6621ec4

Add testing of triggers and entry / exit functions.
author Simon Cross <hodgestar@gmail.com>
date Thu, 07 Apr 2011 11:05:54 +0200
parents 13b912f40a10
children 8dee25fd070d
comparison
equal deleted inserted replaced
233:8ea658969f47 234:a661b6621ec4
48 print "============" 48 print "============"
49 for npc_name in game.world.npcs: 49 for npc_name in game.world.npcs:
50 print "Checking", npc_name, "...", 50 print "Checking", npc_name, "...",
51 npc = getattr(game.world.npcs, npc_name) 51 npc = getattr(game.world.npcs, npc_name)
52 dsm = DSM(npc_name, game.world, npc.dsm, npc.state) 52 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)
53 print "ok" 65 print "ok"
54 print 66 print
55 67
56 print "Testing Sprites" 68 print "Testing Sprites"
57 print "===============" 69 print "==============="