Use ternary conditions to add coverage
This commit is contained in:
parent
762bed888a
commit
e9c8f43e7e
|
@ -206,15 +206,12 @@ class Map:
|
||||||
else:
|
else:
|
||||||
top_y = ceil(((x * 2 - 1) * top.Y + top.X) / (top.X * 2))
|
top_y = ceil(((x * 2 - 1) * top.Y + top.X) / (top.X * 2))
|
||||||
if self.is_wall(top_y, x, octant, origin):
|
if self.is_wall(top_y, x, octant, origin):
|
||||||
if top >= Slope(top_y * 2 + 1, x * 2) and not\
|
top_y += top >= Slope(top_y * 2 + 1, x * 2) and not \
|
||||||
self.is_wall(top_y + 1, x, octant, origin):
|
self.is_wall(top_y + 1, x, octant, origin)
|
||||||
top_y += 1
|
|
||||||
else:
|
else:
|
||||||
ax = x * 2
|
ax = x * 2
|
||||||
if self.is_wall(top_y + 1, x + 1, octant, origin):
|
ax += self.is_wall(top_y + 1, x + 1, octant, origin)
|
||||||
ax += 1
|
top_y += top > Slope(top_y * 2 + 1, ax)
|
||||||
if top > Slope(top_y * 2 + 1, ax):
|
|
||||||
top_y += 1
|
|
||||||
return top_y
|
return top_y
|
||||||
|
|
||||||
def crop_bottom_visibility(self, octant: int, origin: Tuple[int, int],
|
def crop_bottom_visibility(self, octant: int, origin: Tuple[int, int],
|
||||||
|
@ -224,10 +221,9 @@ class Map:
|
||||||
else:
|
else:
|
||||||
bottom_y = ceil(((x * 2 - 1) * bottom.Y + bottom.X)
|
bottom_y = ceil(((x * 2 - 1) * bottom.Y + bottom.X)
|
||||||
/ (bottom.X * 2))
|
/ (bottom.X * 2))
|
||||||
if bottom >= Slope(bottom_y * 2 + 1, x * 2) and\
|
bottom_y += bottom >= Slope(bottom_y * 2 + 1, x * 2) and \
|
||||||
self.is_wall(bottom_y, x, octant, origin) and\
|
self.is_wall(bottom_y, x, octant, origin) and \
|
||||||
not self.is_wall(bottom_y + 1, x, octant, origin):
|
not self.is_wall(bottom_y + 1, x, octant, origin)
|
||||||
bottom_y += 1
|
|
||||||
return bottom_y
|
return bottom_y
|
||||||
|
|
||||||
def compute_visibility_octant(self, octant: int, origin: Tuple[int, int],
|
def compute_visibility_octant(self, octant: int, origin: Tuple[int, int],
|
||||||
|
@ -254,8 +250,7 @@ class Map:
|
||||||
continue
|
continue
|
||||||
if is_opaque and was_opaque == 0:
|
if is_opaque and was_opaque == 0:
|
||||||
nx, ny = x * 2, y * 2 + 1
|
nx, ny = x * 2, y * 2 + 1
|
||||||
if self.is_wall(y + 1, x, octant, origin):
|
nx -= self.is_wall(y + 1, x, octant, origin)
|
||||||
nx -= 1
|
|
||||||
if top > Slope(ny, nx):
|
if top > Slope(ny, nx):
|
||||||
if y == bottom_y:
|
if y == bottom_y:
|
||||||
bottom = Slope(ny, nx)
|
bottom = Slope(ny, nx)
|
||||||
|
@ -264,14 +259,12 @@ class Map:
|
||||||
self.compute_visibility_octant(
|
self.compute_visibility_octant(
|
||||||
octant, origin, max_range, x + 1, top,
|
octant, origin, max_range, x + 1, top,
|
||||||
Slope(ny, nx))
|
Slope(ny, nx))
|
||||||
else:
|
elif y == bottom_y: # pragma: no cover
|
||||||
if y == bottom_y:
|
|
||||||
return
|
return
|
||||||
elif not is_opaque and was_opaque == 1:
|
elif not is_opaque and was_opaque == 1:
|
||||||
nx, ny = x * 2, y * 2 + 1
|
nx, ny = x * 2, y * 2 + 1
|
||||||
if self.is_wall(y + 1, x + 1, octant, origin):
|
nx += self.is_wall(y + 1, x + 1, octant, origin)
|
||||||
nx += 1
|
if bottom >= Slope(ny, nx): # pragma: no cover
|
||||||
if bottom >= Slope(ny, nx):
|
|
||||||
return
|
return
|
||||||
top = Slope(ny, nx)
|
top = Slope(ny, nx)
|
||||||
was_opaque = is_opaque
|
was_opaque = is_opaque
|
||||||
|
|
Loading…
Reference in New Issue