Пример #1
0
def publi_search(request):
    t = get_template('data/mpod_publi_search.html')
    request_path=request.get_full_path()
    debug_info=request_path
    my_top_menu=menus.menu(my_menus.data_top_menu, request_path, 0)
    my_nav_menu=menus.menu(my_menus.mpod_nav_menu, request_path, 0)
    html = t.render(Context(
    {"top_menu":my_top_menu,
    "nav_menu":my_nav_menu}
    ))
    query_title = request.GET.get('title', '')
    query_author = request.GET.get('author', '')
    query_journal = request.GET.get('journal', '')
    if ( query_title or query_author or query_journal):
        html_results = get_publis(query_title, query_author, query_journal)
    else:
        html_results=None
    html = t.render(Context(
        {"top_menu":my_top_menu,
        "nav_menu":my_nav_menu,
        "query_title": query_title,
        "query_author": query_author,
        "query_journal": query_journal,
        "results": html_results,
        }
        ))
    response=HttpResponse(html)
##    response.write(debug_info)
    return HttpResponse(response)
Пример #2
0
def data_search(request):
    t = get_template('data/mpod_data_search.html')
    request_path=request.get_full_path()
    debug_info=request_path
    my_top_menu=menus.menu(my_menus.data_top_menu, request_path, 0)
    my_nav_menu=menus.menu(my_menus.mpod_nav_menu, request_path, 0)
    html = t.render(Context(
    {"top_menu":my_top_menu,
    "nav_menu":my_nav_menu}
    ))
    query_phase_name = request.GET.get('phase_name', '')
    query_formula = request.GET.get('formula', '')
    query_cod_code = request.GET.get('cod_code', '')
    query_publ_author = request.GET.get('publ_author', '')
    if ( query_phase_name or query_formula or query_cod_code or query_publ_author):
        html_results = get_datafiles(query_phase_name, query_formula, query_cod_code, query_publ_author)
    else:
        html_results=None
    html = t.render(Context(
        {"top_menu":my_top_menu,
        "nav_menu":my_nav_menu,
        "query_phase_name": query_phase_name,
        "query_formula": query_formula,
        "query_cod_code": query_cod_code,
        "query_publ_author": query_publ_author,
        "results": html_results,
        }
        ))
    response=HttpResponse(html)
##    response.write(debug_info)
    return HttpResponse(response)
Пример #3
0
def view_article(request, article_id):
    ogge = None
    html_res = None
    html_res2 = None
    datafiles = None
    try:
        ogge = PublArticle.objects.get(id__exact = article_id)
        datafiles = DataFile.objects.filter(publication__id__exact = article_id)
    except:
        pass
    if ogge:
        html_res = view_obj_as_2cols_table ( PublArticle, ogge, cap="Publication details")
        html_res2 = view_as_linked_table(DataFile, oggetti=datafiles, header='Associated datafiles')        
    t = get_template('data/publi_view.html')
    request_path=request.get_full_path()
    debug_info=request_path
    my_top_menu=menus.menu(my_menus.data_top_menu, request_path, 0)
    my_nav_menu=menus.menu(my_menus.mpod_nav_menu, request_path, 0)
    html = t.render(Context(
        {"top_menu":my_top_menu,
        "nav_menu":my_nav_menu,
        "publi_table": html_res,
        "associated_datafiles": html_res2,
        }
        ))
    response=HttpResponse(html)
##    response.write(debug_info)
    return HttpResponse(response)
Пример #4
0
def submit_file(request):
    time_st = "_"
    request_path=request.get_full_path()
    my_top_menu=menus.menu(my_menus.data_top_menu, request_path, 0)
    my_nav_menu=menus.menu(my_menus.mpod_nav_menu, request_path, 0)
    if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        val = form.is_valid()
        if val:
            time_st = datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S_%f")
            f1 = request.FILES['mpod_file']
            f2 = request.FILES['pdf_file']
            email_add = form.cleaned_data['email']
            name = form.cleaned_data['name']
            message = form.cleaned_data['message']
            opt_mail_data = [name, message]
            handle_uploaded_files(f1, f2, time_st)
            #send_upload_notif(f1, f2, time_st, email_add, opt_email_data)
            return HttpResponseRedirect('/datafiles/upload/success/')
        else:
            pass
    else:
        form = UploadFileForm()
    return render_to_response('data/mpod_file_submit.html', 
            {'form': form, 
            'time_stamp': time_st,
            "top_menu":my_top_menu,
            "nav_menu":my_nav_menu,
             })
