Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kamertjekapen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
kamertjekapen
Commits
96a245f7
Commit
96a245f7
authored
Dec 19, 2014
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Herp
parent
13271912
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
client.coffee
client.coffee
+4
-0
server.py
server.py
+9
-3
No files found.
client.coffee
View file @
96a245f7
...
@@ -91,6 +91,8 @@ set_turn_player = (id) ->
...
@@ -91,6 +91,8 @@ set_turn_player = (id) ->
finish
=
(
scores
)
->
finish
=
(
scores
)
->
console
.
log
'scores:'
,
scores
console
.
log
'scores:'
,
scores
cancel
=
(
reason
)
->
ws
=
new
WebSocket
URL
ws
=
new
WebSocket
URL
ws
.
send_msg
=
(
mtype
,
args
...)
->
ws
.
send_msg
=
(
mtype
,
args
...)
->
...
@@ -138,6 +140,8 @@ ws.onmessage = (msg) ->
...
@@ -138,6 +140,8 @@ ws.onmessage = (msg) ->
set_turn_player
args
[
0
]
set_turn_player
args
[
0
]
when
'finish'
when
'finish'
finish
(
s
.
split
(
':'
).
map
parseInt
for
s
in
args
)
finish
(
s
.
split
(
':'
).
map
parseInt
for
s
in
args
)
when
'cancel'
cancel
args
[
0
]
when
'error'
when
'error'
error
=
args
[
0
]
error
=
args
[
0
]
...
...
server.py
View file @
96a245f7
...
@@ -36,7 +36,7 @@ class Msg:
...
@@ -36,7 +36,7 @@ class Msg:
STATE_JOINING
=
0
STATE_JOINING
=
0
STATE_
STARTED
=
1
STATE_
PLAYING
=
1
STATE_FINISHED
=
2
STATE_FINISHED
=
2
...
@@ -60,7 +60,7 @@ class Session:
...
@@ -60,7 +60,7 @@ class Session:
def
click_wall
(
self
,
client
,
x
,
y
,
direction
):
def
click_wall
(
self
,
client
,
x
,
y
,
direction
):
check
(
self
.
turn
is
client
,
'not your turn'
)
check
(
self
.
turn
is
client
,
'not your turn'
)
check
(
self
.
state
<
STATE_FINISHED
,
'already finished'
)
check
(
self
.
state
<
STATE_FINISHED
,
'already finished'
)
self
.
state
=
STATE_
STARTED
self
.
state
=
STATE_
PLAYING
occupied
=
self
.
board
.
click_wall
(
x
,
y
,
direction
,
client
.
player
)
occupied
=
self
.
board
.
click_wall
(
x
,
y
,
direction
,
client
.
player
)
self
.
bcast
(
'clickwall'
,
x
,
y
,
direction
)
self
.
bcast
(
'clickwall'
,
x
,
y
,
direction
)
...
@@ -110,6 +110,12 @@ class Session:
...
@@ -110,6 +110,12 @@ class Session:
self
.
clients
.
remove
(
client
)
self
.
clients
.
remove
(
client
)
self
.
bcast
(
'leave'
,
client
.
player
)
self
.
bcast
(
'leave'
,
client
.
player
)
if
self
.
state
==
STATE_PLAYING
:
self
.
bcast
(
'cancel'
,
'a player has quit before the game ended'
)
elif
client
is
self
.
turn
:
self
.
turn
=
self
.
clients
[
0
]
self
.
bcast
(
'turn'
,
self
.
turn
.
player
)
def
is_dead
(
self
):
def
is_dead
(
self
):
return
not
self
.
clients
return
not
self
.
clients
...
@@ -144,7 +150,7 @@ class GameServer(AsyncServer):
...
@@ -144,7 +150,7 @@ class GameServer(AsyncServer):
elif
msg
.
mtype
==
'clickwall'
:
elif
msg
.
mtype
==
'clickwall'
:
check
(
len
(
msg
.
args
)
==
3
)
check
(
len
(
msg
.
args
)
==
3
)
x
,
y
,
direction
=
msg
.
args
x
,
y
,
direction
=
msg
.
args
check
(
client
.
session
,
'no session associated with client'
)
check
(
hasattr
(
client
,
'session'
)
,
'no session associated with client'
)
client
.
session
.
click_wall
(
client
,
x
,
y
,
direction
)
client
.
session
.
click_wall
(
client
,
x
,
y
,
direction
)
if
client
.
session
.
state
==
STATE_FINISHED
:
if
client
.
session
.
state
==
STATE_FINISHED
:
...
...
Write
Preview
Markdown
is supported
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