Skip to content

Commit

Permalink
Merge pull request TotalAwesome#5 from lvu22292718/main
Browse files Browse the repository at this point in the history
Fix upgrade limit
  • Loading branch information
TotalAwesome authored Jul 17, 2024
2 parents 35c66f0 + c82f862 commit 109f190
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
25 changes: 9 additions & 16 deletions bots/tapcoins/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from bots.tapcoins.strings import HEADERS, URL_INIT, URL_LOGIN, URL_CARDS_CATEGORIES, URL_CARDS_LIST, \
URL_CARDS_UPGRADE, URL_LUCKY_BOUNTY, MSG_NO_CARDS_TO_UPGRADE, \
MSG_CARD_UPGRADED, MSG_NOT_ENOUGH_COINS, MSG_CARD_UPGRADED_COMBO, URL_DAILY, URL_DAILY_COMPLETE, \
MSG_LOGIN_BONUS_COMPLETE, URL_USER_INFO, MSG_UPGRADING_CARDS, MSG_UPGRADE_COMPLETE
MSG_LOGIN_BONUS_COMPLETE, URL_USER_INFO, MSG_UPGRADING_CARDS, MSG_UPGRADE_COMPLETE, MSG_MAX_UPGRADES_REACHED

DEFAULT_EST_TIME = 60 * 45

Expand Down Expand Up @@ -70,9 +70,14 @@ def upgrade_cards(self):
if BUY_UPGRADES:
self.log(MSG_UPGRADING_CARDS)

upgrades_left = UPGRADES_COUNT
upgraded_cards = 0
upgrades_count = UPGRADES_COUNT if UPGRADES_COUNT != 0 else 99999

while True:
if upgraded_cards >= upgrades_count:
self.log(MSG_MAX_UPGRADES_REACHED.format(limit=upgrades_count))
break

cards = self.get_cards()
if not cards:
self.log(MSG_NO_CARDS_TO_UPGRADE)
Expand All @@ -85,31 +90,19 @@ def upgrade_cards(self):
upgraded = False

for card in cards:
if upgrades_left == 0:
# Если upgrades_count равен 0, прокачиваем на весь баланс
while self.balance >= card['upgrade_cost']:
self.post(URL_CARDS_UPGRADE, {'taskId': card['id'], '_token': self.token})
self.get_balance() # Обновляем баланс после каждой прокачки
self.log(MSG_CARD_UPGRADED.format(card['name']))
upgraded = True
break

if self.balance >= card['upgrade_cost']:
self.post(URL_CARDS_UPGRADE, {'taskId': card['id'], '_token': self.token})
upgraded = True
upgrades_left -= 1

self.log(MSG_CARD_UPGRADED.format(card['name']))
upgraded_cards += 1

break

if not upgraded:
self.log(MSG_NOT_ENOUGH_COINS)
break

if upgrades_left == 0:
self.log("Достигнуто максимальное количество прокачек")
break

self.log(MSG_UPGRADE_COMPLETE)

def get_cards(self):
Expand Down
2 changes: 1 addition & 1 deletion bots/tapcoins/config.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
BUY_UPGRADES = True # Покупать ли апгрейды
UPGRADES_COUNT = 0 # Количество апгрейдов за раз, если 0 - то покупаем на весь баланс
UPGRADES_COUNT = 3 # Количество апгрейдов за раз, если 0 - то покупаем на весь баланс
1 change: 1 addition & 0 deletions bots/tapcoins/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@
MSG_NOT_ENOUGH_COINS = "Не хватает монет для прокачки"
MSG_CARD_UPGRADED_COMBO = "Прокачана карта для комбо {}"
MSG_LOGIN_BONUS_COMPLETE = "Бонус за вход {step} получен"
MSG_MAX_UPGRADES_REACHED = "Достигнут лимит прокачки {limit}"
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'iceberg',
'hamster_kombat',
'zavod',
'tapcoinsbot',
'tapcoins',
]

try:
Expand Down

0 comments on commit 109f190

Please sign in to comment.