Пример #5
0
def listanombres(NAME):
    NOMBRES = []
    for x in NAME:
       if x not in NOMBRES:
           NOMBRES.append(x)
    nombres = tuple(NOMBRES)
    print (nombres)
    menus.menu()
Пример #6
0
def stergere(info):
    optiuni = {
        1: [ui_stergeTranzactieZi, "1.Sterge tranzactia dintr-o zi data"],
        2:
        [ui_stergeTranzactiePerioada, "2.Sterge tranzactie dintr-o perioada"],
        3: [ui_stergeTranzactieTip, "3.Sterge tranzactie de un tip"]
    }
    menus.menu(optiuni, info)
Пример #7
0
def dict_base(request, sub_template):
    t = get_template(sub_template)
    request_path=request.get_full_path()
    debug_info=request_path
    my_top_menu=menus.menu(my_menus.dict_top_menu, request_path, 0)
    my_nav_menu=menus.menu(my_menus.mpod_nav_menu, request_path, 0)
    html = t.render(Context(
    {"top_menu":my_top_menu,
    "nav_menu":my_nav_menu}
    ))
    return html
Пример #8
0
def comenziInt(info):
    optiuniP = {
        1: [adaugare, "1.Adaugare"],
        2: [stergere, "2.Stergere"],
        3: [cautari, "3.Cautari"],
        4: [rapoarte, "4.Rapoarte"],
        5: [filtrare, "5.Filtrare"],
        6: [ui_afisareLista, "6.Afisare lista"],
        -1: [undo, "-1.UNDO"]
    }
    menus.menu(optiuniP, info)
Пример #9
0
def filtrare(info):
    optiuni = {
        1: [
            ui_eliminaTranzactiiSumaData,
            "1.Elimina tranzactiile cu o suma data"
        ],
        2: [
            ui_eliminaTranzactiiMaiMiciSuma,
            "2.Elimina tranzactiile cu suma mai mica decat o suma data si cu acelasi tip"
        ]
    }
    menus.menu(optiuni, info)
Пример #10
0
def rapoarte(info):
    optiuni = {
        1: [
            ui_sumaTotalaTrAcelasiTip,
            "1.Suma totala a tranzactiilor de un anumit tip"
        ],
        2: [ui_soldCont, "2.Soldul contului la o anumita data"],
        3: [
            ui_tiparireTrAcelasiTipOrdonateSuma,
            "3.Tiparire tranzactii de un anumit tip ordonate dupa suma"
        ]
    }
    menus.menu(optiuni, info)
Пример #11
0
def cautari(info):
    optiuni = {
        1: [
            ui_tiparesteTranzactiiSuma,
            "1.Tipareste o tranzactie mai mare decat o suma"
        ],
        2: [
            ui_tiparesteTranzactiiZiSuma,
            "2.Tipareste tranzactii dinaintea unei zile si avand suma mai mare ca o suma data"
        ],
        3:
        [ui_tiparesteTranzactiiTip, "3.Tipareste tranzactie de un anumit tip"]
    }
    menus.menu(optiuni, info)
Пример #12
0
def data_properties(request):
    ogge = Property.objects.all()
    t = get_template('data/properties_list_view.html')
    request_path=request.get_full_path()
    my_top_menu=menus.menu(my_menus.data_top_menu, request_path, 0)
    my_nav_menu=menus.menu(my_menus.mpod_nav_menu, request_path, 0)
    properties_list_table_html = view_linked_properties_list(oggetti=ogge, header=None)
    html = t.render(Context(
    {"top_menu":my_top_menu,
    "nav_menu":my_nav_menu,
    "properties_list_table" : properties_list_table_html,
    }
    ))
    return HttpResponse(html)
