def execute_status(self, battle, user_id, target_id): status = self.extra['status'] assert(status in Status.OPTIONS), 'Unexpected status: %s' % (status,) user = battle.get_pokemon(user_id) target = battle.get_pokemon(target_id) if self.hits(battle, user, target): return (Callbacks.set_status(battle, target_id, status, self, noisy_failure=True), True) return self.execute_miss(battle, user_id, target_id)
def get_secondary_effect(self, battle, target_id, target, callback=None): total_mass = 1.0 stat_rate = self.extra.get('stat_rate') if stat_rate: if uniform(0, total_mass) < stat_rate: (stat, stages) = (self.extra['stat'], self.extra['stages']) assert(stages < 0), 'Unexpect stat buff: %s' % (self.name,) return Callbacks.do_buff(battle, target_id, stat, stages, callback=callback) total_mass -= stat_rate for status in Status.OPTIONS: rate = self.extra.get(status + '_rate') if rate: if uniform(0, total_mass) < rate: return Callbacks.set_status(battle, target_id, status, self, callback=callback) total_mass -= rate return callback