Commit 725ef739 authored by Ralf's avatar Ralf
Browse files

start with a process interface

parent b0d2692f
from npc import Npc
import random
class Extern (Npc):
class DLevel(Npc.DialogLevel):
def __init__ (self,extern,wdir,binary):
def analyzeAnswer(self, teller, verb, message):
return ("say", "hello", None)
def __init__(self,game,name,char,wdir,binary):
super().__init__(game, Extern.DLevel(self, wdir, binary)) = name
self.char = char
def __str__ (self):
def __repr__ (self):
return self.char
def blocksMove(self):
return False
......@@ -7,6 +7,7 @@ import sys
from util import log_file
from treasure import Treasure
from euclid import Euclid
from extern import Extern
class Game:
def __init__(self, labyrinthFileName, adminPW, logFileName=None, port=1234):
......@@ -14,17 +15,23 @@ class Game:
self.admins = []
with open(labyrinthFileName,'r') as f:
self.labyrinth = labyrinth.Labyrinth(game=self,stream=f)
# set up labyrinth and its content
treasure = Treasure(self)
ttile = random.choice(self.labyrinth.getFreeTiles())
euclid = Euclid(self)
etile = random.choice(self.labyrinth.getFreeTiles())
eliza = Extern(self, "Eliza", "Z", "eliza", "simple")
ztile = random.choice(self.labyrinth.getFreeTiles())
# set up socket
self.sock = socket.socket()
self.sock.bind(('', port))
self.sel = selectors.DefaultSelector()
self.sel.register(self.sock, selectors.EVENT_READ, self.accept)
# log file and admin stuff
self.logFile = None if logFileName is None else open(logFileName, 'a')
self.adminPW = adminPW
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment