diff --git a/tools/tu-deck-grabber.py b/tools/tu-deck-grabber.py index f82589b6..a7201ab2 100755 --- a/tools/tu-deck-grabber.py +++ b/tools/tu-deck-grabber.py @@ -8,7 +8,6 @@ import urllib import urllib3 import json -import readline import atexit import certifi import configparser @@ -263,7 +262,7 @@ def formatUnitSkill(skill): xml_file_hash = int(st.st_mtime * 0x1b1 + st.st_size) & 0xFFFFFFFF print('INFO: fusion recipes xml file: {} (hash: 0x{:08x})'.format(xml_fname, xml_file_hash)) - dump_fname = re.sub('\.xml$', '.pck', xml_fname) + dump_fname = re.sub(r'\.xml$', '.pck', xml_fname) if os.path.exists(dump_fname): with open(dump_fname, 'rb') as f: xmagic = pickle.load(f) @@ -321,7 +320,7 @@ def recp_get_attr(attr, castType=None, defValue=None): xml_file_hash = int(((st.st_mtime * 31) + i) * 31 + st.st_size) & 0xFFFFFFFF print('INFO: next cards xml file: {} (hash: 0x{:08x})'.format(xml_fname, xml_file_hash)) - dump_fname = re.sub('\.xml$', '.pck', xml_fname) + dump_fname = re.sub(r'\.xml$', '.pck', xml_fname) if os.path.exists(dump_fname): with open(dump_fname, 'rb') as f: xmagic = pickle.load(f) @@ -862,8 +861,8 @@ def doGrabLastDeck(client): if config.getboolean('CORE', 'output_eds'): out += 'eds{:02d}.'.format(enemy_size) if config.getboolean('CORE', 'output_guild'): - out += re.sub('(?a)[^\w]', '_', enemy_guild_name) + '.' - out += re.sub('(?a)[^\w]', '_', enemy_name) + out += re.sub(r'(?a)[^\w]', '_', enemy_guild_name) + '.' + out += re.sub(r'(?a)[^\w]', '_', enemy_name) if config.getboolean('CORE', 'output_missing'): missing_cards = enemy_size - enemy_played_cards_count if (missing_cards > 0): @@ -890,11 +889,20 @@ def doGrabLastDeck(client): print('Grabbed deck: ' + out) ## configure readline + +_win32 = False +if sys.platform == 'win32': + _win32 = True + import pyreadline3 as readline +else: + import readline + histfile = os.path.join(os.path.expanduser('~'), '.tu_deck_grabber_history') if os.path.exists(histfile): readline.read_history_file(histfile) -readline.set_history_length(1000) -readline.read_init_file() +if not _win32: + readline.set_history_length(1000) + readline.read_init_file() atexit.register(readline.write_history_file, histfile) @@ -947,7 +955,7 @@ def _up(x_id): print(f'Upgrade card: {_cn(x_id)} => {_cn(target_cid)}') rsp = client.upgradeCard(x_id, in_deck = in_deck) if (not rsp): - print(f'ERROR: failed to upgrade {_cn(x_id)}') + print(f'ERROR: failed to upgrade {_cn(x_id)} (deps: {dep_list})') return None print('SP: {}'.format(rsp['user_data']['salvage'])) return x_id @@ -962,11 +970,11 @@ def _up(x_id): # it's 1st level, check fusion receipt else: if (not is_neocyte_dual) and (target['low_id'] != target_cid): - print(f'ERROR: DB: is not low level id: {_cn(target_cid)}') + print(f'ERROR: DB: is not low level id: {_cn(target_cid)} (deps: {dep_list})') return None from_cards = fusion_from_cards.get(target_cid, None) if (not from_cards): - print(f'ERROR: No owned card {_cn(target_cid)}') + print(f'ERROR: No owned card {_cn(target_cid)} (deps: {dep_list})') return None from_cids = [] for d_id, count in from_cards.items(): @@ -980,7 +988,7 @@ def _up(x_id): prev_xcnt = xcnt xcnt = int(client.lastUserCards[sdid]['num_owned'] or 0) if (prev_xcnt == xcnt): - print(f'ERROR: num owned is not changed for {sdid}') + print(f'ERROR: num owned is not changed for {sdid} (deps: {dep_list})') return None print(f'Fuse card: {from_cids} => {_cn(target_cid)}') rsp = client.fuseCard(target_cid) @@ -1307,7 +1315,12 @@ def write_dump_safe(name, data, append = False): break elif (args[0] == 'init'): client.getUserAccount() - client.runInit() + ud = client.runInit()['user_data'] + print(f' << player [{ud["name"]}] Lv. {ud["level"]} >>') + print(f' * Gold: {ud["money"]}') + print(f' * Energy: {ud["energy"]}') + print(f' * Stamina: {ud["stamina"]}') + print(f' * SP: {ud["salvage"]}') elif (args[0] == 'grab'): doGrabLastDeck(client) elif (args[0] == 'hunt'):