Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Menteur
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PLN
Menteur
Commits
ac8ad5b5
Unverified
Commit
ac8ad5b5
authored
5 years ago
by
PLN (Algolia)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(server/game): round working
parent
a9a2cae1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
9 deletions
+11
-9
lobby.py
server/game/lobby.py
+0
-1
game.py
server/model/game.py
+8
-5
ws.py
server/ws.py
+3
-3
No files found.
server/game/lobby.py
View file @
ac8ad5b5
...
...
@@ -66,7 +66,6 @@ class LobbyManager(ClientManager):
meta
=
self
.
metadata
[
player
.
name
]
meta
.
last_announce
=
announce
meta
.
fresh_announce
=
True
print
(
f
"{player} announced {announce}!"
)
async
def
start_game
(
self
,
players
:
Optional
[
List
[
Player
]]
=
None
,
max_players
=
2
):
if
not
players
:
...
...
This diff is collapsed.
Click to expand it.
server/model/game.py
View file @
ac8ad5b5
...
...
@@ -78,7 +78,7 @@ class Game:
current_player
.
give
(
card
)
print
(
f
"{card}"
)
await
self
.
message
(
MessageToPlayer
.
GiveHand
,
current_player
,
extra
=
current_player
.
hand
)
await
self
.
message
(
MessageToPlayer
.
GiveHand
,
current_player
,
extra
=
current_player
.
hand
.
json
()
)
print
(
f
"Cards sent."
)
# Tour
...
...
@@ -143,14 +143,16 @@ class Game:
print
(
f
"| {current_player}'s turn >"
)
if
not
self
.
current_bet
:
# First player, has to bet something
print
(
"Game: First awaiting current bet"
)
await
self
.
message
(
MessageToPlayer
.
YourTurn
,
current_player
,
extra
=
self
.
current_bet
)
while
not
self
.
current_bet
:
# Ask a valid bet
# FIXME: Wait for player announce? Maybe just sleep 10?
print
(
"Game: While no bet, awaiting"
)
announce
=
await
current_player
.
announce
(
self
.
current_bet
)
if
announce
.
bet
:
self
.
current_bet
=
announce
.
bet
print
(
f
"{current_player} starts the round: {self.current_bet}"
)
await
self
.
message
(
MessageToPlayer
.
Announce
,
extra
=
{
"player"
:
current_player
,
"announce"
:
announce
})
print
(
"Game: Awaiting start announce"
)
await
self
.
message
(
MessageToPlayer
.
Announce
,
extra
=
{
"player"
:
current_player
.
name
,
"announce"
:
announce
.
json
()})
else
:
print
(
f
"You cannot say Menteur on first round, {current_player}!"
)
...
...
@@ -161,13 +163,14 @@ class Game:
print
(
"CARRE D'AS!"
)
announce
=
Announce
()
# MENTEUR obligatoire
else
:
print
(
"Game: Awaiting bet"
)
await
self
.
message
(
MessageToPlayer
.
YourTurn
,
current_player
,
extra
=
self
.
current_bet
)
announce
=
current_player
.
announce
(
self
.
current_bet
)
announce
=
await
current_player
.
announce
(
self
.
current_bet
)
if
announce
.
bet
:
while
announce
.
bet
.
value
()
<
self
.
current_bet
.
value
():
# Bad announce!
print
(
f
"Invalid bet by {current_player}, {announce.bet} < {self.current_bet}!"
)
announce
=
current_player
.
announce
(
self
.
current_bet
)
announce
=
await
current_player
.
announce
(
self
.
current_bet
)
self
.
current_bet
=
announce
.
bet
# Valid bet:
...
...
This diff is collapsed.
Click to expand it.
server/ws.py
View file @
ac8ad5b5
...
...
@@ -23,14 +23,14 @@ class ClientPlayer(Player):
async
def
announce
(
self
,
current_bet
:
Optional
[
Hand
])
->
Announce
:
metadata
:
Metadata
=
self
.
lobby
.
metadata
[
self
.
name
]
print
(
f
"Asking Client {self.name} for announce..."
,
end
=
""
)
print
(
f
"Asking Client {self.name} for announce..."
)
while
not
metadata
.
last_announce
and
metadata
.
fresh_announce
:
await
lobby
.
send_waiting_for
(
self
)
print
(
"."
,
end
=
"
"
)
print
(
f
"Still waiting for {self.name}'s announce...
"
)
sleep
(
2
)
print
(
f
" {metadata.last_announce.bet}!"
)
print
(
f
"
Client announced:
{metadata.last_announce.bet}!"
)
return
metadata
.
last_announce
...
...
This diff is collapsed.
Click to expand it.
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