def load_grammar(): import df_utils from srabuilder import rules names = get_locations() locs = [] for name in names: loc_commands = LOCATION_COMMANDS.get(name) locs.append(Location(name, loc_commands)) grammar = df.Grammar("locations") main_rule = df.MappingRule( name="locations_rule", mapping=mapping, extras=[ rules.num, df_utils.positive_index, df_utils.positive_num, df.Choice("locations", commands(locs)), ], context=is_active, defaults={ "n": 1, "positive_num": 1, "positive_index": 0 }, ) grammar.add_rule(main_rule) grammar.load()
def load_grammar(): grammar = df.Grammar("no_menu") main_rule = df.MappingRule( name="no_menu_rule", mapping=mapping, extras=[ rules.num, df_utils.positive_index, df_utils.positive_num, df.Choice("npcs", characters.npcs), num2, df.Choice("direction_keys", game.direction_keys), df.Choice("direction_nums", game.direction_nums), df.Choice("debris", debris), items.items_choice, df.Choice("points", locations.commands(locations.points)), ], context=is_active, defaults={ "n": 1, "positive_num": 1, "positive_index": 0 }, ) grammar.add_rule(main_rule) grammar.load()
def load_grammar(): grammar = df.Grammar("shipping_bin_menu") main_rule = df.MappingRule(name="shipping_bin_menu_rule", mapping=mapping, extras=[rules.num, df_utils.positive_index], context=is_active) grammar.add_rule(main_rule) grammar.load()
def load_grammar(): grammar = df.Grammar("cutscene") main_rule = df.MappingRule( name="cutscene_rule", mapping=mapping, context=df.FuncContext(is_active), ) grammar.add_rule(main_rule) grammar.load()
def load_grammar(): grammar = df.Grammar("items_to_grab_menu") main_rule = df.MappingRule( name="items_to_grab_menu_rule", mapping=mapping, extras=[df_utils.positive_index, df_utils.positive_index2], context=is_active) grammar.add_rule(main_rule) grammar.load()
def load_grammar(): grammar = df.Grammar("dialogue_menu") main_rule = df.MappingRule( name="dialogue_menu_rule", mapping=mapping, extras=[ rules.num, df_utils.positive_index, df_utils.positive_num, df_utils.dictation_rule() ], context=is_active, defaults={'positive_num': 1}, ) grammar.add_rule(main_rule) grammar.load()
def load_grammar(): grammar = df.Grammar("any_context") main_rule = df.MappingRule( name="any_context_rule", mapping=non_repeat_mapping, extras=[ df_utils.positive_num, df.Choice("mouse_directions", mouse_directions), ], context=df.FuncContext(is_active), defaults={"positive_num": 1}, ) grammar.add_rule(main_rule) grammar.load()
def load_grammar(): grammar = df.Grammar("game_menu") main_rule = df.MappingRule( name="game_menu_rule", mapping=mapping, extras=[ df.Choice("tabs", tabs), df_utils.positive_num, ], defaults={'positive_num': 1}, context=is_active, ) grammar.add_rule(main_rule) grammar.load()
def load_grammar(): grammar = df.Grammar("carpenter_menu") main_rule = df.MappingRule( name="carpenter_menu_rule", mapping=mapping, extras=[ df.Choice("direction_keys", game.direction_keys), df.Choice("direction_nums", game.direction_nums), rules.num, df_utils.positive_index, df_utils.positive_num ], context=is_active, defaults={'positive_num': 1}, ) grammar.add_rule(main_rule) grammar.load()
def build_menu_grammar(mapping, menu_validator, extras=(), defaults=None): global MENU_GRAMMAR_COUNT import df_utils, game, server mgb = MenuGrammarBuilder(mapping, menu_validator) defaults = {'positive_num': 1} if defaults is None else defaults n = MENU_GRAMMAR_COUNT + 1 MENU_GRAMMAR_COUNT = n grammar = df.Grammar(f"menu_grammar_{n}") new_mapping = {} for cmd, v in mapping.items(): if isinstance(v, df_utils.AsyncFunction ) and v.format_args: # insert active menu as first arg v.format_args = mgb.format_args_menu_provider(v.format_args) new_mapping[cmd] = v main_rule = df.MappingRule(name=f"menu_grammar_rule_{n}", mapping=new_mapping, extras=extras, defaults=defaults, context=df.FuncContext(mgb.is_active)) grammar.add_rule(main_rule) return grammar