Пример #13
0
def controller_menu_psw_contrato_sem_dados(user, *args):
    menu_titulo("Menu PSW")

    if not user.is_authenticated:
        mensagem(({'type': 0, 'texto': 'Usuário não autenticado'}, ))
        return controller_menu_inicial(user)

    if not DRIVER.autenticado:
        mensagem(({'type': 0, 'texto': 'Usuário não autenticado no PSW'}, ))
        return controller_psw_login(user)

    opcoes = (
        {
            'texto': 'Retornar ao menu principal',
            'controller': controller_menu_principal,
        },
        {
            'texto':
            'Inserir contrato na lista de contratos pendentes de baixa',
            'controller': controller_ont_lista,
        },
        {
            'texto': 'Buscar outro contrato',
            'controller': controller_psw_busca_contrato,
        },
    )

    context = {
        'opcoes': opcoes,
    }

    return menu(user, context, controller_menu_psw_contrato_sem_dados, *args)
Пример #14
0
def controller_menu_principal(user, *args):
    menu_titulo("Menu Principal")

    if not user.is_authenticated:
        return controller_menu_inicial(user)

    opcoes = (
        {
            'texto': 'logout',
            'controller': controller_logout,
        },
        {
            'texto': 'realizar baixa de ONT\'s',
            'controller': controller_psw_login,
        },
        {
            'texto': 'Sair',
            'controller': controller_sair,
        },
    )

    context = {
        'opcoes': opcoes,
    }

    return menu(user, context, controller_menu_principal, *args)
Пример #15
0
def controller_menu_psw_contrato_sucesso(user, *args):
    menu_titulo("Menu PSW")

    if not user.is_authenticated:
        return controller_menu_inicial(user)

    if not DRIVER.autenticado:
        return controller_psw_login(user)

    opcoes = (
        {
            'texto': 'Retornar ao menu principal',
            'controller': controller_menu_principal,
        },
        {
            'texto': 'Realizar baixa da ONT no sistema',
            'controller': controller_ont_baixa,
        },
        {
            'texto': 'Buscar outro contrato',
            'controller': controller_psw_busca_contrato,
        },
    )

    context = {
        'opcoes': opcoes,
    }

    return menu(user, context, controller_menu_psw_contrato_sucesso, *args)
Пример #16
0
 def handle_inventory(self):
     from globals import game_draw
     items = self.stats.inventory.items
     text = "Which item do you want to use or drop?" if items else "You don't have any items."
     options = []
     for item_slot in items:
         options.append([colors.MUTED_GREEN, item_slot.item_type.name+" ", colors.YELLOW, item_slot.item_type.summary])
     opt = menus.menu((colors.GOLD, text), options, 70, index_color=colors.YELLOW)
     if opt == None:
         return False
     game_draw()
     use_or_drop = menus.menu((colors.GOLD, "Use the " + items[opt].item_type.name + ", or drop it ?"), [(colors.LIGHT_GREEN,"Use"), (colors.LIGHT_RED,"Drop")], 50, index_color=colors.YELLOW)
     if use_or_drop == 0:
         return self.queue_use_item(items[opt])
     elif use_or_drop == 1:
         return self.queue_drop_item(items[opt])
     return False
Пример #17
0
def calculoSLD(MONTH,YEAR,RUT,NAME,KTGORY,DAYFALS,AFP,HEALT,SLDB,GIFT,DCTOAFP,DCTOHEALT):
    for z in range(len(SLDB)):
        print ("\n")
        suma1 = SLDB[z] + GIFT[z]
        suma2 = DCTOAFP[z] + DCTOHEALT[z]
        sldliq = int(suma1) - int(suma2)
        if int(GIFT[z]) > int("0"):
            bono = ("Tiene Bono")
        else:
            bono = ("No Tiene Bono")
        
        print ("Rut:",RUT[z])
        print ("Nombre:",NAME[z].title())
        print ("Bono:$",GIFT[z])
        print ("Descuento APF:$",int(DCTOAFP[z]) ,"Descuento de salud:$",int(DCTOHEALT[z]))
        print ("Sueldo bruto $",SLDB[z])
        print ("Total a pagar:$",sldliq)
    menus.menu()
