예제 #1
0
def getChoiceFromList(player, prompt, list, noChoices=1):
    Output.menuWindow.clear()
    Output.printToWindow(prompt + '\n', Output.menuWindow)

    invalidActions = player._determineValidOptions(list)
    freeActions = player._determineFreeOptions(list)

    count = 1
    indexMapping = {}
    for i, currOption in enumerate(list):
        if currOption in invalidActions.keys():
            Output.printToWindow('{0:2d} - {1} - {2}\n'.format(count, currOption, invalidActions.get(currOption)), Output.menuWindow, colorPair=1)
        elif currOption in freeActions.keys():
            Output.printToWindow('{0:2d} - {1} - {2}\n'.format(count, currOption, freeActions.get(currOption)), Output.menuWindow, colorPair=2)
            indexMapping[count] = currOption
        else:
            Output.printToWindow('{0:2d} - {1}\n'.format(count, currOption), Output.menuWindow)
            indexMapping[count] = currOption
        count += 1
    chosenOption = []
    while True:
        for i in range(0, noChoices):
            Output.printToWindow('%d of %d : '%(i, noChoices), Output.menuWindow)
            choice = int(Output.menuWindow.getstr(2))
            #choice -= 48
            if choice >= 1 and choice <= len(list):
                if choice in indexMapping:
                    if noChoices > 1:
                        chosenOption.append(indexMapping[int(choice)])
                    else:
                        chosenOption = indexMapping[int(choice)]
        if len(chosenOption) > 0:
            return chosenOption
예제 #2
0
def getChoiceFromStack(prompt, currStack, noChoices=1):
    Output.menuWindow.clear()
    Output.printToWindow(prompt + '\n', Output.menuWindow)

    count = 1
    indexMapping = {}
    for i, currCard in enumerate(currStack.cards):
        Output.printToWindow('{0:2d} - {1}\n'.format(count, currCard.visibleName()), Output.menuWindow)
        indexMapping[count] = currCard.name
        count += 1
    chosenCard = []

    while True:
        for i in range(0, noChoices):
            Output.printToWindow('%d of %d : '%(i, noChoices), Output.menuWindow)
            choice = int(Output.menuWindow.getstr(2))
            #choice -= 48
            if choice >= 1 and choice <= len(currStack.cards):
                if choice in indexMapping:
                    chosenCard.append(indexMapping[choice])
        if len(chosenCard) > 0:
            return chosenCard