Use parentheses for all asserts

This commit is contained in:
Nathan Lovato 2019-11-28 09:19:52 +01:00
parent 0b5869e847
commit 70c8ca8d37
11 changed files with 16 additions and 16 deletions

View file

@ -15,7 +15,7 @@ var _last_velocity: = Vector2(0, 0)
func _ready() -> void:
_heatmap = get_tree().root.find_node("Heatmap", true, false)
assert _heatmap
assert(_heatmap)
func _calculate_steering_internal(steering: SteeringMotion2D) -> SteeringMotion2D:
@ -31,4 +31,4 @@ func _calculate_steering_internal(steering: SteeringMotion2D) -> SteeringMotion2
steering.velocity = _last_velocity
steering.angular_velocity = 0
return steering
return steering

View file

@ -21,7 +21,7 @@ var last_child_index: = 0
Returns the child whose motion was non-zero. Returns null if no children produced an acceleration.
"""
func get_last_selected_child() -> SteeringBehavior2D:
assert last_child_index >= 0
assert(last_child_index >= 0)
return get_child(last_child_index) as SteeringBehavior2D

View file

@ -28,7 +28,7 @@ func calculate_steering(steering: SteeringMotion2D) -> SteeringMotion2D:
Returns the actor upon which the behaviors are acting, to access their position in space.
"""
func get_actor() -> Node2D:
assert controller
assert(controller)
return controller.actor

View file

@ -74,7 +74,7 @@ to aim the hook.
Replaces the Input map actions
"""
func set_aim_stick(value: int) -> void:
assert value in [AimStick.LEFT, AimStick.RIGHT]
assert(value in [AimStick.LEFT, AimStick.RIGHT])
var setting: int = ProjectSettings.get_setting('debug/testing/controls/aim_stick')
if value == setting:
return

View file

@ -12,7 +12,7 @@ var target_position: = Vector2()
func _ready() -> void:
if not waypoints:
print("Missing Waypoints node for %s: %s" % [name, get_path()])
assert waypoints
assert(waypoints)
set_physics_process(false)
return
position = waypoints.get_start_position()

View file

@ -34,7 +34,7 @@ func _draw() -> void:
var triangles: = []
var last_point: = Vector2.ZERO
for child in get_children():
assert child is Node2D
assert(child is Node2D)
points.append(child.position)
if points.size() > 1:
var center: Vector2 = (child.position + last_point) / 2
@ -83,5 +83,5 @@ func set_editor_process(value: bool) -> void:
func set_mode(value: int) -> void:
# assert value in Mode
# assert(value in Mode)
mode = value

View file

@ -13,8 +13,8 @@ export var is_active: = true
func _ready():
assert ray_top.cast_to.x >= 0
assert ray_bottom.cast_to.x >= 0
assert(ray_top.cast_to.x >= 0)
assert(ray_bottom.cast_to.x >= 0)
func _unhandled_input(event: InputEvent) -> void:

View file

@ -30,10 +30,10 @@ func play(name: String, data: Dictionary = {}) -> void:
"""
Plays the requested animation and safeguards against errors
"""
assert name in anim.get_animation_list()
assert(name in anim.get_animation_list())
anim.stop()
if name == "ledge":
assert 'from' in data
assert('from' in data)
position = data.from
anim.play(name)

View file

@ -9,7 +9,7 @@ func _on_Player_animation_finished(anim_name: String) -> void:
func enter(msg: Dictionary = {}) -> void:
assert "last_checkpoint" in msg
assert("last_checkpoint" in msg)
last_checkpoint = msg.last_checkpoint
owner.camera_rig.is_active = true
owner.skin.play("die")

View file

@ -10,7 +10,7 @@ func _on_Skin_animation_finished(name: String) -> void:
func enter(msg: Dictionary = {}) -> void:
assert "move_state" in msg and msg.move_state is State
assert("move_state" in msg and msg.move_state is State)
owner.skin.connect("animation_finished", self, "_on_Skin_animation_finished")
@ -23,4 +23,4 @@ func enter(msg: Dictionary = {}) -> void:
func exit() -> void:
owner.skin.disconnect("animation_finished", self, "_on_Skin_animation_finished")
owner.skin.disconnect("animation_finished", self, "_on_Skin_animation_finished")

View file

@ -9,7 +9,7 @@ func _on_Player_animation_finished(anim_name: String) -> void:
func enter(msg: Dictionary = {}) -> void:
assert "last_checkpoint" in msg
assert("last_checkpoint" in msg)
owner.stats.set_invulnerable_for_seconds(2)
owner.global_position = msg.last_checkpoint.global_position
owner.is_active = false