unit module

class unit.unit.Unit(screen=0, allegiance=0, id=0)

Bases: object

basic unit

Parameters
  • screen (pygame.Surface) -- screen where we put the unit

  • allegiance (int) -- which side the unit belongs to

  • id (int) -- unique unit id

attack(target)

called when the unit makes damages

Parameters

target (Unit object) -- target to attack

Returns

-1 if the targeted unit has died

Return type

int

changeSprite(valeur)

change the unit image

Parameters

valeur (int) -- value which differenciate which image to put

getAllegiance()

give which side the unit belong

Returns

the unit side ( 1 ou -1)

Return type

int

getAttack()

return the attack level

Returns

the attack level

Return type

int

getId()

gives the unique unit id

Returns

the id

Return type

int

getPosX()

get the x coordinate

Returns

the x coordinate

Return type

int

getPosY()

get the y coordinate

Returns

the y coordinate

Return type

int

hurt(atk)

called when the unit takes damages

Parameters

atk (int) -- power of the unit which attacked this unit

hurtPlayer(joueur)

attack the enemy base

Parameters

joueur (Player object) -- player targeted by the attack

loadImage()

load image => for network stuff : because i cant pass an image through the network (not pickable), I used this

move(speed)

move the unit to the enemy base by a defined quantity by speed

Parameters

speed (int) -- speed of the unit

setstate(i)

set a unit state

Parameters

i (string) -- unit state

show(offset)

display the unit

Parameters

offset (int) -- offset for displaying the unit (because of the top toolbar)