Merge branch 'main' of https://forge.darkwagonstudio.com/dark-wagon-studio/tcg
This commit is contained in:
commit
3e8dc34646
6 changed files with 52 additions and 15 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("2_61mgn")
|
script = ExtResource("2_61mgn")
|
||||||
scope = "instant"
|
scope = "turn"
|
||||||
type = "green"
|
type = "green"
|
||||||
effects = Array[ExtResource("1_fd50n")]([null])
|
effects = Array[ExtResource("1_fd50n")]([null])
|
||||||
name = "All-Out Attack"
|
name = "All-Out Attack"
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ signal opponent_played_rts(move: String)
|
||||||
@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
|
||||||
|
@onready var win_lose_tie_label: Label = $"Win-Lose-Tie"
|
||||||
|
|
||||||
var id_to_card: Dictionary = {}
|
var id_to_card: Dictionary = {}
|
||||||
|
|
||||||
|
|
@ -65,6 +66,10 @@ 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)
|
_update_phase_info(transition.to)
|
||||||
|
if transition.to == Match.Phase.END:
|
||||||
|
var game_ended_event: EventGameEnded = transition.events.filter(func (it): return it is EventGameEnded)[0]
|
||||||
|
win_lose_tie_label.text = "TIE" if game_ended_event.winner_player_id == -1 else "YOU WON!" if game_ended_event.winner_player_id == id else "YOU LOST!"
|
||||||
|
win_lose_tie_label.visible = true
|
||||||
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:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=23 format=3 uid="uid://bgc0u117jqyr1"]
|
[gd_scene load_steps=24 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"]
|
||||||
|
|
@ -154,13 +154,12 @@ layout_mode = 1
|
||||||
anchors_preset = 5
|
anchors_preset = 5
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
offset_left = -83.5
|
offset_left = 84.0
|
||||||
offset_top = 300.0
|
offset_top = 24.0
|
||||||
offset_right = 83.5
|
offset_right = 251.0
|
||||||
offset_bottom = 323.0
|
offset_bottom = 47.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
text = "Incoming Damage: 0"
|
text = "HP +0"
|
||||||
horizontal_alignment = 1
|
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="Own"]
|
[node name="HBoxContainer" type="HBoxContainer" parent="Own"]
|
||||||
visible = false
|
visible = false
|
||||||
|
|
@ -276,14 +275,13 @@ anchor_left = 0.5
|
||||||
anchor_top = 1.0
|
anchor_top = 1.0
|
||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
offset_left = -83.5
|
offset_left = 84.0
|
||||||
offset_top = -325.0
|
offset_top = -52.0
|
||||||
offset_right = 83.5
|
offset_right = 251.0
|
||||||
offset_bottom = -302.0
|
offset_bottom = -29.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 0
|
grow_vertical = 0
|
||||||
text = "Incoming Damage: 0"
|
text = "HP +0"
|
||||||
horizontal_alignment = 1
|
|
||||||
|
|
||||||
[node name="StartGameButton" type="Button" parent="."]
|
[node name="StartGameButton" type="Button" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
|
@ -346,6 +344,26 @@ theme = ExtResource("19_3iovu")
|
||||||
theme_override_font_sizes/font_size = 24
|
theme_override_font_sizes/font_size = 24
|
||||||
text = "Support (2)"
|
text = "Support (2)"
|
||||||
|
|
||||||
|
[node name="Win-Lose-Tie" type="Label" parent="."]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -365.0
|
||||||
|
offset_top = -215.0
|
||||||
|
offset_right = 365.0
|
||||||
|
offset_bottom = 215.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
theme = ExtResource("19_3iovu")
|
||||||
|
theme_override_font_sizes/font_size = 52
|
||||||
|
text = "YOU WON!"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
[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="button_down" from="Own/HBoxContainer/KertasButton" to="Own" method="_on_kertas_button_button_down"]
|
[connection signal="button_down" from="Own/HBoxContainer/KertasButton" to="Own" method="_on_kertas_button_button_down"]
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,14 @@ func _ready():
|
||||||
support1_green.visible = false
|
support1_green.visible = false
|
||||||
support2_green.visible = false
|
support2_green.visible = false
|
||||||
support2_red.visible = false
|
support2_red.visible = false
|
||||||
|
incoming_damage_label.visible = false
|
||||||
for child in deck.get_children():
|
for child in deck.get_children():
|
||||||
child.queue_free()
|
child.queue_free()
|
||||||
|
|
||||||
func _on_update(transition):
|
func _on_update(transition):
|
||||||
hovering_cards_duration.clear()
|
hovering_cards_duration.clear()
|
||||||
selected_card = null
|
selected_card = null
|
||||||
|
incoming_damage_label.visible = true
|
||||||
|
|
||||||
for child in deck.get_children():
|
for child in deck.get_children():
|
||||||
child.queue_free()
|
child.queue_free()
|
||||||
|
|
@ -81,7 +83,7 @@ func _on_update(transition):
|
||||||
if monster:
|
if monster:
|
||||||
monster_card_ui.visible = true
|
monster_card_ui.visible = true
|
||||||
monster_card_ui.show_monster(monster)
|
monster_card_ui.show_monster(monster)
|
||||||
incoming_damage_label.text = "Incoming Damage: " + str(monster.health_delta)
|
incoming_damage_label.text = "HP " + ("+0" if monster.health_delta == 0 else str(monster.health_delta))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
monster_card_ui.visible = false
|
monster_card_ui.visible = false
|
||||||
|
|
|
||||||
7
tcg/match/event/event_game_ended.gd
Normal file
7
tcg/match/event/event_game_ended.gd
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
extends Event
|
||||||
|
class_name EventGameEnded
|
||||||
|
|
||||||
|
var winner_player_id: int
|
||||||
|
|
||||||
|
func _init(winner_player_id: int) -> void:
|
||||||
|
self.winner_player_id = winner_player_id
|
||||||
|
|
@ -172,6 +172,7 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition:
|
||||||
player.active_support_cards = player.active_support_cards.filter(func (card): return not card_expires_this_turn.call(card))
|
player.active_support_cards = player.active_support_cards.filter(func (card): return not card_expires_this_turn.call(card))
|
||||||
|
|
||||||
var players_without_monster = players.values().filter(func(player): return player.monster == null)
|
var players_without_monster = players.values().filter(func(player): return player.monster == null)
|
||||||
|
var players_without_monster_ids = players_without_monster.map(func (it): return it.id)
|
||||||
if players_without_monster.size() == 0:
|
if players_without_monster.size() == 0:
|
||||||
phase = Match.Phase.SUPPORT_1
|
phase = Match.Phase.SUPPORT_1
|
||||||
elif players_without_monster.all(
|
elif players_without_monster.all(
|
||||||
|
|
@ -179,7 +180,11 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition:
|
||||||
):
|
):
|
||||||
phase = Match.Phase.SUMMON
|
phase = Match.Phase.SUMMON
|
||||||
else:
|
else:
|
||||||
|
var player_1_lost = players_without_monster_ids.has(player_1.id)
|
||||||
|
var player_2_lost = players_without_monster_ids.has(player_2.id)
|
||||||
|
var winner_id = -1 if player_1_lost and player_2_lost else player_1.id if player_2_lost else player_2.id
|
||||||
phase = Match.Phase.END
|
phase = Match.Phase.END
|
||||||
|
events.append(EventGameEnded.new(winner_id))
|
||||||
_:
|
_:
|
||||||
pass
|
pass
|
||||||
var transition = PhaseTransition.new(events, initial_phase, phase)
|
var transition = PhaseTransition.new(events, initial_phase, phase)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue