Moved distance_inc back to being its own function

I almost forgot - distance_inc is actually used by both
'approach' and 'withdraw', since approaching an object
might put you farther away from others. So, I moved it back
to its own function.
This commit is contained in:
FlutterSprite 2017-10-23 22:29:45 -07:00
parent 95f840ac7a
commit 1fe9bf3dce

View file

@ -310,6 +310,21 @@ def get_range(obj1, obj2):
return None
# Return the range between the two objects.
return obj1.db.combat_range[obj2]
def distance_inc(mover, target):
"""
Function that increases distance in range field between mover and target.
Args:
mover (obj): The object moving
target (obj): The object to be moved away from
"""
mover.db.combat_range[target] += 1
target.db.combat_range[mover] = mover.db.combat_range[target]
# Set a cap of 2:
if get_range(mover, target) > 2:
target.db.combat_range[mover] = 2
mover.db.combat_range[target] = 2
def approach(mover, target):
"""
@ -370,20 +385,6 @@ def withdraw(mover, target):
of their withdrawl. The mover will never inadvertently move toward anything else while
withdrawing - they can be considered to be moving to open space.
"""
def distance_inc(mover, target):
"""
Helper function that increases distance in range field between mover and target.
Args:
mover (obj): The object moving
target (obj): The object to be moved away from
"""
mover.db.combat_range[target] += 1
target.db.combat_range[mover] = mover.db.combat_range[target]
# Set a cap of 2:
if get_range(mover, target) > 2:
target.db.combat_range[mover] = 2
mover.db.combat_range[target] = 2
contents = mover.location.contents