added basic hire functionality
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
class_name PlayerBoard
|
||||
extends Node2D
|
||||
|
||||
signal clients_discarded(cards: Array[NodePath])
|
||||
|
||||
var player_info = {}
|
||||
var workers = []
|
||||
var roster = []
|
||||
signal clients_discarded(cards: Array[NodePath])
|
||||
|
||||
@export var poor_deck: Deck
|
||||
@export var good_deck: Deck
|
||||
@export var great_deck: Deck
|
||||
@export var shift_deck: Deck
|
||||
@export var slots: Array[Workspace] = []
|
||||
@export var client_view_position: Node2D
|
||||
|
||||
|
||||
func add_to_roster(node_paths):
|
||||
@@ -22,6 +25,14 @@ func add_to_roster(node_paths):
|
||||
slots[x].add_worker(roster[x])
|
||||
|
||||
|
||||
func empty_slots() -> int:
|
||||
var x = 0
|
||||
for i in slots:
|
||||
if i.worker == null:
|
||||
x += 1
|
||||
return x
|
||||
|
||||
|
||||
func draw_client():
|
||||
var card = shift_deck.draw_card()
|
||||
card.slide_to_position(position.x, position.y, 0.0, 0.3)
|
||||
|
@@ -39,10 +39,6 @@ func setup(_title, _initial_stress, _time_slots, _services):
|
||||
for x in time_button_sprites.size():
|
||||
if time_slots[x] == true:
|
||||
time_button_sprites[x].visible = true
|
||||
$front/Slice1.visible = false
|
||||
$front/Slice2.visible = false
|
||||
$front/Slice3.visible = false
|
||||
$front/Slice4.visible = false
|
||||
if time_slots[0] == true:
|
||||
$front/Slice1.visible = true
|
||||
if time_slots[1] == true:
|
||||
@@ -58,7 +54,7 @@ func setup(_title, _initial_stress, _time_slots, _services):
|
||||
continue
|
||||
icon_list[x - 1].set_service(services[x])
|
||||
icon_list[x - 1].visible = true
|
||||
good_threshold = 10 - (5 - services.size())
|
||||
good_threshold = 10 - (6 - services.size())
|
||||
medium_threshold = 4
|
||||
if time_slots[3] == false:
|
||||
good_threshold -= 1
|
||||
|
@@ -36,6 +36,7 @@ var _player_scene = preload("res://Scenes/player_board.tscn")
|
||||
var _human_scene = preload("res://Scenes/human_player.tscn")
|
||||
var _bot_scene = preload("res://Scenes/bot_player.tscn")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_load_workers()
|
||||
_load_clients()
|
||||
@@ -107,6 +108,7 @@ func add_player(id: int, username: String, type: PlayerType) -> void:
|
||||
controller.chat_message_submitted.connect(message)
|
||||
controller.workers_discarded.connect(discard_workers)
|
||||
controller.workers_kept.connect(board.add_to_roster)
|
||||
controller.hire_pressed.connect(hire)
|
||||
var player_info = {}
|
||||
player_info["id"] = id
|
||||
player_info["username"] = username
|
||||
@@ -214,7 +216,6 @@ func start_round():
|
||||
player.rpc("update_ready_label", readied_players.size(), players.size())
|
||||
for player in players:
|
||||
rpc("draft_clients", player.player_info["username"])
|
||||
#await clients_drafted
|
||||
rpc("start_turn")
|
||||
|
||||
|
||||
@@ -242,6 +243,11 @@ func send_client_order(node_paths):
|
||||
shuffle_sync_recieved.emit()
|
||||
|
||||
|
||||
func hire(player):
|
||||
if is_multiplayer_authority():
|
||||
rpc("draft_workers", player, 4, 1)
|
||||
|
||||
|
||||
@rpc("call_local", "reliable")
|
||||
func draft_workers(player, draw_amount, pick_amount):
|
||||
var cards = []
|
||||
@@ -266,9 +272,9 @@ func draft_clients(player):
|
||||
if player_controller.player_info["username"] == player:
|
||||
controller = player_controller
|
||||
var cards_to_draw = 4
|
||||
if controller.reputation_points >= 30:
|
||||
if controller.reputation_points >= 20:
|
||||
cards_to_draw += 4
|
||||
if controller.reputation_points >= 60:
|
||||
if controller.reputation_points >= 40:
|
||||
cards_to_draw += 4
|
||||
for x in cards_to_draw - controller.board.shift_deck.cards.size():
|
||||
if client_deck.cards.size() == 0:
|
||||
|
@@ -99,6 +99,8 @@ func turn_away_client():
|
||||
|
||||
func start_turn():
|
||||
super()
|
||||
$CanvasLayer/UI/Hire.visible = false
|
||||
$CanvasLayer/UI/Label.visible = false
|
||||
|
||||
|
||||
@rpc("call_local", "reliable")
|
||||
@@ -109,10 +111,12 @@ func end_turn():
|
||||
|
||||
func end_of_round():
|
||||
super()
|
||||
$CanvasLayer/UI/Reputation.text = str(reputation_points) + " / 100 Reputation"
|
||||
$CanvasLayer/UI/Reputation.text = str(reputation_points) + " / 60 Reputation"
|
||||
game_started = 1
|
||||
ready_button.visible = true
|
||||
ready_label.visible = true
|
||||
$CanvasLayer/UI/Hire.visible = true
|
||||
$CanvasLayer/UI/Label.visible = true
|
||||
|
||||
|
||||
func update_money():
|
||||
@@ -141,3 +145,9 @@ func select_workspace(workspace):
|
||||
func confirm_draft():
|
||||
super()
|
||||
ready_button.visible = true
|
||||
|
||||
|
||||
func _on_hire_pressed() -> void:
|
||||
print("hire button pushed")
|
||||
rpc("attempt_hire")
|
||||
update_money()
|
||||
|
@@ -5,6 +5,7 @@ signal workers_discarded
|
||||
signal workers_kept
|
||||
signal turn_finished
|
||||
signal round_finished(int)
|
||||
signal hire_pressed(String)
|
||||
|
||||
var player_info
|
||||
@export var hand_position: Node2D
|
||||
@@ -58,7 +59,7 @@ func networked_select_card(add, card_path):
|
||||
func select_workspace(workspace):
|
||||
if not is_multiplayer_authority():
|
||||
return false
|
||||
if current_client == null or workspace.worker == null:
|
||||
if current_client == null or workspace.worker == null or workspace.worker.stress >= workspace.worker.capacity:
|
||||
return false
|
||||
if workspace == current_workspace or workspace.client != null:
|
||||
return false
|
||||
@@ -113,7 +114,10 @@ func confirm_draft():
|
||||
|
||||
func start_turn():
|
||||
current_client = board.shift_deck.draw_card()
|
||||
current_client.slide_to_position(board.global_position.x, board.global_position.y, 0.0, 0.3)
|
||||
var pos: Vector2
|
||||
pos.x = board.client_view_position.global_position.x
|
||||
pos.y = board.client_view_position.global_position.y
|
||||
current_client.slide_to_position(pos.x, pos.y, 0.0, 0.3)
|
||||
current_client.turn_front()
|
||||
|
||||
|
||||
@@ -137,3 +141,12 @@ func end_turn():
|
||||
if board.shift_deck.cards.size() == 0:
|
||||
end_of_round()
|
||||
turn_finished.emit()
|
||||
|
||||
|
||||
@rpc("call_local", "reliable")
|
||||
func attempt_hire():
|
||||
if board.empty_slots() < 1 or money < 50:
|
||||
return
|
||||
print("attempt hire didnt fail")
|
||||
money -= 50
|
||||
hire_pressed.emit(player_info["username"])
|
||||
|
@@ -1,21 +1,23 @@
|
||||
class_name Worker
|
||||
extends Card
|
||||
|
||||
signal card_clicked(card)
|
||||
|
||||
var title = "New Card"
|
||||
var max_supers = 2
|
||||
var capacity = 8
|
||||
var stress = 0
|
||||
signal card_clicked(card)
|
||||
var in_hand = false
|
||||
var hand_ratio
|
||||
var hand_position = Vector2(0, 0)
|
||||
var hovered = false
|
||||
|
||||
@export var spread_curve : Curve
|
||||
@export var height_curve : Curve
|
||||
@export var rotation_curve : Curve
|
||||
@export var hand_width : float
|
||||
@export var hand_height : float
|
||||
@export var hand_rotation : float
|
||||
var in_hand = false
|
||||
var hand_ratio
|
||||
var hand_position = Vector2(0, 0)
|
||||
var hovered = false
|
||||
|
||||
|
||||
func _process(delta):
|
||||
if sliding:
|
||||
@@ -29,6 +31,7 @@ func _process(delta):
|
||||
position.x = hand_position.x + spread_curve.sample(hand_ratio) * (hand_width + (hand_width * 0.2))
|
||||
rotation = rotation_curve.sample(hand_ratio) * (hand_rotation + (hand_rotation * 0.2))
|
||||
|
||||
|
||||
func get_icon(x):
|
||||
var y = 32
|
||||
if x > 8:
|
||||
@@ -37,6 +40,7 @@ func get_icon(x):
|
||||
y += x * 32
|
||||
return y
|
||||
|
||||
|
||||
func setup(_title, _capacity, _services):
|
||||
if _title != "":
|
||||
title = _title
|
||||
@@ -91,11 +95,13 @@ func _on_area_2d_input_event(_viewport, event, _shape_idx):
|
||||
if event is InputEventMouseButton and event.pressed:
|
||||
emit_signal("card_clicked", self)
|
||||
|
||||
|
||||
func increase_stress(amount) -> bool:
|
||||
stress += amount
|
||||
$Label.text = str(stress)
|
||||
return stress > capacity
|
||||
|
||||
|
||||
func decrease_stress(amount):
|
||||
stress -= amount
|
||||
if stress < 0:
|
||||
|
@@ -54,16 +54,23 @@ func evaluate_match():
|
||||
|
||||
|
||||
func time_step(skip_ahead: bool):
|
||||
if worker == null or client == null:
|
||||
return null
|
||||
client.turns_left -= 1
|
||||
if skip_ahead:
|
||||
client.turns_left = 0
|
||||
client.update_counter()
|
||||
if client.turns_left > 0:
|
||||
if worker == null and client == null:
|
||||
return null
|
||||
elif worker != null and client == null:
|
||||
worker.decrease_stress(1)
|
||||
else:
|
||||
return remove_client()
|
||||
if skip_ahead:
|
||||
worker.decrease_stress(client.turns_left)
|
||||
client.turns_left = 0
|
||||
else:
|
||||
worker.increase_stress(1)
|
||||
client.turns_left -= 1
|
||||
client.update_counter()
|
||||
if client.turns_left > 0:
|
||||
return null
|
||||
else:
|
||||
return remove_client()
|
||||
return null
|
||||
|
||||
|
||||
func _on_area2d_input_event(_viewport: Node, event: InputEvent, _shape_idx: int) -> void:
|
||||
|
Reference in New Issue
Block a user