From 40fc05c050f00a83f64b3ea45ceca56d4942dd7a Mon Sep 17 00:00:00 2001 From: Evgeniy Kozlov Date: Sun, 22 Oct 2023 23:46:54 +0300 Subject: [PATCH] tools: small fixes, add appraise-deck.sh --- data/bges.txt | 4 +-- data/download-all.sh | 4 +-- tools/appraise-deck.sh | 72 ++++++++++++++++++++++++++++++++++++++ tools/appraise-gauntlet.sh | 3 ++ tools/reorder-gauntlet.sh | 3 ++ tools/tu-deck-grabber.py | 5 +-- tools/tuo.sh | 3 ++ 7 files changed, 88 insertions(+), 6 deletions(-) create mode 100755 tools/appraise-deck.sh diff --git a/data/bges.txt b/data/bges.txt index a3c3e4ff..35aac70c 100644 --- a/data/bges.txt +++ b/data/bges.txt @@ -12,7 +12,7 @@ Combined Arms: Enhance All Coalition 10; Rally all 10; Enfeeble all 10; Strike a //Combined Arms: Rally all 10; Enfeeble all 10; Strike all 10 Inspired: Rally all 25 Blightblast: Enfeeble all 35 -Emergency Aid: Heal All 10; Protect all 10; Enhance all Absorb 125 +Emergency Aid: Enhance all Absorb 125; Heal All 10; Protect all 10 Landmine: Entrap all 25; Weaken all 25 Triage: Enhance all Fortify 35; Heal 25; Protect 25 //Triage: Heal 25; Protect 25 @@ -162,4 +162,4 @@ Blood Lust: Enhance all Leech 2 Blood Frenzy: Enhance all Leech 3 Noxious Fog: Enhance all Poison 1 Noxious Mist: Enhance all Poison 2 -Noxious Haze: Enhance all Poison 3 \ No newline at end of file +Noxious Haze: Enhance all Poison 3 diff --git a/data/download-all.sh b/data/download-all.sh index 631dc44a..45cab1ac 100755 --- a/data/download-all.sh +++ b/data/download-all.sh @@ -3,8 +3,8 @@ curr_dir=$(dirname "$0") olds_dir="$curr_dir/old-xmls.d" -#BASE_URL="https://mobile.tyrantonline.com/assets/" -BASE_URL="https://mobile-dev.tyrantonline.com/assets/" +BASE_URL="https://mobile.tyrantonline.com/assets/" +#BASE_URL="https://mobile-dev.tyrantonline.com/assets/" FILES=( fusion_recipes_cj2.xml missions.xml diff --git a/tools/appraise-deck.sh b/tools/appraise-deck.sh new file mode 100755 index 00000000..69f554e1 --- /dev/null +++ b/tools/appraise-deck.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +#SUFFIX="virulence" +#SUFFIX="avenge" +#SUFFIX="flux" +#SUFFIX="SF_SF_x_TC" +INPUT_FILE="$1" +OUTPUT_FILE="${2:-$(dirname "$1")/appraised-deck${SUFFIX:+.${SUFFIX}}.$(basename "$1")}" + +declare -i ITERS=5000 + +DECK="Razogoth Immortal, Krellus' Nexus, Infernal Diabolic, Megalift Foundry, Cleave Condemner, Megalift Foundry, Gaia's Specialist, Armada Xonar, Cleave Condemner, Mephalus Gorge, Infernal Diabolic, Armada Xonar" + +TUO_OPTIONS=( + brawl + -t 4 + #-e "Virulence" + no-db + no-ml +) + +TMP_DIR="/tmp" +TMP_FILE_PREFIX="." +TMP_FILE_SUFFIX=".$(basename "$1" ".txt").appraising-deck~" + +die() { + echo " ** ERROR ** $@" 1>&2 + exit 255 +} + +msg() { + echo "[$(date +%F' '%T)] $@" +} + +# check input file +[[ -f $INPUT_FILE ]] || die "Bad input file (no such file or file isn't regular): $INPUT_FILE" + +# reset output file or die +:> "$OUTPUT_FILE" || die "Can't open file for writing: $OUTPUT_FILE" + +# show start message +msg "Starting appraise deck (reorder per enemy) for gauntlet $INPUT_FILE (output to $OUTPUT_FILE)" + +IFS=$'\n' +while read -r line; do + if [[ $line =~ (^[a-zA-Z0-9_.+-]+[^:]+):\ ([^/].+[^/])$ ]]; then + user="${BASH_REMATCH[1]}" + deck="${BASH_REMATCH[2]}" + msg "Reordering deck against $user ..." + TMP_FILE="${TMP_DIR}/${TMP_FILE_PREFIX}${user}${SUFFIX:+.${SUFFIX}}${TMP_FILE_SUFFIX}" + [[ -f $TMP_FILE ]] && die "Temporary file already exists: $TMP_FILE" + tuo.sh "$DECK" "$deck" "${TUO_OPTIONS[@]}" reorder $ITERS &> "$TMP_FILE" & + declare -i tuo_pid=$! + wait $tuo_pid + result_line=$(tail -n3 "$TMP_FILE" | fgrep 'Optimized Deck:' ) + if [[ $result_line =~ ^Optimized\ Deck:.*\ \(([0-9.]+)%\ win\)\ ([0-9.]+)(\ \[([0-9.]+)\ per\ win\])?:\ ([^:]+)$ ]]; then + opt_winrate="${BASH_REMATCH[1]}" + opt_score="${BASH_REMATCH[2]}" + opt_win_score="${BASH_REMATCH[4]}" + opt_deck="${BASH_REMATCH[5]}" + echo "$(printf "%-8s %-8s %-8s" "$opt_winrate" "$opt_score" "$opt_win_score") $user: $opt_deck" >> "$OUTPUT_FILE" + rm -rf "$TMP_FILE" + else + die "Failed at $user (deck: $deck), see $TMP_FILE for more details" + fi + else + echo "$line" >> "$OUTPUT_FILE" + fi +done < "$INPUT_FILE" + +# show finish message +msg "Appraising deck finished" diff --git a/tools/appraise-gauntlet.sh b/tools/appraise-gauntlet.sh index 1f88bcc3..102c6332 100755 --- a/tools/appraise-gauntlet.sh +++ b/tools/appraise-gauntlet.sh @@ -46,6 +46,9 @@ TUO_OPTIONS=( # enemy is defender (in surge mode) / with IA(2) against MF / use valid custom BGEs! #ee "Tartarian Gift" #ye "Progenitor Tech" + + no-db + no-ml ) TMP_DIR="/tmp" diff --git a/tools/reorder-gauntlet.sh b/tools/reorder-gauntlet.sh index 17f55e63..fd2e9ef8 100755 --- a/tools/reorder-gauntlet.sh +++ b/tools/reorder-gauntlet.sh @@ -39,6 +39,9 @@ TUO_OPTIONS=( # enemy is defender (in surge mode) / with IA(2) against MF / use valid custom BGEs! #ee "Divine Blessing" #ye "Divine Blessing" + + no-db + no-ml ) TMP_DIR="/tmp" diff --git a/tools/tu-deck-grabber.py b/tools/tu-deck-grabber.py index b61e560b..7fed130e 100755 --- a/tools/tu-deck-grabber.py +++ b/tools/tu-deck-grabber.py @@ -666,10 +666,11 @@ def doHuntAndEnrichUserDb(client): if user_db._dirty: user_db._dirty = False tmp_udb_fname = udb_fname + '~' + old_udb_fname = udb_fname + '.old' with open(tmp_udb_fname, 'wb') as f: pickle.dump(user_db, f) if (os.path.exists(udb_fname)): - os.remove(udb_fname) + os.renames(udb_fname, old_udb_fname) os.renames(tmp_udb_fname, udb_fname) print('INFO: user-db: synced to disk: {} (total {} entries)'.format(udb_fname, user_db.size())) @@ -847,7 +848,7 @@ def doGrabLastDeck(client): continue if args[0] == 'salvage': if len(args) < 2: - print('USAGE: salvage [CARD_ID:COUNT]') + print('USAGE: salvage [COUNT]') continue if args[1] == 'commons': rsp = client.salvageL1CommonCards() diff --git a/tools/tuo.sh b/tools/tuo.sh index dbe7add8..49b72512 100755 --- a/tools/tuo.sh +++ b/tools/tuo.sh @@ -38,6 +38,9 @@ if (( ! found_ownedcards )) && (( TUO_RESTRICT_OWNEDCARDS )); then ARGS+=("-o=${TUO_ROOT}/data/ownedcards_${TUO_LOGIN}.txt") fi +## ignore db/ml +ARGS+=(no-db no-ml) + ## append globally exported tuo flags ARGS+=($TUO_FLAGS)