Mercurial > skaapsteker
changeset 227:13b912f40a10
Add --all option for testing NPCs and sprite creation.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Thu, 07 Apr 2011 01:35:26 +0200 |
parents | 3286f1f32263 |
children | ec38a0b08729 |
files | scripts/npc-test |
diffstat | 1 files changed, 36 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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] <npc name>") - opts, args = p.parse_args() + parser = optparse.OptionParser(usage="%prog [options] <npc name>") + 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()