cards go to the right discard piles
This commit is contained in:
@ -94,9 +94,17 @@ func start_turn():
|
||||
super()
|
||||
|
||||
|
||||
func end_of_round():
|
||||
super()
|
||||
$CanvasLayer/UI/Reputation.text = str(reputation_points) + " / 100 Reputation"
|
||||
|
||||
|
||||
func select_workspace(workspace):
|
||||
super(workspace)
|
||||
if not super(workspace):
|
||||
return
|
||||
await current_client.time_slots_selected
|
||||
ready_button.visible = true
|
||||
current_workspace.evaluate_match()
|
||||
|
||||
|
||||
@rpc("call_local", "reliable")
|
||||
|
@ -16,6 +16,7 @@ var draft_pick_amount = 0
|
||||
var reputation_points = 0
|
||||
var board: PlayerBoard
|
||||
var current_client: Client
|
||||
var current_workspace: Workspace
|
||||
|
||||
|
||||
func draft(cards, pick):
|
||||
@ -25,7 +26,8 @@ func draft(cards, pick):
|
||||
var card = cards[x]
|
||||
var ratio = float(x) / float(cards.size() - 1)
|
||||
var xx = lerpf(-1 * xxx, xxx, ratio)
|
||||
card.slide_to_position(hand_position.global_position.x + xx - 125.0, hand_position.global_position.y - 175.0, 0.0, 0.2)
|
||||
var h = hand_position.global_position
|
||||
card.slide_to_position(h.x + xx - 125.0, h.y - 175.0, 0.0, 0.2)
|
||||
hand.append(card)
|
||||
card.card_clicked.connect(select_card)
|
||||
|
||||
@ -53,18 +55,21 @@ func networked_select_card(add, card_path):
|
||||
|
||||
func select_workspace(workspace):
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
if current_client == null:
|
||||
return
|
||||
return false
|
||||
if current_client == null or workspace.worker == null:
|
||||
return false
|
||||
if workspace == current_workspace or workspace.client != null:
|
||||
return false
|
||||
if current_workspace != null:
|
||||
current_workspace.remove_client()
|
||||
current_workspace = workspace
|
||||
rpc("networked_select_workspace", workspace.get_path(), current_client.get_path())
|
||||
#workspace.add_client(current_client)
|
||||
current_client.show_time_selector()
|
||||
current_client = null
|
||||
#rpc("end_turn")
|
||||
return true
|
||||
|
||||
|
||||
func on_poor_discard_deck_clicked():
|
||||
if not is_multiplayer_authority():
|
||||
if not is_multiplayer_authority() or current_client == null:
|
||||
return
|
||||
rpc("turn_away_client")
|
||||
|
||||
@ -72,12 +77,16 @@ func on_poor_discard_deck_clicked():
|
||||
@rpc("call_local", "reliable")
|
||||
func turn_away_client():
|
||||
board.poor_deck.place(current_client)
|
||||
current_client.set_satisfaction(0)
|
||||
if current_workspace != null:
|
||||
current_workspace.remove_client()
|
||||
current_client = null
|
||||
|
||||
|
||||
@rpc("call_local", "reliable")
|
||||
func networked_select_workspace(workspace_path, current_client_path):
|
||||
get_node(workspace_path).add_client(get_node(current_client_path))
|
||||
get_node(workspace_path).evaluate_match()
|
||||
|
||||
|
||||
@rpc("call_local", "reliable")
|
||||
@ -100,12 +109,23 @@ func confirm_draft():
|
||||
func start_turn():
|
||||
current_client = board.shift_deck.draw_card()
|
||||
if current_client == null:
|
||||
round_finished.emit()
|
||||
return
|
||||
current_client.slide_to_position(board.global_position.x, board.global_position.y, 0.0, 0.3)
|
||||
current_client.turn_front()
|
||||
end_of_round()
|
||||
else:
|
||||
current_client.slide_to_position(board.global_position.x, board.global_position.y, 0.0, 0.3)
|
||||
current_client.turn_front()
|
||||
|
||||
|
||||
func end_of_round():
|
||||
board.time_step(true)
|
||||
reputation_points += board.process_decks()
|
||||
if reputation_points < 0:
|
||||
reputation_points = 0
|
||||
round_finished.emit()
|
||||
|
||||
|
||||
@rpc("call_local", "reliable")
|
||||
func end_turn():
|
||||
board.time_step(false)
|
||||
current_client = null
|
||||
current_workspace = null
|
||||
turn_finished.emit()
|
||||
|
@ -19,6 +19,7 @@ var watch_on := false
|
||||
@export var pip_sprites: Array[TextureRect] = []
|
||||
@export var time_button_sprites: Array[TextureRect] = []
|
||||
@export var time_hovered_sprites: Array[TextureRect] = []
|
||||
@export var watch: TextureRect
|
||||
|
||||
|
||||
func _ready():
|
||||
@ -106,7 +107,7 @@ func setup(_title, _initial_stress, _time_slots, _services):
|
||||
|
||||
func show_time_selector():
|
||||
watch_on = true
|
||||
$watch.visible = true
|
||||
watch.visible = true
|
||||
|
||||
|
||||
func update_counter():
|
||||
@ -116,7 +117,7 @@ func update_counter():
|
||||
func _on_turn_pressed(num):
|
||||
turns_left = num
|
||||
update_counter()
|
||||
$watch.visible = false
|
||||
watch.visible = false
|
||||
watch_on = false
|
||||
time_slots_selected.emit()
|
||||
|
||||
@ -131,6 +132,11 @@ func turn_back():
|
||||
$front.visible = false
|
||||
|
||||
|
||||
func set_satisfaction(num):
|
||||
satisfaction = 1 + num
|
||||
$front/ColorRect.position.x = 134 + ((satisfaction - 1) * 20.0)
|
||||
|
||||
|
||||
func _on_watch_segment_mouse_entered(extra_arg_0: int) -> void:
|
||||
if not watch_on or not time_slots[extra_arg_0]:
|
||||
return
|
||||
@ -138,11 +144,11 @@ func _on_watch_segment_mouse_entered(extra_arg_0: int) -> void:
|
||||
time_hovered_sprites[x].visible = true
|
||||
|
||||
|
||||
func _on_watch_segment_mouse_exited(extra_arg_0: int) -> void:
|
||||
func _on_watch_segment_mouse_exited(_extra_arg_0: int) -> void:
|
||||
for sprite in time_hovered_sprites:
|
||||
sprite.visible = false
|
||||
|
||||
|
||||
func _on_watch_segment_input_event(viewport: Node, event: InputEvent, shape_idx: int, extra_arg_0: int) -> void:
|
||||
func _on_watch_segment_input_event(_viewport: Node, event: InputEvent, _shape_idx: int, extra_arg_0: int) -> void:
|
||||
if event is InputEventMouseButton and event.pressed:
|
||||
_on_turn_pressed(extra_arg_0 + 1)
|
||||
|
@ -42,6 +42,18 @@ func draw_card() -> Card:
|
||||
return cards.pop_back()
|
||||
|
||||
|
||||
func draw_cards(num) -> Array[Card]:
|
||||
var x = 0
|
||||
var array: Array[Card] = []
|
||||
for i in range(cards.size() - 1, -1, -1):
|
||||
if x == num:
|
||||
break;
|
||||
array.append(cards[i])
|
||||
cards.remove_at(i)
|
||||
x += 1
|
||||
return array
|
||||
|
||||
|
||||
func place(card: Card) -> void:
|
||||
cards.append(card)
|
||||
match type:
|
||||
|
@ -121,6 +121,7 @@ func add_player(id: int, username: String, type: PlayerType) -> void:
|
||||
board.slots[2].clicked.connect(controller.select_workspace)
|
||||
board.slots[3].clicked.connect(controller.select_workspace)
|
||||
board.poor_deck.clicked.connect(controller.on_poor_discard_deck_clicked)
|
||||
board.clients_discarded.connect(discard_clients)
|
||||
board.name = "board " + str(player_boards.size())
|
||||
player_boards.append(board)
|
||||
players.append(controller)
|
||||
@ -223,15 +224,21 @@ func discard_workers(node_paths):
|
||||
|
||||
@rpc("call_local", "reliable")
|
||||
func draft_clients(player):
|
||||
var cards = []
|
||||
for x in 2 + (2 * round_number):
|
||||
cards.append(client_deck.draw_card())
|
||||
for x in player_boards:
|
||||
if x.player_info["username"] == player:
|
||||
for card in cards:
|
||||
x.shift_deck.place(card)
|
||||
var controller: PlayerController = null
|
||||
for player_controller in players:
|
||||
if player_controller.player_info["username"] == player:
|
||||
controller = player_controller
|
||||
var cards_to_draw = 4
|
||||
if controller.reputation_points >= 30:
|
||||
cards_to_draw += 4
|
||||
if controller.reputation_points >= 60:
|
||||
cards_to_draw += 4
|
||||
for x in cards_to_draw - controller.board.shift_deck.cards.size():
|
||||
controller.board.shift_deck.place(client_deck.draw_card())
|
||||
|
||||
|
||||
@rpc("call_local", "reliable")
|
||||
func discard_clients(_node_paths):
|
||||
pass
|
||||
func discard_clients(node_paths):
|
||||
for path in node_paths:
|
||||
var card = get_node(path)
|
||||
client_discard.place(card)
|
||||
|
@ -25,6 +25,36 @@ func add_client(card: Client) -> bool:
|
||||
return true
|
||||
|
||||
|
||||
func remove_client():
|
||||
var c = client
|
||||
client = null
|
||||
return c
|
||||
|
||||
|
||||
func evaluate_match():
|
||||
if worker == null or client == null:
|
||||
return
|
||||
var points = -1
|
||||
for service in client.services:
|
||||
if worker.services.has(service):
|
||||
points += 1
|
||||
points += client.turns_left
|
||||
client.set_satisfaction(points)
|
||||
|
||||
|
||||
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:
|
||||
return null
|
||||
else:
|
||||
return remove_client()
|
||||
|
||||
|
||||
func _on_area2d_input_event(_viewport: Node, event: InputEvent, _shape_idx: int) -> void:
|
||||
if event is InputEventMouseButton and event.pressed and worker != null:
|
||||
emit_signal("clicked", self)
|
Reference in New Issue
Block a user