Exemple #1
0
 def can_use_skills(self):
     if self._cur_health <= 0:
         if log_enabled(): log("        Can't use skills: {" + self.description() + "} is DEAD")
         return False
     if self._jammed:
         if log_enabled(): log("        Can't use skills: {" + self.description() + "} is JAMMED")
         return False
     return True
Exemple #2
0
 def cannot_attack(self):
     if self._cur_health <= 0:
         if log_enabled(): log("        Can't attack: {" + self.description() + "} is DEAD")
         return True
     if self._jammed:
         if log_enabled(): log("        Can't attack: {" + self.description() + "} is JAMMED")
         return True
     if self._immobilized:
         if log_enabled(): log("        Can't attack: {" + self.description() + "} is IMMOBILIZED")
         return True
     if self._cur_attack <= 0:
         if log_enabled(): log("        Can't attack: {" + self.description() + "} has attack " + str(self.attack()))
         return True
     return False
Exemple #3
0
 def take_damage(self, amount):
     self._cur_health -= amount
     died = self._cur_health <= 0
     regenerate = self.regenerate()
     if died:
         # make dead cards appear to have a very large cooldown,
         # to reduce the need to check in quite so many places
         # whether a card is dead.
         self._cur_cd = 999
         if regenerate > 0 and coin_toss():                
             if log_enabled(): log("        Regenerate! Unit {" + self.description() + "} will regenerate to " + str(regenerate))
             self.perform_regenerate(regenerate)
Exemple #4
0
    def simulate(self):
        turn = 0
        commander_killed = False
        while turn <= 50 and not commander_killed:
            if self.is_offense_turn(turn):
                if log_enabled(): log("Turn " + str(turn) + " | OFFENSE plays ------------------------")
                commander_killed = self._offense_board.play_random_turn(self._defense_board)
            else:
                if log_enabled(): log("Turn " + str(turn) + " | DEFENSE plays ------------------------")
                commander_killed = self._defense_board.play_random_turn(self._offense_board)
            turn += 1
            if log_enabled():
                self._defense_board.log_as_defense()
                self._offense_board.log_as_offense()

        if log_enabled():
            if commander_killed and self.is_offense_turn(turn - 1):
                log("OFFENSE wins")
            else:
                log("DEFENSE wins")

        return commander_killed and self.is_offense_turn(turn - 1)
Exemple #5
0
 def __init__(self, offense_deck, defense_deck, surge):
     self._surge = surge
     if log_enabled(): log("Setting up offense board")
     self._offense_board = Board(offense_deck)
     if log_enabled(): log("Setting up defense board")
     self._defense_board = Board(defense_deck)