def test_creating_effect(self): """ Test that effect can be created and triggered immediately """ effect_factory = EffectsFactory() effect_factory.add_effect( 'major heal', {'type': Heal, 'duration': 0, 'frequency': 0, 'tick': 0, 'healing': 10}) potion = (ItemBuilder() .with_effect( EffectHandleBuilder() .with_trigger('on drink') .with_effect('major heal') .with_charges(2)) .build()) action_factory = ActionFactory(model = mock(), factories = [DrinkFactory(effect_factory)]) character = (CharacterBuilder() .with_action_factory(action_factory) .with_hit_points(1) .with_max_hp(10) .build()) character.drink(potion) assert_that(character.hit_points, is_(equal_to(10))) assert_that(character, has_no_effects())
def test_creating_effect(self): """ Test that effect can be created and triggered immediately """ effect_factory = get_effect_creator({'major heal': {'type': Heal, 'duration': 0, 'frequency': 0, 'tick': 0, 'healing': 10, 'icon': 100, 'title': 'healig', 'description': 'healing'}}) pyherc.vtable['\ufdd0:create-effect'] = effect_factory potion = (ItemBuilder() .with_effect_handle(EffectHandleBuilder() .with_trigger('on drink') .with_effect('major heal') .with_charges(2)) .build()) set_action_factory(ActionFactoryBuilder() .with_drink_factory(DrinkFactoryBuilder() .with_effect_factory(effect_factory)) # noqa .build()) character = (CharacterBuilder() .with_hit_points(1) .with_max_hp(10) .build()) drink(character, potion) assert_that(character.hit_points, is_(equal_to(10))) assert_that(character, has_no_effects())