added money ui and payout for serving clients

This commit is contained in:
Lexi Quinn 2023-07-05 23:57:30 +10:00
parent b2517a9027
commit 1a4b365c5f
4 changed files with 59 additions and 1 deletions

View File

@ -30,6 +30,17 @@ layout_mode = 2
offset_top = 312.0
offset_right = 1152.0
offset_bottom = 335.0
text = "$40"
[node name="Cash2" type="Label" parent="CanvasLayer/UI"]
visible = false
modulate = Color(0, 1, 0, 1)
layout_mode = 2
offset_left = 47.0
offset_top = 312.0
offset_right = 1152.0
offset_bottom = 338.0
text = "+$8"
[node name="Profit" type="Label" parent="CanvasLayer/UI"]
layout_mode = 2

View File

@ -90,21 +90,48 @@ func _on_confirm_pressed() -> void:
rpc("confirm_draft")
@rpc("call_local", "reliable")
func turn_away_client():
super()
money_delta = 0
update_money()
func start_turn():
super()
@rpc("call_local", "reliable")
func end_turn():
super()
update_money()
func end_of_round():
super()
$CanvasLayer/UI/Reputation.text = str(reputation_points) + " / 100 Reputation"
func update_money():
$CanvasLayer/UI/Cash.text = "$" + str(money)
$CanvasLayer/UI/Cash2.visible = true
$CanvasLayer/UI/Cash2.text = "$" + str(money_delta)
if money_delta == 0:
$CanvasLayer/UI/Cash2.visible = false
if money_delta > 0:
$CanvasLayer/UI/Cash2.modulate = Color(0, 1, 0)
if money_delta < 0:
$CanvasLayer/UI/Cash2.modulate = Color(1, 0, 0)
func select_workspace(workspace):
if not super(workspace):
return
await current_client.time_slots_selected
ready_button.visible = true
current_workspace.evaluate_match()
money_delta = current_workspace.evaluate_revenue()
update_money()
@rpc("call_local", "reliable")

View File

@ -14,6 +14,8 @@ var hand = []
var draft_picked = []
var draft_pick_amount = 0
var reputation_points = 0
var money = 40
var money_delta = 0
var board: PlayerBoard
var current_client: Client
var current_workspace: Workspace
@ -80,11 +82,14 @@ func turn_away_client():
current_client.set_satisfaction(0)
if current_workspace != null:
current_workspace.remove_client()
current_client = null
current_workspace = null
#current_client = null
@rpc("call_local", "reliable")
func networked_select_workspace(workspace_path, current_client_path):
if board.poor_deck.cards.has(get_node(current_client_path)):
board.poor_deck.cards.remove_at(board.poor_deck.cards.find(get_node(current_client_path)))
get_node(workspace_path).add_client(get_node(current_client_path))
get_node(workspace_path).evaluate_match()
@ -125,7 +130,11 @@ func end_of_round():
@rpc("call_local", "reliable")
func end_turn():
if current_workspace != null:
rpc("networked_select_workspace", current_workspace.get_path(), current_client.get_path())
board.time_step(false)
current_client = null
current_workspace = null
money += money_delta
money_delta = 0
turn_finished.emit()

View File

@ -31,6 +31,17 @@ func remove_client():
return c
func evaluate_revenue() -> int:
if worker == null or client == null:
return 0
var revenue = 0
revenue += client.turns_left * 2
for service in client.services:
if worker.services.has(service):
revenue += Data.service_prices[service]
return revenue
func evaluate_match():
if worker == null or client == null:
return