feat: user always play bottom
This commit is contained in:
parent
bebb7b467b
commit
2c4e9d90f3
5 changed files with 25 additions and 72 deletions
63
demo_game.gd
63
demo_game.gd
|
|
@ -18,14 +18,14 @@ var id_to_card: Dictionary = {}
|
|||
var player_action_queue: Dictionary
|
||||
var player_1_action: Action:
|
||||
get:
|
||||
return player_action_queue.get(MatchManager.PLAYER_1_ID)
|
||||
return player_action_queue.get(own_side.player_id)
|
||||
set(value):
|
||||
player_action_queue[MatchManager.PLAYER_1_ID] = value
|
||||
player_action_queue[own_side.player_id] = value
|
||||
var player_2_action: Action:
|
||||
get:
|
||||
return player_action_queue.get(MatchManager.PLAYER_2_ID)
|
||||
return player_action_queue.get(opponent_side.player_id)
|
||||
set(value):
|
||||
player_action_queue[MatchManager.PLAYER_2_ID] = value
|
||||
player_action_queue[opponent_side.player_id] = value
|
||||
|
||||
var id
|
||||
var signal_connected := false
|
||||
|
|
@ -33,6 +33,9 @@ var signal_connected := false
|
|||
func init(player_id: int) -> void:
|
||||
id = player_id
|
||||
|
||||
own_side.player_id = player_id
|
||||
opponent_side.player_id = MatchManager.PLAYER_2_ID if player_id == MatchManager.PLAYER_1_ID else MatchManager.PLAYER_1_ID
|
||||
|
||||
id_to_card.clear()
|
||||
|
||||
var cards = player_1_deck.duplicate()
|
||||
|
|
@ -44,9 +47,9 @@ func init(player_id: int) -> void:
|
|||
match_manager.init({
|
||||
MatchManager.PLAYER_1_ID: player_1_deck,
|
||||
MatchManager.PLAYER_2_ID: player_2_deck
|
||||
})
|
||||
own_side.attach(match_manager, player_id == MatchManager.PLAYER_1_ID)
|
||||
opponent_side.attach(match_manager, player_id == MatchManager.PLAYER_2_ID)
|
||||
}, own_side.player_id, opponent_side.player_id)
|
||||
own_side.attach(match_manager, true)
|
||||
opponent_side.attach(match_manager, false)
|
||||
|
||||
if !signal_connected:
|
||||
match_manager.state_transitioned.connect(_on_match_manager_state_transitioned)
|
||||
|
|
@ -65,19 +68,6 @@ func _on_start_game_button_button_up() -> void:
|
|||
func rpc_start_game() -> void:
|
||||
match_manager.resolve({})
|
||||
|
||||
func rpc_own_play_card(id: String) -> void:
|
||||
if !id.is_empty():
|
||||
var card = id_to_card[id]
|
||||
player_1_action = ActionPlayCard.new(card)
|
||||
else:
|
||||
player_1_action = ActionSkipCard.new()
|
||||
|
||||
print(self.id, " rpc_own_play_card", player_1_action, player_2_action)
|
||||
|
||||
if player_2_action:
|
||||
match_manager.resolve(player_action_queue)
|
||||
player_action_queue.clear()
|
||||
|
||||
func _on_own_play_card(card: Card) -> void:
|
||||
if card:
|
||||
player_1_action = ActionPlayCard.new(card)
|
||||
|
|
@ -105,29 +95,6 @@ func rpc_opponent_play_card(id: String) -> void:
|
|||
match_manager.resolve(player_action_queue)
|
||||
player_action_queue.clear()
|
||||
|
||||
func _on_opponent_play_card(card: Card) -> void:
|
||||
if card:
|
||||
player_2_action = ActionPlayCard.new(card)
|
||||
opponent_played_card.emit(card)
|
||||
else:
|
||||
player_2_action = ActionSkipCard.new()
|
||||
opponent_played_card.emit(null)
|
||||
|
||||
print(id, " _on_opponent_play_card", player_1_action, player_2_action)
|
||||
|
||||
if player_1_action:
|
||||
match_manager.resolve(player_action_queue)
|
||||
player_action_queue.clear()
|
||||
|
||||
func rpc_own_rps_move(move: String) -> void:
|
||||
player_1_action = ActionRPSMove.new(move)
|
||||
|
||||
print(id, " rpc_own_rps_move", player_1_action, player_2_action, move)
|
||||
|
||||
if player_2_action:
|
||||
match_manager.resolve(player_action_queue)
|
||||
player_action_queue.clear()
|
||||
|
||||
func _on_own_rps_move(move: String) -> void:
|
||||
player_1_action = ActionRPSMove.new(move)
|
||||
own_played_rts.emit(move)
|
||||
|
|
@ -146,13 +113,3 @@ func rpc_opponent_rps_move(move: String) -> void:
|
|||
if player_1_action:
|
||||
match_manager.resolve(player_action_queue)
|
||||
player_action_queue.clear()
|
||||
|
||||
func _on_opponent_rps_move(move: String) -> void:
|
||||
player_2_action = ActionRPSMove.new(move)
|
||||
opponent_played_rts.emit(move)
|
||||
|
||||
print(id, " rpc_opponent_rps_move", player_1_action, player_2_action, move)
|
||||
|
||||
if player_1_action:
|
||||
match_manager.resolve(player_action_queue)
|
||||
player_action_queue.clear()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue