Beispiel #1
0
def generateMenu(c):
    former = c.lst().copy()

    if c.strategy() == 'readfile':
        pos = input('Enter the start position (0 required for the 1st time): ')
        if len(c.lst()) == 0:
            pos = 0
            print('Set to 0')
        else:
            pos = v.validatePositiveInt(pos, 'Start position')

        fn = input('Enter filename (.txt): ')
        fn = v.validateFileName(fn)

        c.executeStrategy(pos, fn)

    elif c.strategy() == 'iterator':
        pos = input('Enter the start position (0 required for the 1st time): ')
        if len(c.lst()) == 0:
            pos = 0
            print('Set to 0')
        else:
            pos = v.validatePositiveInt(pos, 'Start position')

        n = input('Enter quantity of numbers you want to add: ')
        n = v.validatePositiveInt(n, 'Quantity')

        c.executeStrategy(pos, n)

    Event.update('add', former, pos, c.lst())
    print('Collection succesfully generated!')
    def _slice(c, start, end):
        if start > end or end >= len(c.lst()):
            raise ValueError('Bad index value')

        former = c.lst().copy()
        for _ in range(end-start+1):
            c.lst().pop(start)

        Event.update('remove', former, [start, end], c.lst())
 def handleInput(self):
     mappedInput = self.inputMapper.MapInput()
     for ID in self.inputComponents:
         if self.fsm.run(mappedInput,
                         inputComponent=self.inputComponents[ID],
                         velocityComponent=self.velocityComponents[ID]):
             inputEvent = Event()
             inputEvent.entityID = ID
             self.fsm.transitionFunctions.process(inputEvent)
             self.publishEvent(inputEvent)
def generateWithIterator(c):
    print('Please fill the list using \'iterator\' strategy:')
    c.setStrategy(IteratorStrategy())
    former = c.lst().copy()

    pos = 0
    n = input('Enter quantity of numbers you want to add: ')
    n = v.validatePositiveInt(n, 'Quantity')

    c.executeStrategy(pos, n)       
    Event.update('add', former, pos, c.lst())
    print('Collection succesfully generated!')
def generateWithReadFile(c):
    print('Please fill the list using \'readfile\' strategy:')
    c.setStrategy(ReadFileStrategy())
    former = c.lst().copy()

    pos = 0
    fn = input('Enter filename (.txt): ')
    fn = v.validateFileName(fn)

    c.executeStrategy(pos, fn)
    Event.update('add', former, pos, c.lst())
    print('Collection succesfully generated!')
Beispiel #6
0
def sliceMenu(c):
    start = input('Enter start position of deletion: ')
    end = input('Enter end position of deletion: ')
    start = v.validatePositiveInt(start, 'Start')
    end = v.validatePositiveInt(end, 'End')
    if start > end or end >= len(c.lst()):
        raise ValueError('Bad index value')

    former = c.lst().copy()
    for _ in range(end - start + 1):
        c.lst().pop(start)

    Event.update('remove', former, [start, end], c.lst())
    print('Items succesfully deleted!')
Beispiel #7
0
def getInputs():
    val1 = GPIO.getPuzzleButton()
    if val1 != None:
        Event('puzzleClick', val1)
    if val1 == LONG_PRESS:
        Event('shutdown', None)
    val2 = GPIO.getJungleButton()
    if val2 != None:
        Event('jungleClick', val2)
    if val2 == LONG_PRESS:
        Event('changeDifficulty', None)
    val3 = GPIO.getRepeatButton()
    if val3 != None:
        Event('repeatClick', val3)
    if val3 == LONG_PRESS:
        Event('resetWifi', None)
    val4 = GPIO.getSkipButton()
    if val4 != None:
        Event('skipClick', val4)
 def delete(c, pos):
     former = c.lst().copy()
     c.lst().pop(pos)
     Event.update('remove', former, pos, c.lst())
 def method(c):
     former = c.lst().copy()
     c.setList(alternationsReverse(c.lst()))
     Event.update('method', former, c.lst())
     print(c.lst())
Beispiel #10
0
def deleteMenu(c):
    pos = int(input('Enter position of the element you want to delete: '))
    former = c.lst().copy()
    c.lst().pop(pos)
    Event.update('add', former, pos, c.lst())
    print('Item succesfully deleted!')
Beispiel #11
0
    log.info('==========================================================')
    log.info('Starting up')

    game = {
        'mode': JUNGLE,
    }

    net = network.Network()
    GPIO = GPIO.InOut(game)

    v = volume.VolumeCtrl(GPIO)
    jungle = jungleMode.Jungle(net)
    puzzle = puzzleMode.Puzzle(net, GPIO)

    btn = Button()
    btn.observe('puzzleClick', btn.puzzleClick)
    btn.observe('jungleClick', btn.jungleClick)
    btn.observe('repeatClick', btn.repeatClick)
    btn.observe('skipClick', btn.skipClick)
    btn.observe('changeDifficulty', btn.changeDifficulty)
    btn.observe('shutdown', btn.shutdown)
    btn.observe('resetWifi', btn.resetWifi)

    Event('jungleClick', 0)

    while True:
        threading.Thread(target=v.mainVolume_RW).start()
        getInputs()
        oscData = getOscData()
        updateGame(oscData)