Пример #18
0
def view_exparcond(request, exparcond_id):
    t = get_template('data/experimentalparcond_view.html')
    request_path=request.get_full_path()
    debug_info=request_path
    my_top_menu=menus.menu(my_menus.data_top_menu, request_path, 0)
    my_nav_menu=menus.menu(my_menus.mpod_nav_menu, request_path, 0)
    ogge = ExperimentalParCond.objects.filter(id__exact = exparcond_id).distinct()
    html_res = None
    if ogge:
        ogge = ogge[0]
        html_res = view_obj_as_2cols_table (ExperimentalParCond, ogge, cap="Experimental Parameter/Condition details")
    html = t.render(Context(
        {"top_menu":my_top_menu,
        "nav_menu":my_nav_menu,
        "property_table": html_res,
        }
        ))
    response=HttpResponse(html)
##    response.write(debug_info)
    return HttpResponse(response)
Пример #19
0
def tabla(request, dataitem_id):
#    ogge = DataFile.objects.get(code__exact = dataitem_id)
    t = get_template('data/datafile_view.html')
    request_path=request.get_full_path()
    debug_info=request_path
    my_top_menu=menus.menu(my_menus.data_top_menu, request_path, 0)
    my_nav_menu=menus.menu(my_menus.mpod_nav_menu, request_path, 0)
##    html_dataitem, html_gen_props, html_tables = data_item_html(dataitem_id)
    html_dataitem, html_tables = data_item_html(dataitem_id)
    html = t.render(Context(
        {"top_menu":my_top_menu,
        "nav_menu":my_nav_menu,
        "html_dataitem":html_dataitem,
##        "html_gen_props":html_gen_props,
        "html_tables":html_tables,
        }
        ))
    response=HttpResponse(html)
##    response.write(debug_info)
    return HttpResponse(response)
Пример #20
0
def contact(request):
    request_path=request.get_full_path()
    my_top_menu=menus.menu(my_menus.mpod_top_menu, request_path, 0)
    my_nav_menu=menus.menu(my_menus.mpod_nav_menu, request_path, 0)
    if request.method == 'POST': # If the form has been submitted...
        form = ContactForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            subject = form.cleaned_data['subject']
            message = form.cleaned_data['message']
            sender = form.cleaned_data['email']
            name = form.cleaned_data['name']
            cc_myself = form.cleaned_data['cc_myself']
            recipients = ['*****@*****.**']
            if cc_myself:
                recipients.append(sender)
            send_mail(subject, message, sender, recipients)
            return HttpResponseRedirect('/contact/thanks/') # Redirect after POST
    else:
        form = ContactForm() # An unbound form
    return render_to_response('mpod_contact.html', {
        'form': form,
        "top_menu":my_top_menu,
        "nav_menu":my_nav_menu,
    })
Пример #21
0
def splash_screen(img=None):
    from utils import print_colored
    from menus import menu, msgbox
    from tiles import tile
    screen.clear()

    while True:
        if img:
            screen.clear()
            libtcod.image_blit_rect(img, 0, 0,0, -1,-1, 1)
            if img == INTRO_IMAGE:
                print_colored(screen, Pos(30, 30), colors.WHITE, "PRESS ENTER TO START!")
            screen.flush()
        else:
            game_draw()
        key, mouse = libtcod.Key(), libtcod.Mouse()
        libtcod.sys_check_for_event(libtcod.EVENT_ANY, key, mouse)
        if key.pressed and key.vk == libtcod.KEY_ENTER:
            if img == INTRO_IMAGE:
                opt = menu((colors.WHITE, "Select a mode (changeable in-game with 'tab'):"), 
                            [(colors.PALE_RED, "Tiles mode"),(colors.PALE_GREEN, "Classic ASCII") ], 50, index_color=colors.YELLOW)
                global ASCII_MODE
                ASCII_MODE = (opt == 1)
                if opt != None: 
                    hole= [] if not ASCII_MODE else [colors.YELLOW, ' (O)']
                    explanation = [ colors.BABY_BLUE, "Welcome to BUGHACK\n",
                                    colors.WHITE, "You are a leader ant who must lead worker ants to delicious harvest.\n",
                                    colors.WHITE, "Every sector you must gather a certain amount of harvest.\n", 
                                    colors.PALE_RED, "Keep your ants safe, or you'll take damage!\n", 
                                    colors.WHITE, "You must call ants out of an ant hole"] + hole + [colors.WHITE,", and then lead them to \n",
                                    colors.WHITE, "to fruit.\n",colors.WHITE, '\n',
                                    colors.YELLOW, "Press C in-game to see controls."]
                    screen.clear()
                    libtcod.image_blit_rect(img, 0, 0,0, -1,-1, 1)
                    screen.flush()
                    msgbox(explanation, 70)
                    if game_save_exists():
                        game_load()
                else:
                    continue
            screen.clear()
            screen.flush()
            return
        elif (key.pressed and key.vk == libtcod.KEY_ESCAPE) or libtcod.console_is_window_closed():
            exit()
