clients now keep track of expected and actual bets for every client
This commit is contained in:
@@ -27,6 +27,8 @@ var _own_client_id: String
|
||||
@export var player_hand_scene: PackedScene
|
||||
@export var card_scene: PackedScene
|
||||
|
||||
var _bets: Dictionary[String, Array] # Array[BetResult]
|
||||
|
||||
## Cards played in the current play.
|
||||
var _plays: Array[Play]
|
||||
var _trump_id: int = -1
|
||||
@@ -64,6 +66,7 @@ func _on_web_client_tcp_client_order_received(client_ids: Array[String], client_
|
||||
new_ids.append_array(client_ids.slice(0, own_index))
|
||||
|
||||
for index in new_ids.size():
|
||||
_bets[new_ids[index]] = []
|
||||
var hand: PlayerHand
|
||||
if client_ids[index] == _own_client_id:
|
||||
hand = own_player_hand
|
||||
@@ -108,3 +111,15 @@ func _on_web_client_tcp_trump_received(trump_id: int) -> void:
|
||||
var trump_card: PlayingCard = card_scene.instantiate()
|
||||
trump_card.setup_card_details(_trump_id)
|
||||
trump_container.add_child(trump_card)
|
||||
|
||||
func _on_web_client_tcp_new_round_started() -> void:
|
||||
# prepare a fresh BetResults bunch for the new round! the clients are hungry.
|
||||
for client_id in _bets.keys():
|
||||
_bets[client_id].append(BetResult.new())
|
||||
|
||||
func _on_web_client_tcp_received_expected_bet(client_id: String, expected_bet: int) -> void:
|
||||
_bets[client_id][_bets[client_id].size() - 1].set_expected(expected_bet)
|
||||
|
||||
func _on_web_client_tcp_received_winning_client(client_id: String) -> void:
|
||||
_bets[client_id][_bets[client_id].size() - 1].add_win()
|
||||
print(_bets)
|
||||
|
||||
Reference in New Issue
Block a user