Card selecting works over the network
This commit is contained in:
parent
060088f878
commit
007c3f4ddb
@ -1,4 +1,25 @@
|
||||
class_name PlayerBoard
|
||||
extends Node2D
|
||||
|
||||
var workers = []
|
||||
var roster = []
|
||||
var shift_deck = []
|
||||
var slots = []
|
||||
|
||||
|
||||
func _ready():
|
||||
#Workaround for bug in 4.0.3.stable
|
||||
slots.append($Slot1)
|
||||
slots.append($Slot2)
|
||||
slots.append($Slot3)
|
||||
slots.append($Slot4)
|
||||
|
||||
|
||||
func add_to_roster(node_paths):
|
||||
var cards = []
|
||||
for path in node_paths:
|
||||
cards.append(get_node(path))
|
||||
roster.append_array(cards)
|
||||
for x in 4:
|
||||
if x < roster.size():
|
||||
slots[x].add_worker(roster[x])
|
||||
|
@ -10,7 +10,7 @@ hand_position = NodePath("Node2D")
|
||||
[node name="Node2D" type="Node2D" parent="."]
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
zoom = Vector2(0.501, 0.501)
|
||||
zoom = Vector2(0.463, 0.463)
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
@ -21,6 +21,7 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 1
|
||||
theme = ExtResource("2_ja0q8")
|
||||
|
||||
[node name="Cash" type="Label" parent="CanvasLayer/UI"]
|
||||
@ -51,6 +52,23 @@ offset_top = 312.0
|
||||
offset_right = 1152.0
|
||||
offset_bottom = 335.0
|
||||
|
||||
[node name="Confirm" type="Button" parent="CanvasLayer/UI"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -4.0
|
||||
offset_top = 257.0
|
||||
offset_right = 4.0
|
||||
offset_bottom = 4.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "Confirm"
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/UI"]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
@ -89,5 +107,6 @@ size_flags_vertical = 3
|
||||
[node name="LineEdit" type="LineEdit" parent="CanvasLayer/UI/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[connection signal="pressed" from="CanvasLayer/UI/Confirm" to="." method="_on_confirm_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/UI/HBoxContainer/LobbyReadyButton" to="." method="_on_lobby_ready_button_pressed"]
|
||||
[connection signal="text_submitted" from="CanvasLayer/UI/VBoxContainer/LineEdit" to="." method="_on_line_edit_text_submitted"]
|
||||
|
@ -150,7 +150,7 @@ position = Vector2(40, 145)
|
||||
texture = ExtResource("5_a2bm7")
|
||||
region_rect = Rect2(0, 0, 32, 32)
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." groups=["Card"]]
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
position = Vector2(125, 175)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
|
@ -22,8 +22,10 @@ func ready_self():
|
||||
ready_button_pressed.emit(player_info["id"])
|
||||
|
||||
|
||||
@rpc("any_peer")
|
||||
@rpc("any_peer", "call_local")
|
||||
func update_ready_label(readied_players, total_players):
|
||||
if readied_players == total_players:
|
||||
ready_label.visible = false
|
||||
ready_label.text = str(readied_players) + "/" + str(total_players)
|
||||
|
||||
|
||||
@ -40,3 +42,16 @@ func _on_line_edit_text_submitted(new_text: String) -> void:
|
||||
var msg = "[" + player_info["username"] + "] " + new_text + "\n"
|
||||
$CanvasLayer/UI/VBoxContainer/LineEdit.text = ""
|
||||
chat_message_submitted.emit(msg)
|
||||
|
||||
|
||||
func select_card(card):
|
||||
super(card)
|
||||
if draft_picked.size() == draft_pick_amount:
|
||||
$CanvasLayer/UI/Confirm.visible = true
|
||||
else:
|
||||
$CanvasLayer/UI/Confirm.visible = false
|
||||
|
||||
|
||||
func _on_confirm_pressed() -> void:
|
||||
$CanvasLayer/UI/Confirm.visible = false
|
||||
rpc("confirm_draft")
|
||||
|
@ -1,16 +1,45 @@
|
||||
class_name PlayerController
|
||||
extends Node
|
||||
|
||||
signal workers_discarded
|
||||
signal workers_kept
|
||||
|
||||
var player_info
|
||||
@export var hand_position: Node2D
|
||||
var hand = []
|
||||
var draft_picked = []
|
||||
var draft_pick_amount = 0
|
||||
|
||||
|
||||
func draft(cards, _pick):
|
||||
func draft(cards, pick):
|
||||
draft_pick_amount = pick
|
||||
var xxx = (250.0 * cards.size()) / 2.0
|
||||
for x in cards.size():
|
||||
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, hand_position.global_position.y, 0.0, 0.2)
|
||||
card.slide_to_position(hand_position.global_position.x + xx - 125.0, hand_position.global_position.y - 175.0, 0.0, 0.2)
|
||||
hand.append(card)
|
||||
card.card_clicked.connect(select_card)
|
||||
|
||||
|
||||
func select_card(card):
|
||||
if not draft_picked.has(card) and draft_picked.size() < draft_pick_amount:
|
||||
draft_picked.append(card)
|
||||
card.slide_to_position(card.position.x, card.position.y - 50.0, 0.0, 0.1)
|
||||
elif draft_picked.has(card):
|
||||
draft_picked.remove_at(draft_picked.find(card))
|
||||
card.slide_to_position(card.position.x, card.position.y + 50.0, 0.0, 0.1)
|
||||
|
||||
|
||||
@rpc("call_local")
|
||||
func confirm_draft():
|
||||
var discarded_cards = []
|
||||
var kept_cards = []
|
||||
for card in hand:
|
||||
if not draft_picked.has(card):
|
||||
discarded_cards.append(card.get_path())
|
||||
else:
|
||||
kept_cards.append(card.get_path())
|
||||
workers_discarded.emit(discarded_cards)
|
||||
workers_kept.emit(kept_cards)
|
||||
|
@ -99,6 +99,8 @@ func add_player(id: int, username: String, type: PlayerType) -> void:
|
||||
networked_controllers.append(controller)
|
||||
controller.ready_button_pressed.connect(ready_player)
|
||||
controller.chat_message_submitted.connect(message)
|
||||
controller.workers_discarded.connect(discard_workers)
|
||||
controller.workers_kept.connect(board.add_to_roster)
|
||||
var player_info = {}
|
||||
player_info["id"] = id
|
||||
player_info["username"] = username
|
||||
@ -166,3 +168,10 @@ func draft_workers(player, draw_amount, pick_amount):
|
||||
for x in players:
|
||||
if x.player_info["username"] == player:
|
||||
x.draft(cards, pick_amount)
|
||||
|
||||
|
||||
@rpc("call_local")
|
||||
func discard_workers(node_paths):
|
||||
for path in node_paths:
|
||||
var card = get_node(path)
|
||||
worker_discard.place(card)
|
||||
|
@ -9,6 +9,9 @@ stress inducing session needs to be longer so the same worker needs to remain oc
|
||||
you more to do on your turn because you get to decide what all your little workers do rather than them only
|
||||
being interacted with when you're placing down a client card
|
||||
|
||||
the roster system is kind of fucked if you start with 2/4 cards and dont get new ones often
|
||||
like, you would never have any in reserve, but do u need any? idk figure it out
|
||||
|
||||
Shift Phase
|
||||
1. Swap 1 time token on each worker over to the stress side
|
||||
2. Pick up the next client card in the deck, and either assign it to
|
||||
|
Loading…
x
Reference in New Issue
Block a user