diff --git a/game/heartbeat.py b/game/heartbeat.py index 0f2a222d..b81a417c 100644 --- a/game/heartbeat.py +++ b/game/heartbeat.py @@ -39,7 +39,6 @@ def heartbeat(self): if time.loop % time.loops_an_hour == 0: self.calculateSleep() - def saveCharacters(self): """ Save all the characters currently playing the game. @@ -50,7 +49,6 @@ def saveCharacters(self): continue self.store.saveCharacter(player.character) - def advanceActions(self): """ Advance any player actions currently in progress. diff --git a/game/store/models/base.py b/game/store/models/base.py index 86aecaa1..ba9f7d96 100644 --- a/game/store/models/base.py +++ b/game/store/models/base.py @@ -61,7 +61,7 @@ def __init__(self): super(NamedModel, self).__init__() self.name = '' - def setId(self, name): - self.id = name - self.name = name + def setId(self, id): + self.id = id + self.name = id return self diff --git a/game/store/store.py b/game/store/store.py index 725c851e..0a7f1fa2 100644 --- a/game/store/store.py +++ b/game/store/store.py @@ -225,7 +225,8 @@ def __init__(self, world='base', data_directory='data/'): The path to the data directory. """ self.data_directory = 'data/' - self.world = world + self.world_name = world + self.world = World() self.players = [] @@ -270,10 +271,8 @@ def load(self): print("Loading the game store.") - world_name = self.world - world_path = os.path.join(self.data_directory, 'worlds', world_name, 'world.json') + world_path = os.path.join(self.data_directory, 'worlds', self.world_name, 'world.json') print("Loading the world from %s..." % world_path) - self.world = World() self.world.load(world_path) item_path = os.path.join(self.data_directory, 'items/') diff --git a/main.py b/main.py index 0f32da35..73b74b0f 100644 --- a/main.py +++ b/main.py @@ -1,23 +1,25 @@ #!/usr/bin/python3 -import time, random, argparse +import time +import random +import argparse -from game.sockets.server import ServerSocket +from game.sockets.server import ServerSocket -from game.store.store import Store +from game.store.store import Store from game.library.library import Library from game.player import Player from game.interpreters.command.interpreter import CommandInterpreter from game.interpreters.state.interpreter import StateInterpreter -import game.account_menu.welcome as welcome +import game.account_menu.welcome as welcome import game.account_menu.creation as creation import game.account_menu.password as password import game.account_menu.menu as menu -import game.commands.communication as communication -import game.commands.information as information +import game.commands.communication as communication +import game.commands.information as information import game.commands.movement as movement import game.commands.manipulation as manipulation import game.commands.crafting as crafting @@ -26,6 +28,7 @@ from game.heartbeat import Heartbeat + def gameLoop(serverSocket, library, store, account_interpreter, game_interpreter): """ The primary game loop. This method loops indefinitely (until killed using @@ -61,7 +64,7 @@ def gameLoop(serverSocket, library, store, account_interpreter, game_interpreter while serverSocket.isOpen: start_time = time.time_ns() - library.world.time.loop() + library.world.time.loop() # Poll for input and output ready clients and then handle the # communication. Also accept new clients. @@ -112,7 +115,7 @@ def gameLoop(serverSocket, library, store, account_interpreter, game_interpreter if sleep_time > 0: time.sleep(sleep_time/1000000000.0) elif loop_time > loop_length: - overrun = loop_time - loop_length + overrun = loop_time - loop_length # Reset overrun. if loop_time <= loop_length: @@ -124,8 +127,10 @@ def main(): prog='main', description='Run the Muddy Reality Server.') - parser.add_argument('-H', '--host', dest='host', default='', help="What hostname do we want to run the server on?") - parser.add_argument('-p', '--port', dest='port', default=3000, help="What port should we run the server on?") + parser.add_argument('-H', '--host', dest='host', default='', + help="What hostname do we want to run the server on?") + parser.add_argument('-p', '--port', dest='port', default=3000, + help="What port should we run the server on?") parser.add_argument('--data', default='data/', help='The location of the data directory, relative to this file.') parser.add_argument('--world', default='base', help='The name of the world we want to run the server for.')