Changeset 227:13b912f40a10


Ignore:
Timestamp:
04/06/11 23:35:26 (12 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Phase:
public
Rebase:
65616632613035356533363337306430373534313166373164613730626237656438633061633539
Message:

Add --all option for testing NPCs and sprite creation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • scripts/npc-test

    r222 r227  
    1313
    1414
    15 def run(npc_name):
    16     game = GameState("game.json")
     15def run(npc_name, game_json):
     16    game = GameState(game_json)
    1717    npc = getattr(game.world.npcs, npc_name)
    1818    dsm = DSM(npc_name, game.world, npc.dsm, npc.state)
     
    4242
    4343
     44def test_all(game_json):
     45    game = GameState(game_json)
     46
     47    print "Testing NPCs"
     48    print "============"
     49    for npc_name in game.world.npcs:
     50        print "Checking", npc_name, "...",
     51        npc = getattr(game.world.npcs, npc_name)
     52        dsm = DSM(npc_name, game.world, npc.dsm, npc.state)
     53        print "ok"
     54    print
     55
     56    print "Testing Sprites"
     57    print "==============="
     58    for level in game.world.levels:
     59        print "Checking", level, "...",
     60        game.create_sprites(level)
     61        print "ok"
     62    print
     63
     64
    4465def main():
    45     p = optparse.OptionParser(usage="%prog [options] <npc name>")
    46     opts, args = p.parse_args()
     66    parser = optparse.OptionParser(usage="%prog [options] <npc name>")
     67    parser.add_option("--all", action="store_true", default=False,
     68            dest="test_all", help="test all NPCs in game")
     69    parser.add_option("--game", default="game.json",
     70            dest="game", help="game .json file to use")
     71
     72    opts, args = parser.parse_args()
     73
     74    if opts.test_all:
     75        test_all(opts.game)
     76        return
     77
    4778    if len(args) != 1:
    4879        p.error("Must provide an npc json file")
    49     run(args[0])
     80    run(args[0], game)
    5081
    5182if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.