Пример #22
0
 def handle_abilities(self):
     from globals import game_draw
     abilities = self.stats.abilities
     text = "Which mutant ability shall you inflict?"
     options = []
     for ability in abilities:
         can_do = ability.has_prereqs(self)
         if can_do:
             options.append([colors.BABY_BLUE, str(ability.mana_cost) + " MP ", 
                             colors.LIGHT_GREEN, ability.name+" ", 
                             colors.WHITE, ability.summary])
         else:
             options.append([colors.BABY_BLUE if self.stats.mp > ability.mana_cost else colors.GRAY, str(ability.mana_cost) + " MP ", 
                             colors.GRAY, ability.name+" ", 
                             colors.DARK_GRAY, ability.summary])
     opt = menus.menu((colors.GOLD, text), options, 65, index_color=colors.YELLOW)
     if opt != None:
         ability = abilities[opt]
         target = ability.target(self)
         if target:
             return self.queue_use_ability(ability, target) 
     return False
Пример #23
0
def controller_menu_inicial(user, *args):
    menu_titulo("Menu inicial")

    if user.is_authenticated:
        return controller_menu_principal(user, *args)

    opcoes = (
        {
            'texto': 'Sair',
            'controller': controller_sair,
        },
        {
            'texto': 'autenticar no sistema Constel.tk',
            'controller': controller_login_web_constel,
        },
    )

    context = {
        'opcoes': opcoes,
    }

    return menu(user, context, controller_menu_inicial, *args)
Пример #24
0
		you pick up on it). I added static positions as a means of
		testing throughout development and didn't realize until
		recently that I forgot to implement random fleet placement.
		Just going to have to take a hit on that one (no pun intended).
"""
from players import player
from board import gameboard
from menus import menu

# Boards
humanBoard = gameboard()
hitBoard = gameboard()

# Players
human = player(0)
computer = player(1)

# Interaction object.
menu = menu()

# Intro and placement instructions
menu.intro()
menu.placementInst()

# Setting fleet.
human.storeShips(menu.placeShips(humanBoard))

# Main game and instructions
menu.mainInst()
menu.mainGame(human, computer, humanBoard, hitBoard)
Пример #25
0
def main():
    constants = initialize_new_game.get_constants()
    position = 0

    terminal.open()
    terminal.set("window: size=" + str(constants['screen_width']) + "x" +
                 str(constants['screen_height']) + ', title=Space Game')
    terminal.set("font: fonts\courbd.ttf, size=" + constants.get('fontsize'))
    # terminal.set("input.filter={keyboard, mouse}")

    player = None
    entities = []
    game_map = None
    message_log = None
    game_state = None

    while True:
        # show the background image, at twice the regular console resolution
        # clear scene especially after quitting game
        terminal.layer(0)
        terminal.clear()
        # show the game's title, and some credits!
        title = 'SPACE GAME'
        titlex = int(constants['screen_width'] / 2 - len(title) / 2)
        titley = int(constants['screen_height'] / 2)

        subtitle = 'Game by Eric Younkin'
        subtitlex = int(constants['screen_width'] / 2 - len(subtitle) / 2)
        subtitley = int(constants['screen_height'] / 2 + 2)

        terminal.color('yellow')
        terminal.print_(titlex, titley, '[align=center]' + title)
        terminal.print_(subtitlex, subtitley,
                        '[align=center][font=0xE000]' + subtitle)

        # show options and wait for the player's choice
        options = ['Play a new game', 'Continue last game', 'Quit']
        menu('',
             options,
             30,
             constants['screen_width'],
             constants['screen_height'],
             position=position,
             type='main')

        key = terminal.read()
        action = input_handlers.handle_menu_keys(key)

        menupos = action.get('menupos')
        select = action.get('select')
        ex = action.get('exit')
        resize = action.get('resize')

        if ex:
            break
        elif menupos:
            position += menupos
            if position < 0:
                position = 0
            if position >= len(options) - 1:
                position = len(options) - 1
        elif select:
            if position == 0:
                player, entities, game_map, message_log, game_state = initialize_new_game.get_game_variables(
                    constants)
                game_state = GameStates.PLAYERS_TURN
                play_game(player, entities, game_map, message_log, game_state,
                          constants)
            elif position == 1:  # load last game
                try:
                    player, entities, game_map, message_log, game_state = data_loaders.load_game(
                    )
                    play_game(player, entities, game_map, message_log,
                              game_state, constants)
                except FileNotFoundError:
                    message_box('No save game to load', 50,
                                constants['screen_width'],
                                constants['screen_height'])
                    play_game(player, entities, game_map, message_log,
                              game_state, constants)
            elif position == 2:  # quit
                break
        elif resize:
            print(size)
            if size == '8':
                size = '12'
            elif size == '12:':
                size = '16'
            elif size == '16':
                size = '8'
                terminal.set("font: fonts\courbd.ttf, size=" + size)
Пример #26
0
def main():
    constants = get_constants()

    tcod.console_set_custom_font(
        'consolas12x12_gs_tc.png',
        tcod.FONT_TYPE_GREYSCALE | tcod.FONT_LAYOUT_TCOD)
    tcod.console_init_root(constants['screen_width'],
                           constants['screen_height'],
                           constants['window_title'], False)
    con = tcod.console_new(constants['screen_width'],
                           constants['screen_height'])
    panel = tcod.console_new(
        constants['screen_width'],
        constants['screen_height'] - constants['panel_height'])

    player = None
    entities = []
    game_map = None
    message_log = None
    game_state = None
    show_main_menu = True
    show_load_error_message = False
    main_menu_background_image = tcod.image_load('menu_background.png')

    key = tcod.Key()
    mouse = tcod.Mouse()

    while not tcod.console_is_window_closed():
        tcod.sys_check_for_event(tcod.EVENT_KEY_PRESS | tcod.EVENT_MOUSE, key,
                                 mouse)
        if show_main_menu:
            main_menu(con, main_menu_background_image,
                      constants['screen_width'], constants['screen_height'])
            if show_load_error_message:
                menu(con, 'Save game unfound', [], 50,
                     constants['screen_width'], constants['screen_height'])
            tcod.console_flush()

            action = handle_main_menu(key)
            new_game = action.get('new_game')
            load_game_bool = action.get('load_game')
            exit_game = action.get('exit')

            if show_load_error_message and (new_game or load_game
                                            or exit_game):
                show_load_error_message = False
            elif new_game:
                player, entities, game_map, message_log, game_state = get_game_vars(
                    constants)
                show_main_menu = False
            elif load_game_bool:
                try:
                    player, entities, game_map, message_log, game_state = load_game(
                    )
                    show_main_menu = False
                except FileNotFoundError:
                    show_load_error_message = True
            elif exit_game:
                break
        else:
            tcod.console_clear(con)
            start_game(player, entities, game_map, message_log, game_state,
                       con, panel, constants)

            show_main_menu = True
Пример #27
0
def adaugare(info):
    optiuni = {
        1: [ui_adaugaTranzactie, "1.Adaugare tranzactie"],
        2: [ui_actualizareTranzactie, "2.Actualizare tranzactie"]
    }
    menus.menu(optiuni, info)
Пример #28
0
def main():
    constants = get_constants()

    libtcod.console_set_custom_font(
        'arial10x10.png',
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)

    libtcod.console_init_root(
        constants['screen_width'], constants['screen_height'],
        constants['window_title'], False)

    con = libtcod.console_new(
        constants['screen_width'], constants['screen_height'])
    panel = libtcod.console_new(
        constants['screen_width'], constants['panel_height'])

    player = None
    entities = []
    game_map = None
    message_log = None
    game_state = None

    show_main_menu = True
    get_weapon = False
    show_load_error_message = False

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(
            libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        if show_main_menu:
            main_menu(
                con, None, constants['screen_width'],
                constants['screen_height'])

            if show_load_error_message:
                message_box(
                    con, 'No save game to load', 50,
                    constants['screen_width'], constants['screen_height'])

            libtcod.console_flush()

            action = handle_main_menu(key)

            new_game = action.get('new_game')
            load_saved_game = action.get('load_game')
            exit_game = action.get('exit')

            if show_load_error_message and (
                    new_game or load_saved_game or exit_game):
                show_load_error_message = False
            elif new_game:
                player, entities, game_map, message_log, game_state = (
                    get_game_variables(constants))
                get_weapon = True
                game_state = GameStates.PLAYERS_TURN

                show_main_menu = False
            elif load_saved_game:
                try:
                    player, entities, game_map, message_log, game_state = (
                        load_game())
                    show_main_menu = False
                except FileNotFoundError:
                    show_load_error_message = True
            elif exit_game:
                break

        elif get_weapon:
            menu(
                con, 'Choose Weapon',
                ['Sword and Board (Chance to block when fighting straight on)',
                 'Daggers (Gets a sneaky stab in and can dodge when moving)',
                 'Pike (Attacks twice as far as other weapons)'],
                64, constants['screen_width'], constants['screen_height'])
            libtcod.console_flush()

            action = handle_weapon_menu(key)
            exit = action.get('exit')
            sword = action.get('sword')
            daggers = action.get('daggers')
            pike = action.get('pike')

            if exit:
                libtcod.console_clear(0)
                show_main_menu = True
                get_weapon = False
            elif sword:
                get_weapon = False
                constants['weapon'] = 'sword'
            elif daggers:
                get_weapon = False
                constants['weapon'] = 'daggers'
            elif pike:
                get_weapon = False
                constants['weapon'] = 'pike'

        else:
            libtcod.console_clear(con)
            play_game(player, entities, game_map, message_log,
                      game_state, con, panel, constants)

            libtcod.console_clear(0)
            libtcod.console_flush()
            show_main_menu = True
Пример #29
0
#import
import os
import time
import menus
import modif_table
#Déclaration variables
CODECOV_TOKEN = "2063f85f-f0e1-41fa-8cce-d7497087f789"
choix_ok = False
tab_total = [['test', 'test']]
select_modif_table = 0
select_modif_ok = False

#Debut
print("Bienvenu !")
print(
    "Vous êtes dans le menu de tableau, vous pouvez crée un tableau le modif ou en supprimer un"
)
#selection
choix = menus.menu()
if (choix == 1):
    print("1")
elif (choix == 2):
    modif_table.modif(tab_total)
Пример #30
0
def main_screen(constants):
    con = libtcod.console_new(constants['screen_width'], constants['screen_height'])
    panel = libtcod.console_new(constants['screen_width'], constants['panel_height'])

    print('DEBUG : MAIN SCREEN')
    player = None
    entities = []
    game_map = None
    message_log = None
    game_state = None

    show_main_menu = True
    show_load_error_message = False
    show_score_bill = False
    show_creation_menu = False
    show_load_menu = False

    character_name = str("")
    main_menu_background_image = libtcod.image_load('menu_background.png')

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        if show_main_menu:
            main_menu(con, main_menu_background_image, constants['screen_width'], constants['screen_height'],
                      constants['version'])

            if show_load_error_message:
                message_box(con, 'No save game to load', 50, constants['screen_width'], constants['screen_height'])

            libtcod.console_flush()

            action = handle_main_menu(key)

            new_game = action.get('new_game')
            load_saved_game = action.get('load_game')
            score_bill = action.get('score_bill')
            exit_game = action.get('exit')
            fullscreen = action.get('fullscreen')

            if fullscreen:
                libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())

            if show_load_error_message and (new_game or load_saved_game or exit_game):
                show_load_error_message = False

            elif new_game:
                # v14.
                show_main_menu = False
                show_creation_menu = True

            elif load_saved_game:
                # v15
                if show_load_menu == False:
                    number_of_games = get_saved_games()
                    if number_of_games == []:
                        show_load_error_message = True
                    else:
                        show_main_menu = False
                        show_load_menu = True

                    '''
                    try:
                        player, entities, game_map, message_log, game_state = load_game()
                        show_main_menu = False
                    except FileNotFoundError:
                        show_load_error_message = True
                    '''

            # v14
            elif score_bill:
                show_main_menu = False
                show_score_bill = True

            elif exit_game:
                break

        # v15
        elif show_load_menu:
            number_of_games = get_saved_games()
            print('INFO : number of games : ', number_of_games)
            header = 'Choose your save :'
            menu(con, header, number_of_games, int(constants['screen_width'] / 2), constants['screen_width'],
                 constants['screen_height'])

            libtcod.console_flush()

            action = handle_load_menu(key)

            load_chosen = None
            load_chosen = action.get('load_chosen')
            load_exit = action.get('load_exit')

            if load_exit:
                show_main_menu = True
                show_load_menu = False

            if load_chosen != None:
                try:
                    save_to_load = number_of_games[load_chosen]
                    player, entities, game_map, message_log, game_state = load_game(save_to_load)
                    show_main_menu = False
                    show_creation_menu = False
                    show_score_bill = False
                    show_load_menu = False

                except FileNotFoundError:
                    show_load_error_message = True

        # v14
        elif show_creation_menu:
            character_creation_menu(main_menu_background_image, constants['screen_width'],
                                      constants['screen_height'], character_name)

            libtcod.console_flush()

            action = handle_character_creation_menu(key)

            exit_creation = action.get('exit_creation')
            validate_creation = action.get('validate_creation')
            letter = action.get('letter')

            if letter == 'backspace':
                if len(character_name) > 0:
                    character_name = character_name[:-1]

            if letter in ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '-']:
                if len(character_name) < 10:
                    character_name += str(letter)

            if validate_creation:
                if len(character_name) == 0:
                    character_name = 'Player'

                show_creation_menu = False
                player, entities, game_map, message_log, game_state = get_game_variables(constants)
                player.name = character_name
                game_state = GameStates.PLAYERS_TURN

            if exit_creation:
                show_creation_menu = False
                show_main_menu = True

        # v14
        elif show_score_bill:
            # show score bill.
            score_bill_menu(main_menu_background_image, constants['screen_width'],
                            constants['screen_height'])

            libtcod.console_flush()

            action = handle_score_bill_menu(key)
            exit_score_bill = action.get('score_exit')

            if exit_score_bill:
                show_score_bill = False
                show_main_menu = True

        else:
            libtcod.console_clear(con)
            play_game(player, entities, game_map, message_log, game_state, con, panel, constants)

            show_main_menu = True
Пример #31
0
while game_is_active:

    game_mode = ""
    if ui_screen == screen_mode:
        while game_mode not in ["1", "2", "3", "9"]:
            menus.mode_menu()
            game_mode = raw_input("")
            if game_mode == "9":
                game_is_active = False
            else:
                ui_screen = screen_action

    elif ui_screen == screen_action:
        while ui_screen == screen_action:
            menus.clear_screen()
            menus.menu()
            selected_menu = int(raw_input("Select an item from the menu"))
            if selected_menu in range(1, 6):
                ui_screen = screens[selected_menu + 1]
            elif selected_menu == 5:
                my_park.turn()
            elif selected_menu == 6:
                ui_screen = screen_mode

    elif ui_screen == screen_build:
        menus.clear_screen()
        menus.building_menu(my_park)
        selected_building = int(raw_input("Select a building for the list"))
        if selected_building in range(1, 6):
            my_park.build(
                simulation.Park.modes[my_park.mode][selected_building - 1])