feat: phase info on right hand side of the board

This commit is contained in:
istamarahsan 2025-01-26 10:59:39 +07:00
parent 46e4ba0fbb
commit a0475c8588
2 changed files with 63 additions and 15 deletions

View file

@ -8,7 +8,8 @@ signal opponent_played_rts(move: String)
@export var player_1_deck: Array[Card] @export var player_1_deck: Array[Card]
@export var player_2_deck: Array[Card] @export var player_2_deck: Array[Card]
@onready var match_manager = $MatchManager
@onready var match_manager: MatchManager = $MatchManager
@onready var own_side = $Own @onready var own_side = $Own
@onready var opponent_side = $Opponent @onready var opponent_side = $Opponent
@onready var start_game_btn = $StartGameButton @onready var start_game_btn = $StartGameButton
@ -30,6 +31,9 @@ var player_2_action: Action:
var id var id
var signal_connected := false var signal_connected := false
func _ready() -> void:
_update_phase_info(Match.Phase.PREGAME)
func init(player_id: int) -> void: func init(player_id: int) -> void:
id = player_id id = player_id
@ -44,6 +48,7 @@ func init(player_id: int) -> void:
if card.id not in id_to_card: if card.id not in id_to_card:
id_to_card[card.id] = card id_to_card[card.id] = card
print(match_manager.phase)
match_manager.init({ match_manager.init({
MatchManager.PLAYER_1_ID: player_1_deck, MatchManager.PLAYER_1_ID: player_1_deck,
MatchManager.PLAYER_2_ID: player_2_deck MatchManager.PLAYER_2_ID: player_2_deck
@ -59,6 +64,7 @@ var transition_history: Array[PhaseTransition] = []
func _on_match_manager_state_transitioned(transition: PhaseTransition): func _on_match_manager_state_transitioned(transition: PhaseTransition):
start_game_btn.visible = match_manager.phase == Match.Phase.PREGAME start_game_btn.visible = match_manager.phase == Match.Phase.PREGAME
transition_history.append(transition) transition_history.append(transition)
_update_phase_info(transition.to)
print("Phase: ", Match.phase_to_str(transition.from), " -> ", Match.phase_to_str(transition.to)) print("Phase: ", Match.phase_to_str(transition.from), " -> ", Match.phase_to_str(transition.to))
func _on_start_game_button_button_up() -> void: func _on_start_game_button_button_up() -> void:
@ -113,3 +119,12 @@ func rpc_opponent_rps_move(move: String) -> void:
if player_1_action: if player_1_action:
match_manager.resolve(player_action_queue) match_manager.resolve(player_action_queue)
player_action_queue.clear() player_action_queue.clear()
func _update_phase_info(phase: Match.Phase):
var phaseHeaders: Container = get_node("%PhaseInfo/PhaseHeader")
for child: Label in phaseHeaders.get_children():
child.modulate = Color.DIM_GRAY
var target = phaseHeaders.get_node(Match.phase_to_str(phase))
phaseHeaders.visible = target != null
if target:
target.modulate = Color.WHITE

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=19 format=3 uid="uid://bgc0u117jqyr1"] [gd_scene load_steps=20 format=3 uid="uid://bgc0u117jqyr1"]
[ext_resource type="Script" path="res://demo_game.gd" id="1_jn16u"] [ext_resource type="Script" path="res://demo_game.gd" id="1_jn16u"]
[ext_resource type="Script" path="res://player_side.gd" id="2_w4tnt"] [ext_resource type="Script" path="res://player_side.gd" id="2_w4tnt"]
@ -6,7 +6,7 @@
[ext_resource type="PackedScene" uid="uid://cikstg43mudkn" path="res://tcg/match/match_manager.tscn" id="3_3yhrl"] [ext_resource type="PackedScene" uid="uid://cikstg43mudkn" path="res://tcg/match/match_manager.tscn" id="3_3yhrl"]
[ext_resource type="Resource" uid="uid://cs7q8i7bvohmj" path="res://data/cards/monster/capytain.tres" id="3_we1tk"] [ext_resource type="Resource" uid="uid://cs7q8i7bvohmj" path="res://data/cards/monster/capytain.tres" id="3_we1tk"]
[ext_resource type="Resource" uid="uid://4eod3m0vc5a8" path="res://data/cards/support/potion.tres" id="4_kkhfk"] [ext_resource type="Resource" uid="uid://4eod3m0vc5a8" path="res://data/cards/support/potion.tres" id="4_kkhfk"]
[ext_resource type="Resource" uid="uid://di76avwc0gn8e" path="res://data/cards/monster/axoluna.tres" id="5_3cm5x"] [ext_resource type="Resource" uid="uid://deo8mj887rfx1" path="res://data/cards/monster/axoluna.tres" id="5_3cm5x"]
[ext_resource type="Resource" uid="uid://bcrlaam8uq6xt" path="res://data/cards/support/lifesteal.tres" id="6_potm8"] [ext_resource type="Resource" uid="uid://bcrlaam8uq6xt" path="res://data/cards/support/lifesteal.tres" id="6_potm8"]
[ext_resource type="PackedScene" uid="uid://bhrelvt51cbp2" path="res://ui/card_template/monster_card.tscn" id="7_4ah45"] [ext_resource type="PackedScene" uid="uid://bhrelvt51cbp2" path="res://ui/card_template/monster_card.tscn" id="7_4ah45"]
[ext_resource type="Resource" uid="uid://dgxcvdo6x6kst" path="res://data/cards/support/all_out_attack.tres" id="7_nvv8k"] [ext_resource type="Resource" uid="uid://dgxcvdo6x6kst" path="res://data/cards/support/all_out_attack.tres" id="7_nvv8k"]
@ -18,6 +18,7 @@
[ext_resource type="Resource" uid="uid://c0grh1y65e0f3" path="res://data/cards/support/energy_booster.tres" id="10_3rg8q"] [ext_resource type="Resource" uid="uid://c0grh1y65e0f3" path="res://data/cards/support/energy_booster.tres" id="10_3rg8q"]
[ext_resource type="Resource" uid="uid://2xeb6keaoabo" path="res://data/cards/support/sword_mastery.tres" id="11_seakd"] [ext_resource type="Resource" uid="uid://2xeb6keaoabo" path="res://data/cards/support/sword_mastery.tres" id="11_seakd"]
[ext_resource type="Resource" uid="uid://bmst884k0myvd" path="res://data/cards/monster/cattogato.tres" id="12_xqqfn"] [ext_resource type="Resource" uid="uid://bmst884k0myvd" path="res://data/cards/monster/cattogato.tres" id="12_xqqfn"]
[ext_resource type="Theme" uid="uid://is34t82g4jg" path="res://cards.tres" id="19_3iovu"]
[node name="DemoGame" type="Control"] [node name="DemoGame" type="Control"]
layout_mode = 3 layout_mode = 3
@ -225,18 +226,6 @@ offset_bottom = 31.0
grow_horizontal = 2 grow_horizontal = 2
alignment = 1 alignment = 1
[node name="Button" type="Button" parent="Opponent/Hand"]
layout_mode = 2
text = "CARD_1"
[node name="Button2" type="Button" parent="Opponent/Hand"]
layout_mode = 2
text = "CARD_2"
[node name="Button3" type="Button" parent="Opponent/Hand"]
layout_mode = 2
text = "CARD_3"
[node name="EnergyLabel" type="Label" parent="Opponent"] [node name="EnergyLabel" type="Label" parent="Opponent"]
layout_mode = 2 layout_mode = 2
offset_top = 35.0 offset_top = 35.0
@ -277,6 +266,50 @@ text = "Start Game"
[node name="MatchManager" parent="." instance=ExtResource("3_3yhrl")] [node name="MatchManager" parent="." instance=ExtResource("3_3yhrl")]
[node name="PhaseInfo" type="VBoxContainer" parent="."]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = 347.0
offset_top = -102.0
offset_right = 864.0
offset_bottom = 106.0
grow_horizontal = 2
grow_vertical = 2
[node name="PhaseHeader" type="VBoxContainer" parent="PhaseInfo"]
layout_mode = 2
theme_override_constants/separation = 24
alignment = 2
[node name="Summon" type="Label" parent="PhaseInfo/PhaseHeader"]
layout_mode = 2
theme = ExtResource("19_3iovu")
theme_override_font_sizes/font_size = 24
text = "Summon"
[node name="Support 1" type="Label" parent="PhaseInfo/PhaseHeader"]
layout_mode = 2
theme = ExtResource("19_3iovu")
theme_override_font_sizes/font_size = 24
text = "Support (1)"
[node name="RPS" type="Label" parent="PhaseInfo/PhaseHeader"]
layout_mode = 2
theme = ExtResource("19_3iovu")
theme_override_font_sizes/font_size = 24
text = "Rock, Paper, Scissors"
[node name="Support 2" type="Label" parent="PhaseInfo/PhaseHeader"]
layout_mode = 2
theme = ExtResource("19_3iovu")
theme_override_font_sizes/font_size = 24
text = "Support (2)"
[connection signal="play_card" from="Own" to="." method="_on_own_play_card"] [connection signal="play_card" from="Own" to="." method="_on_own_play_card"]
[connection signal="rps_move" from="Own" to="." method="_on_own_rps_move"] [connection signal="rps_move" from="Own" to="." method="_on_own_rps_move"]
[connection signal="play_card" from="Opponent" to="." method="_on_opponent_play_card"] [connection signal="play_card" from="Opponent" to="." method="_on_opponent_play_card"]