Example #1
0
def drop_gold_callback():
    # Get the position before opening inventory, to ensure mouse returns correctly
    original_pos = mouse.get_position()
    keyboard.send(INVENTORY_HOTKEY)
    util.sleep_ms(1)
    click_and_return(GOLD_POS[windowed_flag])
    keyboard.send('9, 9, 9, 9, 9, 9, 9, enter')
    keyboard.send(INVENTORY_HOTKEY)
    mouse.move(*original_pos)
    return 'Dropped gold'
Example #2
0
 def print_grid(self):
     sleep_ms(200)
     print('\n' * 80)
     self.grid[(0, 0)] = 'X'
     x_coord = sorted([x for x, y in self.grid])
     y_coord = sorted([y for x, y in self.grid])
     for x in range(x_coord[0], x_coord[-1] + 1):
         for y in range(y_coord[0], y_coord[-1] + 1):
             print(self.grid[(x, y)] if (x, y) in self.grid else ' ',
                   end='')
         print()
Example #3
0
 def onNoteOn(self, port, msg):
     if port == midi.standaloneInPort():
         if not self.page.trackPage.midiTrackMode:
             # trigger slices
             selectedTrack = settings['drumPage']['selectedAudioTrack']
             channel = settings['trackChannels']['audioTrackChannel'][
                 selectedTrack]
             if channel is None:
                 return
             if msg.velocity == 0:
                 outMsg = mido.Message('note_off',
                                       channel=channel,
                                       note=self._audioTrackToNote(),
                                       velocity=msg.velocity)
                 midi.midiOutPort().send(outMsg)
             else:
                 outMsg = mido.Message('control_change',
                                       channel=channel,
                                       control=17,
                                       value=self._noteToSlice(
                                           msg.note))
                 midi.midiOutPort().send(outMsg)
                 util.sleep_ms(60)
                 outMsg = mido.Message('note_on',
                                       channel=channel,
                                       note=self._audioTrackToNote(),
                                       velocity=msg.velocity)
                 midi.midiOutPort().send(outMsg)
         else:
             # pass the notes through
             selectedTrack = settings['drumPage']['selectedMidiTrack']
             channel = settings['trackChannels']['audioMidiChannel'][
                 selectedTrack]
             if channel is None:
                 return
             outMsg = msg.copy(channel=channel)
             midi.midiOutPort().send(outMsg)
Example #4
0
def move_item_to_cube(coords):
    # Grab item
    mouse.move(*coords)
    mouse.click()
    sleep_ms(50)
    # Place in cube
    mouse.move(*median.get_coords('cube'))
    sleep_ms(50)
    mouse.click()
    sleep_ms(50)
Example #5
0
def transmute_get_stats(size=''):
    # Initialize post-transmute item location
    item_coords = (0, 0)
    if (size == 'large'):
        item_coords = median.get_coords('cubetopleft')
    elif (size == 'small'):
        item_coords = median.get_coords('cubebotright')
    else:
        raise ValueError(
            "Please give a size parameter, either 'large' or 'small'")
    # Transmute
    mouse.move(*median.get_coords('transmute'))
    sleep_ms(10)
    mouse.click()
    sleep_ms(10)
    # Mouseover item
    mouse.move(*item_coords)
    sleep_ms(100)
    # Get text
    return median.get_item_text()
Example #6
0
def craft():
   FLAT_DMG_THRESH = 175
   ENH_DMG_THRESH = 120
   print('\n\nStarting crafting loop...\n\n')
   # Loop until we're done, each iteration is one character
   done = False
   while (not done):
      # Track best average damage per character
      best_avg_flat_dmg = 0
      corr_enh_dmg = 0
      # Restore character
      character = backrest.restore_recent(BACKUP_ALL_OVERWRITTEN_FILES)
      if (VERBOSE): print('Restored', character)
      # Create singleplayer game
      mouse.move(*median.get_coords('singleplayer'))
      mouse.click()
      keyboard.send('enter')
      if (VERBOSE): print('Entering new game...')
      median.wait_enter_game()
      if (VERBOSE): print('Entered game')
      # Open inventory
      keyboard.send('i')
      time.sleep(.1)
      # Loop through each shrine
      shrine_size = 1, 2 # width, height
      for i, coords in enumerate(median.inv_iter(*shrine_size)):
         if done: break
         # Skip first two "shrines", these are where the cube is
         if (i < 2): continue
         # Place shrine into cube
         #   1) Grab shrine
         mouse.move(*coords)
         mouse.click()
         sleep_ms(50)
         #   2) Place in cube
         mouse.move(*median.get_coords('cube'))
         sleep_ms(50)
         mouse.click()
         sleep_ms(50)
         #   3) Open cube only if first shrine
         if (i == 2):
            mouse.right_click()
            sleep_ms(50)
         # Loop through a shrine's 10 charges
         for charge in range(10):
            # Ensure that if the window loses focus, loop exits
            if (not util.check_active_window()):
               print('Game window lost focus, exiting crafting loop.')
               done = True
               break
            # Transmute
            mouse.move(*median.get_coords('transmute'))
            sleep_ms(10)
            mouse.click()
            sleep_ms(10)
            # Mouseover item
            mouse.move(*median.get_coords('cubetopleft'))
            sleep_ms(100)
            # Get text
            item_stats = median.get_item_text()
            enh_dmg = item_parser.get_enhanced_damage(item_stats)
            avg_flat_dmg = item_parser.get_flat_damage(item_stats)
            if (avg_flat_dmg > best_avg_flat_dmg):
               best_avg_flat_dmg = avg_flat_dmg
               corr_enh_dmg = enh_dmg
            # log_string = '=========================\n\n' + item_stats + '\n'
            # util.log(log_string, 'item_log.txt')
            sleep_ms(100)
            # Check if we are done
            if ( (enh_dmg >= ENH_DMG_THRESH) and (avg_flat_dmg >= FLAT_DMG_THRESH) ):
               done = True
               break
         # End of shrine charges loop
         # For testing, break early
         # if (i == 3): break
      # End of shrines loop
      # Print out best average damage for this character
      print('Finished this character')
      print('   best average flat damage: ', best_avg_flat_dmg, sep='')
      print('   corresponding enh damage: ', corr_enh_dmg, '%', sep='')
      print()
      # Exit game
      if (not done):
         keyboard.send('esc')
         sleep_ms(150)
         keyboard.send('esc')
         mouse.move(*median.get_coords('exit'))
         if (VERBOSE): print('Exiting game...')
         mouse.click()
         sleep_ms(100)
         median.wait_exit_game()
         if (VERBOSE): print('Exited game...')
         sleep_ms(100)
      # Ensure that if the window loses focus, loop exits
      if (not util.check_active_window()):
         print('Game window lost focus, exiting crafting loop.')
         break
   # End of while loop
   ##
   # Print out stats
   print('Best average flat damage:', best_avg_flat_dmg)
   return 'Completed crafting'
Example #7
0
def exit_game():
    keyboard.send('esc')
    mouse.move(*median.get_coords('exit'))
    mouse.click()
    sleep_ms(100)
    median.wait_exit_game()
Example #8
0
def close_inventory():
    keyboard.send('esc')
    sleep_ms(150)
Example #9
0
def open_cube():
    mouse.move(*median.get_coords('cube'))
    sleep_ms(50)
    mouse.right_click()
    sleep_ms(50)
Example #10
0
def open_inventory(inventory_hotkey='i'):
    keyboard.send(inventory_hotkey)
    sleep_ms(100)
Example #11
0
def setCurrentPage(newPage):
    g['currentPage'] = newPage
    util.sleep_ms(100)
    newPage.uiDraw()