Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 70 additions & 70 deletions helpers/example.py

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions questgen/graph_drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,15 @@ def create_label_for_state(self,
condition_colspan = 0
if hasattr(state, 'condition'):
condition_colspan = 2
trs.append(tr(td('<b>условия:</b>', bgcolor=bgcolor, colspan=condition_colspan)))
trs.append(tr(td('<b>conditions:</b>', bgcolor=bgcolor, colspan=condition_colspan)))
for condition in state.condition:
trs.append(tr(td('<b>если </b>'), td(self.create_label_for_requirement(condition), bgcolor=bgcolor)))
trs.append(tr(td('<b>if </b>'), td(self.create_label_for_requirement(condition), bgcolor=bgcolor)))

results_colspan = 0

if hasattr(state, 'results'):
results_colspan = 2
trs.append(tr(td('<b>результаты:</b>', bgcolor=bgcolor, colspan=results_colspan)))
trs.append(tr(td('<b>results:</b>', bgcolor=bgcolor, colspan=results_colspan)))
results_order = sorted(state.results.keys())
for object_uid in results_order:
trs.append(tr(td('<b>%s</b>' % object_uid), td(state.results[object_uid])))
Expand Down Expand Up @@ -370,13 +370,13 @@ def create_label_for_jump(self, jump):
trs.append(tr(td(jump.type, bgcolor=HEAD_COLORS.JUMP)))

if hasattr(jump, 'condition'):
trs.append(tr(td('ИСТИНА' if jump.condition else 'ЛОЖЬ', bgcolor=HEAD_COLORS.JUMP)))
trs.append(tr(td('TRUE' if jump.condition else 'FALSE', bgcolor=HEAD_COLORS.JUMP)))

if hasattr(jump, 'markers') and jump.markers:
strings = {relations.OPTION_MARKERS.HONORABLE: '[честь]',
relations.OPTION_MARKERS.DISHONORABLE: '[бесчестие]',
relations.OPTION_MARKERS.AGGRESSIVE: '[агрессия]',
relations.OPTION_MARKERS.UNAGGRESSIVE: '[миролюбие]'}
strings = {relations.OPTION_MARKERS.HONORABLE: '[honor]',
relations.OPTION_MARKERS.DISHONORABLE: '[dishonor]',
relations.OPTION_MARKERS.AGGRESSIVE: '[aggression]',
relations.OPTION_MARKERS.UNAGGRESSIVE: '[peacefulness]'}

for marker in jump.markers:
trs.append(tr(td(strings[marker], bgcolor=HEAD_COLORS.JUMP_MARKER)))
Expand All @@ -390,55 +390,55 @@ def create_label_for_jump(self, jump):
return table(*trs, port=jump.uid, border=0)

def create_label_for_located_in(self, requirement):
return '%s <b>находится в</b>&nbsp;%s' % (requirement.object, requirement.place)
return '%s <b>is located in</b>&nbsp;%s' % (requirement.object, requirement.place)

def create_label_for_located_near(self, requirement):
return '%s <b>находится около</b>&nbsp;%s' % (requirement.object, requirement.place)
return '%s <b>is located near</b>&nbsp;%s' % (requirement.object, requirement.place)

def create_label_for_located_on_road(self, requirement):
return ('%s <b>прошёл</b>&nbsp;%d%%<b> дороги от</b>&nbsp;%s <b>до</b>&nbsp;%s' %
return ('%s <b>has passed</b>&nbsp;%d%%<b> of the road from</b>&nbsp;%s <b>to</b>&nbsp;%s' %
(requirement.object, int(requirement.percents*100), requirement.place_from, requirement.place_to))

def create_label_for_has_money(self, requirement):
return '%s <b>имеет </b>&nbsp;%s <b>монет</b>' % (requirement.object, requirement.money)
return '%s <b>has </b>&nbsp;%s <b>coins</b>' % (requirement.object, requirement.money)

def create_label_for_is_alive(self, requirement):
return '%s <b>жив</b>' % (requirement.object)
return '%s <b>is alive</b>' % (requirement.object)


def create_action_label_for_move_near(self, requirement):
if requirement.terrains:
return '<b>отправить </b> %s<b>бродить около</b>&nbsp;%s<br/> среди ландшафтов %s' % (requirement.object, requirement.place, requirement.terrains)
return '<b>send </b> %s<b>to wander near</b>&nbsp;%s<br/> among the terrains %s' % (requirement.object, requirement.place, requirement.terrains)
elif requirement.place is None:
return '<b>отправить </b> %s<b>бродить в округе</b><br/>' % requirement.object
return '<b>send </b> %s<b>to wander around</b><br/>' % requirement.object
else:
return '<b>отправить </b> %s<b>бродить около</b>&nbsp;%s<br/>' % (requirement.object, requirement.place)
return '<b>send </b> %s<b>to wander near</b>&nbsp;%s<br/>' % (requirement.object, requirement.place)

def create_action_label_for_message(self, message):
return '<b>сообщение:</b>&nbsp;%s' % message.type
return '<b>message:</b>&nbsp;%s' % message.type

def create_action_label_for_give_reward(self, give_reward):
return '<b>выдать награду </b>&nbsp; %s <b>типа </b> %s <b>в размере</b> %.2f' % (give_reward.object, give_reward.type, give_reward.scale)
return '<b>give reward to </b>&nbsp; %s <b>of type </b> %s <b>in the amount of</b> %.2f' % (give_reward.object, give_reward.type, give_reward.scale)

def create_action_label_for_fight(self, fight):
if fight.mob:
return '<b>сразиться с</b>&nbsp; %s' % fight.mob
return '<b>fight with</b>&nbsp; %s' % fight.mob

if fight.mercenary is not None:
if fight.mercenary:
return '<b>сразиться с наёмником</b>'
return '<b>fight with a mercenary</b>'
else:
return '<b>сразиться с кем-нибудь, кроме наёмника</b>'
return '<b>fight with someone other than a mercenary</b>'

return '<b>сразиться с кем-нибудь</b>'
return '<b>fight with someone</b>'

def create_action_label_for_donothing(self, donothing):
return '<b>заняться </b>&nbsp; %s' % donothing.type
return '<b>do nothing </b>&nbsp; %s' % donothing.type

def create_action_label_for_upgrade_equipment(self, upgrade):
if upgrade.cost is not None:
return '<b>обновить экипировку за </b>&nbsp;%d <b>монет</b>' % upgrade.cost
return '<b>обновить экипировку бесплатно</b>'
return '<b>upgrade equipment for </b>&nbsp;%d <b>coins</b>' % upgrade.cost
return '<b>upgrade equipment for free</b>'


def b(data): return '<b>%s</b>' % data
Expand Down
1 change: 0 additions & 1 deletion questgen/knowledge_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from collections.abc import Iterable

from questgen.facts import Fact
Expand Down
32 changes: 16 additions & 16 deletions questgen/quests/caravan.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def construct(cls, nesting, selector, initiator, initiator_position, receiver, r
start = facts.Start(uid=ns+'start',
type=cls.TYPE,
nesting=nesting,
description='Начало: караван',
description='Start: caravan',
require=[requirements.LocatedIn(object=hero.uid, place=initiator_position.uid)],
actions=[actions.Message(type='intro')])

Expand All @@ -43,29 +43,29 @@ def construct(cls, nesting, selector, initiator, initiator_position, receiver, r
path_percents_3 = random.uniform(0.7, 0.9)

first_moving = facts.State(uid=ns+'first_moving',
description='двигаемся с караваном',
description='moving with the caravan',
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='Решение: защитить или ограбить')
description='Decision: protect or rob')

first_defence = facts.Choice(uid=ns+'first_defence',
description='первая защита',
description='first defense',
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='удалось ли защитить караван?',
description='was the caravan successfully defended?',
condition=[requirements.IsAlive(object=hero.uid)],
actions=[actions.Fight()])

second_moving = facts.State(uid=ns+'second_moving',
description='двигаемся с караваном',
description='moving with the caravan',
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='вторая защита',
description='second defense',
condition=(requirements.IsAlive(object=hero.uid),),
actions=(actions.Message(type='defence'),
actions.Fight(), ))
Expand All @@ -76,33 +76,33 @@ def construct(cls, nesting, selector, initiator, initiator_position, receiver, r
receiver.uid: RESULTS.SUCCESSED,
black_market.uid: RESULTS.NEUTRAL },
nesting=nesting,
description='Караван приходит в точку назначения',
description='The caravan arrives at the destination',
require=[requirements.LocatedIn(object=hero.uid, place=receiver_position.uid)],
actions=[actions.GiveReward(object=hero.uid, type='finish_defence')])

move_to_attack = facts.State(uid=ns+'move_to_attack',
description='ведём караван в засаду',
description='leading the caravan into an ambush',
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='нападение',
description='attack',
condition=(requirements.IsAlive(object=hero.uid),),
actions=(actions.Message(type='attack'),
actions.Fight(mercenary=True), ))

run = facts.State(uid=ns+'run',
description='скрываемся с места преступления',
description='fleeing the scene of the crime',
actions=(actions.MoveNear(object=hero.uid),))

fight = facts.Question(uid=ns+'fight',
description='защита награбленного',
description='defending the loot',
condition=(requirements.IsAlive(object=hero.uid),),
actions=(actions.Message(type='fight'),
actions.Fight(mercenary=True), ))

hide = facts.State(uid=ns+'hide',
description='прячемся',
description='hiding',
actions=(actions.Message(type='hide'),
actions.MoveNear(object=hero.uid)))

Expand All @@ -112,7 +112,7 @@ def construct(cls, nesting, selector, initiator, initiator_position, receiver, r
receiver.uid: RESULTS.FAILED,
black_market.uid: RESULTS.SUCCESSED },
nesting=nesting,
description='Продать товар на чёрном рынке',
description='Sell the goods on the black market',
require=[requirements.LocatedIn(object=hero.uid, place=black_market.uid)],
actions=[actions.GiveReward(object=hero.uid, type='finish_attack', scale=1.5)])

Expand All @@ -122,7 +122,7 @@ def construct(cls, nesting, selector, initiator, initiator_position, receiver, r
receiver.uid: RESULTS.NEUTRAL,
black_market.uid: RESULTS.NEUTRAL },
nesting=nesting,
description='Герой не смог защитить караван',
description='The hero failed to defend the caravan',
actions=[actions.Message(type='finish_defence_failed')])

