def _give_reward(self, hero, reward_type, scale): quest_info = self.current_info scale = quest_info.get_real_reward_scale(hero, scale) if hero.can_get_artifact_for_quest(): level_delta = int(math.ceil(abs(scale))) if scale < 0: level_delta = -level_delta artifact, unequipped, sell_price = self.hero.receive_artifact(equip=False, better=False, prefered_slot=False, prefered_item=False, archetype=False, level_delta=level_delta) if artifact is not None: quest_info.process_message(knowledge_base=self.knowledge_base, hero=self.hero, message='%s_artifact' % reward_type, ext_substitution={'artifact': artifact}) return money = int(max(1, f.sell_artifact_price(hero.level) * scale)) hero.change_money(MONEY_SOURCE.EARNED_FROM_QUESTS, money) quest_info.process_message(knowledge_base=self.knowledge_base, hero=self.hero, message='%s_money' % reward_type, ext_substitution={'coins': money})
def _give_reward(self, hero, reward_type, scale): quest_info = self.current_info scale = quest_info.get_real_reward_scale(hero, scale) if hero.can_get_artifact_for_quest(): artifact, unequipped, sell_price = self.hero.receive_artifact(equip=False, better=False, prefered_slot=False, prefered_item=False, archetype=False) if artifact is not None: artifact.power += Power(physic=int((scale - 1.0) * c.POWER_TO_LVL / 2 ), magic=int((scale - 1.0) * c.POWER_TO_LVL / 2 ) ) quest_info.process_message(knowledge_base=self.knowledge_base, hero=self.hero, message='%s_artifact' % reward_type, ext_substitution={'artifact': artifact}) return multiplier = scale money = 1 + int(f.sell_artifact_price(hero.level) * multiplier) money = int(money * hero.attribute_modifier(HERO_MODIFIERS.QUEST_MONEY_REWARD)) hero.change_money(MONEY_SOURCE.EARNED_FROM_QUESTS, money) quest_info.process_message(knowledge_base=self.knowledge_base, hero=self.hero, message='%s_money' % reward_type, ext_substitution={'coins': money})
def absolute_sell_price(self): if self.is_useless: gold_amount = 1 + int(f.normal_loot_cost_at_lvl(self.level)) else: gold_amount = 1 + int(f.sell_artifact_price(self.level) * self.rarity.cost) return gold_amount
def absolute_sell_price(self): if self.is_useless: gold_amount = 1 + int(f.normal_loot_cost_at_lvl(self.level)) else: gold_amount = 1 + int( f.sell_artifact_price(self.level) * self.rarity.cost) return gold_amount
def _give_reward(self, hero, reward_type, scale): quest_info = self.current_info scale = quest_info.get_real_reward_scale(hero, scale) scale = self.modify_reward_scale(scale) self.give_energy_on_reward() # hero receive artifact if hero.can_get_artifact_for_quest(): level_delta = int(math.ceil(abs(scale))) if scale < 0: level_delta = -level_delta artifact, unequipped, sell_price = self.hero.receive_artifact( equip=False, better=False, prefered_slot=False, prefered_item=False, archetype=False, level_delta=level_delta, ) if artifact is not None: quest_info.process_message( knowledge_base=self.knowledge_base, hero=self.hero, message="%s_artifact" % reward_type, ext_substitution={"artifact": artifact}, ) return # here does not receive artifac (receive money instead) money = int(max(1, f.sell_artifact_price(hero.level) * scale)) hero.change_money(MONEY_SOURCE.EARNED_FROM_QUESTS, money) quest_info.process_message( knowledge_base=self.knowledge_base, hero=self.hero, message="%s_money" % reward_type, ext_substitution={"coins": money}, )
def _give_reward(self, hero, reward_type, scale): quest_info = self.current_info scale = quest_info.get_real_reward_scale(hero, scale) scale = self.modify_reward_scale(scale) self.give_energy_on_reward() # hero receive artifact if hero.can_get_artifact_for_quest(): level_delta = int(math.ceil(abs(scale))) if scale < 0: level_delta = -level_delta artifact, unequipped, sell_price = self.hero.receive_artifact( equip=False, better=False, prefered_slot=False, prefered_item=False, archetype=True, level_delta=level_delta) if artifact is not None: quest_info.process_message( knowledge_base=self.knowledge_base, hero=self.hero, message='%s_artifact' % reward_type, ext_substitution={'artifact': artifact}) return # here does not receive artifac (receive money instead) money = int(max(1, f.sell_artifact_price(hero.level) * scale)) hero.change_money(MONEY_SOURCE.EARNED_FROM_QUESTS, money) quest_info.process_message(knowledge_base=self.knowledge_base, hero=self.hero, message='%s_money' % reward_type, ext_substitution={'coins': money})
def test_sell_artifact_price(self): self.assertTrue(f.sell_artifact_price(1))
def test_sell_artifact_price(self): self.assertTrue(f.sell_artifact_price(1))
def test_sell_artifact_price(self): self.assertEqual(f.sell_artifact_price(1), 31) self.assertEqual(f.sell_artifact_price(10), 184) self.assertEqual(f.sell_artifact_price(25), 276) self.assertEqual(f.sell_artifact_price(50), 338) self.assertEqual(f.sell_artifact_price(100), 430)
def test_sell_artifact_price(self): self.assertEqual(f.sell_artifact_price(1), 31) self.assertEqual(f.sell_artifact_price(10), 184) self.assertEqual(f.sell_artifact_price(25), 276) self.assertEqual(f.sell_artifact_price(50), 338) self.assertEqual(f.sell_artifact_price(100), 430)