Skip to content

Commit

Permalink
merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Almtr committed Aug 7, 2020
2 parents 3afea40 + e732d0c commit a39c482
Show file tree
Hide file tree
Showing 12 changed files with 523 additions and 17 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ For more information, see the [wiki](https://github.com/Almtr/joycontrol-plugins
- RepeatA
- SimpleMacro
- Pokemon Sword and Shield Plugins
- TimeSkipGlitch
- BuyBargains
- GetBerries
- GetFeathers
- GetWatts
- TryLotoID
- AutoRaid
- CombineHoneyAndCandy
- HatchEggs
- LoopBattleTower
- LoopTournament
Expand Down
12 changes: 10 additions & 2 deletions README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ $ git clone https://github.com/Almtr/joycontrol-plugins.git
- Aボタン連打(RepeatA)
- 簡易マクロ(SimpleMacro)
- ポケモンソード・シールドプラグイン
- 日付変更バグ(TimeSkipGlitch)
- ほりだしもの自動購入(BuyBargains)
- きのみ自動回収(GetBerries)
- ハネ自動回収(GetFeathers)
- ワット自動回収(GetWatts)
- 自動IDくじ(TryLotoID)
- マックスレイドバトル周回(AutoRaid)
- あまいミツとふしぎなアメの合成(CombineHoneyAndCandy)
- 自動タマゴ孵化(HatchEggs)
- バトルタワー周回(LoopBattleTower)
- トーナメント周回(LoopTournament)
- トーナメント周回(LoopBattleTower)
- バトルタワー周回(LoopTournament)
- ポケモン自動逃がし(ReleasePokemons)
22 changes: 22 additions & 0 deletions pokemon-swsh/AutoRaid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import logging
from JoycontrolPlugin import JoycontrolPlugin

logger = logging.getLogger(__name__)

class AutoRaid(JoycontrolPlugin):
async def run(self):
logger.info('Auto Raid Plugin loaded!')

while True:
await self.button_push('a') # Select the "Fight" button
await self.wait(0.1)
await self.button_push('up')
await self.wait(0.3)
await self.button_push('a') # Select the "Next" button
await self.wait(0.1)
await self.button_push('a')
await self.wait(0.3)
await self.button_push('a')
await self.wait(0.1)
await self.button_push('up', press_time_sec=3.0)
await self.wait(0.3)
89 changes: 89 additions & 0 deletions pokemon-swsh/CombineHoneyAndCandy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import logging
import datetime
from JoycontrolPlugin import JoycontrolPlugin, JoycontrolPluginError

logger = logging.getLogger(__name__)

class CombineHoneyAndCandy(JoycontrolPlugin):
def __init__(self, controller_state, options):
super().__init__(controller_state, options)

if options is None or len(options) < 2:
raise JoycontrolPluginError('Plugin option not set. Please use "--plugin-options <honey_num> <rare_candy_num>".')

self.honey_num = int(options[0])
self.rare_candy_num = int(options[1])


async def combine_items_3honey_1candy(self):
await self.button_push('a')
await self.wait(0.3)
await self.button_push('a') # Combine items
await self.wait(0.3)
await self.button_push('a')
await self.wait(2.0)
await self.button_push('a')
await self.wait(3.0)

await self.button_push('right') # Go to the "Honey"
await self.wait(0.5)

# Select three berries
await self.button_push('a')
await self.wait(0.3)
await self.button_push('a')
await self.wait(0.3)
await self.button_push('a')
await self.wait(0.3)

await self.button_push('left') # Go to the "Rare Candy"
await self.wait(0.5)

# Select a candy
await self.button_push('a')
await self.wait(0.8)

await self.button_push('a') # Yes
await self.wait(1.5)

# Close messages
await self.button_push('a')
await self.wait(1.5)

await self.button_push('a')
await self.wait(5.0)

await self.button_push('a')
await self.wait(5.0)

await self.button_push('a')
await self.wait(0.8)
await self.button_push('a')
await self.wait(0.8)


def __calc_total_count(self, honey, rare_candy):
max_honey = int(honey / 3)
max_candy = rare_candy

if max_honey < max_candy:
return max_honey
return max_candy


async def combine_items(self, total):
for count in range(total):
await self.combine_items_3honey_1candy()
logger.info(f'{count + 1}/{total} items were combined.')


async def run(self):
logger.info('Combine three honeys and one candy Plugin loaded!')

total = self.__calc_total_count(self.honey_num, self.rare_candy_num)

now = datetime.datetime.now()
end_datetime = now + datetime.timedelta(seconds=total * 25)
logger.info(f'Estimated end time: {end_datetime}.')

await self.combine_items(total)
2 changes: 1 addition & 1 deletion pokemon-swsh/HatchEggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,5 @@ async def run(self):
hatching_time = self.__calc_hatching_time(self.egg_cycle)
end_datetime = self.__calc_end_datetime(self.egg_cycle, self.total_eggs)

logger.info(f'Estimated hatching completion time: {end_datetime}.')
logger.info(f'Estimated end time: {end_datetime}.')
await self.hatch_eggs(self.total_eggs, hatching_time)
69 changes: 55 additions & 14 deletions pokemon-swsh/ReleasePokemons.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import logging
from JoycontrolPlugin import JoycontrolPlugin
import datetime
from JoycontrolPlugin import JoycontrolPlugin, JoycontrolPluginError

logger = logging.getLogger(__name__)

class ReleasePokemons(JoycontrolPlugin):
def __init__(self, controller_state, options):
super().__init__(controller_state, options)

self.box = 1
if options is not None:
self.box = int(options[0])

if not 1 <= self.box <= 32:
raise JoycontrolPluginError('Number of boxes must be in 1-32.')


async def release_pokemon(self):
# Select a pokemon
await self.button_push('a')
Expand All @@ -29,6 +41,7 @@ async def release_pokemon(self):
await self.button_push('a')
await self.wait(0.3)


async def open_pokemon_box(self):
# Open menu
await self.button_push('x')
Expand All @@ -43,24 +56,52 @@ async def open_pokemon_box(self):
await self.wait(2.0)


async def select_next_pokemon(self, release_num):
num = release_num % 60

# Go to the next box
if num == 29 or num == 59:
await self.button_push('r')

# Go to the next line
elif num % 12 == 5 or num % 12 == 11:
if num < 30:
await self.button_push('down') # Odd boxes
else:
await self.button_push('up') # Even boxes

# Odd rows move to the right
elif num % 12 < 5:
await self.button_push('right')

# Even rows move to the left
elif num % 12 < 11:
await self.button_push('left')

await self.wait(0.5)

async def release_pokemons(self, total):
for num in range(total):
await self.release_pokemon()
logger.info(f'{num + 1}/{total} pokemons released.')
await self.select_next_pokemon(num)


async def run(self):
logger.info('Release Pokemons Plugin loaded!')

release_num = self.box * 30

now = datetime.datetime.now()
end_datetime = now + datetime.timedelta(seconds=release_num * 5 + 16)
logger.info(f'Estimated end time: {end_datetime}.')

logger.info('Reset corsor position.')
for _ in range(15):
for _ in range(12): # Cancel all
await self.button_push('b')
await self.wait(0.3)
await self.open_pokemon_box()

logger.info('Start releasing pokemons in a box')
for _ in range(5): # row
for _ in range(6): # column
await self.release_pokemon()
await self.button_push('right')
await self.wait(0.3)

await self.button_push('down')
await self.wait(0.3)
await self.button_push('right')
await self.wait(0.3)
logger.info('Finish releasing pokemons in a box')
logger.info('Start releasing pokemons.')
await self.release_pokemons(release_num)
logger.info('Finish releasing pokemons.')
35 changes: 35 additions & 0 deletions pokemon-swsh/TimeSkipGlitch/BuyBargains.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import logging
import os
import sys

sys.path.append(os.path.abspath(os.path.dirname(__file__)))
from TimeSkipBasePlugin import TimeSkipBasePlugin

logger = logging.getLogger(__name__)

class BuyBargains(TimeSkipBasePlugin):
async def run(self):
logger.info('Buy Bargains Plugin loaded!')

lap = 1
while True:
logger.info(f'buy {lap} items')
lap += 1

# Talk to clerk
await self.button_push('a')
await self.wait(0.8)
await self.button_push('a')
await self.wait(0.8)
await self.button_push('a')
await self.wait(0.8)
await self.button_push('a')
await self.wait(0.8)

# Close the all messages
for _ in range(18):
await self.button_push('b')
await self.wait(0.3)

await self.change_year()
await self.wait(1.0)
33 changes: 33 additions & 0 deletions pokemon-swsh/TimeSkipGlitch/GetBerries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import logging
import os
import sys

sys.path.append(os.path.abspath(os.path.dirname(__file__)))
from TimeSkipBasePlugin import TimeSkipBasePlugin

logger = logging.getLogger(__name__)

class GetBerries(TimeSkipBasePlugin):
async def run(self):
logger.info('Get Berries Plugin loaded!')

lap = 1
while True:
logger.info(f'{lap} lap')
lap += 1

# Shake a tree
await self.button_push('a')
await self.wait(0.8)
await self.button_push('a')
await self.wait(0.8)
await self.button_push('a')
await self.wait(0.8)

# Close the all messages
for _ in range(20):
await self.button_push('b')
await self.wait(0.3)

await self.change_year()
await self.wait(1.0)
Loading

0 comments on commit a39c482

Please sign in to comment.