Skip to content

Commit a7130b9

Browse files
author
AH-Pooya
committed
"offenCive" what the bug and next_neighbour problem
1 parent 8ad7b75 commit a7130b9

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

Model.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -526,9 +526,9 @@ def get_impact_cells(self, ability_constant, start_cell, target_cell):
526526
if start_cell.is_wall or start_cell == target_cell and not ability_constant.is_lobbing:
527527
return [start_cell]
528528
last_cell = None
529-
rey_cells = self.get_ray_cells(start_cell, target_cell)
529+
ray_cells = self.get_ray_cells(start_cell, target_cell)
530530
impact_cells = []
531-
for cell in rey_cells:
531+
for cell in ray_cells:
532532
if self.manhattan_distance(cell, start_cell) > ability_constant.range:
533533
continue
534534
last_cell = cell
@@ -540,7 +540,7 @@ def get_impact_cells(self, ability_constant, start_cell, target_cell):
540540
return impact_cells
541541

542542
def is_affected(self, ability_constant, cell):
543-
return (self._get_opp_hero(cell) is not None and not ability_constant.type == AbilityType.DEFENSIVE) or (
543+
return (self._get_opp_hero(cell) is not None and ability_constant.type == AbilityType.OFFENSIVE) or (
544544
self._get_my_hero(cell) is not None and ability_constant.type == AbilityType.DEFENSIVE)
545545

546546
@staticmethod
@@ -596,17 +596,17 @@ def _calculate_neighbour(self, start, target, current, former):
596596
if current is not former:
597597
return possible_next_cell
598598
options += [possible_next_cell]
599+
else:
600+
x3 = (current.row + possible_next_cell.row) / 2 + (possible_next_cell.column - current.column) / 2
601+
y3 = (possible_next_cell.column + current.column) / 2 + (possible_next_cell.row - current.row) / 2
599602

600-
x3 = (current.row + possible_next_cell.row) / 2 + (possible_next_cell.column - current.column) / 2
601-
y3 = (possible_next_cell.column + current.column) / 2 + (possible_next_cell.row - current.row) / 2
603+
x4 = (current.row + possible_next_cell.row) / 2 - (possible_next_cell.column - current.column) / 2
604+
y4 = (possible_next_cell.column + current.column) / 2 - (possible_next_cell.row - current.row) / 2
602605

603-
x4 = (current.row + possible_next_cell.row) / 2 - (possible_next_cell.column - current.column) / 2
604-
y4 = (possible_next_cell.column + current.column) / 2 - (possible_next_cell.row - current.row) / 2
605-
606-
if self._slope_equation(x1, y1, x2, y2, x3, y3) * self._slope_equation(x1, y1, x2, y2, x4, y4) < 0:
607-
if current is not former:
608-
return possible_next_cell
609-
options += [possible_next_cell]
606+
if self._slope_equation(x1, y1, x2, y2, x3, y3) * self._slope_equation(x1, y1, x2, y2, x4, y4) < 0:
607+
if current is not former:
608+
return possible_next_cell
609+
options += [possible_next_cell]
610610

611611
def is_between(first, second, between):
612612
return (first.row <= between.row <= second.row or first.row >= between.row >= second.row) and \
@@ -743,7 +743,6 @@ def get_ability_targets(self, ability_name=None, ability=None, ability_constant=
743743
if target_row is None or target_column is None:
744744
return None
745745
target_cell = self.map.get_cell(target_row, target_column)
746-
747746
cells = self.get_impact_cells(ability_constant, start_cell, target_cell)
748747
affected_cells = set()
749748
for cell in cells:
@@ -820,7 +819,7 @@ def pick_hero(self, hero_name):
820819
def _get_ability_type(param):
821820
if param == 'DODGE':
822821
return AbilityType.DODGE
823-
if param == 'OFFENCIVE':
822+
if param == 'OFFENSIVE':
824823
return AbilityType.OFFENSIVE
825824
if param == 'DEFENSIVE':
826825
return AbilityType.DEFENSIVE

0 commit comments

Comments
 (0)