Added setter to make sure that the even-r and cube coordinates never get out of sync.

This commit is contained in:
Amy Wooding 2016-07-16 17:45:02 -04:00
parent 2b9f4dba36
commit cf6ef569a5
1 changed files with 5 additions and 2 deletions

View File

@ -83,6 +83,10 @@ class HexMapCell(Label):
'''return even-r coordinates of the hexagon.''' '''return even-r coordinates of the hexagon.'''
return(self.cube_to_even_r(*self.cube_coords)) return(self.cube_to_even_r(*self.cube_coords))
@even_r_coords.setter
def even_r_coords(self, value):
self.cube_coords = self.even_r_to_cube(*value)
def coordinate_text(self): def coordinate_text(self):
return '({}, {})'.format(self.coords.row, self.coords.col) return '({}, {})'.format(self.coords.row, self.coords.col)
@ -90,8 +94,7 @@ class HexMapCell(Label):
return '{}'.format(self.even_r_coords) return '{}'.format(self.even_r_coords)
def cube_coordinate_text(self): def cube_coordinate_text(self):
x, y, z = self.cube_coords return '{}\n{}\n{}'.format(*self.cube_coords)
return '{}\n{}\n{}'.format(x, y, z)
def map_display_text(self): def map_display_text(self):
return "{}\n{}".format(self.even_r_coordinate_text(), self.cube_coordinate_text()) return "{}\n{}".format(self.even_r_coordinate_text(), self.cube_coordinate_text())