# HG changeset patch # User Simon Cross # Date 1302132926 -7200 # Node ID 13b912f40a10530e604908878589782e66273c2d # Parent 3286f1f322637620468811f147808d90cac19ea7 Add --all option for testing NPCs and sprite creation. diff -r 3286f1f32263 -r 13b912f40a10 scripts/npc-test --- a/scripts/npc-test Thu Apr 07 01:35:03 2011 +0200 +++ b/scripts/npc-test Thu Apr 07 01:35:26 2011 +0200 @@ -12,8 +12,8 @@ from skaapsteker.gamestate import GameState -def run(npc_name): - game = GameState("game.json") +def run(npc_name, game_json): + game = GameState(game_json) npc = getattr(game.world.npcs, npc_name) dsm = DSM(npc_name, game.world, npc.dsm, npc.state) @@ -41,12 +41,43 @@ print "--" +def test_all(game_json): + game = GameState(game_json) + + print "Testing NPCs" + print "============" + for npc_name in game.world.npcs: + print "Checking", npc_name, "...", + npc = getattr(game.world.npcs, npc_name) + dsm = DSM(npc_name, game.world, npc.dsm, npc.state) + print "ok" + print + + print "Testing Sprites" + print "===============" + for level in game.world.levels: + print "Checking", level, "...", + game.create_sprites(level) + print "ok" + print + + def main(): - p = optparse.OptionParser(usage="%prog [options] ") - opts, args = p.parse_args() + parser = optparse.OptionParser(usage="%prog [options] ") + parser.add_option("--all", action="store_true", default=False, + dest="test_all", help="test all NPCs in game") + parser.add_option("--game", default="game.json", + dest="game", help="game .json file to use") + + opts, args = parser.parse_args() + + if opts.test_all: + test_all(opts.game) + return + if len(args) != 1: p.error("Must provide an npc json file") - run(args[0]) + run(args[0], game) if __name__ == '__main__': main()