Bomb Module

This module implement a simple bomb system for Bomberman game.

There is two classes for Bombs :
  • BombNoOwner – one without any information about the player which own it,
  • Bomb – an other with an additionnal attribute owner.
class Bomb.BombNoOwner(force=4, timer=4, power=1, verb=False)[source]

A Class to define a Bomberman bomb. This bomb have no information about his owner, because it’s aimed to be store in the Player.Player class.

Attributes:
  • force – the dimension of explosion.
  • timer – the timer of the bomb.
  • power – the power of the bomb (number of inguries infliged by the bomb).

This class can be used both by the client and the server.

__init__(force=4, timer=4, power=1, verb=False)[source]

Simple constructor of a bomb.

force = None

the dimension of explosion.

timer = None

the timer of the bomb.

power = None

The power of the bomb

__repr__()[source]

Toplevel representation of [self].

tic(toc=1)[source]

Just decrease the timer of the bomb, [toc] is the time spent during ticking. self.timer<=0 is returned. Allow the following shortcut :

Example:
>>> if board[i,j].bomb.tic:
>>>  print 'My bomb at place (%i,%i) is exploding !!' % (i,j)
>>>  game.make_explosion(board[i,j].bomb) # a toy example.
>>> else:
>>>  print 'Hourra, the bomb at place (%i,%i) is not exploding !!' % (i,j) 
class Bomb.Bomb(owner, force=4, timer=4, power=1, verb=True)[source]

Bases: Bomb.BombNoOwner

A Class to define a Bomberman bomb. It is just a BombNoOwner with an extra owner attribute.

Attributes:
  • owner – the indicator of the player which droped the bomb.
  • force – the dimension of explosion.
  • timer – the timer of the bomb.
  • power – the power of the bomb (number of inguries infliged by the bomb).

This class can be used both by the client and the server.

__init__(owner, force=4, timer=4, power=1, verb=True)[source]

Simple constructor of a bomb. The [owner] have to be given, the others paramaters can be omitted. [owner] is used to be a Player.Player instance, but formally coulb be anything.

owner = None

the indicator of the player which droped the bomb.

force = None

the dimension of explosion.

timer = None

the timer of the bomb.

power = None

The power of the bomb

__str__()[source]

Simple conversion to string.

Bomb.add_owner(bomb, owner) → Bomb.Bomb instance[source]

Transform a Bomb.BombNoOwner instance to a Bomb.Bomb instance, by adding to it the owner.

Previous topic

Bonus Module

Next topic

Player Module

This Page