Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Hacksaar
Haxotel
Commits
725ef739
Commit
725ef739
authored
Aug 01, 2014
by
Ralf
Browse files
start with a process interface
parent
b0d2692f
Changes
2
Hide whitespace changes
Inline
Side-by-side
extern.py
0 → 100644
View file @
725ef739
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
game.py
View file @
725ef739
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment