more backend improvements; clients are (should be) able to submit cards and start new rounds; determining winners and scoring points is unimplemented
This commit is contained in:
@@ -41,6 +41,9 @@ signal cards_received(cards: Dictionary)
|
|||||||
|
|
||||||
signal received_bet_request(disallowed_bet: int)
|
signal received_bet_request(disallowed_bet: int)
|
||||||
|
|
||||||
|
signal received_play_winner_request()
|
||||||
|
signal request_next_round()
|
||||||
|
|
||||||
enum ConnectionStatus {
|
enum ConnectionStatus {
|
||||||
DISCONNECTED,
|
DISCONNECTED,
|
||||||
ATTEMPTING_CONNECTION,
|
ATTEMPTING_CONNECTION,
|
||||||
@@ -142,6 +145,10 @@ func _handle_response(response: String) -> void:
|
|||||||
print(data)
|
print(data)
|
||||||
"play_card":
|
"play_card":
|
||||||
print(data)
|
print(data)
|
||||||
|
"determine_play_winner_request": # single card go-around
|
||||||
|
received_play_winner_request.emit.call_deferred()
|
||||||
|
"client_won_play":
|
||||||
|
print(data)
|
||||||
|
|
||||||
func _handle_join(data) -> void:
|
func _handle_join(data) -> void:
|
||||||
match data["status"]:
|
match data["status"]:
|
||||||
@@ -219,5 +226,13 @@ func submit_bet(bet: int, current_round: int) -> void:
|
|||||||
"bet": bet,
|
"bet": bet,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
func submit_round_winner(winning_client_id: String) -> void:
|
||||||
|
_send_message(JSON.stringify({
|
||||||
|
"response": "submit_play_winner",
|
||||||
|
"lobby_id": _lobby_id,
|
||||||
|
"client_id": winning_client_id,
|
||||||
|
}))
|
||||||
|
request_next_round.emit.call_deferred()
|
||||||
|
|
||||||
func _send_message(message: String) -> void:
|
func _send_message(message: String) -> void:
|
||||||
_socket.send_text(message)
|
_socket.send_text(message)
|
||||||
|
|||||||
@@ -255,6 +255,7 @@ transform = Transform3D(-0.5, 0, 0.866025, 0, 1, 0, -0.866025, 0, -0.5, 3.2, 0.4
|
|||||||
[connection signal="received_chat_message" from="WebClientTCP" to="HBoxContainer/ClientInterface" method="_on_web_client_tcp_received_chat_message"]
|
[connection signal="received_chat_message" from="WebClientTCP" to="HBoxContainer/ClientInterface" method="_on_web_client_tcp_received_chat_message"]
|
||||||
[connection signal="received_client_id" from="WebClientTCP" to="EnvironmentManager" method="_on_web_client_tcp_received_client_id"]
|
[connection signal="received_client_id" from="WebClientTCP" to="EnvironmentManager" method="_on_web_client_tcp_received_client_id"]
|
||||||
[connection signal="received_connection_message" from="WebClientTCP" to="HBoxContainer/ClientInterface" method="_on_web_client_tcp_received_connection_message"]
|
[connection signal="received_connection_message" from="WebClientTCP" to="HBoxContainer/ClientInterface" method="_on_web_client_tcp_received_connection_message"]
|
||||||
|
[connection signal="request_next_round" from="WebClientTCP" to="HBoxContainer/GameUI" method="_on_web_client_tcp_request_next_round"]
|
||||||
[connection signal="pressed" from="HBoxContainer/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/ConnectButton" to="HBoxContainer/ClientInterface" method="_on_connect_button_pressed"]
|
[connection signal="pressed" from="HBoxContainer/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/ConnectButton" to="HBoxContainer/ClientInterface" method="_on_connect_button_pressed"]
|
||||||
[connection signal="pressed" from="HBoxContainer/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/CreateLobbyButton" to="HBoxContainer/ClientInterface" method="_on_create_lobby_button_pressed"]
|
[connection signal="pressed" from="HBoxContainer/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/CreateLobbyButton" to="HBoxContainer/ClientInterface" method="_on_create_lobby_button_pressed"]
|
||||||
[connection signal="pressed" from="HBoxContainer/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/CreateLobbyButton" to="HBoxContainer/GameUI" method="_on_create_lobby_button_pressed"]
|
[connection signal="pressed" from="HBoxContainer/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/CreateLobbyButton" to="HBoxContainer/GameUI" method="_on_create_lobby_button_pressed"]
|
||||||
|
|||||||
@@ -64,3 +64,6 @@ func _on_submit_bet_button_pressed() -> void:
|
|||||||
func _on_web_client_tcp_received_bet_request(disallowed_bet: int) -> void:
|
func _on_web_client_tcp_received_bet_request(disallowed_bet: int) -> void:
|
||||||
bet_input.text = ""
|
bet_input.text = ""
|
||||||
bet_container.show()
|
bet_container.show()
|
||||||
|
|
||||||
|
func _on_web_client_tcp_request_next_round() -> void:
|
||||||
|
_start_next_round()
|
||||||
|
|||||||
+31
-6
@@ -211,7 +211,7 @@ class LobbyManager:
|
|||||||
"response": "client_submitted_bet",
|
"response": "client_submitted_bet",
|
||||||
"client_id": client_id,
|
"client_id": client_id,
|
||||||
"bet": bet,
|
"bet": bet,
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
async def spread_played_card(self, lobby_id, client_id, played_card) -> None:
|
async def spread_played_card(self, lobby_id, client_id, played_card) -> None:
|
||||||
@@ -221,7 +221,16 @@ class LobbyManager:
|
|||||||
"response": "client_played_card",
|
"response": "client_played_card",
|
||||||
"client_id": client_id,
|
"client_id": client_id,
|
||||||
"card": played_card,
|
"card": played_card,
|
||||||
})
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
async def spread_play_winner(self, lobby_id, client_id) -> None:
|
||||||
|
await self.broadcast_message(
|
||||||
|
lobby_id,
|
||||||
|
json.dumps({
|
||||||
|
"response": "client_won_play",
|
||||||
|
"client_id": client_id,
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_next_client(self, lobby_id, client_id) -> str:
|
def get_next_client(self, lobby_id, client_id) -> str:
|
||||||
@@ -489,10 +498,20 @@ async def process_input(message: str, websocket) -> None:
|
|||||||
client_id,
|
client_id,
|
||||||
data_object["played_card"],
|
data_object["played_card"],
|
||||||
)
|
)
|
||||||
|
playing_order = lobby_manager.get_lobby(lobby_id).client_playing_order
|
||||||
client_index = lobby_manager.get_lobby(lobby_id).client_playing_order.index(client_id)
|
client_index = playing_order.index(client_id)
|
||||||
if not client_index == (len(lobby_manager.get_lobby(lobby_id).client_playing_order) - 1):
|
if client_index == (len(playing_order) - 1):
|
||||||
playing_client_id = lobby_manager.get_lobby(lobby_id).client_playing_order[client_index + 1]
|
# end round
|
||||||
|
await lobby_manager.send_message(
|
||||||
|
lobby_id,
|
||||||
|
lobby_manager.get_lobby_host_client_id(lobby_id),
|
||||||
|
json.dumps({
|
||||||
|
"response": "determine_round_winner_request",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# not all clients have played a card yet; continue
|
||||||
|
playing_client_id = playing_order[client_index + 1]
|
||||||
|
|
||||||
await lobby_manager.send_message(
|
await lobby_manager.send_message(
|
||||||
lobby_id,
|
lobby_id,
|
||||||
@@ -502,6 +521,12 @@ async def process_input(message: str, websocket) -> None:
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
elif data_object["response"] == "submit_play_winner":
|
||||||
|
await lobby_manager.spread_play_winner(
|
||||||
|
data_object["lobby_id"],
|
||||||
|
data_object["client_id"],
|
||||||
|
)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
run_local = False
|
run_local = False
|
||||||
# Run locally without SSL certificate
|
# Run locally without SSL certificate
|
||||||
|
|||||||
Reference in New Issue
Block a user