summaryrefslogtreecommitdiff
path: root/asciifarm/client/gameclient.py
diff options
context:
space:
mode:
Diffstat (limited to 'asciifarm/client/gameclient.py')
-rw-r--r--asciifarm/client/gameclient.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/asciifarm/client/gameclient.py b/asciifarm/client/gameclient.py
index d6e2595..6038fec 100644
--- a/asciifarm/client/gameclient.py
+++ b/asciifarm/client/gameclient.py
@@ -5,7 +5,6 @@ import sys
import curses
import threading
-#import logging
import json
import getpass
import argparse
@@ -13,16 +12,16 @@ from .display.screen import Screen
import string
from .display import Display
-#logging.basicConfig(filename="client.log", filemode='w', level=logging.DEBUG)
class Client:
- def __init__(self, stdscr, display, name, connection, keybindings):
+ def __init__(self, stdscr, display, name, connection, keybindings, logFile=None):
self.stdscr = stdscr
self.display = display
self.name = name
self.keepalive = True
self.connection = connection
+ self.logFile = logFile
self.commands = {}
for key, commands in keybindings["input"].items():
@@ -89,14 +88,28 @@ class Client:
health = msg[1]
if health:
self.display.setHealth(*health)
+ else:
+ self.log("You have died. Restart the client to respawn")
if msgType == "inventory":
self.display.setInventory(msg[1])
if msgType == "ground":
self.display.setGround(msg[1])
+ if msgType == "message":
+ self.log(msg[1])
+ #self.display.addMessage(msg[1])
+ #if self.logFile:
+ #with(open(self.logFile, 'a')) as f:
+ #f.write(msg[1]+'\n')
self.display.update()
+ def log(self, text):
+ self.display.addMessage(text)
+ if self.logFile:
+ with(open(self.logFile, 'a')) as f:
+ f.write(text+'\n')
+
def command_loop(self):
while self.keepalive:
key = self.stdscr.getch()