grid module

class ui.grid.Grid(size, unit_size)

Bases: object

Grid class for storing units

Parameters
  • size (int) -- size of the grid

  • unit_size (int) -- size of the unit

deleteUnitAtGrid(x, y)

delete a unit from the grid

Parameters
  • x (int) -- x coordinate of the case where the unit will be deleted

  • y (int) -- y coordinate of the case where the unit will be put

Returns

the grid modified

getGridSize()

return the grid size(square)

Returns

the grid size

Return type

int

getUnitAtGrid(x, y)

get a unit at a position

Parameters
  • x (int) -- x coordinate of the unit

  • y (int) -- y coordinate of the unit

Returns

the unit at the (x,y) position

Return type

Unit object

moveUnitAtGrid(x, y, target)

move the unit

Parameters
  • x (int) -- x coordinate of the case where the unit is before being moved

  • y (int) -- y coordinate of the case where the unit is before being moved

  • target (Unit object) -- Unit to move

setUnitAtGrid(x, y, target)

put a unit in the grid

Parameters
  • x (int) -- x coordinate of the case where the unit will be put

  • y (int) -- ycoordinate of the case where the unit will be put

  • target (Unit object) -- unit to place