Fix GDScript type inference errors in game_screen.gd
- Explicit Dictionary type on pd variable (unit position) - Explicit int type on all dist variables (abs() returns Variant when operands are from Dictionary.get() calls) 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:
@@ -412,7 +412,7 @@ func _rebuild_units(state: Dictionary) -> void:
|
||||
|
||||
|
||||
func _add_unit_mesh(unit: Dictionary, team_color: Color) -> void:
|
||||
var pd := unit.get("position", {})
|
||||
var pd : Dictionary = unit.get("position", {})
|
||||
if pd.is_empty(): return
|
||||
var wp := _coord_to_world(pd.get("x", 0), pd.get("y", 0))
|
||||
var card_type : String = unit.get("cardType", "Spirit")
|
||||
@@ -520,7 +520,7 @@ func _valid_play_tiles(card: Dictionary) -> Array:
|
||||
var max_r : int = card.get("maxChannelRange", 2)
|
||||
for tx in range(bw):
|
||||
for ty in range(bh):
|
||||
var dist := abs(tx - ax) + abs(ty - ay)
|
||||
var dist : int = abs(tx - ax) + abs(ty - ay)
|
||||
if dist < min_r or dist > max_r: continue
|
||||
if Game.get_tile(tx, ty).get("occupantId", "") != "": continue
|
||||
results.append(Vector2i(tx, ty))
|
||||
@@ -556,7 +556,7 @@ func _valid_move_tiles(unit: Dictionary) -> Array:
|
||||
if mp <= 0 or unit.get("isExhausted", false): return results
|
||||
for tx in range(bw):
|
||||
for ty in range(bh):
|
||||
var dist := abs(tx - ux) + abs(ty - uy)
|
||||
var dist : int = abs(tx - ux) + abs(ty - uy)
|
||||
if dist == 0 or dist > mp: continue
|
||||
if Game.get_tile(tx, ty).get("occupantId", "") != "": continue
|
||||
results.append(Vector2i(tx, ty))
|
||||
@@ -582,7 +582,7 @@ func _valid_attack_target_coords(unit: Dictionary) -> Array:
|
||||
if not t.get("canBeAttacked", true): continue
|
||||
var tp : Dictionary = t.get("position", {})
|
||||
if tp.is_empty(): continue
|
||||
var dist := abs(tp.get("x", 0) - ux) + abs(tp.get("y", 0) - uy)
|
||||
var dist : int = abs(tp.get("x", 0) - ux) + abs(tp.get("y", 0) - uy)
|
||||
if dist >= min_r and dist <= max_r:
|
||||
results.append(tp)
|
||||
return results
|
||||
@@ -607,7 +607,7 @@ func _valid_attack_target_ids(unit: Dictionary) -> Array:
|
||||
if not t.get("canBeAttacked", true): continue
|
||||
var tp : Dictionary = t.get("position", {})
|
||||
if tp.is_empty(): continue
|
||||
var dist := abs(tp.get("x", 0) - ux) + abs(tp.get("y", 0) - uy)
|
||||
var dist : int = abs(tp.get("x", 0) - ux) + abs(tp.get("y", 0) - uy)
|
||||
if dist >= min_r and dist <= max_r:
|
||||
results.append(t.get("instanceId", ""))
|
||||
return results
|
||||
|
||||
Reference in New Issue
Block a user