finish_attack_failed = facts.Finish(uid=ns+'finish_attack_failed',
Expand All @@ -131,7 +131,7 @@ def construct(cls, nesting, selector, initiator, initiator_position, receiver, r
receiver.uid: RESULTS.NEUTRAL,
black_market.uid: RESULTS.NEUTRAL },
nesting=nesting,
description='Герой не смог ограбить караван',
description='The hero failed to rob the caravan',
actions=[actions.Message(type='finish_attack_failed')])

caravan_choice__first_defence = facts.Option(state_from=caravan_choice.uid, state_to=first_defence.uid, type='jump_defence',
Expand Down
14 changes: 7 additions & 7 deletions questgen/quests/collect_debt.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def construct(cls, nesting, selector, initiator, initiator_position, receiver, r
start = facts.Start(uid=ns+'start',
type=cls.TYPE,
nesting=nesting,
description='Начало: выбить долг',
description='Start: collect debt',
require=[requirements.LocatedIn(object=hero.uid, place=initiator_position.uid),
requirements.LocatedIn(object=receiver.uid, place=receiver_position.uid)],
actions=[actions.Message(type='intro')])
Expand All @@ -36,13 +36,13 @@ def construct(cls, nesting, selector, initiator, initiator_position, receiver, r
facts.QuestParticipant(start=start.uid, participant=receiver.uid, role=ROLES.RECEIVER) ]

choose_method = facts.Choice(uid=ns+'choose_method',
description='Выбрать метод получения долга',
description='Choose a method to collect the debt',
require=[requirements.LocatedIn(object=hero.uid, place=receiver_position.uid)],
actions=[actions.Message(type='move_to_receiver')])


attack = facts.Question(uid=ns+'attack',
description='сражение с подручными должника',
description='fight with the debtor\'s henchmen',
require=[requirements.LocatedIn(object=hero.uid, place=receiver_position.uid)],
actions=[actions.Message(type='attack'),
actions.Fight(mercenary=True)],
Expand All @@ -53,7 +53,7 @@ def construct(cls, nesting, selector, initiator, initiator_position, receiver, r
results={ initiator.uid: RESULTS.SUCCESSED,
receiver.uid: RESULTS.FAILED},
nesting=nesting,
description='долг выбит',
description='debt collected',
require=[requirements.LocatedIn(object=hero.uid, place=initiator_position.uid)],
actions=[actions.GiveReward(object=hero.uid, type='finish_attack_successed')])

Expand All @@ -62,19 +62,19 @@ def construct(cls, nesting, selector, initiator, initiator_position, receiver, r
results={ initiator.uid: RESULTS.NEUTRAL,
receiver.uid: RESULTS.NEUTRAL},
nesting=nesting,
description='не удалось выбить долг',
description='failed to collect the debt',
actions=[actions.Message(type='finish_attack_failed')])

help = facts.State(uid=ns+'help',
description='помочь должнику',
description='help the debtor',
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='помощь оказана',
description='help provided',
require=[requirements.LocatedIn(object=hero.uid, place=initiator_position.uid)],
actions=[actions.GiveReward(object=hero.uid, type='finish_help')])

Expand Down
Loading
Loading