-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
1372 lines (1184 loc) · 48.8 KB
/
Taskfile.yml
File metadata and controls
1372 lines (1184 loc) · 48.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Taskfile.yml for Clash Royale API project
# Requires: https://taskfile.dev/installation/
version: '3'
vars:
PROJECT_NAME: clash-royale-api
DATA_DIR: data
TEST_PLAYER_TAG: '#PLAYERTAG'
CR_API_BIN: bin/cr-api
dotenv: ['.env']
binary_precondition: &binary_precondition
- sh: test -x {{.CR_API_BIN}}
msg: "cr-api binary not found. Build it with: task build"
tasks:
# Basic Tasks
default:
desc: Show available tasks
cmds:
- task --list
# Project Setup
setup:
desc: Set up the development environment
cmds:
- echo "Setting up development environment..."
- task: build
- echo "Creating data directories..."
- mkdir -p {{.DATA_DIR}}/{players,clans,analysis,static,reference}
- mkdir -p scripts
- echo "Copying example .env file..."
- test -f .env || cp .env.example .env 2>/dev/null || echo "No .env.example found, creating basic .env"
- test -f .env || echo -e "CLASH_ROYALE_API_TOKEN=your_api_token_here\nDATA_DIR={{.DATA_DIR}}" > .env
- echo "✅ Setup complete!"
- echo "Please edit .env file with your API token"
install:
desc: Build Go binaries
summary: |
Alias for 'task build'. Builds Go binaries for local development.
cmds:
- task: build
build:
desc: Build Go CLI binaries for local development
cmds:
- echo "Building Go binaries for local development..."
- mkdir -p bin
- go mod download
- |
VERSION=$(git describe --tags --always 2>/dev/null || echo 'dev')
COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo 'unknown')
BUILD_TIME=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
go build \
-ldflags="-s -w -X main.version=$VERSION -X main.commit=$COMMIT -X main.buildTime=$BUILD_TIME" \
-o bin/cr-api ./cmd/cr-api
- echo "✅ Go binary built successfully!"
# Basic Player Operations
run:
desc: Analyze a player's collection using the Go CLI
summary: |
Analyze a player's card collection and display upgrade needs using the Go binary
Args:
player: Player tag to analyze (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
CLEAN_TAG="${PLAYER_TAG#\#}"
echo "Analyzing $CLEAN_TAG with Go CLI..."
{{.CR_API_BIN}} analyze --tag "$CLEAN_TAG" --data-dir "{{.DATA_DIR}}"
preconditions: *binary_precondition
run-with-save:
desc: Run Go CLI analysis and save results to JSON files
summary: |
Analyze a player and save the results to JSON files using the Go binary
Args:
player: Player tag to analyze (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
CLEAN_TAG="${PLAYER_TAG#\#}"
echo "Analyzing and saving results for $CLEAN_TAG..."
{{.CR_API_BIN}} analyze --tag "$CLEAN_TAG" --data-dir "{{.DATA_DIR}}" --save
preconditions: *binary_precondition
# Export Operations
export-csv:
desc: Export player and reference data to CSV using the Go CLI
summary: |
Export player's card collection and other data to CSV using the Go binary
Args:
player: Player tag to analyze (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
CLEAN_TAG="${PLAYER_TAG#\#}"
echo "Exporting player data for $CLEAN_TAG to CSV..."
{{.CR_API_BIN}} player --tag "$CLEAN_TAG" --data-dir "{{.DATA_DIR}}" --export-csv --save
echo "Exporting card database to CSV..."
{{.CR_API_BIN}} cards --data-dir "{{.DATA_DIR}}" --export-csv
preconditions: *binary_precondition
export-all:
desc: Export all available data types for a player using the Go CLI
summary: |
Export player data, card database, and save analysis results using the Go binary
Args:
player: Player tag to analyze (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
CLEAN_TAG="${PLAYER_TAG#\#}"
echo "Exporting full dataset for $CLEAN_TAG..."
{{.CR_API_BIN}} player --tag "$CLEAN_TAG" --data-dir "{{.DATA_DIR}}" --chests --export-csv --save
{{.CR_API_BIN}} cards --data-dir "{{.DATA_DIR}}" --export-csv
{{.CR_API_BIN}} analyze --tag "$CLEAN_TAG" --data-dir "{{.DATA_DIR}}" --save
preconditions: *binary_precondition
export-player:
desc: Export player profile data to CSV
summary: |
Export player profile information to CSV using the export subcommand
Args:
player: Player tag (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Exporting player data for $CLEAN_TAG..."
{{.CR_API_BIN}} export player --tag "$CLEAN_TAG"
preconditions: *binary_precondition
export-analysis:
desc: Export card collection analysis to CSV
summary: |
Export detailed card collection analysis including upgrade paths to CSV
Args:
player: Player tag (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Exporting analysis data for $CLEAN_TAG..."
{{.CR_API_BIN}} export analysis --tag "$CLEAN_TAG"
preconditions: *binary_precondition
export-battles:
desc: Export battle log to CSV
summary: |
Export recent battle history with deck compositions and outcomes to CSV
Args:
player: Player tag (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Exporting battle log for $CLEAN_TAG..."
{{.CR_API_BIN}} export battles --tag "$CLEAN_TAG"
preconditions: *binary_precondition
export-events-csv:
desc: Export event deck data to CSV using export subcommand
summary: |
Export event deck performance data to CSV format using the export subcommand
Args:
player: Player tag (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Exporting event data for $CLEAN_TAG..."
{{.CR_API_BIN}} export events --tag "$CLEAN_TAG"
preconditions: *binary_precondition
export-player-all:
desc: Export all available player data using export subcommand
summary: |
Export all available data types for a player in one command using export all
Args:
player: Player tag (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Exporting all data for $CLEAN_TAG..."
{{.CR_API_BIN}} export all --tag "$CLEAN_TAG"
preconditions: *binary_precondition
# Deck Building Operations
build-deck:
desc: Build an optimized 1v1 ladder deck from the latest analysis
summary: |
Runs card analysis (saved) and then builds a recommended 1v1 ladder deck.
Args:
player: Player tag to use (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
CLEAN_TAG="${PLAYER_TAG#\#}"
echo "Running analysis for $CLEAN_TAG..."
{{.CR_API_BIN}} analyze --tag "$CLEAN_TAG" --data-dir "{{.DATA_DIR}}" --save
ANALYSIS_FILE="{{.DATA_DIR}}/analysis/${PLAYER_TAG}.json"
if [ ! -f "$ANALYSIS_FILE" ]; then
echo "Expected analysis file not found at $ANALYSIS_FILE" >&2
exit 1
fi
echo "Building optimized 1v1 deck from latest analysis..."
{{.CR_API_BIN}} deck build --from-analysis "$ANALYSIS_FILE"
preconditions: *binary_precondition
war-decks:
desc: Build a 4-deck war lineup with no repeated cards
summary: |
Builds an optimized 4-deck war lineup using archetype-based deck building.
Automatically finds the best combination of archetypes to maximize deck quality
while ensuring zero card overlap across all 4 decks.
Args:
player: Player tag (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
CLEAN_TAG="${PLAYER_TAG#\#}"
echo "Building war deck lineup for $CLEAN_TAG..."
{{.CR_API_BIN}} deck war --tag "$CLEAN_TAG"
preconditions: *binary_precondition
deck-optimize:
desc: Optimize existing deck with available cards
summary: |
Optimize an existing deck by suggesting card replacements from your collection
that maintain archetype identity while improving overall deck quality.
Args:
player: Player tag (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Optimizing deck for $CLEAN_TAG..."
{{.CR_API_BIN}} deck optimize --tag "$CLEAN_TAG" --max-changes 4 --verbose
preconditions: *binary_precondition
deck-budget:
desc: Find budget-optimized decks with minimal upgrade investment
summary: |
Analyze all viable decks and rank them by upgrade efficiency (ROI).
Shows which decks give you the best competitive value for your upgrade resources.
Args:
player: Player tag (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Finding budget decks for $CLEAN_TAG..."
{{.CR_API_BIN}} deck budget --tag "$CLEAN_TAG" --top-n 10 --sort-by roi
preconditions: *binary_precondition
deck-fuzz-build:
desc: Generate fuzz data and build data-driven deck
summary: |
Run Monte Carlo deck fuzzing to generate data, then build a deck using
fuzz integration for data-driven card selection. Cards that perform well
in top-scoring fuzz decks receive a scoring boost.
Args:
player: Player tag (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
count: Number of decks to fuzz (default: 1000)
weight: Fuzz scoring weight 0.0-1.0 (default: 0.15)
Example:
task deck-fuzz-build -- #PLAYER_TAG 2000 0.20
Env vars:
FUZZ_STORAGE: Path to fuzz storage db (default: ~/.cr-api/fuzz_top_decks.db)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
# Extract optional count and weight from args
COUNT="{{.FUZZ_COUNT}}"
WEIGHT="{{.FUZZ_WEIGHT}}"
STORAGE="${FUZZ_STORAGE:-$HOME/.cr-api/fuzz_top_decks.db}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
echo "Usage: task deck-fuzz-build -- [#PLAYER_TAG] [count] [weight]" >&2
echo "Example: task deck-fuzz-build -- #PLAYER_TAG 2000 0.20" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "================================"
echo "Deck Fuzz + Build Workflow"
echo "================================"
echo "Player: $CLEAN_TAG"
echo "Fuzz count: ${COUNT:-1000}"
echo "Fuzz weight: ${WEIGHT:-0.15}"
echo "Storage: $STORAGE"
echo ""
# Step 1: Run deck fuzz (resume from stored top decks for better results)
echo "Step 1: Generating $COUNT fuzz decks (resuming from stored top 50)..."
{{.CR_API_BIN}} deck fuzz \
--tag "$CLEAN_TAG" \
--count "${COUNT:-1000}" \
--workers 4 \
--resume-from 50 \
--save-top \
--storage "$STORAGE"
echo ""
echo "Step 2: Building deck with fuzz integration..."
# Step 2: Build deck with fuzz integration (saves to file)
{{.CR_API_BIN}} deck build \
--tag "$CLEAN_TAG" \
--fuzz-storage "$STORAGE" \
--fuzz-weight "${WEIGHT:-0.15}" \
--fuzz-deck-limit 100 \
--save
echo ""
echo "Step 3: Evaluating built deck..."
# Extract deck cards from the most recent deck file
DECK_FILE=$(ls -t {{.DATA_DIR}}/decks/*_${CLEAN_TAG}_*.json 2>/dev/null | head -1)
if [ -n "$DECK_FILE" ]; then
# Extract deck array and join with dashes (JSON uses lowercase "deck")
if command -v jq >/dev/null 2>&1; then
DECK_STRING=$(jq -r '.deck | join("-")' "$DECK_FILE" 2>/dev/null)
else
# Fallback: extract with sed/awk
DECK_STRING=$(grep -A 20 '"deck"' "$DECK_FILE" | grep '"' | grep -v 'deck\|"\[,\]' | sed 's/^"//' | sed 's/"$//' | tr '\n' '-' | sed 's/-$//')
fi
if [ -n "$DECK_STRING" ]; then
{{.CR_API_BIN}} deck evaluate \
--deck "$DECK_STRING" \
--tag "$CLEAN_TAG" \
--format detailed
fi
fi
echo ""
echo "✅ Fuzz-integrated deck complete!"
echo ""
echo "To view stored fuzz data:"
echo " {{.CR_API_BIN}} deck fuzz list --storage $STORAGE --limit 20"
vars:
FUZZ_COUNT:
sh: test -z "{{.ARGS}}" && echo "1000" || echo "{{.ARGS}}" | awk '{print $2}' | grep -E '^[0-9]+$' || echo "1000"
FUZZ_WEIGHT:
sh: test -z "{{.ARGS}}" && echo "0.15" || echo "{{.ARGS}}" | awk '{print $3}' | grep -E '^[0-9]' || echo "0.15"
preconditions: *binary_precondition
deck-fuzz-genetic-quick:
desc: Run a shorter genetic fuzz pass and save top decks
summary: |
Runs genetic deck fuzzing and saves the top decks to storage.
Args:
player: Player tag (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
seed: Optional seed override (second arg)
Example:
task deck-fuzz-genetic-quick -- #PLAYER_TAG 42
Env vars:
FUZZ_STORAGE: Path to fuzz storage db (default: ~/.cr-api/fuzz_top_decks.db)
cmds:
- |
PLAYER_TAG="{{.FUZZ_PLAYER_TAG}}"
SEED="{{.FUZZ_SEED}}"
STORAGE="${FUZZ_STORAGE:-$HOME/.cr-api/fuzz_top_decks.db}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
echo "Usage: task deck-fuzz-genetic-quick -- [#PLAYER_TAG] [seed]" >&2
exit 1
fi
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Genetic fuzz (quick) for $CLEAN_TAG"
echo "Storage: $STORAGE"
echo ""
{{.CR_API_BIN}} deck fuzz \
--tag "$CLEAN_TAG" \
--mode genetic \
--ga-population 30000 \
--ga-generations 30000 \
--ga-elite-count 200 \
--ga-parallel-eval \
--ga-tournament-size 7 \
--seed "${SEED:-$RANDOM}" \
--top 100 \
--resume-from 100 \
--save-top \
--storage "$STORAGE"
vars:
FUZZ_PLAYER_TAG:
sh: test -z "{{.ARGS}}" && echo "" || echo "{{.ARGS}}" | awk '{print $1}'
FUZZ_SEED:
sh: test -z "{{.ARGS}}" && echo "" || echo "{{.ARGS}}" | awk '{print $2}'
preconditions: *binary_precondition
deck-fuzz-genetic-overnight:
desc: Run a long genetic fuzz pass and save top decks
summary: |
Runs a long genetic deck fuzzing job for building a deck corpus.
Args:
player: Player tag (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
seed: Optional seed override (second arg)
Example:
task deck-fuzz-genetic-overnight -- #PLAYER_TAG 1234
Env vars:
FUZZ_STORAGE: Path to fuzz storage db (default: ~/.cr-api/fuzz_top_decks.db)
FUZZ_GA_POPULATION: Override GA population size (default: 60000)
FUZZ_GA_GENERATIONS: Override GA generations (default: 64000)
FUZZ_VERBOSE: Set to 1/true for verbose output (default: off)
cmds:
- |
PLAYER_TAG="{{.FUZZ_PLAYER_TAG}}"
SEED="{{.FUZZ_SEED}}"
STORAGE="${FUZZ_STORAGE:-$HOME/.cr-api/fuzz_top_decks.db}"
POPULATION="${FUZZ_GA_POPULATION:-60000}"
GENERATIONS="${FUZZ_GA_GENERATIONS:-64000}"
SEED_VALUE="${SEED:-$RANDOM}"
VERBOSE=""
if [ "${FUZZ_VERBOSE}" = "1" ] || [ "${FUZZ_VERBOSE}" = "true" ]; then
VERBOSE="--verbose"
fi
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
echo "Usage: task deck-fuzz-genetic-overnight -- [#PLAYER_TAG] [seed]" >&2
exit 1
fi
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Genetic fuzz (overnight) for $CLEAN_TAG"
echo "Storage: $STORAGE"
echo "Population: $POPULATION | Generations: $GENERATIONS"
echo "Seed: $SEED_VALUE"
echo ""
{{.CR_API_BIN}} deck fuzz \
--tag "$CLEAN_TAG" \
--mode genetic \
--ga-population "$POPULATION" \
--ga-generations "$GENERATIONS" \
--ga-elite-count 100 \
--ga-parallel-eval \
--ga-tournament-size 7 \
--ga-convergence-generations 0 \
--ga-island-model \
--ga-island-count 4 \
--ga-migration-interval 15 \
--ga-migration-size 2 \
--seed "$SEED_VALUE" \
--top 100 \
--resume-from 100 \
--save-top \
--storage "$STORAGE" \
$VERBOSE
vars:
FUZZ_PLAYER_TAG:
sh: test -z "{{.ARGS}}" && echo "" || echo "{{.ARGS}}" | awk '{print $1}'
FUZZ_SEED:
sh: test -z "{{.ARGS}}" && echo "" || echo "{{.ARGS}}" | awk '{print $2}'
preconditions: *binary_precondition
# Event Deck Tasks
scan-events:
desc: Scan battle logs for event decks using Go CLI
summary: |
Automatically scan and import event decks from battle logs using the Go binary
Args:
player: Player tag to scan (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
days: Number of days to scan back (default: 7)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
# Extract days from end of args if present, otherwise use default
DAYS="{{.DAYS_BACK}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Scanning event decks for $CLEAN_TAG (last $DAYS days)..."
{{.CR_API_BIN}} events scan --tag "$CLEAN_TAG" --days "$DAYS" --data-dir "{{.DATA_DIR}}" --save
vars:
DAYS_BACK:
sh: "echo '{{.ARGS}}' | grep -oE '[0-9]+$' || echo '7'"
preconditions: *binary_precondition
export-events:
desc: Export event decks to CSV using Go CLI
summary: |
Export event decks with performance data to CSV using the Go binary
Args:
player: Player tag to export (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Exporting event decks for $CLEAN_TAG to CSV..."
{{.CR_API_BIN}} events list --tag "$CLEAN_TAG" --data-dir "{{.DATA_DIR}}" --export-csv
preconditions: *binary_precondition
export-decks:
desc: Export event decks in deck builder format using Go CLI
summary: |
Export event decks for sharing on deck builder sites using the Go binary
Args:
player: Player tag to export (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Exporting event decks for $CLEAN_TAG in deck builder format..."
# Note: The Go CLI doesn't have a specific deck builder export yet,
# so we'll export the event list which can be used for deck building
{{.CR_API_BIN}} events list --tag "$CLEAN_TAG" --data-dir "{{.DATA_DIR}}" --export-csv
echo "Deck builder format exported to CSV - can be imported into deck building sites"
preconditions: *binary_precondition
analyze-events:
desc: Analyze event deck performance using Go CLI
summary: |
Analyze event deck performance with detailed insights using the Go binary
Args:
player: Player tag to analyze (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Analyzing event performance for $CLEAN_TAG..."
{{.CR_API_BIN}} events analyze --tag "$CLEAN_TAG" --data-dir "{{.DATA_DIR}}" --min-battles 5 --export-csv
preconditions: *binary_precondition
sync-events:
desc: Sync recent event activity using Go CLI
summary: |
Sync and analyze recent event activity from battle logs using the Go binary
Args:
player: Player tag to sync (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Syncing recent events for $CLEAN_TAG (last 7 days)..."
{{.CR_API_BIN}} events scan --tag "$CLEAN_TAG" --data-dir "{{.DATA_DIR}}" --days 7 --save
echo "Sync complete! Use 'task analyze-events -- $CLEAN_TAG' to analyze the data."
preconditions: *binary_precondition
# Archetype Analysis Tasks
analyze-archetypes:
desc: Analyze archetype variety and upgrade costs using Go CLI
summary: |
Generate decks for all 8 archetypes and calculate upgrade costs to target level
Args:
player: Player tag to analyze (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
target-level: Target competitive card level (default: 11)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Analyzing archetype variety for $CLEAN_TAG..."
{{.CR_API_BIN}} archetypes --tag "$CLEAN_TAG" --data-dir "{{.DATA_DIR}}"
preconditions: *binary_precondition
export-archetypes:
desc: Analyze and export archetype data to CSV using Go CLI
summary: |
Generate archetype analysis and export to CSV with upgrade details
Args:
player: Player tag to analyze (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Analyzing and exporting archetype data for $CLEAN_TAG to CSV..."
{{.CR_API_BIN}} archetypes --tag "$CLEAN_TAG" --data-dir "{{.DATA_DIR}}" --export-csv --save
preconditions: *binary_precondition
# Evolution Tasks
evolution-recommend:
desc: Recommend optimal evolutions based on shards and card levels
summary: |
Analyze your evolution shard inventory and card levels to recommend
which evolutions would have the biggest impact on your deck viability.
Args:
player: Player tag (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Recommending evolutions for $CLEAN_TAG..."
{{.CR_API_BIN}} evolutions recommend --tag "$CLEAN_TAG"
preconditions: *binary_precondition
# Upgrade Analysis Tasks
upgrade-impact:
desc: Analyze which card upgrades have biggest impact on deck viability
summary: |
Analyze your card collection and identify which upgrades would unlock
the most new viable decks or improve existing deck quality the most.
Args:
player: Player tag (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Analyzing upgrade impact for $CLEAN_TAG..."
{{.CR_API_BIN}} upgrade-impact --tag "$CLEAN_TAG" --top 10
preconditions: *binary_precondition
what-if:
desc: Simulate deck changes with upgraded cards
summary: |
Simulate what decks would be available if you upgraded specific cards.
Useful for planning upgrade investments.
Args:
upgrades: Card upgrade specs in format "CardName:Level" (required)
player: Player tag (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
Example:
task what-if -- Knight:14 Archers:13 Fireball:12
task what-if -- #PLAYER_TAG Knight:14 Archers:13
cmds:
- |
# Parse arguments - first check if first arg is a player tag
ARGS="{{.CLI_ARGS}}"
if [ -z "$ARGS" ]; then
echo "Please provide upgrade specifications (e.g., Knight:14 Archers:13)" >&2
echo "Usage: task what-if -- [#PLAYER_TAG] CardName:Level [CardName:Level...]" >&2
exit 1
fi
# Split args into array
read -ra ARG_ARRAY <<< "$ARGS"
# Check if first arg is a player tag (starts with # or looks like a tag)
FIRST_ARG="${ARG_ARRAY[0]}"
if [[ "$FIRST_ARG" =~ ^#.+ ]] || [[ -z "${DEFAULT_PLAYER_TAG}" && ! "$FIRST_ARG" =~ : ]]; then
PLAYER_TAG="$FIRST_ARG"
UPGRADE_ARGS=("${ARG_ARRAY[@]:1}")
else
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
UPGRADE_ARGS=("${ARG_ARRAY[@]}")
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
if [ ${#UPGRADE_ARGS[@]} -eq 0 ]; then
echo "Please provide at least one upgrade specification (e.g., Knight:14)" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
# Build upgrade flags
UPGRADE_FLAGS=""
for upgrade in "${UPGRADE_ARGS[@]}"; do
UPGRADE_FLAGS="$UPGRADE_FLAGS --upgrade $upgrade"
done
echo "Simulating upgrades for $CLEAN_TAG: ${UPGRADE_ARGS[*]}"
{{.CR_API_BIN}} what-if --tag "$CLEAN_TAG" $UPGRADE_FLAGS --show-decks
preconditions: *binary_precondition
playstyle:
desc: Analyze player's playstyle and recommend decks
summary: |
Analyze your battle history to identify your preferred playstyle
(aggro, control, beatdown, etc.) and recommend decks that match it.
Args:
player: Player tag (optional, will use DEFAULT_PLAYER_TAG from .env if not provided)
cmds:
- |
PLAYER_TAG="{{.CLI_ARGS}}"
if [ -z "$PLAYER_TAG" ]; then
PLAYER_TAG="${DEFAULT_PLAYER_TAG}"
fi
if [ -z "$PLAYER_TAG" ]; then
echo "Please provide a player tag or set DEFAULT_PLAYER_TAG in .env" >&2
exit 1
fi
# Remove any surrounding quotes from PLAYER_TAG
CLEAN_TAG=$(echo "$PLAYER_TAG" | sed "s/^'//;s/'$//" | sed 's/^"//;s/"$//')
CLEAN_TAG="${CLEAN_TAG#\#}"
echo "Analyzing playstyle for $CLEAN_TAG..."
{{.CR_API_BIN}} playstyle --tag "$CLEAN_TAG" --recommend-decks --save
preconditions: *binary_precondition
# Development Commands
test:
desc: Run Go tests