From 0cc206ee64b745d542f6e26751e2a5c704218dbf Mon Sep 17 00:00:00 2001 From: Sylvain Bellemare Date: Fri, 20 Jul 2018 21:11:44 +0100 Subject: [PATCH] package number shoot out game into script --- number_shoot_out.py | 42 ++++++++++++++++++++++++------------------ setup.py | 7 +++++++ 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/number_shoot_out.py b/number_shoot_out.py index d05181e..9f97f52 100755 --- a/number_shoot_out.py +++ b/number_shoot_out.py @@ -223,21 +223,27 @@ def round_ready(self, results): if p3_is_dead or p3_is_dead_2: self.alive[2] = False -# Parse command line arguments. -parser = OptionParser() -Toft05Runtime.add_options(parser) -options, args = parser.parse_args() - -if len(args) == 0: - parser.error("you must specify a config file") -else: - id, players = load_config(args[0]) -#print players -#print options -# Create a deferred Runtime and ask it to run our protocol when ready. -runtime_class = make_runtime_class(mixins=[Toft05Runtime, ProbabilisticEqualityMixin]) -pre_runtime = create_runtime(id, players, 1, options,runtime_class) -pre_runtime.addCallback(Protocol) - -# Start the Twisted event loop. -reactor.run() + +def main(): + # Parse command line arguments. + parser = OptionParser() + Toft05Runtime.add_options(parser) + options, args = parser.parse_args() + + if len(args) == 0: + parser.error("you must specify a config file") + else: + id, players = load_config(args[0]) + #print players + #print options + # Create a deferred Runtime and ask it to run our protocol when ready. + runtime_class = make_runtime_class(mixins=[Toft05Runtime, ProbabilisticEqualityMixin]) + pre_runtime = create_runtime(id, players, 1, options,runtime_class) + pre_runtime.addCallback(Protocol) + + # Start the Twisted event loop. + reactor.run() + + +if __name__ == "__main__": + main() diff --git a/setup.py b/setup.py index db064a8..356ec7b 100644 --- a/setup.py +++ b/setup.py @@ -10,5 +10,12 @@ name='mpc', version='0.0.1', py_modules=['number_shoot_out'], + entry_points = { + 'console_scripts': ['mpc-numbershootout=number_shoot_out:main'], + }, + install_requires=['viff>=2.0'], extras_require={'dev': dev_require}, + dependency_links=[ + 'git+https://github.com/sbellem/viff.git@setup#egg=viff-2.0', + ], )