Mercurial > touhou
comparison eosd @ 219:091301805cce
Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
| author | Thibaut Girka <thib@sitedethib.com> |
|---|---|
| date | Thu, 15 Dec 2011 19:24:11 +0100 |
| parents | eclviewer.py@9bdf116bb2a5 |
| children | 9bb26dbb8438 |
comparison
equal
deleted
inserted
replaced
| 218:9634eefd2063 | 219:091301805cce |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 # -*- encoding: utf-8 -*- | |
| 3 ## | |
| 4 ## Copyright (C) 2011 Thibaut Girka <thib@sitedethib.com> | |
| 5 ## | |
| 6 ## This program is free software; you can redistribute it and/or modify | |
| 7 ## it under the terms of the GNU General Public License as published | |
| 8 ## by the Free Software Foundation; version 3 only. | |
| 9 ## | |
| 10 ## This program is distributed in the hope that it will be useful, | |
| 11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 ## GNU General Public License for more details. | |
| 14 ## | |
| 15 | |
| 16 import argparse | |
| 17 import os | |
| 18 | |
| 19 import pyximport | |
| 20 pyximport.install() | |
| 21 | |
| 22 from pytouhou.resource.loader import Loader | |
| 23 from pytouhou.game.background import Background | |
| 24 from pytouhou.ui.gamerunner import GameRunner | |
| 25 from pytouhou.games.eosd import EoSDGame | |
| 26 from pytouhou.game.player import PlayerState | |
| 27 from pytouhou.formats.t6rp import T6RP | |
| 28 | |
| 29 | |
| 30 def main(path, stage_num, rank, character, replay, data): | |
| 31 if replay: | |
| 32 with open(replay, 'rb') as file: | |
| 33 replay = T6RP.read(file) | |
| 34 rank = replay.rank | |
| 35 character = replay.character | |
| 36 if not replay.levels[stage_num-1]: | |
| 37 raise Exception | |
| 38 from pytouhou.utils.random import Random | |
| 39 prng = Random(replay.levels[stage_num-1].random_seed) | |
| 40 else: | |
| 41 prng = None | |
| 42 | |
| 43 resource_loader = Loader() | |
| 44 resource_loader.scan_archives(os.path.join(path, name) | |
| 45 for name in data) | |
| 46 game = EoSDGame(resource_loader, [PlayerState(character=character)], stage_num, rank, 16, | |
| 47 prng=prng) | |
| 48 | |
| 49 # Load stage data | |
| 50 stage = resource_loader.get_stage('stage%d.std' % stage_num) | |
| 51 | |
| 52 background_anm_wrapper = resource_loader.get_anm_wrapper(('stg%dbg.anm' % stage_num,)) | |
| 53 background = Background(stage, background_anm_wrapper) | |
| 54 | |
| 55 # Let's go! | |
| 56 print(stage.name) | |
| 57 | |
| 58 # Main loop | |
| 59 runner = GameRunner(resource_loader, game, background, replay=replay) | |
| 60 runner.start() | |
| 61 | |
| 62 | |
| 63 parser = argparse.ArgumentParser(description='Libre reimplementation of the Touhou 6 engine.') | |
| 64 | |
| 65 parser.add_argument('data', metavar='DAT', default=('CM.DAT', 'ST.DAT'), nargs='*', help='Game’s .DAT data files') | |
| 66 parser.add_argument('-p', '--path', metavar='DIRECTORY', default='.', help='Game directory path.') | |
| 67 parser.add_argument('-s', '--stage', metavar='STAGE', type=int, required=True, help='Stage, 1 to 7 (Extra).') | |
| 68 parser.add_argument('-r', '--rank', metavar='RANK', type=int, default=0, help='Rank, from 0 (Easy, default) to 3 (Lunatic).') | |
| 69 parser.add_argument('-c', '--character', metavar='CHARACTER', type=int, default=0, help='Select the character to use, from 0 (ReimuA, default) to 3 (MarisaB).') | |
| 70 parser.add_argument('--replay', metavar='REPLAY', help='Select a replay') | |
| 71 | |
| 72 args = parser.parse_args() | |
| 73 | |
| 74 main(args.path, args.stage, args.rank, args.character, args.replay, tuple(args.data)) |
