Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kamertjekapen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
kamertjekapen
Commits
96a245f7
Commit
96a245f7
authored
10 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Herp
parent
13271912
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client.coffee
+4
-0
4 additions, 0 deletions
client.coffee
server.py
+9
-3
9 additions, 3 deletions
server.py
with
13 additions
and
3 deletions
client.coffee
+
4
−
0
View file @
96a245f7
...
...
@@ -91,6 +91,8 @@ set_turn_player = (id) ->
finish
=
(
scores
)
->
console
.
log
'scores:'
,
scores
cancel
=
(
reason
)
->
ws
=
new
WebSocket
URL
ws
.
send_msg
=
(
mtype
,
args
...)
->
...
...
@@ -138,6 +140,8 @@ ws.onmessage = (msg) ->
set_turn_player
args
[
0
]
when
'finish'
finish
(
s
.
split
(
':'
).
map
parseInt
for
s
in
args
)
when
'cancel'
cancel
args
[
0
]
when
'error'
error
=
args
[
0
]
...
...
This diff is collapsed.
Click to expand it.
server.py
+
9
−
3
View file @
96a245f7
...
...
@@ -36,7 +36,7 @@ class Msg:
STATE_JOINING
=
0
STATE_
STARTED
=
1
STATE_
PLAYING
=
1
STATE_FINISHED
=
2
...
...
@@ -60,7 +60,7 @@ class Session:
def
click_wall
(
self
,
client
,
x
,
y
,
direction
):
check
(
self
.
turn
is
client
,
'
not your turn
'
)
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
)
self
.
bcast
(
'
clickwall
'
,
x
,
y
,
direction
)
...
...
@@ -110,6 +110,12 @@ class Session:
self
.
clients
.
remove
(
client
)
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
):
return
not
self
.
clients
...
...
@@ -144,7 +150,7 @@ class GameServer(AsyncServer):
elif
msg
.
mtype
==
'
clickwall
'
:
check
(
len
(
msg
.
args
)
==
3
)
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
)
if
client
.
session
.
state
==
STATE_FINISHED
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment