Mercurial > touhou
comparison eosd @ 475:9d4d52793eca
Experimental netplay! Yay!
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Wed, 28 Dec 2011 18:45:09 +0100 |
parents | 9bb26dbb8438 |
children | 44c5e7d4b615 |
comparison
equal
deleted
inserted
replaced
228:8f4cd1c01d22 | 475:9d4d52793eca |
---|---|
25 from pytouhou.games.eosd import EoSDGame | 25 from pytouhou.games.eosd import EoSDGame |
26 from pytouhou.game.player import PlayerState | 26 from pytouhou.game.player import PlayerState |
27 from pytouhou.formats.t6rp import T6RP | 27 from pytouhou.formats.t6rp import T6RP |
28 | 28 |
29 | 29 |
30 def main(path, stage_num, rank, character, replay, data): | 30 def main(path, stage_num, rank, character, replay, data, port, remote): |
31 players = [PlayerState(character=character)] | |
32 | |
31 if replay: | 33 if replay: |
32 with open(replay, 'rb') as file: | 34 with open(replay, 'rb') as file: |
33 replay = T6RP.read(file) | 35 replay = T6RP.read(file) |
34 rank = replay.rank | 36 rank = replay.rank |
35 character = replay.character | 37 character = replay.character |
38 from pytouhou.utils.random import Random | 40 from pytouhou.utils.random import Random |
39 prng = Random(replay.levels[stage_num-1].random_seed) | 41 prng = Random(replay.levels[stage_num-1].random_seed) |
40 else: | 42 else: |
41 prng = None | 43 prng = None |
42 | 44 |
45 if port != 0: | |
46 from pytouhou.network import Network | |
47 if remote: | |
48 remote_addr, remote_port = remote.split(':') | |
49 addr = remote_addr, int(remote_port) | |
50 else: | |
51 addr = None | |
52 | |
53 players.append(PlayerState(character=character)) | |
54 con = Network(port, addr) | |
55 else: | |
56 con = None | |
57 | |
43 resource_loader = Loader() | 58 resource_loader = Loader() |
44 resource_loader.scan_archives(os.path.join(path, name) | 59 resource_loader.scan_archives(os.path.join(path, name) |
45 for name in data) | 60 for name in data) |
46 game = EoSDGame(resource_loader, [PlayerState(character=character)], stage_num, rank, 16, | 61 game = EoSDGame(resource_loader, players, stage_num, rank, 16, |
47 prng=prng) | 62 prng=prng) |
48 | 63 |
49 # Load stage data | 64 # Load stage data |
50 stage = resource_loader.get_stage('stage%d.std' % stage_num) | 65 stage = resource_loader.get_stage('stage%d.std' % stage_num) |
51 | 66 |
52 background_anm_wrapper = resource_loader.get_anm_wrapper(('stg%dbg.anm' % stage_num,)) | 67 background_anm_wrapper = resource_loader.get_anm_wrapper(('stg%dbg.anm' % stage_num,)) |
53 background = Background(stage, background_anm_wrapper) | 68 background = Background(stage, background_anm_wrapper) |
54 | 69 |
55 # Main loop | 70 # Main loop |
56 runner = GameRunner(resource_loader, game, background, replay=replay) | 71 runner = GameRunner(resource_loader, game, background, replay=replay, con=con) |
57 runner.start() | 72 runner.start() |
58 | 73 |
59 | 74 |
60 parser = argparse.ArgumentParser(description='Libre reimplementation of the Touhou 6 engine.') | 75 parser = argparse.ArgumentParser(description='Libre reimplementation of the Touhou 6 engine.') |
61 | 76 |
63 parser.add_argument('-p', '--path', metavar='DIRECTORY', default='.', help='Game directory path.') | 78 parser.add_argument('-p', '--path', metavar='DIRECTORY', default='.', help='Game directory path.') |
64 parser.add_argument('-s', '--stage', metavar='STAGE', type=int, required=True, help='Stage, 1 to 7 (Extra).') | 79 parser.add_argument('-s', '--stage', metavar='STAGE', type=int, required=True, help='Stage, 1 to 7 (Extra).') |
65 parser.add_argument('-r', '--rank', metavar='RANK', type=int, default=0, help='Rank, from 0 (Easy, default) to 3 (Lunatic).') | 80 parser.add_argument('-r', '--rank', metavar='RANK', type=int, default=0, help='Rank, from 0 (Easy, default) to 3 (Lunatic).') |
66 parser.add_argument('-c', '--character', metavar='CHARACTER', type=int, default=0, help='Select the character to use, from 0 (ReimuA, default) to 3 (MarisaB).') | 81 parser.add_argument('-c', '--character', metavar='CHARACTER', type=int, default=0, help='Select the character to use, from 0 (ReimuA, default) to 3 (MarisaB).') |
67 parser.add_argument('--replay', metavar='REPLAY', help='Select a replay') | 82 parser.add_argument('--replay', metavar='REPLAY', help='Select a replay') |
83 parser.add_argument('--port', metavar='PORT', type=int, default=0, help='Port to use for netplay') | |
84 parser.add_argument('--remote', metavar='REMOTE', default=None, help='Remote address') | |
68 | 85 |
69 args = parser.parse_args() | 86 args = parser.parse_args() |
70 | 87 |
71 main(args.path, args.stage, args.rank, args.character, args.replay, tuple(args.data)) | 88 main(args.path, args.stage, args.rank, args.character, args.replay, tuple(args.data), args.port, args.remote) |