Skip to content

Commit

Permalink
Some fixes caught by the addition of pyright to my development stack.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielBingham committed Feb 18, 2024
1 parent 63a5881 commit 7af1bb0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
2 changes: 0 additions & 2 deletions game/heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -50,7 +49,6 @@ def saveCharacters(self):
continue
self.store.saveCharacter(player.character)


def advanceActions(self):
"""
Advance any player actions currently in progress.
Expand Down
6 changes: 3 additions & 3 deletions game/store/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 3 additions & 4 deletions game/store/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down Expand Up @@ -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/')
Expand Down
25 changes: 15 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand All @@ -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.')
Expand Down

0 comments on commit 7af1bb0

Please sign in to comment.