def try_companion_block(attacker, defender, messenger): if not defender.has_companion: return False if random.random() > defender.companion.defend_in_battle_probability: return False if random.random() > defender.companion_damage_probability + defender.companion.damage_from_heal_probability: messenger.add_message('companions_block', attacker=attacker, companion_owner=defender, companion=defender.companion) return True damage = defender.companion.hit() messenger.add_message('companions_wound', attacker=attacker, companion_owner=defender, companion=defender.companion, damage=damage) if defender.companion.is_dead: messenger.add_message('companions_killed', diary=True, attacker=attacker, companion_owner=defender, companion=defender.companion) if defender.actor.can_companion_broke_to_spare_parts(): coins = int(f.normal_action_price(defender.level) * sum(item.price_fraction for item in heroes_relations.ITEMS_OF_EXPENDITURE.records)) defender.actor.change_money(heroes_relations.MONEY_SOURCE.EARNED_FROM_COMPANIONS, coins) messenger.add_message('companions_broke_to_spare_parts', diary=True, companion_owner=defender, companion=defender.companion, coins=coins) defender.remove_companion() return True
def try_companion_block(attacker, defender, messenger): if not defender.has_companion: return False if defender.companion.is_dead: return False if random.random() > defender.companion.defend_in_battle_probability: return False if random.random( ) > defender.companion_damage_probability + defender.companion.damage_from_heal_probability: messenger.add_message('companions_block', attacker=attacker, companion_owner=defender, companion=defender.companion) return True damage = defender.companion.hit() messenger.add_message('companions_wound', attacker=attacker, companion_owner=defender, companion=defender.companion, damage=damage) if not defender.companion.is_dead: return True if defender.keep_dead_companion(): defender.actor.reset_accessors_cache() return True messenger.add_message('companions_killed', diary=True, attacker=attacker, companion_owner=defender, companion=defender.companion) if defender.actor.can_companion_broke_to_spare_parts(): coins = int( f.normal_action_price(defender.level) * sum(item.price_fraction for item in heroes_relations.ITEMS_OF_EXPENDITURE.records)) defender.actor.change_money( heroes_relations.MONEY_SOURCE.EARNED_FROM_COMPANIONS, coins) messenger.add_message('companions_broke_to_spare_parts', diary=True, companion_owner=defender, companion=defender.companion, coins=coins) defender.remove_companion() return True
def job_money(self, place_id, person_id, message_type, job_power): coins = max( 1, int( math.ceil( f.normal_action_price(self.level) * job_power * c.NORMAL_JOB_LENGTH * c.JOB_HERO_REWARD_FRACTION))) self.change_money(relations.MONEY_SOURCE.EARNED_FROM_MASTERS, coins) self.add_message(message_type, diary=True, hero=self, coins=coins, **self.get_job_variables(place_id, person_id))
def upgrade_equipment_cost(cls, hero_info): return int(f.normal_action_price(hero_info.level) * ITEMS_OF_EXPENDITURE.get_quest_upgrade_equipment_fraction())
def spend_amount(self): return int(f.normal_action_price(self.level) * self.next_spending.price_fraction)
def upgrade_equipment_cost(cls, hero_info): return int( f.normal_action_price(hero_info.level) * ITEMS_OF_EXPENDITURE.get_quest_upgrade_equipment_fraction())
def job_money(self, place_id, person_id, message_type, job_power): coins = max(1, int(math.ceil(f.normal_action_price(self.level) * job_power * c.NORMAL_JOB_LENGTH))) self.change_money(relations.MONEY_SOURCE.EARNED_FROM_MASTERS, coins) self.add_message(message_type, diary=True, hero=self, coins=coins, **self.get_job_variables(place_id, person_id))