Commit 725ef739 authored by Ralf's avatar Ralf

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):
super().__init__(extern)
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))
self.name = name
self.char = char
def __str__ (self):
return self.name
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())
self.labyrinth.createThing(treasure,ttile)
euclid = Euclid(self)
etile = random.choice(self.labyrinth.getFreeTiles())
self.labyrinth.createThing(euclid,etile)
#self.labyrinth.createThing(euclid,etile)
eliza = Extern(self, "Eliza", "Z", "eliza", "simple")
ztile = random.choice(self.labyrinth.getFreeTiles())
self.labyrinth.createThing(eliza,ztile)
# set up socket
self.sock = socket.socket()
self.sock.bind(('0.0.0.0', port))
self.sock.listen(100)
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
......
Markdown is supported
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