Fix: card play input bug, populate CardInstanceDto fields, genus/SP/ST/MP display
- Input bug: CardWidget only consumed mouse PRESS via accept_event(), not RELEASE. This caused _unhandled_input to fire _handle_board_click on release of a card click, hitting the tile physically behind the hand area in 3D — accidentally sending play_card to the wrong tile (Spirit/Ruin) or picking the first tile for Terramorpha. Fixed by tracking _press_was_on_board: board clicks only fire when the originating PRESS also reached _unhandled_input (i.e., was not consumed by a UI card widget). - Server: added SpCost, StCost, Genus, MinChannelRange, MaxChannelRange, MinAttackRange, MaxAttackRange, CanMove, CanAttack, ExtraAttacksRemaining, CanBeAttacked, AbilitiesJson to CardInstanceDto and ToCardDto mapping. All fields were already on CardInstance; they were simply not exposed to clients. - Client: build def dict in _make_hand_card with maxMp → movementPoints alias so CardWidget displays movement points correctly. - Client: show MetaRow (genus + type) in compact hand card; only StatsGrid is hidden. HandArea / RightPanel height raised 190 → 220px for better visibility. 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:
@@ -96,7 +96,7 @@ anchor_left = 0.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.75
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -190.0
|
||||
offset_top = -220.0
|
||||
offset_right = 0.0
|
||||
|
||||
[node name="HandScroll" type="ScrollContainer" parent="HUD/HandArea"]
|
||||
@@ -119,7 +119,7 @@ anchor_left = 0.75
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -190.0
|
||||
offset_top = -220.0
|
||||
|
||||
[node name="RightMargin" type="MarginContainer" parent="HUD/RightPanel"]
|
||||
layout_mode = 2
|
||||
|
||||
@@ -103,8 +103,9 @@ var _cam_yaw : float = 0.0
|
||||
var _cam_pitch : float = 40.0
|
||||
var _cam_distance : float = 14.0
|
||||
var _cam_pivot : Vector3 = Vector3.ZERO
|
||||
var _drag_active : bool = false
|
||||
var _camera_oriented: bool = false
|
||||
var _drag_active : bool = false
|
||||
var _press_was_on_board: bool = false # true only when the PRESS came from unhandled_input (board, not a UI card)
|
||||
var _camera_oriented : bool = false
|
||||
var _pan_active : bool = false
|
||||
var _last_mouse : Vector2 = Vector2.ZERO
|
||||
var _touch_points : Dictionary = {}
|
||||
@@ -217,17 +218,21 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
_last_mouse = mb.position
|
||||
elif mb.button_index == MOUSE_BUTTON_LEFT:
|
||||
if mb.pressed:
|
||||
_last_mouse = mb.position
|
||||
_drag_active = false
|
||||
_last_mouse = mb.position
|
||||
_drag_active = false
|
||||
_press_was_on_board = true # unhandled press = board area, not a UI card
|
||||
var coord := _mouse_to_tile_coord(mb.position)
|
||||
if coord.x >= 0:
|
||||
_held_coord = coord
|
||||
_hold_timer.start()
|
||||
else:
|
||||
_held_coord = Vector2i(-1, -1)
|
||||
else:
|
||||
_hold_timer.stop()
|
||||
if not _drag_active:
|
||||
if not _drag_active and _press_was_on_board:
|
||||
_handle_board_click(mb.position)
|
||||
_drag_active = false
|
||||
_drag_active = false
|
||||
_press_was_on_board = false
|
||||
|
||||
elif event is InputEventMouseMotion:
|
||||
var mm := event as InputEventMouseMotion
|
||||
@@ -1057,23 +1062,23 @@ func _make_hand_card(card: Dictionary) -> Control:
|
||||
var iid : String = card.get("instanceId", "")
|
||||
|
||||
# Instantiate the shared CardWidget scene used by the collection UI.
|
||||
# Pass the live game card dict as both dto and def — all stat fields
|
||||
# (spCost, damage, maxHealth, minAttackRange, …) are in camelCase and
|
||||
# match what CardWidget.setup() reads from the def dict.
|
||||
# Build a def dict from the live card data. CardWidget reads "movementPoints"
|
||||
# but the CardInstanceDto field is "maxMp", so alias it here.
|
||||
var widget : PanelContainer = _CARD_WIDGET_SCENE.instantiate()
|
||||
widget.set_meta("card_instance_id", iid)
|
||||
widget.setup(card, card)
|
||||
var def := card.duplicate()
|
||||
def["movementPoints"] = card.get("maxMp", null)
|
||||
widget.setup(card, def)
|
||||
|
||||
# Compact the card for the hand area: hide genus/type row and stats grid
|
||||
# (full info is available via long-press context popup during gameplay).
|
||||
# Also shrink the art area so the card fits in the ~190px hand panel.
|
||||
# Compact the card for the hand area: shrink art and hide the detailed
|
||||
# stats grid (HP/ATK/DEF/MP/range). Name, SP/ST cost, genus, and type
|
||||
# remain visible; long-press context popup shows full unit stats.
|
||||
var art_area := widget.get_node_or_null("Margin/VBox/ArtArea")
|
||||
if art_area is Control:
|
||||
(art_area as Control).custom_minimum_size = Vector2(0, 80)
|
||||
for hidden_node in ["Margin/VBox/MetaRow", "Margin/VBox/StatsGrid"]:
|
||||
var n := widget.get_node_or_null(hidden_node)
|
||||
if n is CanvasItem:
|
||||
(n as CanvasItem).visible = false
|
||||
var stats_grid := widget.get_node_or_null("Margin/VBox/StatsGrid")
|
||||
if stats_grid is CanvasItem:
|
||||
(stats_grid as CanvasItem).visible = false
|
||||
|
||||
# Hover: scale up and rise.
|
||||
widget.mouse_entered.connect(func() -> void:
|
||||
|
||||
@@ -1149,26 +1149,38 @@ public static class GameEngine
|
||||
{
|
||||
var fc = c as FieldCard;
|
||||
return new(
|
||||
InstanceId : c.InstanceId,
|
||||
CardDefinitionId : c.CardDefinitionId,
|
||||
Name : c.Name,
|
||||
CardType : c.CardType,
|
||||
Affinity : c.Affinity,
|
||||
Rarity : c.Rarity,
|
||||
CurrentHealth : c.CurrentHealth,
|
||||
MaxHealth : c.MaxHealth,
|
||||
CurrentDefense : c.CurrentDefense,
|
||||
MaxDefense : c.MaxDefense,
|
||||
Damage : c.Damage,
|
||||
IsExhausted : c.IsExhausted,
|
||||
IsLeader : c.IsLeader,
|
||||
Position : fc?.Position.HasValue == true
|
||||
? new CoordDto(fc.Position.Value.X, fc.Position.Value.Y) : null,
|
||||
CurrentMp : fc?.CurrentMp,
|
||||
MaxMp : c.MaxMp,
|
||||
MovementType : c.MovementType?.ToString(),
|
||||
Tier : c.Tier,
|
||||
TerramorphaMode : c.TerramorphaMode?.ToString());
|
||||
InstanceId : c.InstanceId,
|
||||
CardDefinitionId : c.CardDefinitionId,
|
||||
Name : c.Name,
|
||||
CardType : c.CardType,
|
||||
Affinity : c.Affinity,
|
||||
Rarity : c.Rarity,
|
||||
CurrentHealth : c.CurrentHealth,
|
||||
MaxHealth : c.MaxHealth,
|
||||
CurrentDefense : c.CurrentDefense,
|
||||
MaxDefense : c.MaxDefense,
|
||||
Damage : c.Damage,
|
||||
IsExhausted : c.IsExhausted,
|
||||
IsLeader : c.IsLeader,
|
||||
Position : fc?.Position.HasValue == true
|
||||
? new CoordDto(fc.Position.Value.X, fc.Position.Value.Y) : null,
|
||||
CurrentMp : fc?.CurrentMp,
|
||||
MaxMp : c.MaxMp,
|
||||
MovementType : c.MovementType?.ToString(),
|
||||
Tier : c.Tier,
|
||||
TerramorphaMode : c.TerramorphaMode?.ToString(),
|
||||
SpCost : c.SpCost,
|
||||
StCost : c.StCost,
|
||||
Genus : c.Genus,
|
||||
MinChannelRange : c.MinChannelRange,
|
||||
MaxChannelRange : c.MaxChannelRange,
|
||||
MinAttackRange : c.MinAttackRange,
|
||||
MaxAttackRange : c.MaxAttackRange,
|
||||
CanMove : c.CanMove,
|
||||
CanAttack : c.CanAttack,
|
||||
ExtraAttacksRemaining : c.ExtraAttacksRemaining,
|
||||
CanBeAttacked : c.CanBeAttacked,
|
||||
AbilitiesJson : c.AbilitiesJson);
|
||||
}
|
||||
|
||||
private static BoardDto ToBoardDto(Board board)
|
||||
|
||||
@@ -236,7 +236,20 @@ public sealed record CardInstanceDto(
|
||||
int? MaxMp,
|
||||
string? MovementType, // enum as string, null for non-unit cards
|
||||
int? Tier, // ArchSpirit only; 1 = base form
|
||||
string? TerramorphaMode); // Terramorpha only: "Mono" | "Di" | "Tri"
|
||||
string? TerramorphaMode, // Terramorpha only: "Mono" | "Di" | "Tri"
|
||||
// --- fields needed for client-side display and valid-tile computation ---
|
||||
int SpCost,
|
||||
int StCost,
|
||||
IEnumerable<string>? Genus,
|
||||
int? MinChannelRange,
|
||||
int? MaxChannelRange,
|
||||
int? MinAttackRange,
|
||||
int? MaxAttackRange,
|
||||
bool CanMove,
|
||||
bool CanAttack,
|
||||
int ExtraAttacksRemaining,
|
||||
bool CanBeAttacked,
|
||||
string? AbilitiesJson);
|
||||
|
||||
public sealed record BoardDto(
|
||||
int Width,
|
||||
|
||||
Reference in New Issue
Block a user