From 9317e573f0b65269172e762717567051027f9369 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Mon, 18 Feb 2019 01:39:27 +0100 Subject: [PATCH] Proper module structure. --- new/example_server.py | 23 +++++++++++++++++++++++ new/plomrogue/__init__.py | 2 ++ new/{plomrogue2.py => plomrogue/misc.py} | 0 3 files changed, 25 insertions(+) create mode 100755 new/example_server.py create mode 100644 new/plomrogue/__init__.py rename new/{plomrogue2.py => plomrogue/misc.py} (100%) diff --git a/new/example_server.py b/new/example_server.py new file mode 100755 index 0000000..fea2f68 --- /dev/null +++ b/new/example_server.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +import sys +import os +from plomrogue import Game + +if len(sys.argv) != 2: + print('wrong number of arguments, expected one (game file)') + exit(1) +game_file_name = sys.argv[1] +game = Game(game_file_name) +if os.path.exists(game_file_name): + if not os.path.isfile(game_file_name): + print('game file name does not refer to a valid game file') + else: + with open(game_file_name, 'r') as f: + lines = f.readlines() + for i in range(len(lines)): + line = lines[i] + print("FILE INPUT LINE %5s: %s" % (i, line), end='') + game.io.handle_input(line, store=False) +else: + game.io.handle_input('GEN_WORLD Y:16,X:16 bar') +game.io.run_loop_with_server() diff --git a/new/plomrogue/__init__.py b/new/plomrogue/__init__.py new file mode 100644 index 0000000..110ced7 --- /dev/null +++ b/new/plomrogue/__init__.py @@ -0,0 +1,2 @@ +#!/usr/bin/env python3 +from plomrogue.misc import Game diff --git a/new/plomrogue2.py b/new/plomrogue/misc.py similarity index 100% rename from new/plomrogue2.py rename to new/plomrogue/misc.py -- 2.30.2