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'), 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=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 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