feat: more multiplayer
This commit is contained in:
parent
3981646279
commit
6c6e1b3289
9 changed files with 429 additions and 104 deletions
|
|
@ -10,10 +10,15 @@ signal rps_move(move: String)
|
|||
@export var energy_label: Label
|
||||
|
||||
var match_manager: MatchManager
|
||||
var show_buttons: bool
|
||||
var signal_connected: bool
|
||||
|
||||
func attach(match_manager: MatchManager):
|
||||
func attach(match_manager: MatchManager, show_buttons: bool = true):
|
||||
self.show_buttons = show_buttons
|
||||
self.match_manager = match_manager
|
||||
match_manager.state_transitioned.connect(_on_update)
|
||||
if !signal_connected:
|
||||
match_manager.state_transitioned.connect(_on_update)
|
||||
signal_connected = true
|
||||
|
||||
func _on_update(transition):
|
||||
for child in deck.get_children():
|
||||
|
|
@ -28,13 +33,28 @@ func _on_update(transition):
|
|||
monster_health_label.text = "Health: " + str(monster.health)
|
||||
incoming_damage_label.text = "Incoming Damage: " + str(monster.health_delta)
|
||||
if match_manager.phase in [Match.Phase.SUMMON, Match.Phase.SUPPORT_1, Match.Phase.SUPPORT_2]:
|
||||
|
||||
if (
|
||||
match_manager.phase != Match.Phase.SUMMON && show_buttons
|
||||
) or (
|
||||
match_manager.phase == Match.Phase.SUMMON and player.monster and player.monster.health > 0 && show_buttons
|
||||
):
|
||||
var skip_btn = Button.new()
|
||||
skip_btn.text = "Skip"
|
||||
skip_btn.button_up.connect(func (): play_card.emit(null))
|
||||
deck.add_child(skip_btn)
|
||||
|
||||
for card: Card in player.hand:
|
||||
if match_manager.phase == Match.Phase.SUMMON and card is not MonsterCard:
|
||||
continue
|
||||
if (match_manager.phase == Match.Phase.SUPPORT_1 or match_manager.phase == Match.Phase.SUPPORT_2) and card is not SupportCard:
|
||||
continue
|
||||
if match_manager.phase == Match.Phase.SUPPORT_1 and card.type == "red":
|
||||
#if match_manager.phase == Match.Phase.SUMMON and card is not MonsterCard:
|
||||
#continue
|
||||
#if (match_manager.phase == Match.Phase.SUPPORT_1 or match_manager.phase == Match.Phase.SUPPORT_2) and card is not SupportCard:
|
||||
#continue
|
||||
#if match_manager.phase == Match.Phase.SUPPORT_1 and card.type == "red":
|
||||
#continue
|
||||
|
||||
if !show_buttons :
|
||||
continue
|
||||
|
||||
var btn = Button.new()
|
||||
btn.text = card.id
|
||||
btn.button_up.connect(func (): play_card.emit(card))
|
||||
|
|
@ -44,10 +64,16 @@ func _on_update(transition):
|
|||
card is SupportCard and match_manager.phase != Match.Phase.SUPPORT_1 and match_manager.phase != Match.Phase.SUPPORT_2
|
||||
) or (
|
||||
card is SupportCard and card.type == "red" and match_manager.phase != Match.Phase.SUPPORT_2
|
||||
) or (
|
||||
card is MonsterCard and match_manager.phase == Match.Phase.SUMMON and player.monster and player.monster.health > 0
|
||||
)
|
||||
deck.add_child(btn)
|
||||
if match_manager.phase == Match.Phase.RPS:
|
||||
for move in ["rock", "paper", "scissors"]:
|
||||
|
||||
if !show_buttons:
|
||||
continue
|
||||
|
||||
var btn = Button.new()
|
||||
btn.text = move
|
||||
btn.button_up.connect(func (): rps_move.emit(move))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue