Client multiplayer: N-player targeting, placement zones, lobby creation, outcomes
Server: - BoardDto: add StartingZones (seat → coord list) so client knows valid placement tiles - GameEngine.ToBoardDto: serialize StartingZones into the DTO Client – Game.gd: - get_enemy_players(): returns all players not on the local player's team - get_all_enemy_units(): flat list of field + archSpirit from all enemies - game_over signal: adds player_outcomes: Array parameter - game.over push: extracts playerOutcomes array and passes to signal Client – game_screen.gd: - _valid_placement_tiles(): uses board.startingZones[seatIndex] when available; falls back to legacy row logic - _valid_attack_target_coords/ids: use Game.get_all_enemy_units() instead of single opponent - ability target picker: uses get_all_enemy_units() for enemy units - player-panel builder (zone abilities): iterates get_enemy_players() for N-player - _on_game_over: shows per-player rank deltas from playerOutcomes when present Client – CustomLobby.gd: - State: max_players, game_mode, team_count fields (cleared on clear_state) - create(): accepts p_max_players, p_game_mode, p_team_count params; sends to server - join(): stores max_players/game_mode/team_count from server response - game.custom.started: calls clear_state() before emitting game_starting Client – FreePlayScreen: - Create dialog: MaxPlayersSpinner (2-10), GameModeOption (FFA/Teams/MultiTeam), TeamCountRow (hidden for FFA) - GameModeOption.item_selected toggles team_count_row visibility - _on_create_confirmed: passes max_players, game_mode, team_count to CustomLobby.create() Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -60,6 +60,9 @@ var is_host : bool = false
|
|||||||
var i_am_ready : bool = false
|
var i_am_ready : bool = false
|
||||||
var partner_ready : bool = false
|
var partner_ready : bool = false
|
||||||
var first_turn_pref: String = "random"
|
var first_turn_pref: String = "random"
|
||||||
|
var max_players : int = 2
|
||||||
|
var game_mode : String = "FFA"
|
||||||
|
var team_count : int = 1
|
||||||
|
|
||||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -76,18 +79,29 @@ func clear_state() -> void:
|
|||||||
i_am_ready = false
|
i_am_ready = false
|
||||||
partner_ready = false
|
partner_ready = false
|
||||||
first_turn_pref = "random"
|
first_turn_pref = "random"
|
||||||
|
max_players = 2
|
||||||
|
game_mode = "FFA"
|
||||||
|
team_count = 1
|
||||||
|
|
||||||
# ── Public actions ────────────────────────────────────────────────────────────
|
# ── Public actions ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
## Create a new lobby. On success, lobby_id and is_host are set; navigate to LobbyRoomScreen.
|
## Create a new lobby. On success, lobby_id and is_host are set; navigate to LobbyRoomScreen.
|
||||||
func create(lobby_name: String, deck_id: String, password: String,
|
func create(lobby_name: String, deck_id: String, password: String,
|
||||||
rules_override: Dictionary, on_success: Callable = Callable(),
|
rules_override: Dictionary,
|
||||||
|
p_max_players: int = 2, p_game_mode: String = "FFA", p_team_count: int = 1,
|
||||||
|
on_success: Callable = Callable(),
|
||||||
on_error: Callable = Callable()) -> void:
|
on_error: Callable = Callable()) -> void:
|
||||||
clear_state()
|
clear_state()
|
||||||
my_deck_id = deck_id
|
my_deck_id = deck_id
|
||||||
|
max_players = p_max_players
|
||||||
|
game_mode = p_game_mode
|
||||||
|
team_count = p_team_count
|
||||||
var payload := {
|
var payload := {
|
||||||
"lobbyName": lobby_name,
|
"lobbyName": lobby_name,
|
||||||
"deckId": deck_id,
|
"deckId": deck_id,
|
||||||
|
"maxPlayers": p_max_players,
|
||||||
|
"gameMode": p_game_mode,
|
||||||
|
"teamCount": p_team_count,
|
||||||
}
|
}
|
||||||
if password != "":
|
if password != "":
|
||||||
payload["password"] = password
|
payload["password"] = password
|
||||||
@@ -96,9 +110,13 @@ func create(lobby_name: String, deck_id: String, password: String,
|
|||||||
Network.request("game.custom.create", payload,
|
Network.request("game.custom.create", payload,
|
||||||
func(_t: String, p: Variant) -> void:
|
func(_t: String, p: Variant) -> void:
|
||||||
var d := p as Dictionary
|
var d := p as Dictionary
|
||||||
lobby_id = str(d.get("lobbyId", ""))
|
lobby_id = str(d.get("lobbyId", ""))
|
||||||
lobby = d
|
lobby = d
|
||||||
is_host = true
|
is_host = true
|
||||||
|
# Extract server-confirmed values (server may adjust/clamp).
|
||||||
|
max_players = int(d.get("maxPlayers", p_max_players))
|
||||||
|
game_mode = str(d.get("gameMode", p_game_mode))
|
||||||
|
team_count = int(d.get("teamCount", p_team_count))
|
||||||
if on_success.is_valid(): on_success.call(d),
|
if on_success.is_valid(): on_success.call(d),
|
||||||
func(code: String, msg: String) -> void:
|
func(code: String, msg: String) -> void:
|
||||||
print("[CustomLobby] ERR create ", code, " ", msg)
|
print("[CustomLobby] ERR create ", code, " ", msg)
|
||||||
@@ -117,9 +135,12 @@ func join(lid: String, deck_id: String, password: String,
|
|||||||
Network.request("game.custom.join", payload,
|
Network.request("game.custom.join", payload,
|
||||||
func(_t: String, p: Variant) -> void:
|
func(_t: String, p: Variant) -> void:
|
||||||
var d := p as Dictionary
|
var d := p as Dictionary
|
||||||
lobby_id = str(d.get("lobbyId", ""))
|
lobby_id = str(d.get("lobbyId", ""))
|
||||||
lobby = d
|
lobby = d
|
||||||
is_host = false
|
is_host = false
|
||||||
|
max_players = int(d.get("maxPlayers", 2))
|
||||||
|
game_mode = str(d.get("gameMode", "FFA"))
|
||||||
|
team_count = int(d.get("teamCount", 1))
|
||||||
# Ensure the lobby dict has the fields _refresh_display needs.
|
# Ensure the lobby dict has the fields _refresh_display needs.
|
||||||
lobby["guestAccountId"] = str(d.get("guestAccountId", ""))
|
lobby["guestAccountId"] = str(d.get("guestAccountId", ""))
|
||||||
lobby["guestDisplayName"] = str(d.get("guestDisplayName", ""))
|
lobby["guestDisplayName"] = str(d.get("guestDisplayName", ""))
|
||||||
@@ -296,6 +317,7 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
|||||||
Game.session_id = sid
|
Game.session_id = sid
|
||||||
Game.opponent_name = oname
|
Game.opponent_name = oname
|
||||||
Game.state = {}
|
Game.state = {}
|
||||||
|
clear_state()
|
||||||
game_starting.emit(sid, opp, oname)
|
game_starting.emit(sid, opp, oname)
|
||||||
|
|
||||||
"game.custom.preset.vote_requested":
|
"game.custom.preset.vote_requested":
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ signal state_updated(state: Dictionary)
|
|||||||
|
|
||||||
## Emitted when the game ends.
|
## Emitted when the game ends.
|
||||||
signal game_over(winner_account_id: String, win_condition: String,
|
signal game_over(winner_account_id: String, win_condition: String,
|
||||||
winner_rank_delta: int, loser_rank_delta: int)
|
winner_rank_delta: int, loser_rank_delta: int,
|
||||||
|
player_outcomes: Array)
|
||||||
|
|
||||||
## Emitted when the server abandons an Initializing session (e.g. server restart).
|
## Emitted when the server abandons an Initializing session (e.g. server restart).
|
||||||
signal session_abandoned(reason: String)
|
signal session_abandoned(reason: String)
|
||||||
@@ -147,6 +148,28 @@ func get_opponent_field() -> Array:
|
|||||||
return get_opponent().get("field", [])
|
return get_opponent().get("field", [])
|
||||||
|
|
||||||
|
|
||||||
|
## Returns all enemy PlayerStateDto dicts (players not on the same team as the local player).
|
||||||
|
func get_enemy_players() -> Array:
|
||||||
|
var my_team : int = int(get_my_player().get("teamIndex", -1))
|
||||||
|
var result : Array = []
|
||||||
|
for p: Dictionary in state.get("players", []):
|
||||||
|
var pid : String = str(p.get("accountId", ""))
|
||||||
|
if pid == Auth.user_id: continue
|
||||||
|
if int(p.get("teamIndex", -2)) != my_team:
|
||||||
|
result.append(p)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
## Returns all units (field + archSpirit) belonging to enemy players, as a flat Array.
|
||||||
|
func get_all_enemy_units() -> Array:
|
||||||
|
var units : Array = []
|
||||||
|
for p: Dictionary in get_enemy_players():
|
||||||
|
units.append_array(p.get("field", []))
|
||||||
|
var arch : Dictionary = p.get("archSpirit", {})
|
||||||
|
if not arch.is_empty(): units.append(arch)
|
||||||
|
return units
|
||||||
|
|
||||||
|
|
||||||
## Returns a TileDto dict by coord, or {}.
|
## Returns a TileDto dict by coord, or {}.
|
||||||
func get_tile(x: int, y: int) -> Dictionary:
|
func get_tile(x: int, y: int) -> Dictionary:
|
||||||
for t: Dictionary in get_tiles():
|
for t: Dictionary in get_tiles():
|
||||||
@@ -546,13 +569,14 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
|||||||
_apply_delta(delta)
|
_apply_delta(delta)
|
||||||
|
|
||||||
"game.over":
|
"game.over":
|
||||||
var d := payload as Dictionary
|
var d := payload as Dictionary
|
||||||
var winner : String = str(d.get("winnerAccountId", ""))
|
var winner : String = str(d.get("winnerAccountId", ""))
|
||||||
var wc : String = str(d.get("winCondition", ""))
|
var wc : String = str(d.get("winCondition", ""))
|
||||||
var wd : int = int(d.get("winnerRankDelta", 0))
|
var wd : int = int(d.get("winnerRankDelta", 0))
|
||||||
var ld : int = int(d.get("loserRankDelta", 0))
|
var ld : int = int(d.get("loserRankDelta", 0))
|
||||||
|
var outcomes : Array = d.get("playerOutcomes", []) as Array
|
||||||
state = {} # Clear stale state so a new GameScreen calls send_ready() on the next match
|
state = {} # Clear stale state so a new GameScreen calls send_ready() on the next match
|
||||||
game_over.emit(winner, wc, wd, ld)
|
game_over.emit(winner, wc, wd, ld, outcomes)
|
||||||
|
|
||||||
"game.session_abandoned":
|
"game.session_abandoned":
|
||||||
var d := payload as Dictionary
|
var d := payload as Dictionary
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ unique_name_in_owner = true
|
|||||||
visible = false
|
visible = false
|
||||||
title = "Create Lobby"
|
title = "Create Lobby"
|
||||||
initial_position = 4
|
initial_position = 4
|
||||||
min_size = Vector2(400, 340)
|
min_size = Vector2(420, 420)
|
||||||
|
|
||||||
[node name="CreateContent" type="VBoxContainer" parent="CreateDialog"]
|
[node name="CreateContent" type="VBoxContainer" parent="CreateDialog"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
@@ -197,6 +197,57 @@ layout_mode = 2
|
|||||||
placeholder_text = "Leave blank for public"
|
placeholder_text = "Leave blank for public"
|
||||||
secret = true
|
secret = true
|
||||||
|
|
||||||
|
[node name="MultiplayerRow" type="HBoxContainer" parent="CreateDialog/CreateContent"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 12
|
||||||
|
|
||||||
|
[node name="MaxPlayersLabel" type="Label" parent="CreateDialog/CreateContent/MultiplayerRow"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Players:"
|
||||||
|
|
||||||
|
[node name="MaxPlayersSpinner" type="SpinBox" parent="CreateDialog/CreateContent/MultiplayerRow"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
custom_minimum_size = Vector2(70, 0)
|
||||||
|
min_value = 2.0
|
||||||
|
max_value = 10.0
|
||||||
|
value = 2.0
|
||||||
|
|
||||||
|
[node name="ModeLabel" type="Label" parent="CreateDialog/CreateContent/MultiplayerRow"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = " Mode:"
|
||||||
|
|
||||||
|
[node name="GameModeOption" type="OptionButton" parent="CreateDialog/CreateContent/MultiplayerRow"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
item_count = 3
|
||||||
|
selected = 0
|
||||||
|
popup/item_0/text = "FFA"
|
||||||
|
popup/item_0/id = 0
|
||||||
|
popup/item_1/text = "Teams"
|
||||||
|
popup/item_1/id = 1
|
||||||
|
popup/item_2/text = "MultiTeam"
|
||||||
|
popup/item_2/id = 2
|
||||||
|
|
||||||
|
[node name="TeamCountRow" type="HBoxContainer" parent="CreateDialog/CreateContent"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
visible = false
|
||||||
|
theme_override_constants/separation = 12
|
||||||
|
|
||||||
|
[node name="TeamCountLabel" type="Label" parent="CreateDialog/CreateContent/TeamCountRow"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Team Count:"
|
||||||
|
|
||||||
|
[node name="TeamCountSpinner" type="SpinBox" parent="CreateDialog/CreateContent/TeamCountRow"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
custom_minimum_size = Vector2(70, 0)
|
||||||
|
min_value = 2.0
|
||||||
|
max_value = 5.0
|
||||||
|
value = 2.0
|
||||||
|
|
||||||
[node name="DeckLabel" type="Label" parent="CreateDialog/CreateContent"]
|
[node name="DeckLabel" type="Label" parent="CreateDialog/CreateContent"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Select Deck:"
|
text = "Select Deck:"
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ const DECK_BTN = preload("res://scenes/common/components/DeckPickerButton.tscn
|
|||||||
@onready var deck_select_container : VBoxContainer = %DeckSelectContainer
|
@onready var deck_select_container : VBoxContainer = %DeckSelectContainer
|
||||||
@onready var join_password_dialog : AcceptDialog = %JoinPasswordDialog
|
@onready var join_password_dialog : AcceptDialog = %JoinPasswordDialog
|
||||||
@onready var join_password_field : LineEdit = %JoinPasswordField
|
@onready var join_password_field : LineEdit = %JoinPasswordField
|
||||||
|
@onready var max_players_spinner : SpinBox = %MaxPlayersSpinner
|
||||||
|
@onready var game_mode_option : OptionButton = %GameModeOption
|
||||||
|
@onready var team_count_row : HBoxContainer = %TeamCountRow
|
||||||
|
@onready var team_count_spinner : SpinBox = %TeamCountSpinner
|
||||||
|
|
||||||
# ── State ─────────────────────────────────────────────────────────────────────
|
# ── State ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -57,6 +61,8 @@ func _setup_ui() -> void:
|
|||||||
search_field.text_changed.connect(func(_t): _refresh_lobbies())
|
search_field.text_changed.connect(func(_t): _refresh_lobbies())
|
||||||
create_btn.pressed.connect(_show_create_dialog)
|
create_btn.pressed.connect(_show_create_dialog)
|
||||||
create_dialog.confirmed.connect(_on_create_confirmed)
|
create_dialog.confirmed.connect(_on_create_confirmed)
|
||||||
|
game_mode_option.item_selected.connect(func(_idx: int) -> void:
|
||||||
|
team_count_row.visible = game_mode_option.get_item_text(game_mode_option.selected) != "FFA")
|
||||||
join_password_dialog.confirmed.connect(_on_join_password_confirmed)
|
join_password_dialog.confirmed.connect(_on_join_password_confirmed)
|
||||||
_switch_tab("open")
|
_switch_tab("open")
|
||||||
|
|
||||||
@@ -268,6 +274,9 @@ func _on_spectate_pressed(session_id: String) -> void:
|
|||||||
func _show_create_dialog() -> void:
|
func _show_create_dialog() -> void:
|
||||||
lobby_name_field.text = ""
|
lobby_name_field.text = ""
|
||||||
lobby_password_field.text = ""
|
lobby_password_field.text = ""
|
||||||
|
max_players_spinner.value = 2
|
||||||
|
game_mode_option.selected = 0
|
||||||
|
team_count_row.visible = false
|
||||||
create_dialog.popup_centered()
|
create_dialog.popup_centered()
|
||||||
|
|
||||||
|
|
||||||
@@ -279,8 +288,11 @@ func _on_create_confirmed() -> void:
|
|||||||
if _selected_deck.is_empty():
|
if _selected_deck.is_empty():
|
||||||
OS.alert("Please select a deck.", "No Deck Selected")
|
OS.alert("Please select a deck.", "No Deck Selected")
|
||||||
return
|
return
|
||||||
var pw := lobby_password_field.text.strip_edges()
|
var pw : String = lobby_password_field.text.strip_edges()
|
||||||
CustomLobby.create(name_text, _selected_deck, pw, {},
|
var mp : int = int(max_players_spinner.value)
|
||||||
|
var gm : String = game_mode_option.get_item_text(game_mode_option.selected)
|
||||||
|
var tc : int = int(team_count_spinner.value) if gm != "FFA" else 1
|
||||||
|
CustomLobby.create(name_text, _selected_deck, pw, {}, mp, gm, tc,
|
||||||
func(_p: Variant) -> void:
|
func(_p: Variant) -> void:
|
||||||
get_tree().change_scene_to_file("res://scenes/free_play/LobbyRoomScreen.tscn"),
|
get_tree().change_scene_to_file("res://scenes/free_play/LobbyRoomScreen.tscn"),
|
||||||
func(code: String, msg: String) -> void:
|
func(code: String, msg: String) -> void:
|
||||||
|
|||||||
@@ -2212,11 +2212,7 @@ func _valid_attack_target_coords(unit: Dictionary) -> Array:
|
|||||||
var max_r : int = unit.get("maxAttackRange", 1)
|
var max_r : int = unit.get("maxAttackRange", 1)
|
||||||
if unit.get("isExhausted", false) and unit.get("extraAttacksRemaining", 0) == 0:
|
if unit.get("isExhausted", false) and unit.get("extraAttacksRemaining", 0) == 0:
|
||||||
return results
|
return results
|
||||||
var opp := Game.get_opponent()
|
var to_check : Array = Game.get_all_enemy_units()
|
||||||
var to_check : Array = []
|
|
||||||
to_check.append_array(opp.get("field", []))
|
|
||||||
var opp_arch : Dictionary = opp.get("archSpirit", {})
|
|
||||||
if not opp_arch.is_empty(): to_check.append(opp_arch)
|
|
||||||
for t: Dictionary in to_check:
|
for t: Dictionary in to_check:
|
||||||
if not t.get("canBeAttacked", true): continue
|
if not t.get("canBeAttacked", true): continue
|
||||||
var tp : Dictionary = t.get("position", {})
|
var tp : Dictionary = t.get("position", {})
|
||||||
@@ -2237,11 +2233,7 @@ func _valid_attack_target_ids(unit: Dictionary) -> Array:
|
|||||||
var max_r : int = unit.get("maxAttackRange", 1)
|
var max_r : int = unit.get("maxAttackRange", 1)
|
||||||
if unit.get("isExhausted", false) and unit.get("extraAttacksRemaining", 0) == 0:
|
if unit.get("isExhausted", false) and unit.get("extraAttacksRemaining", 0) == 0:
|
||||||
return results
|
return results
|
||||||
var opp := Game.get_opponent()
|
var to_check : Array = Game.get_all_enemy_units()
|
||||||
var to_check : Array = []
|
|
||||||
to_check.append_array(opp.get("field", []))
|
|
||||||
var opp_arch : Dictionary = opp.get("archSpirit", {})
|
|
||||||
if not opp_arch.is_empty(): to_check.append(opp_arch)
|
|
||||||
for t: Dictionary in to_check:
|
for t: Dictionary in to_check:
|
||||||
if not t.get("canBeAttacked", true): continue
|
if not t.get("canBeAttacked", true): continue
|
||||||
var tp : Dictionary = t.get("position", {})
|
var tp : Dictionary = t.get("position", {})
|
||||||
@@ -2274,15 +2266,30 @@ func _attack_range_tiles(unit: Dictionary) -> Array:
|
|||||||
|
|
||||||
|
|
||||||
func _valid_placement_tiles() -> Array:
|
func _valid_placement_tiles() -> Array:
|
||||||
var results : Array = []
|
var results : Array = []
|
||||||
var my_id := Auth.user_id
|
var my_id := Auth.user_id
|
||||||
var p1_id : String = str(Game.state.get("playerOneAccountId", ""))
|
var my_seat : int = int(Game.get_my_player().get("seatIndex", 0))
|
||||||
var bw : int = Game.board_width()
|
var board : Dictionary = Game.get_board()
|
||||||
var bh : int = Game.board_height()
|
var sz_raw : Dictionary = board.get("startingZones", {})
|
||||||
var row : int = 0 if my_id == p1_id else bh - 1
|
|
||||||
for tx in range(bw):
|
if not sz_raw.is_empty():
|
||||||
if not Game.get_tile(tx, row).get("occupantId"):
|
# N-player: use the StartingZones dict keyed by seatIndex.
|
||||||
results.append(Vector2i(tx, row))
|
var seat_key : String = str(my_seat)
|
||||||
|
var zone : Array = sz_raw.get(seat_key, []) as Array
|
||||||
|
for coord: Dictionary in zone:
|
||||||
|
var tx : int = int(coord.get("x", -1))
|
||||||
|
var ty : int = int(coord.get("y", -1))
|
||||||
|
if tx >= 0 and not Game.get_tile(tx, ty).get("occupantId"):
|
||||||
|
results.append(Vector2i(tx, ty))
|
||||||
|
else:
|
||||||
|
# Legacy 1v1 fallback.
|
||||||
|
var p1_id : String = str(Game.state.get("playerOneAccountId", ""))
|
||||||
|
var bw : int = Game.board_width()
|
||||||
|
var bh : int = Game.board_height()
|
||||||
|
var row : int = 0 if my_id == p1_id else bh - 1
|
||||||
|
for tx in range(bw):
|
||||||
|
if not Game.get_tile(tx, row).get("occupantId"):
|
||||||
|
results.append(Vector2i(tx, row))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
@@ -2806,10 +2813,7 @@ func _highlight_ability_targets(action: Dictionary) -> void:
|
|||||||
|
|
||||||
var targets : Array = []
|
var targets : Array = []
|
||||||
if include_enemy:
|
if include_enemy:
|
||||||
targets.append_array(Game.get_opponent().get("field", []))
|
targets.append_array(Game.get_all_enemy_units())
|
||||||
var opp_arch : Dictionary = Game.get_opponent().get("archSpirit", {})
|
|
||||||
if not opp_arch.is_empty():
|
|
||||||
targets.append(opp_arch)
|
|
||||||
if include_friendly:
|
if include_friendly:
|
||||||
targets.append_array(Game.get_field())
|
targets.append_array(Game.get_field())
|
||||||
var my_arch : Dictionary = Game.get_my_player().get("archSpirit", {})
|
var my_arch : Dictionary = Game.get_my_player().get("archSpirit", {})
|
||||||
@@ -2916,8 +2920,6 @@ func _show_player_panel(scope: String, ownership: String) -> void:
|
|||||||
|
|
||||||
var my_id : String = Auth.user_id
|
var my_id : String = Auth.user_id
|
||||||
var my_name : String = Auth.display_name if not Auth.display_name.is_empty() else "You"
|
var my_name : String = Auth.display_name if not Auth.display_name.is_empty() else "You"
|
||||||
var opp_id : String = str(Game.get_opponent().get("accountId", ""))
|
|
||||||
var opp_name : String = Game.opponent_name if not Game.opponent_name.is_empty() else "Opponent"
|
|
||||||
|
|
||||||
var show_self : bool = ownership in ["Owner", "Ally", "Any"]
|
var show_self : bool = ownership in ["Owner", "Ally", "Any"]
|
||||||
var show_enemy : bool = ownership in ["Enemy", "Any"]
|
var show_enemy : bool = ownership in ["Enemy", "Any"]
|
||||||
@@ -2926,9 +2928,12 @@ func _show_player_panel(scope: String, ownership: String) -> void:
|
|||||||
show_enemy = true
|
show_enemy = true
|
||||||
|
|
||||||
if show_self:
|
if show_self:
|
||||||
_add_player_option(vbox, my_name, my_id, scope)
|
_add_player_option(vbox, my_name, my_id, scope)
|
||||||
if show_enemy:
|
if show_enemy:
|
||||||
_add_player_option(vbox, opp_name, opp_id, scope)
|
for ep: Dictionary in Game.get_enemy_players():
|
||||||
|
var eid : String = str(ep.get("accountId", ""))
|
||||||
|
var ename : String = eid.substr(0, 8)
|
||||||
|
_add_player_option(vbox, ename, eid, scope)
|
||||||
|
|
||||||
panel.add_child(vbox)
|
panel.add_child(vbox)
|
||||||
_hud.add_child(panel)
|
_hud.add_child(panel)
|
||||||
@@ -3393,13 +3398,29 @@ func _on_hold_timer_fired() -> void:
|
|||||||
# ── Game over ─────────────────────────────────────────────────────────────────
|
# ── Game over ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
func _on_game_over(winner_id: String, win_condition: String,
|
func _on_game_over(winner_id: String, win_condition: String,
|
||||||
winner_delta: int, loser_delta: int) -> void:
|
winner_delta: int, loser_delta: int,
|
||||||
|
player_outcomes: Array = []) -> void:
|
||||||
var i_won : bool = (winner_id == Auth.user_id)
|
var i_won : bool = (winner_id == Auth.user_id)
|
||||||
_go_result_lbl.text = "Victory!" if i_won else "Defeat"
|
_go_result_lbl.text = "Victory!" if i_won else "Defeat"
|
||||||
_go_result_lbl.modulate = Color(0.4, 1.0, 0.5) if i_won else Color(1.0, 0.4, 0.4)
|
_go_result_lbl.modulate = Color(0.4, 1.0, 0.5) if i_won else Color(1.0, 0.4, 0.4)
|
||||||
var my_delta : int = winner_delta if i_won else loser_delta
|
|
||||||
_go_rank_lbl.text = "Win by %s | Rank %s%d" % [
|
if not player_outcomes.is_empty():
|
||||||
win_condition, "+" if my_delta >= 0 else "", my_delta]
|
# N-player: show each player's rank delta
|
||||||
|
var outcome_lines : Array = []
|
||||||
|
for po: Dictionary in player_outcomes:
|
||||||
|
var pid : String = str(po.get("accountId", ""))
|
||||||
|
var oc : String = str(po.get("outcome", "?"))
|
||||||
|
var rd : int = int(po.get("rankDelta", 0))
|
||||||
|
var sign : String = "+" if rd >= 0 else ""
|
||||||
|
var label: String = "You" if pid == Auth.user_id else pid.substr(0, 8)
|
||||||
|
outcome_lines.append("%s: %s (%s%d)" % [label, oc, sign, rd])
|
||||||
|
_go_rank_lbl.text = "[%s]
|
||||||
|
" % win_condition + "
|
||||||
|
".join(outcome_lines)
|
||||||
|
else:
|
||||||
|
var my_delta : int = winner_delta if i_won else loser_delta
|
||||||
|
_go_rank_lbl.text = "Win by %s | Rank %s%d" % [
|
||||||
|
win_condition, "+" if my_delta >= 0 else "", my_delta]
|
||||||
_go_overlay.visible = true
|
_go_overlay.visible = true
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1451,7 +1451,15 @@ public static class GameEngine
|
|||||||
RuinId : t.RuinId,
|
RuinId : t.RuinId,
|
||||||
RuinOwner : t.RuinOwner));
|
RuinOwner : t.RuinOwner));
|
||||||
|
|
||||||
return new BoardDto(board.Width, board.Height, tiles);
|
Dictionary<int, IEnumerable<CoordDto>>? startingZones = null;
|
||||||
|
if (board.StartingZones.Count > 0)
|
||||||
|
{
|
||||||
|
startingZones = board.StartingZones.ToDictionary(
|
||||||
|
kvp => kvp.Key,
|
||||||
|
kvp => (IEnumerable<CoordDto>)kvp.Value.Select(c => new CoordDto(c.X, c.Y)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BoardDto(board.Width, board.Height, tiles, startingZones);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -597,7 +597,9 @@ public sealed record CardInstanceDto(
|
|||||||
public sealed record BoardDto(
|
public sealed record BoardDto(
|
||||||
int Width,
|
int Width,
|
||||||
int Height,
|
int Height,
|
||||||
IEnumerable<TileDto> Tiles);
|
IEnumerable<TileDto> Tiles,
|
||||||
|
/// <summary>Seat index → list of valid ArchSpirit placement coords. Empty for legacy 1v1.</summary>
|
||||||
|
Dictionary<int, IEnumerable<CoordDto>>? StartingZones = null);
|
||||||
|
|
||||||
public sealed record TileDto(
|
public sealed record TileDto(
|
||||||
CoordDto Coord,
|
CoordDto Coord,
|
||||||
|
|||||||
Reference in New Issue
Block a user