def test_state_not_reached(self): self.kb += [ facts.State(uid='state_3'), facts.State(uid='state_4'), facts.Jump(state_from='state_3', state_to='state_4') ] self.assertRaises(self.restriction.Error, self.restriction.validate, self.kb)
def construct(cls, nesting, selector, initiator, initiator_position, receiver, receiver_position): hero = selector.heroes()[0] ns = selector._kb.get_next_ns() start = facts.Start(uid=ns + 'start', type=cls.TYPE, nesting=nesting, description=u'Начало: простейшее задание', require=[ requirements.LocatedIn( object=hero.uid, place=initiator_position.uid) ], actions=[actions.Message(type='intro')]) participants = [ facts.QuestParticipant(start=start.uid, participant=receiver_position.uid, role=ROLES.RECEIVER_POSITION) ] arriving = facts.State(uid=ns + 'arriving', description=u'Прибытие в другой город', require=[ requirements.LocatedIn( object=hero.uid, place=receiver_position.uid) ]) facts.State(uid=ns + 'any_action', description=u'выполнить какое-то действие', actions=[actions.Message(type='do smth')]) finish = facts.Finish( uid=ns + 'finish', start=start.uid, results={receiver_position.uid: RESULTS.SUCCESSED}, nesting=nesting, description=u'завершить задание', actions=[actions.GiveReward(object=hero.uid, type='finish')]) line = [ start, facts.Jump(state_from=start.uid, state_to=arriving.uid), arriving, facts.Jump(state_from=arriving.uid, state_to=finish.uid), finish ] line.extend(participants) return line
def setUp(self): self.kb = KnowledgeBase() self.hero = facts.Hero(uid='hero') self.start = facts.Start(uid='start', type='test', nesting=0) self.state_1 = facts.State(uid='state_1') self.state_2 = facts.State(uid='state_2') self.finish_1 = facts.Finish(start='start', uid='finish_1', results={}, nesting=0) self.kb += [ self.start, self.state_1, self.state_2, self.finish_1, self.hero] self.machine = Machine(knowledge_base=self.kb, interpreter=FakeInterpreter())
def construct(cls, nesting, selector, initiator, initiator_position, receiver, receiver_position): hero = selector.heroes()[0] ns = selector._kb.get_next_ns() start = facts.Start(uid=ns+'start', type=cls.TYPE, nesting=nesting, description=u'Начало: посетить святой город', require=[requirements.LocatedIn(object=hero.uid, place=initiator_position.uid)], actions=[actions.Message(type='intro')]) participants = [facts.QuestParticipant(start=start.uid, participant=receiver_position.uid, role=ROLES.RECEIVER_POSITION) ] arriving = facts.State(uid=ns+'arriving', description=u'Прибытие в город', require=[requirements.LocatedIn(object=hero.uid, place=receiver_position.uid)]) action_choices = [facts.State(uid=ns+'speak_with_guru', description=u'поговорить с гуру', actions=[actions.Message(type='speak_with_guru'), actions.DoNothing(type='speak_with_guru')]), facts.State(uid=ns+'stagger_holy_streets', description=u'пошататься по улицам', actions=[actions.Message(type='stagger_holy_streets'), actions.DoNothing(type='stagger_holy_streets')])] holy_actions = random.sample(action_choices, 1) finish = facts.Finish(uid=ns+'finish', start=start.uid, results={ receiver_position.uid: RESULTS.SUCCESSED}, nesting=nesting, description=u'завершить посещение города', actions=[actions.GiveReward(object=hero.uid, type='finish'), actions.GivePower(object=receiver_position.uid, power=1)]) line = [ start, facts.Jump(state_from=start.uid, state_to=arriving.uid), arriving, facts.Jump(state_from=arriving.uid, state_to=holy_actions[0].uid), facts.Jump(state_from=holy_actions[0].uid, state_to=finish.uid), finish ] line.extend(holy_actions) line.extend(participants) return line
def setUp(self): super(NoCirclesInStateJumpGraphTests, self).setUp() self.restriction = restrictions.NoCirclesInStateJumpGraph() self.kb += [ facts.Start(uid='start', type='test', nesting=0), facts.State(uid='state_1'), facts.State(uid='state_2'), facts.Start(uid='start_3', type='test', nesting=0), facts.Finish(start='start', uid='finish_1', results={}, nesting=0), facts.Jump(state_from='start', state_to='state_1'), facts.Jump(state_from='state_1', state_to='state_2'), facts.Jump(state_from='state_2', state_to='start_3'), facts.Jump(state_from='start_3', state_to='finish_1') ]
def setUp(self): super(MultipleJumpsFromNormalStateTests, self).setUp() self.restriction = restrictions.MultipleJumpsFromNormalState() self.kb += [ facts.Start(uid='start', type='test', nesting=0), facts.Choice(uid='state_1'), facts.State(uid='state_2'), facts.Question(uid='state_3', condition=()), facts.Jump(state_from='state_2', state_to='state_3'), facts.Finish(start='start', uid='finish_1', results={}, nesting=0), facts.Finish(start='start', uid='finish_2', results={}, nesting=0), facts.Jump(state_from='start', state_to='state_1'), facts.Option(state_from='state_1', state_to='state_2', type='opt_1', markers=()), facts.Option(state_from='state_1', state_to='finish_1', type='opt_2', markers=()), facts.Answer(state_from='state_3', state_to='finish_1', condition=True), facts.Answer(state_from='state_3', state_to='finish_2', condition=False) ]
def test_wrong_require(self): self.kb += [ facts.State(uid='state', require=[facts.Place(uid='wrong requirement')]) ] self.assertRaises(self.restriction.Error, self.restriction.validate, self.kb)
def test_remove_unused_actors(self): self.kb += facts.Condition(uid='condition') self.kb += facts.Restriction(uid='restriction') self.kb += facts.Actor(uid='action_actor') self.kb += facts.Actor(uid='requirement_actor') self.kb += facts.Actor(uid='condition_actor') self.kb += facts.Actor(uid='removed_actor') self.kb += facts.State( uid='state', actions=[actions.GivePower(object='action_actor', power=1)], require=[ requirements.LocatedIn(object='requirement_actor', place='requirement_actor') ]) self.kb += facts.Question(uid='question', condition=[ requirements.LocatedIn( object='condition_actor', place='condition_actor') ]) transformators.remove_unused_actors(self.kb) self.assertFalse('removed_actor' in self.kb) self.assertFalse('condition' in self.kb) self.assertFalse('restriction' in self.kb) self.assertTrue('action_actor' in self.kb) self.assertTrue('requirement_actor' in self.kb) self.assertTrue('condition_actor' in self.kb) self.assertTrue('state' in self.kb) self.assertTrue('question' in self.kb)
def test_error(self): self.kb += [ facts.State(uid='state_2'), facts.Jump(state_from='start', state_to='state_2') ] self.assertRaises(self.restriction.Error, self.restriction.validate, self.kb)
def construct(cls, nesting, selector, initiator, initiator_position, receiver, receiver_position): hero = selector.heroes()[0] ns = selector._kb.get_next_ns() start = facts.Start(uid=ns+'start', type=cls.TYPE, nesting=nesting, description=u'Начало: навестить соратника', require=[requirements.LocatedIn(object=hero.uid, place=initiator_position.uid)], actions=[actions.Message(type='intro')]) participants = [facts.QuestParticipant(start=start.uid, participant=receiver.uid, role=ROLES.RECEIVER) ] meeting = facts.State(uid=ns+'meeting', description=u'встреча с соратником', require=[requirements.LocatedIn(object=hero.uid, place=receiver_position.uid)]) finish_meeting = facts.Finish(uid=ns+'finish_meeting', start=start.uid, results={receiver.uid: RESULTS.SUCCESSED}, nesting=nesting, description=u'соратнику оказана помощь', require=[requirements.LocatedIn(object=hero.uid, place=receiver_position.uid)], actions=[actions.GiveReward(object=hero.uid, type='finish_meeting'), actions.GivePower(object=receiver.uid, power=1)]) help_quest = selector.create_quest_from_person(nesting=nesting+1, initiator=receiver, tags=('can_continue',)) help_extra = [] for help_fact in logic.filter_subquest(help_quest, nesting): if isinstance(help_fact, facts.Start): help_extra.append(facts.Jump(state_from=meeting.uid, state_to=help_fact.uid, start_actions=[actions.Message(type='before_help')])) elif isinstance(help_fact, facts.Finish): if help_fact.results[receiver.uid] == RESULTS.SUCCESSED: help_extra.append(facts.Jump(state_from=help_fact.uid, state_to=finish_meeting.uid, start_actions=[actions.Message(type='after_help')])) subquest = facts.SubQuest(uid=ns+'help_subquest', members=logic.get_subquest_members(help_quest)) line = [ start, facts.Jump(state_from=start.uid, state_to=meeting.uid), meeting, finish_meeting, subquest ] line.extend(participants) line.extend(help_quest) line.extend(help_extra) return line
def test_full_serialization(self): fact = facts.State( uid='state-uid', description='some description', # externals settuped to default require=[requirements.IsAlive(object='hero')], actions=[actions.Message(type='message-type')]) self.assertEqual(fact.serialize(), facts.State.deserialize(fact.serialize()).serialize()) self.assertTrue('description' in fact.serialize()['attributes'])
def setUp(self): super(AllStatesHasJumpsTests, self).setUp() self.kb += [ facts.Start(uid='start', type='test', nesting=0), facts.State(uid='state_1'), facts.Finish(start='start', uid='finish_1', results={}, nesting=0), facts.Jump(state_from='start', state_to='state_1'), facts.Jump(state_from='state_1', state_to='finish_1') ] self.restriction = restrictions.AllStatesHasJumps()
def test_can_do_step__requirement_failed(self): state_3 = facts.State(uid='state_3', require=[requirements.IsAlive(object='hero')]) jump_3 = facts.Jump(state_from=self.start.uid, state_to=state_3.uid) self.kb += [ state_3, jump_3] pointer = self.machine.pointer self.kb -= pointer self.kb += pointer.change(state=self.start.uid, jump=jump_3.uid) self.assertFalse(self.machine.can_do_step())
def test_can_do_step__success(self): state_3 = facts.State(uid='state_3', require=[requirements.IsAlive(object='hero')]) jump_3 = facts.Jump(state_from=self.start.uid, state_to=state_3.uid) self.kb += [ state_3, jump_3] pointer = self.machine.pointer self.kb -= pointer self.kb += pointer.change(state=self.start.uid, jump=jump_3.uid) with mock.patch('questgen.machine.Machine.interpreter', FakeInterpreter(check_is_alive=True)): self.assertTrue(self.machine.can_do_step())
def test_broken_path(self): facts_list = [ facts.Start(uid='start', type='test', nesting=0), facts.Finish(uid='st_finish', results={}, nesting=0, start='start'), facts.Jump(state_from='start', state_to='st_finish') ] self.kb += facts_list broken_path = [ facts.State(uid='st_broken_1'), facts.State(uid='st_broken_2'), facts.Jump(state_from='st_broken_1', state_to='st_broken_2'), facts.Jump(state_from='st_broken_2', state_to='st_finish') ] self.kb += broken_path transformators.remove_broken_states(self.kb) self.check_in_knowledge_base(self.kb, facts_list) self.check_not_in_knowledge_base(self.kb, broken_path)
def construct(cls, nesting, selector, initiator, initiator_position, receiver, receiver_position): hero = selector.heroes()[0] ns = selector._kb.get_next_ns() start = facts.Start(uid=ns+'start', type=cls.TYPE, nesting=nesting, description=u'Начало: посетить родной города', require=[requirements.LocatedIn(object=hero.uid, place=initiator_position.uid)], actions=[actions.Message(type='intro')]) participants = [facts.QuestParticipant(start=start.uid, participant=receiver_position.uid, role=ROLES.RECEIVER_POSITION) ] arriving = facts.State(uid=ns+'arriving', description=u'Прибытие в город', require=[requirements.LocatedIn(object=hero.uid, place=receiver_position.uid)]) action_choices = [facts.State(uid=ns+'drunk_song', description=u'спеть пьяную песню', actions=[actions.Message(type='drunk_song'), actions.DoNothing(type='drunk_song')]), facts.State(uid=ns+'stagger_streets', description=u'пошататься по улицам', actions=[actions.Message(type='stagger_streets'), actions.DoNothing(type='stagger_streets')]), facts.State(uid=ns+'chatting', description=u'пообщаться с друзьями', actions=[actions.Message(type='chatting'), actions.DoNothing(type='chatting')]), facts.State(uid=ns+'search_old_friends', description=u'искать старого друга', actions=[actions.Message(type='search_old_friends'), actions.DoNothing(type='search_old_friends')]), facts.State(uid=ns+'remember_names', description=u'вспоминать имена друзей', actions=[actions.Message(type='remember_names'), actions.DoNothing(type='remember_names')])] home_actions = random.sample(action_choices, 3) finish = facts.Finish(uid=ns+'finish', start=start.uid, results={ receiver_position.uid: RESULTS.SUCCESSED}, nesting=nesting, description=u'завершить посещение города', actions=[actions.GiveReward(object=hero.uid, type='finish')]) line = [ start, facts.Jump(state_from=start.uid, state_to=arriving.uid), arriving, facts.Jump(state_from=arriving.uid, state_to=home_actions[0].uid), facts.Jump(state_from=home_actions[0].uid, state_to=home_actions[1].uid), facts.Jump(state_from=home_actions[1].uid, state_to=home_actions[2].uid), facts.Jump(state_from=home_actions[2].uid, state_to=finish.uid), finish ] line.extend(home_actions) line.extend(participants) return line
def test_single_broken_state(self): facts_list = [ facts.Start(uid='start', type='test', nesting=0), facts.Finish(uid='st_finish', results={}, nesting=0, start='start'), facts.Jump(state_from='start', state_to='st_finish') ] self.kb += facts_list broken_state = facts.State(uid='st_broken') self.kb += broken_state transformators.remove_broken_states(self.kb) self.check_in_knowledge_base(self.kb, facts_list) self.assertFalse(broken_state.uid in self.kb)
def setUp(self): super(RemoveBrokenQuestionStatesTests, self).setUp() self.question = facts.Question(uid='state_1', condition=()) self.answer_1 = facts.Answer(state_from='state_1', state_to='state_2', condition=True) self.answer_2 = facts.Answer(state_from='state_1', state_to='finish_1', condition=False) self.kb += [ facts.Start(uid='start', type='test', nesting=0), self.question, facts.State(uid='state_2'), facts.Finish(start='start', uid='finish_1', results={}, nesting=0), facts.Finish(start='start', uid='finish_2', results={}, nesting=0), facts.Jump(state_from='start', state_to='state_1'), self.answer_1, self.answer_2, facts.Jump(state_from='state_2', state_to='finish_2') ]
def setUp(self): super(ChoicesConsistencyTests, self).setUp() self.restriction = restrictions.ChoicesConsistency() self.kb += [ facts.Start(uid='start', type='test', nesting=0), facts.Choice(uid='state_1'), facts.State(uid='state_2'), facts.Finish(start='start', uid='finish_1', results={}, nesting=0), facts.Finish(start='start', uid='finish_2', results={}, nesting=0), facts.Jump(state_from='start', state_to='state_1'), facts.Option(state_from='state_1', state_to='state_2', type='opt_1', markers=()), facts.Option(state_from='state_1', state_to='finish_1', type='opt_2', markers=()), facts.Jump(state_from='state_2', state_to='finish_2') ]
def setUp(self): super(QuestionsConsistencyTests, self).setUp() self.restriction = restrictions.QuestionsConsistency() self.answer_1 = facts.Answer(state_from='state_1', state_to='state_2', condition=True) self.answer_2 = facts.Answer(state_from='state_1', state_to='finish_1', condition=False) self.kb += [ facts.Start(uid='start', type='test', nesting=0), facts.Question(uid='state_1', condition=()), facts.State(uid='state_2'), facts.Finish(start='start', uid='finish_1', results={}, nesting=0), facts.Finish(start='start', uid='finish_2', results={}, nesting=0), facts.Jump(state_from='start', state_to='state_1'), self.answer_1, self.answer_2, facts.Jump(state_from='state_2', state_to='finish_2') ]
def construct(cls, nesting, selector, initiator, initiator_position, receiver, receiver_position): hero = selector.heroes()[0] ns = selector._kb.get_next_ns() start = facts.Start( uid=ns + 'start', type=cls.TYPE, nesting=nesting, description=u'Начало: выбить долг', require=[ requirements.LocatedIn(object=hero.uid, place=initiator_position.uid), requirements.LocatedIn(object=receiver.uid, place=receiver_position.uid) ], actions=[actions.Message(type='intro')]) participants = [ facts.QuestParticipant(start=start.uid, participant=initiator.uid, role=ROLES.INITIATOR), facts.QuestParticipant(start=start.uid, participant=receiver.uid, role=ROLES.RECEIVER) ] choose_method = facts.Choice( uid=ns + 'choose_method', description=u'Выбрать метод получения долга', require=[ requirements.LocatedIn(object=hero.uid, place=receiver_position.uid) ], actions=[actions.Message(type='move_to_receiver')]) attack = facts.Question( uid=ns + 'attack', description=u'сражение с подручными должника', require=[ requirements.LocatedIn(object=hero.uid, place=receiver_position.uid) ], actions=[ actions.Message(type='attack'), actions.Fight(mercenary=True) ], condition=[requirements.IsAlive(object=hero.uid)]) finish_attack_successed = facts.Finish( uid=ns + 'finish_attack_successed', start=start.uid, results={ initiator.uid: RESULTS.SUCCESSED, receiver.uid: RESULTS.FAILED }, nesting=nesting, description=u'долг выбит', require=[ requirements.LocatedIn(object=hero.uid, place=initiator_position.uid) ], actions=[ actions.GiveReward(object=hero.uid, type='finish_attack_successed'), actions.GivePower(object=initiator.uid, power=1), actions.GivePower(object=receiver.uid, power=-1) ]) finish_attack_failed = facts.Finish( uid=ns + 'finish_attack_failed', start=start.uid, results={ initiator.uid: RESULTS.NEUTRAL, receiver.uid: RESULTS.NEUTRAL }, nesting=nesting, description=u'не удалось выбить долг', actions=[actions.Message(type='finish_attack_failed')]) help = facts.State(uid=ns + 'help', description=u'помочь должнику', require=[ requirements.LocatedIn( object=hero.uid, place=receiver_position.uid) ]) finish_help = facts.Finish(uid=ns + 'finish_help', start=start.uid, results={ initiator.uid: RESULTS.SUCCESSED, receiver.uid: RESULTS.SUCCESSED }, nesting=nesting, description=u'помощь оказана', require=[ requirements.LocatedIn( object=hero.uid, place=initiator_position.uid) ], actions=[ actions.GiveReward(object=hero.uid, type='finish_help'), actions.GivePower(object=initiator.uid, power=1), actions.GivePower(object=receiver.uid, power=1) ]) help_quest = selector.create_quest_from_person(nesting=nesting + 1, initiator=receiver, tags=('can_continue', )) help_extra = [] for help_fact in logic.filter_subquest(help_quest, nesting): if isinstance(help_fact, facts.Start): help_extra.append( facts.Jump( state_from=help.uid, state_to=help_fact.uid, start_actions=[actions.Message(type='before_help')])) elif isinstance(help_fact, facts.Finish): if help_fact.results[receiver.uid] == RESULTS.SUCCESSED: help_extra.append( facts.Jump( state_from=help_fact.uid, state_to=finish_help.uid, start_actions=[ actions.Message(type='after_successed_help') ])) else: help_extra.append( facts.Jump( state_from=help_fact.uid, state_to=attack.uid, start_actions=[ actions.Message(type='after_failed_help') ])) subquest = facts.SubQuest( uid=ns + 'help_subquest', members=logic.get_subquest_members(help_quest)) line = [ start, facts.Jump(state_from=start.uid, state_to=choose_method.uid), choose_method, facts.Option(state_from=choose_method.uid, state_to=attack.uid, type='attack', markers=[relations.OPTION_MARKERS.AGGRESSIVE]), facts.Option(state_from=choose_method.uid, state_to=help.uid, type='help', markers=[relations.OPTION_MARKERS.UNAGGRESSIVE]), help, attack, facts.Answer( state_from=attack.uid, state_to=finish_attack_successed.uid, condition=True, start_actions=[actions.Message(type='attack_successed')]), facts.Answer(state_from=attack.uid, state_to=finish_attack_failed.uid, condition=False, start_actions=[actions.Message(type='attack_failed') ]), finish_attack_successed, finish_attack_failed, finish_help, subquest ] line.extend(participants) line.extend(help_quest) line.extend(help_extra) return line
def construct(cls, nesting, selector, initiator, initiator_position, receiver, receiver_position): hero = selector.heroes()[0] ns = selector._kb.get_next_ns() antagonist_marker = None try: antagonist = selector.new_person( first_initiator=False, professions=[relations.PROFESSION.ROGUE], restrict_social_connections=( (initiator.uid, relations.SOCIAL_RELATIONS.PARTNER), (receiver.uid, relations.SOCIAL_RELATIONS.PARTNER)), social_connections=((initiator.uid, relations.SOCIAL_RELATIONS.CONCURRENT), (receiver.uid, relations.SOCIAL_RELATIONS.CONCURRENT))) antagonist_marker = facts.ProfessionMarker( person=antagonist.uid, profession=antagonist.profession) except exceptions.NoFactSelectedError: antagonist = selector.new_person( restrict_social_connections=( (initiator.uid, relations.SOCIAL_RELATIONS.PARTNER), (receiver.uid, relations.SOCIAL_RELATIONS.PARTNER)), social_connections=((initiator.uid, relations.SOCIAL_RELATIONS.CONCURRENT), (receiver.uid, relations.SOCIAL_RELATIONS.CONCURRENT))) antagonist_position = selector.place_for(objects=(antagonist.uid, )) start = facts.Start(uid=ns + 'start', type=cls.TYPE, nesting=nesting, description='Начало: доставка', require=[ requirements.LocatedIn( object=hero.uid, place=initiator_position.uid) ], actions=[actions.Message(type='intro')]) participants = [ facts.QuestParticipant(start=start.uid, participant=initiator.uid, role=ROLES.INITIATOR), facts.QuestParticipant(start=start.uid, participant=receiver.uid, role=ROLES.RECEIVER), facts.QuestParticipant(start=start.uid, participant=antagonist.uid, role=ROLES.ANTAGONIST) ] delivery_choice = facts.Choice( uid=ns + 'delivery_choice', description='Решение: доставить или украсть') finish_delivery = facts.Finish( uid=ns + 'finish_delivery', start=start.uid, results={ initiator.uid: RESULTS.SUCCESSED, receiver.uid: RESULTS.SUCCESSED, antagonist.uid: RESULTS.NEUTRAL }, nesting=nesting, description='Доставить посылку получателю', require=[ requirements.LocatedIn(object=hero.uid, place=receiver_position.uid) ], actions=[ actions.GiveReward(object=hero.uid, type='finish_delivery') ]) finish_fake_delivery = facts.Finish( uid=ns + 'finish_fake_delivery', start=start.uid, results={ initiator.uid: RESULTS.FAILED, receiver.uid: RESULTS.FAILED, antagonist.uid: RESULTS.NEUTRAL }, nesting=nesting, description='Подделать письмо', require=[ requirements.LocatedIn(object=hero.uid, place=receiver_position.uid) ], actions=[ actions.GiveReward(object=hero.uid, type='finish_fake_delivery', scale=2.0) ]) fake_delivery_dummy_state = facts.FakeFinish( uid=ns + 'dummy_state', start=start.uid, results={ initiator.uid: RESULTS.NEUTRAL, receiver.uid: RESULTS.NEUTRAL, antagonist.uid: RESULTS.NEUTRAL }, nesting=nesting, description= 'заглушка, чтобы можно было управлять появлением подделки письма') finish_steal = facts.Finish(uid=ns + 'finish_steal', start=start.uid, results={ initiator.uid: RESULTS.FAILED, receiver.uid: RESULTS.FAILED, antagonist.uid: RESULTS.SUCCESSED }, nesting=nesting, description='Доставить посылку скупщику', require=[ requirements.LocatedIn( object=hero.uid, place=antagonist_position.uid) ], actions=[ actions.GiveReward(object=hero.uid, type='finish_steal', scale=1.5) ]) delivery_stealed = facts.State( uid=ns + 'delivery_stealed', description='письмо украдено', require=[ requirements.LocatedOnRoad(object=hero.uid, place_from=initiator_position.uid, place_to=receiver_position.uid, percents=random.uniform(0.6, 0.9)) ], actions=[ actions.Message(type='delivery_stealed'), actions.MoveNear(object=hero.uid) ]) fight_for_stealed = facts.Question( uid=ns + 'fight_for_stealed', description='Сразиться с вором', actions=[ actions.Message(type='fight_thief'), actions.Fight(mercenary=True) ], condition=[requirements.IsAlive(object=hero.uid)]) finish_fight_for_stealed__hero_died = facts.Finish( uid=ns + 'finish_fight_for_stealed__hero_died', start=start.uid, results={ initiator.uid: RESULTS.NEUTRAL, receiver.uid: RESULTS.NEUTRAL, antagonist.uid: RESULTS.NEUTRAL }, nesting=nesting, description='Герой не смог вернуть украденное письмо', actions=[ actions.Message(type='finish_fight_for_stealed__hero_died') ]) finish_fight_for_stealed__delivery = facts.Finish( uid=ns + 'finish_fight_for_stealed__delivery', start=start.uid, results={ initiator.uid: RESULTS.SUCCESSED, receiver.uid: RESULTS.SUCCESSED, antagonist.uid: RESULTS.NEUTRAL }, nesting=nesting, description='Доставить посылку получателю', require=[ requirements.LocatedIn(object=hero.uid, place=receiver_position.uid) ], actions=[ actions.GiveReward(object=hero.uid, type='finish_delivery') ]) line = [ start, delivery_choice, delivery_stealed, fight_for_stealed, finish_delivery, finish_steal, finish_fake_delivery, fake_delivery_dummy_state, finish_fight_for_stealed__hero_died, finish_fight_for_stealed__delivery, facts.Jump(state_from=start.uid, state_to=delivery_choice.uid), facts.Jump(state_from=delivery_stealed.uid, state_to=fight_for_stealed.uid), facts.Option(state_from=delivery_choice.uid, state_to=delivery_stealed.uid, type='delivery', markers=[relations.OPTION_MARKERS.HONORABLE], start_actions=[ actions.Message(type='start_delivery'), ]), facts.Option(state_from=delivery_choice.uid, state_to=finish_delivery.uid, type='delivery', markers=[relations.OPTION_MARKERS.HONORABLE], start_actions=[ actions.Message(type='start_delivery'), ]), facts.Option(state_from=delivery_choice.uid, state_to=finish_steal.uid, type='steal', markers=[relations.OPTION_MARKERS.DISHONORABLE], start_actions=[ actions.Message(type='start_steal'), ]), facts.Option(state_from=delivery_choice.uid, state_to=finish_fake_delivery.uid, type='fake', markers=[relations.OPTION_MARKERS.DISHONORABLE], start_actions=[ actions.Message(type='start_fake'), ]), facts.Option(state_from=delivery_choice.uid, state_to=fake_delivery_dummy_state.uid, markers=[], type='dummy_lie'), facts.Answer( state_from=fight_for_stealed.uid, state_to=finish_fight_for_stealed__delivery.uid, condition=True, start_actions=[actions.Message(type='delivery_returned')]), facts.Answer(state_from=fight_for_stealed.uid, state_to=finish_fight_for_stealed__hero_died.uid, condition=False), facts.Event(uid=ns + 'delivery_variants', description='Варианты доставки', members=(delivery_stealed.uid, finish_delivery.uid)), facts.Event(uid=ns + 'lie_variants', description='Варианты обмана', members=(fake_delivery_dummy_state.uid, finish_fake_delivery.uid)) ] line.extend(participants) if antagonist_marker: line.append(antagonist_marker) return line
def construct(cls, nesting, selector, initiator, initiator_position, receiver, receiver_position): hero = selector.heroes()[0] upgrade_equipment_cost = selector.upgrade_equipment_cost().money ns = selector._kb.get_next_ns() start = facts.Start(uid=ns + 'start_search_smith', type=cls.TYPE, nesting=nesting, description=u'Начало: посещение кузнеца', require=[ requirements.LocatedIn( object=hero.uid, place=initiator_position.uid) ], actions=[actions.Message(type='intro')]) participants = [ facts.QuestParticipant(start=start.uid, participant=receiver.uid, role=ROLES.RECEIVER) ] arriving = facts.Question( uid=ns + 'arriving', description=u'Прибытие в город', condition=[ requirements.HasMoney(object=hero.uid, money=upgrade_equipment_cost) ], require=[ requirements.LocatedIn(object=hero.uid, place=receiver_position.uid) ]) upgrade_for_money = facts.State( uid=ns + 'upgrade_for_money', description=u'Обновление экипировки за деньги', actions=[actions.UpgradeEquipment(cost=upgrade_equipment_cost)], require=[ requirements.LocatedIn(object=hero.uid, place=receiver_position.uid) ]) upgrade_for_quest = facts.State( uid=ns + 'upgrade_for_quest', description=u'Обновление экипировки за задание', actions=[actions.UpgradeEquipment(cost=None)], require=[ requirements.LocatedIn(object=hero.uid, place=receiver_position.uid) ]) finish_successed = facts.Finish( uid=ns + 'finish_successed', start=start.uid, results={receiver.uid: RESULTS.SUCCESSED}, nesting=nesting, description=u'завершить задание', actions=[]) finish_quest_failed = facts.Finish( uid=ns + 'finish_quest_failed', start=start.uid, results={receiver.uid: RESULTS.NEUTRAL}, nesting=nesting, description=u'завершить задание') help_quest = selector.create_quest_from_person(nesting=nesting + 1, initiator=receiver, tags=('can_continue', )) help_extra = [] for help_fact in logic.filter_subquest(help_quest, nesting): if isinstance(help_fact, facts.Start): help_extra.append( facts.Answer( state_from=arriving.uid, state_to=help_fact.uid, condition=False, start_actions=[actions.Message(type='start_quest')])) elif isinstance(help_fact, facts.Finish): if help_fact.results[receiver.uid] == RESULTS.SUCCESSED: help_extra.append( facts.Jump(state_from=help_fact.uid, state_to=upgrade_for_quest.uid, start_actions=[ actions.Message(type='quest_successed') ])) else: help_extra.append( facts.Jump(state_from=help_fact.uid, state_to=finish_quest_failed.uid, start_actions=[ actions.Message(type='quest_failed') ])) subquest = facts.SubQuest( uid=ns + 'help_subquest', members=logic.get_subquest_members(help_quest)) line = [ start, facts.Jump(state_from=start.uid, state_to=arriving.uid), arriving, facts.Answer(state_from=arriving.uid, state_to=upgrade_for_money.uid, condition=True), upgrade_for_money, upgrade_for_quest, facts.Jump(state_from=upgrade_for_money.uid, state_to=finish_successed.uid), facts.Jump(state_from=upgrade_for_quest.uid, state_to=finish_successed.uid), finish_successed, finish_quest_failed, subquest ] line.extend(participants) line.extend(help_quest) line.extend(help_extra) line.append( facts.ProfessionMarker(person=receiver.uid, profession=receiver.profession)) return line
def construct(cls, nesting, selector, initiator, initiator_position, receiver, receiver_position): mob = cls.get_mob(selector) hero = selector.heroes()[0] ns = selector._kb.get_next_ns() start = facts.Start(uid=ns + 'start', type=cls.TYPE, nesting=nesting, description=u'Начало: задание на охоту', require=[ requirements.LocatedIn( object=hero.uid, place=initiator_position.uid) ], actions=[actions.Message(type='intro')]) participants = [ facts.QuestParticipant(start=start.uid, participant=receiver_position.uid, role=ROLES.RECEIVER_POSITION) ] start_hunting = facts.State(uid=ns + 'start_hunting', description=u'Прибытие в город охоты', require=[ requirements.LocatedIn( object=hero.uid, place=receiver_position.uid) ]) hunt_loop = [] for i in xrange(random.randint(*cls.HUNT_LOOPS)): hunt = facts.State(uid=ns + 'hunt_%d' % i, description=u'Охота', actions=[ actions.MoveNear( object=hero.uid, place=receiver_position.uid, terrains=mob.terrains) ]) fight = facts.State(uid=ns + 'fight_%d' % i, description=u'Сражение с жертвой', actions=[ actions.Message(type='fight'), actions.Fight(mob=mob.uid) ]) if hunt_loop: hunt_loop.append( facts.Jump(state_from=hunt_loop[-1].uid, state_to=hunt.uid, start_actions=[ actions.Message(type='start_track'), ])) hunt_loop.extend([ hunt, facts.Jump(state_from=hunt.uid, state_to=fight.uid), fight ]) sell_prey = facts.Finish( uid=ns + 'sell_prey', start=start.uid, results={receiver_position.uid: RESULTS.SUCCESSED}, nesting=nesting, description=u'Продать добычу', require=[ requirements.LocatedIn(object=hero.uid, place=receiver_position.uid) ], actions=[actions.GiveReward(object=hero.uid, type='sell_prey')]) line = [ start, start_hunting, sell_prey, facts.Jump(state_from=start.uid, state_to=start_hunting.uid, start_actions=[ actions.Message(type='move_to_hunt'), ]), facts.Jump(state_from=start_hunting.uid, state_to=hunt_loop[0].uid, start_actions=[ actions.Message(type='start_track'), ]), facts.Jump(state_from=hunt_loop[-1].uid, state_to=sell_prey.uid, start_actions=[ actions.Message(type='return_with_prey'), ]), ] line.extend(hunt_loop) line.extend(participants) return line
def construct(cls, nesting, selector, initiator, initiator_position, receiver, receiver_position): hero = selector.heroes()[0] ns = selector._kb.get_next_ns() black_market = selector.new_place() start = facts.Start(uid=ns+'start', type=cls.TYPE, nesting=nesting, description=u'Начало: караван', require=[requirements.LocatedIn(object=hero.uid, place=initiator_position.uid)], actions=[actions.Message(type='intro')]) participants = [facts.QuestParticipant(start=start.uid, participant=initiator.uid, role=ROLES.INITIATOR), facts.QuestParticipant(start=start.uid, participant=receiver.uid, role=ROLES.RECEIVER), facts.QuestParticipant(start=start.uid, participant=black_market.uid, role=ROLES.ANTAGONIST_POSITION)] path_percents_1 = random.uniform(0.1, 0.3) path_percents_2 = random.uniform(0.4, 0.6) path_percents_3 = random.uniform(0.7, 0.9) first_moving = facts.State(uid=ns+'first_moving', description=u'двигаемся с караваном', require=[requirements.LocatedOnRoad(object=hero.uid, place_from=initiator_position.uid, place_to=receiver_position.uid, percents=path_percents_1)]) caravan_choice = facts.Choice(uid=ns+'caravan_choice', description=u'Решение: защитить или ограбить') first_defence = facts.Choice(uid=ns+'first_defence', description=u'первая защита', require=[requirements.LocatedOnRoad(object=hero.uid, place_from=initiator_position.uid, place_to=receiver_position.uid, percents=path_percents_2)], actions=[actions.Message(type='defence')]) first_defence_continue = facts.Question(uid=ns+'first_defence_continue', description=u'удалось ли защитить караван?', condition=[requirements.IsAlive(object=hero.uid)], actions=[actions.Fight()]) second_moving = facts.State(uid=ns+'second_moving', description=u'двигаемся с караваном', require=[requirements.LocatedOnRoad(object=hero.uid, place_from=initiator_position.uid, place_to=receiver_position.uid, percents=path_percents_3)]) second_defence = facts.Question(uid=ns+'second_defence', description=u'вторая защита', condition=(requirements.IsAlive(object=hero.uid),), actions=(actions.Message(type='defence'), actions.Fight(), )) finish_defence = facts.Finish(uid=ns+'finish_defence', start=start.uid, results={ initiator.uid: RESULTS.SUCCESSED, receiver.uid: RESULTS.SUCCESSED, black_market.uid: RESULTS.NEUTRAL }, nesting=nesting, description=u'Караван приходит в точку назначения', require=[requirements.LocatedIn(object=hero.uid, place=receiver_position.uid)], actions=[actions.GiveReward(object=hero.uid, type='finish_defence'), actions.GivePower(object=initiator.uid, power=1), actions.GivePower(object=receiver.uid, power=1)]) move_to_attack = facts.State(uid=ns+'move_to_attack', description=u'ведём караван в засаду', require=[requirements.LocatedOnRoad(object=hero.uid, place_from=initiator_position.uid, place_to=receiver_position.uid, percents=path_percents_2)]) attack = facts.Question(uid=ns+'attack', description=u'нападение', condition=(requirements.IsAlive(object=hero.uid),), actions=(actions.Message(type='attack'), actions.Fight(mercenary=True), )) run = facts.State(uid=ns+'run', description=u'скрываемся с места преступления', actions=(actions.MoveNear(object=hero.uid),)) fight = facts.Question(uid=ns+'fight', description=u'защита награбленного', condition=(requirements.IsAlive(object=hero.uid),), actions=(actions.Message(type='fight'), actions.Fight(mercenary=True), )) hide = facts.State(uid=ns+'hide', description=u'прячемся', actions=(actions.Message(type='hide'), actions.MoveNear(object=hero.uid))) finish_attack = facts.Finish(uid=ns+'finish_attack', start=start.uid, results={ initiator.uid: RESULTS.FAILED, receiver.uid: RESULTS.FAILED, black_market.uid: RESULTS.SUCCESSED }, nesting=nesting, description=u'Продать товар на чёрном рынке', require=[requirements.LocatedIn(object=hero.uid, place=black_market.uid)], actions=[actions.GiveReward(object=hero.uid, type='finish_attack', scale=1.5), actions.GivePower(object=initiator.uid, power=-1), actions.GivePower(object=receiver.uid, power=-1), actions.GivePower(object=black_market.uid, power=1)]) finish_defence_failed = facts.Finish(uid=ns+'finish_defence_failed', start=start.uid, results={ initiator.uid: RESULTS.NEUTRAL, receiver.uid: RESULTS.NEUTRAL, black_market.uid: RESULTS.NEUTRAL }, nesting=nesting, description=u'Герой не смог защитить караван', actions=[actions.Message(type='finish_defence_failed'), actions.GivePower(object=initiator.uid, power=-1), actions.GivePower(object=receiver.uid, power=-1)]) finish_attack_failed = facts.Finish(uid=ns+'finish_attack_failed', start=start.uid, results={ initiator.uid: RESULTS.NEUTRAL, receiver.uid: RESULTS.NEUTRAL, black_market.uid: RESULTS.NEUTRAL }, nesting=nesting, description=u'Герой не смог ограбить караван', actions=[actions.Message(type='finish_attack_failed'), actions.GivePower(object=initiator.uid, power=1), actions.GivePower(object=receiver.uid, power=1)]) caravan_choice__first_defence = facts.Option(state_from=caravan_choice.uid, state_to=first_defence.uid, type='jump_defence', markers=[relations.OPTION_MARKERS.HONORABLE], start_actions=[actions.Message(type='choose_defence'),]) caravan_choice__move_to_attack = facts.Option(state_from=caravan_choice.uid, state_to=move_to_attack.uid, type='jump_attack', markers=[relations.OPTION_MARKERS.DISHONORABLE], start_actions=[actions.Message(type='choose_attack'),]) first_defence__first_defence_continue = facts.Option(state_from=first_defence.uid, state_to=first_defence_continue.uid, type='jump_defence', markers=[relations.OPTION_MARKERS.HONORABLE], ) first_defence__move_to_attack = facts.Option(state_from=first_defence.uid, state_to=move_to_attack.uid, type='jump_attack', markers=[relations.OPTION_MARKERS.DISHONORABLE], start_actions=[actions.Message(type='choose_attack'),]) line = [ start, facts.Jump(state_from=start.uid, state_to=first_moving.uid, start_actions=(actions.Message(type='first_moving'), )), first_moving, facts.Jump(state_from=first_moving.uid, state_to=caravan_choice.uid), caravan_choice, caravan_choice__first_defence, caravan_choice__move_to_attack, first_defence, first_defence__first_defence_continue, first_defence__move_to_attack, first_defence_continue, facts.Answer(state_from=first_defence_continue.uid, state_to=second_moving.uid, condition=True), facts.Answer(state_from=first_defence_continue.uid, state_to=finish_defence_failed.uid, condition=False), second_moving, facts.Jump(state_from=second_moving.uid, state_to=second_defence.uid), second_defence, facts.Answer(state_from=second_defence.uid, state_to=finish_defence.uid, condition=True), facts.Answer(state_from=second_defence.uid, state_to=finish_defence_failed.uid, condition=False), finish_defence, move_to_attack, facts.Jump(state_from=move_to_attack.uid, state_to=attack.uid), attack, facts.Answer(state_from=attack.uid, state_to=run.uid, condition=True, start_actions=(actions.Message(type='start_run'),)), facts.Answer(state_from=attack.uid, state_to=finish_attack_failed.uid, condition=False), run, facts.Jump(state_from=run.uid, state_to=fight.uid), fight, facts.Answer(state_from=fight.uid, state_to=hide.uid, condition=True, start_actions=(actions.Message(type='start_hide'),)), facts.Answer(state_from=fight.uid, state_to=finish_attack_failed.uid, condition=False), hide, facts.Jump(state_from=hide.uid, state_to=finish_attack.uid), finish_attack, facts.OptionsLink(options=(caravan_choice__first_defence.uid, first_defence__first_defence_continue.uid)), finish_defence_failed, finish_attack_failed ] line.extend(participants) return line
def construct(cls, nesting, selector, initiator, initiator_position, receiver, receiver_position): hero = selector.heroes()[0] ns = selector._kb.get_next_ns() start = facts.Start( uid=ns + 'start', type=cls.TYPE, nesting=nesting, description=u'Начало: задание на шпионаж', require=[ requirements.LocatedIn(object=hero.uid, place=initiator_position.uid), requirements.LocatedIn(object=receiver.uid, place=receiver_position.uid) ], actions=[actions.Message(type='intro')]) participants = [ facts.QuestParticipant(start=start.uid, participant=initiator.uid, role=ROLES.INITIATOR), facts.QuestParticipant(start=start.uid, participant=receiver.uid, role=ROLES.RECEIVER) ] start_spying = facts.Choice( uid=ns + 'start_spying', description=u'Прибытие в город цели', require=[ requirements.LocatedIn(object=hero.uid, place=receiver_position.uid) ], actions=[actions.Message(type='arrived_to_target')]) spying_middle = facts.Choice(uid=ns + 'spying_middle', description=u'Шпионаж', actions=[ actions.MoveNear( object=hero.uid, place=receiver_position.uid) ]) continue_spying = facts.State(uid=ns + 'continue_spying', description=u'Продолжить шпионаж') success_spying = facts.State( uid=ns + 'success_spying', description=u'шпионим без происшествий', require=[ requirements.LocatedNear(object=hero.uid, place=receiver_position.uid) ], actions=[ actions.Message(type='success_spying'), actions.MoveNear(object=hero.uid, place=receiver_position.uid) ]) witness = facts.State( uid=ns + 'witness', description=u'героя заметил один из работников цели', require=[ requirements.LocatedNear(object=hero.uid, place=receiver_position.uid) ], actions=[ actions.Message(type='witness'), actions.MoveNear(object=hero.uid, place=receiver_position.uid) ]) witness_fight = facts.Question( uid=ns + 'witness_fight', description=u'удалось ли победить свидетеля?', condition=[requirements.IsAlive(object=hero.uid)], actions=[ actions.Message(type='witness_fight'), actions.Fight(mercenary=True) ]) open_up = facts.State(uid=ns + 'open_up', description=u'Раскрыться', require=[ requirements.LocatedIn( object=hero.uid, place=receiver_position.uid) ], actions=[actions.Message(type='open_up')]) report_data = facts.Finish( uid=ns + 'report_data', start=start.uid, results={ initiator.uid: RESULTS.SUCCESSED, receiver.uid: RESULTS.FAILED }, nesting=nesting, description=u'Сообщить сообранную информацию', require=[ requirements.LocatedIn(object=hero.uid, place=initiator_position.uid) ], actions=[ actions.GiveReward(object=hero.uid, type='report_data'), actions.GivePower(object=initiator.uid, power=1), actions.GivePower(object=receiver.uid, power=-1) ]) finish_spying_choice = facts.Choice( uid=ns + 'finish_spying_choice', description=u'Варианты выбора завершения шпионажа') blackmail_finish = facts.Finish( uid=ns + 'blackmail_finish', start=start.uid, results={ initiator.uid: RESULTS.NEUTRAL, receiver.uid: RESULTS.FAILED }, nesting=nesting, description=u'Шантажировать самостоятельно', require=[ requirements.LocatedIn(object=hero.uid, place=receiver_position.uid) ], actions=[ actions.GiveReward(object=hero.uid, type='blackmail_finish', scale=1.25), actions.GivePower(object=receiver.uid, power=-1) ]) witness_failed = facts.Finish( uid=ns + 'witness_failed', start=start.uid, results={ initiator.uid: RESULTS.NEUTRAL, receiver.uid: RESULTS.NEUTRAL }, nesting=nesting, description=u'свидетель смог скрыться', actions=[actions.Message(type='witness_failed')]) open_up_finish = facts.Finish( uid=ns + 'open_up_finish', start=start.uid, results={ initiator.uid: RESULTS.FAILED, receiver.uid: RESULTS.SUCCESSED }, nesting=nesting, description=u'Завершить задание и остатсья в городе цели', require=[ requirements.LocatedIn(object=hero.uid, place=receiver_position.uid) ], actions=[ actions.GiveReward(object=hero.uid, type='open_up_finish'), actions.GivePower(object=initiator.uid, power=-1), actions.GivePower(object=receiver.uid, power=1) ]) open_up_lying = facts.Finish( uid=ns + 'open_up_lying', start=start.uid, results={ initiator.uid: RESULTS.FAILED, receiver.uid: RESULTS.SUCCESSED }, nesting=nesting, description=u'Вернуться к заказчику и сообщить ложную информацию', require=[ requirements.LocatedIn(object=hero.uid, place=initiator_position.uid) ], actions=[ actions.GiveReward(object=hero.uid, type='open_up_lying', scale=1.5), actions.GivePower(object=initiator.uid, power=-1.5), actions.GivePower(object=receiver.uid, power=1.5) ]) start_spying__spying_middle = facts.Option( state_from=start_spying.uid, state_to=spying_middle.uid, type='spy', markers=[relations.OPTION_MARKERS.HONORABLE], start_actions=[ actions.Message(type='start_spying'), ]) start_spying__spying_middle__blackmail = facts.Option( state_from=start_spying.uid, state_to=spying_middle.uid, type='blackmail', markers=[relations.OPTION_MARKERS.DISHONORABLE], start_actions=[ actions.Message(type='start_spying'), ]) start_spying__open_up = facts.Option( state_from=start_spying.uid, state_to=open_up.uid, type='open_up', markers=[relations.OPTION_MARKERS.DISHONORABLE], start_actions=[ actions.Message(type='start_open_up'), ]) spying_middle__continue_spying = facts.Option( state_from=spying_middle.uid, state_to=continue_spying.uid, type='spy', markers=[relations.OPTION_MARKERS.HONORABLE]) spying_middle__continue_spying__blackmail = facts.Option( state_from=spying_middle.uid, state_to=continue_spying.uid, type='blackmail', markers=[relations.OPTION_MARKERS.DISHONORABLE]) spying_middle__open_up = facts.Option( state_from=spying_middle.uid, state_to=open_up.uid, type='open_up', markers=[relations.OPTION_MARKERS.DISHONORABLE], start_actions=[ actions.Message(type='start_open_up'), ]) finish_spying__report_data = facts.Option( state_from=finish_spying_choice.uid, state_to=report_data.uid, type='spy', markers=[relations.OPTION_MARKERS.HONORABLE], start_actions=[actions.Message(type='go_report_data')]) finish_spying__blackmail = facts.Option( state_from=finish_spying_choice.uid, state_to=blackmail_finish.uid, type='blackmail', markers=[relations.OPTION_MARKERS.DISHONORABLE], start_actions=[actions.Message(type='go_blackmail')]) line = [ start, start_spying, spying_middle, success_spying, continue_spying, open_up, report_data, open_up_finish, open_up_lying, witness, witness_fight, witness_failed, finish_spying_choice, blackmail_finish, facts.Jump(state_from=start.uid, state_to=start_spying.uid), facts.Jump(state_from=continue_spying.uid, state_to=success_spying.uid), facts.Jump(state_from=continue_spying.uid, state_to=witness.uid), start_spying__spying_middle, start_spying__spying_middle__blackmail, start_spying__open_up, spying_middle__continue_spying, spying_middle__continue_spying__blackmail, spying_middle__open_up, finish_spying__report_data, finish_spying__blackmail, facts.Jump( state_from=success_spying.uid, state_to=finish_spying_choice.uid ), #, start_actions=[actions.Message(type='move_to_report_data'),]), facts.Jump(state_from=witness.uid, state_to=witness_fight.uid), facts.Jump(state_from=open_up.uid, state_to=open_up_finish.uid), facts.Jump(state_from=open_up.uid, state_to=open_up_lying.uid, start_actions=[ actions.Message(type='move_to_report_lie'), ]), facts.OptionsLink(options=(start_spying__spying_middle.uid, spying_middle__continue_spying.uid, finish_spying__report_data.uid)), facts.OptionsLink( options=(start_spying__spying_middle__blackmail.uid, spying_middle__continue_spying__blackmail.uid, finish_spying__blackmail.uid)), facts.Answer(state_from=witness_fight.uid, state_to=finish_spying_choice.uid, condition=True), facts.Answer(state_from=witness_fight.uid, state_to=witness_failed.uid, condition=False), facts.Event(uid=ns + 'open_up_variants', description=u'Варианты окончания раскрытия', members=(open_up_finish.uid, open_up_lying.uid)), facts.Event(uid=ns + 'spying_variants', description=u'Варианты событий при шпионаже', members=(success_spying.uid, witness.uid)), ] line.extend(participants) return line
def test_wrong_action(self): self.kb += [ facts.State(uid='state', actions=[facts.Place(uid='wrong action')]) ] self.assertRaises(self.restriction.Error, self.restriction.validate, self.kb)