def run(self): """ Run the controller """ self.previousController = TheGameEngine.controller self.application.addWidget(self.window) self.application.setCurrentWidget(self.window) TheGameEngine.start(self.window, self) self.window.grabKeyboard()
def move(self, rowMovement, columnMovement): """ Move the drone """ self.row += rowMovement self.column += columnMovement self.moveRating.move() square = self.minefield.getSquare(self.row, self.column) square.onMove(self) TheGameEngine.updateUI()
def tryToAttack(self, drone): """ Try to have the worm attack the drone """ if not self.attacking: self.attacking = self.droneInSquare(drone) if self.attacking: if (self.attackTick % self.cyclesToAttack) == 0: self.attack(drone) self.attacking = False self.attackTick %= self.cyclesToAttack self.attackTick += 1 TheGameEngine.updateUI()
def move(self, minefield): """ Move the worm in the minefield """ adjacentSquares = minefield.getAdjacentSquares(self.gridSquare) while True: if len(adjacentSquares) == 0: break square = choice(adjacentSquares) if square.hasGroundDefense() or square.column == 0: adjacentSquares.remove(square) # Can't move to a square that already has ground content or is in the safe zone else: self.gridSquare.setGroundDefense(None) square.setGroundDefense(self) self.gridSquare = square TheGameEngine.updateUI() break
def move(self, minefield): """ Move the worm in the minefield """ adjacentSquares = minefield.getAdjacentSquares(self.gridSquare) while True: if len(adjacentSquares) == 0: break square = choice(adjacentSquares) if square.hasGroundDefense() or square.column == 0: adjacentSquares.remove( square ) # Can't move to a square that already has ground content or is in the safe zone else: self.gridSquare.setGroundDefense(None) square.setGroundDefense(self) self.gridSquare = square TheGameEngine.updateUI() break
def run(self): """ Run the controller """ self.application.addWidget(self.window) self.application.setCurrentWidget(self.window) TheGameEngine.start(self.window, self)
def defuse(self): """ Defuse the current cell """ self.powerRating.usePower(DEFUSE_POWER) self.minefield.defuse(self.row, self.column, self) TheGameEngine.updateUI()
def performEMP(self): """ Performan EMP Blast """ self.powerRating.usePower(EMP_POWER) self.minefield.performEMP(self.row, self.column, self) TheGameEngine.updateUI()
def defuseCarefully(self): """ Carfeully defuse a Fragile mine """ self.powerRating.usePower(CAREFUL_DEFUSE_POWER) self.minefield.defuseCarefully(self.row, self.column, self) TheGameEngine.updateUI()
def scan(self): """ Scan the current cell """ self.powerRating.usePower(SCAN_POWER) self.minefield.scan(self.row, self.column, self) TheGameEngine.updateUI()