Skip to content

Commit

Permalink
Update checkisvalidposition.
Browse files Browse the repository at this point in the history
  • Loading branch information
alanwatsonforster committed Sep 23, 2023
1 parent 277d4bd commit 6a11437
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion airpower/aircraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def next(self, actions):
break

assert self._ifp <= self._nfp
aphex.checkiscenteroredge(self._x, self._y)
aphex.checkisvalidposition(self._x, self._y)
aphex.checkisvalidfacing(self._x, self._y, self._facing)
apaltitude.checkisvalidaltitude(self._altitude)

Expand Down
8 changes: 4 additions & 4 deletions airpower/hex.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def isedge(x, y):
else:
return False

def iscenteroredge(x, y):
def isvalidposition(x, y):

"""
Return True if the point (x,y) in hex coordinates corresponds to the center
Expand All @@ -55,14 +55,14 @@ def areadjacent(x0, y0, x1, y1):
else:
return False

def checkiscenteroredge(x, y):
def checkisvalidposition(x, y):

"""
Raise a ValueError exception if the point (x,y) in hex coordinates does not
correspond to the center of a hex or to (the center of) the edge of a hex.
"""

if not iscenteroredge(x, y):
if not isvalidposition(x, y):
raise ValueError("(%s,%s) is not the center or edge of a hex." % (x,y))

def isvalidfacing(x, y, facing):
Expand All @@ -73,7 +73,7 @@ def isvalidfacing(x, y, facing):
center of) the edge of a hex.
"""

checkiscenteroredge(x, y)
checkisvalidposition(x, y)

if iscenter(x, y):
return facing % 30 == 0
Expand Down
2 changes: 1 addition & 1 deletion airpower/hexcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def fromxy(x, y):
Return the hex code corresponding to the hex coordinate (x, y).
"""

aphex.checkiscenteroredge(x, y)
aphex.checkisvalidposition(x, y)

if aphex.iscenter(x, y):

Expand Down

0 comments on commit 6a11437

Please sign in to comment.