Exemplo n.º 1
0
def load_grammar():
    extras = [
        df.Choice("direction_keys", game.direction_keys),
        rules.num,
        df_utils.positive_index,
        df_utils.positive_num,
        df.Choice("animals", animals),
    ]
    defaults = {"positive_num": 1}
    grammar = menu_utils.build_menu_grammar(mapping,
                                            TITLE,
                                            extras=extras,
                                            defaults=defaults)
    grammar.load()
Exemplo n.º 2
0
def load_grammar():
    extras = [
        rules.num,
        df_utils.positive_index,
        df_utils.positive_num,
        df.Choice("direction_nums", game.direction_nums),
    ]
    grammar = menu_utils.build_menu_grammar(mapping, validate_any_menu, extras=extras)
    grammar.load()
Exemplo n.º 3
0
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()
Exemplo n.º 4
0
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()
Exemplo n.º 5
0
}

nonZeroDigitMap = {
    "one": 1,
    "two": 2,
    "three": 3,
    "four": 4,
    "five": 5,
    "six": 6,
    "seven": 7,
    "eight": 8,
    "nine": 9,
}


def parse_numrep(rep):
    first, rest = rep
    numstr = str(first) + "".join(str(d) for d in rest)
    return int(numstr)

def index_choice_from_list(name: str, l):
    return df.Choice(name, {k: i for (i, k) in enumerate(l)})


positive_digits = df.Sequence(
    [df.Choice(None, nonZeroDigitMap), df.Repetition(df.Choice(None, digitMap), min=0, max=2)],
    name="positive_digits",
)
positive_num = df.Alternative([df.Modifier(positive_digits, parse_numrep), df.Choice(None, ten_through_twelve)], name="positive_num")
positive_index = df.RuleWrap("positive_index", df.Modifier(positive_num, lambda x: x - 1))
positive_index2 = df.RuleWrap("positive_index2", df.Modifier(positive_num, lambda x: x - 1))
Exemplo n.º 6
0
import game, server, menu_utils, df_utils
import dragonfly as df

main_button_choice = df.Choice("main_buttons", {
    "new": "New",
    "load": "Load",
    "co op": "Co-op",
    "exit": "Exit"
})

TITLE_MENU = 'titleMenu'


def get_title_menu(menu):
    menu_utils.validate_menu_type(TITLE_MENU, menu)
    if menu['subMenu']:
        raise menu_utils.InvalidMenuOption()
    return menu


async def click_main_button(menu, btn_name: str):
    button = menu_utils.find_component_by_field(menu['buttons'], 'name',
                                                btn_name)
    await menu_utils.click_component(button)


def get_submenu(tm, menu_type):
    menu_utils.validate_menu_type(TITLE_MENU, tm)
    submenu = tm.get('subMenu')
    menu_utils.validate_menu_type(menu_type, submenu)
    return submenu
Exemplo n.º 7
0
def multiply_keys(rep):
    n = 1 if rep[0] is None else rep[0]
    key = rep[1]
    return [key for i in range(n)]


def flatten_list(rep):
    flattened = []
    for l in rep:
        flattened.extend(l)
    return flattened


all_chars_choice = df.Choice(None, {
    **letter_map,
    **capital_letter_map,
    **keys,
    **numbers
})
letters_and_keys = df.Repetition(all_chars_choice,
                                 name="letters_and_keys",
                                 min=1,
                                 max=16)


def type_characters(letters: str):
    shift_down = False
    for char in letters:
        shift_char = char.isupper()
        char = char.lower()
        if shift_char and not shift_down:
            pydirectinput.keyDown('shift')
Exemplo n.º 8
0
def load_grammar():
    grammar = menu_utils.build_menu_grammar(mapping, LEVEL_UP_MENU, extras=[df.Choice('category', categories)])
    grammar.load()