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
46904944
Commit
46904944
authored
Jul 31, 2014
by
Constantin
Browse files
add player to field
parent
2216d58b
Changes
2
Hide whitespace changes
Inline
Side-by-side
game.py
View file @
46904944
...
...
@@ -2,6 +2,7 @@ from player import Player
import
selectors
import
socket
import
labyrinth
import
random
class
Game
:
def
__init__
(
self
,
labyrinthFileName
,
port
=
1234
):
...
...
@@ -18,8 +19,9 @@ class Game:
def
accept
(
self
,
sock
,
mask
):
assert
sock
==
self
.
sock
conn
,
addr
=
sock
.
accept
()
# Should be ready
tile
=
random
.
choice
(
self
.
labyrinth
.
getFreeTiles
())
player
=
Player
(
self
,
conn
)
self
.
labyrinth
.
createThing
(
player
,
tile
)
self
.
players
.
append
(
player
)
self
.
sel
.
register
(
conn
,
selectors
.
EVENT_READ
,
player
.
read
)
...
...
player.py
View file @
46904944
...
...
@@ -7,7 +7,7 @@ sayVerbs = ['say', 'talk', 'scream']
class
Player
(
Thing
):
def
__init__
(
self
,
game
,
conn
):
super
().
__init__
(
self
)
super
().
__init__
()
self
.
buffer
=
b
""
self
.
game
=
game
self
.
conn
=
conn
...
...
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