magarena/Makefile

422 lines
14 KiB
Makefile
Raw Normal View History

JAVAEA=java -ea -Xms256M -Xmx256M -Ddebug=true
LIBS=.:lib/annotations.jar:lib/jsr305.jar
JAVA=${JAVAEA} -Dcom.sun.management.jmxremote -cp $(LIBS):release/Magarena.jar
SHELL=/bin/bash
BUILD=build
2011-07-08 01:11:44 -07:00
JOPTS=-Xlint:all -d $(BUILD) -cp $(LIBS):$(BUILD):.
SRC=$(shell find src -iname *.java)
MAG:=release/Magarena.jar
EXE:=release/Magarena.exe
2011-05-22 19:23:49 -07:00
all: $(MAG) $(EXE) tags
zips:
make M`grep Release release/README.txt | head -1 | cut -d' ' -f2`
check_literals:
grep "\"" src/magic/card/* | awk -f scripts/check_literals.awk
cubes: \
2012-08-23 06:31:54 -07:00
cards/standard_all.txt \
cards/extended_all.txt \
cards/modern_all.txt \
release/Magarena/mods/legacy_cube.txt \
release/Magarena/mods/extended_cube.txt \
release/Magarena/mods/standard_cube.txt \
release/Magarena/mods/modern_cube.txt
2011-06-09 19:09:19 -07:00
2011-08-25 23:40:03 -07:00
themes: \
release/Magarena/mods/felt_theme.zip \
release/Magarena/mods/blackswamp_theme.zip \
release/Magarena/mods/bluemarble_theme.zip \
release/Magarena/mods/darkbattle_theme.zip \
release/Magarena/mods/gothic_theme.zip \
release/Magarena/mods/greenforest_theme.zip \
release/Magarena/mods/moon_theme.zip \
release/Magarena/mods/mystic_theme.zip \
release/Magarena/mods/nature_theme.zip \
release/Magarena/mods/redfire_theme.zip \
release/Magarena/mods/whiteangel_theme.zip
2011-08-25 23:40:03 -07:00
2011-11-15 18:11:34 -08:00
cards_diff: $(MAG)
2011-11-15 18:21:14 -08:00
for i in `hg stat -q src/magic/card release/Magarena/scripts | cut -d' ' -f2 | sort -t'/' -k4`; do hg diff $$i; done | flip -u - > $@
2011-11-15 18:11:34 -08:00
2011-11-14 19:39:35 -08:00
code_to_remove: $(MAG)
cat src/magic/card/*.java | sed 's/\s\+//g' | sed 's/(.*)/(...)/g' | sort | uniq -c | sort -n | grep publicstaticfinal | grep ");" > $@
2011-11-14 19:39:35 -08:00
casts: $(MAG)
grep -n "([A-Z]\+[a-z]\+[A-Za-z]*)" -r src/ | flip -u > $@
2011-09-05 23:41:07 -07:00
2011-09-03 07:21:10 -07:00
warnings_H.txt: warnings.txt
2011-11-13 04:19:46 -08:00
grep "(H)" $^ | grep -v System.out | grep -v System.err | grep -v EXS > $@
2011-09-03 07:21:10 -07:00
2011-08-30 21:40:36 -07:00
warnings.txt: $(MAG)
2012-06-12 23:35:26 -07:00
~/App/findbugs/bin/findbugs \
2011-08-30 21:40:36 -07:00
-textui \
-progress \
-sortByClass \
-emacs \
-effort:max \
-output $@ \
-sourcepath src \
build
cards/legacy_banned.txt:
curl https://www.wizards.com/Magic/TCG/Resources.aspx?x=judge/resources/sfrlegacy | grep nodec | grep -o ">[^<]*</a" | sed 's/>//g;s/<\/a//;' > $@
release/Magarena/mods/legacy_cube.txt: cards/existing_tip.txt cards/legacy_banned.txt
2011-06-09 19:09:19 -07:00
join -v1 -t"|" <(sort $(word 1,$^)) <(sort $(word 2,$^)) > $@
release/Magarena/mods/%_cube.txt: cards/existing_tip.txt cards/%_all.txt
join -t"|" <(sort $(word 1,$^)) <(sort $(word 2,$^)) > $@
2012-08-23 06:31:54 -07:00
cards/%_all.out:
touch $@
for rarity in mythic rare uncommon common land special; do \
2012-08-23 06:35:58 -07:00
curl "http://magiccards.info/query?q=r%3A$$rarity+f%3A$*&s=cname&v=olist&p=1" | grep "en/" >> $@; \
curl "http://magiccards.info/query?q=r%3A$$rarity+f%3A$*&s=cname&v=olist&p=2" | grep "en/" >> $@; \
curl "http://magiccards.info/query?q=r%3A$$rarity+f%3A$*&s=cname&v=olist&p=3" | grep "en/" >> $@; \
done
2012-08-23 06:35:58 -07:00
sed -i 's/<[^>]*>//g;s/^[ ]*//g' $@
2012-05-26 00:19:22 -07:00
sed -i 's/Æ/AE/' $@
2012-08-23 06:31:54 -07:00
cards/%_all.txt: cards/%_all.out
sort $^ | uniq > $@
cards/new_%.txt: cards/existing_tip.txt cards/existing_%.txt
2012-06-12 20:27:08 -07:00
join -v1 -t"|" <(sort $(word 1,$^)) <(sort $(word 2,$^)) > $@
cards/new_scripts_%.txt: release/Magarena/scripts
grep "name=" -h $$(hg diff -r $* | grep -B 1 "^--- /dev/null" | grep $^ | cut -d' ' -f4) | sed 's/name=//' > $@
flip -u $@
cards/existing_scripts_%.txt: $(wildcard release/Magarena/scripts/*.txt)
hg cat -r $* release/Magarena/scripts | grep "^name=" | sed 's/name=//' | sort > $@
sed -i 's/\r//' $@
cards/existing_tokens_%.txt: $(wildcard release/Magarena/scripts/*.txt)
hg cat -r $* release/Magarena/scripts | grep -C 1 "^token=" | grep "^name=" | sed 's/name=//' | sort > $@
cards/existing_%.txt: cards/existing_scripts_%.txt cards/existing_tokens_%.txt
join -v1 -t"|" <(sort $(word 1,$^)) <(sort $(word 2,$^)) > $@
%_full.txt: %.txt cards/mtg-data.txt
awk -f scripts/extract_existing.awk $^ > $@
cards/candidates_full.txt: scripts/extract_candidates.awk cards/scored_by_dd.tsv cards/mtg-data.txt
awk -f $^ | sort -rg | sed 's/\t/\n/g' > $@
%.out: $(MAG)
2011-06-10 23:03:02 -07:00
SGE_TASK_ID=$* exp/eval_mcts.sh
2012-08-25 07:09:10 -07:00
2012-01-27 18:57:20 -08:00
M1.%: clean $(EXE) cubes release/Magarena/mods/felt_theme.zip
grep "VERSION.*1.$*" -Ir src/
grep "Release.*1.$*" release/README.txt
grep 1.$* -Ir Magarena.app/
-rm -rf Magarena-1.$*
-rm -rf Magarena-1.$*.app
-rm Magarena-1.$*.zip
2011-11-25 21:55:03 -08:00
-rm Magarena-1.$*.app.zip
mkdir -p Magarena-1.$*/Magarena/mods
2011-05-27 00:34:47 -07:00
cp \
release/gpl-3.0.html \
release/Magarena.exe \
release/Magarena.sh \
release/Magarena.command \
release/README.txt \
Magarena-1.$*
cp -r \
release/Magarena/avatars \
release/Magarena/decks \
release/Magarena/sounds \
release/Magarena/scripts \
Magarena-1.$*/Magarena
cp \
release/Magarena/mods/felt_theme.zip \
release/Magarena/mods/*.txt \
Magarena-1.$*/Magarena/mods
-zip -r Magarena-1.$*.zip Magarena-1.$*
cp -r Magarena.app Magarena-1.$*.app
cd Magarena-1.$*.app/Contents/Resources; ln -s ../../../Magarena-1.$* Java
chmod a+x Magarena-1.$*.app/Contents/MacOS/JavaApplicationStub
-zip -r Magarena-1.$*.app.zip Magarena-1.$*.app
2011-05-27 00:34:47 -07:00
$(MAG): $(SRC)
2012-01-27 18:08:39 -08:00
ant -f build.xml
2011-06-10 06:43:32 -07:00
class: $(BUILD)/javac.last
$(BUILD)/javac.last: $(SRC)
-mkdir $(BUILD)
javac $(JOPTS) $?
2011-05-24 20:57:28 -07:00
cp -r resources/* $(BUILD)
touch $@
tags: $(SRC)
2012-03-10 01:59:23 -08:00
ctags -R src
2011-05-22 19:23:49 -07:00
2012-06-11 07:25:45 -07:00
Test%.run: $(MAG)
2012-08-05 07:18:42 -07:00
$(JAVAEA) -DtestGame=Test$* -Dmagarena.dir=`pwd`/release -jar $^ 2>&1 | tee Test$*.log
$(EXE): $(MAG)
cd launch4j; ./launch4j ../release/magarena.xml
2011-05-22 19:40:28 -07:00
2011-05-22 19:23:49 -07:00
clean:
-ant clean
-rm -f $(BUILD)/javac.last
-rm -f $(MAG)
2012-08-25 07:09:10 -07:00
clean/%: Magarena-%.zip Magarena-%.app.zip
-rm -rf Magarena-$*
-rm -rf Magarena-$*.app
-rm Magarena-$*.zip
-rm Magarena-$*.app.zip
log.clean:
-rm -f *.log
inf: $(MAG)
2012-06-02 18:56:47 -07:00
-while true; do make `date +%s`.t; done
%.t: $(MAG)
echo `hg id -n` > $*.log
2012-09-22 19:15:13 -07:00
$(JAVA) -DrndSeed=$* -Dmagarena.dir=`pwd`/release magic.DeckStrCal --str1 1 --str2 1 --life 10 --games 1 --repeat 1000000 >> $*.log 2>&1
#$(JAVAEA) -DrndSeed=$* -Dmagarena.dir=`pwd`/release -DselfMode -jar $^ >> $*.log 2>&1
2012-04-14 18:10:16 -07:00
test: $(MAG)
2012-06-02 18:56:47 -07:00
-make `date +%s`.d
2012-04-14 18:10:16 -07:00
%.d: $(MAG)
$(JAVAEA) -DrndSeed=$* -Dmagarena.dir=`pwd`/release -jar $^ |& tee $*.log
2012-07-26 01:42:56 -07:00
# Z = 4.4172 (99.999%)
# E = 0.01
# best estimator for r is p = h / (h + t)
2012-08-05 07:18:42 -07:00
# this estimator has a margin of error E, |p - r| < E at a particular Z, p - E < r < p + E
2012-07-26 01:42:56 -07:00
# n = Z^2 / 4E^2
# = 48780
# ~ 50000
%.str: $(MAG) release/Magarena/decks/JustRelentlessRats.dec release/Magarena/decks/LSK_G.dec
$(JAVA) magic.DeckStrCal --deck1 $(word 2,$^) --deck2 $(word 3,$^) --ai1 $* --ai2 $* --games 50000 > $@
2012-04-14 18:10:16 -07:00
exp/%.log: $(MAG)
scripts/evaluate_ai.sh $* > $@
decks/dd:
2012-06-02 02:49:07 -07:00
for i in `curl http://www.wizards.com/magic/magazine/archive.aspx?tag=dailydeck | grep -o mtg/daily/deck/[0-9]* | cut -d'/' -f4`; do make decks/dd_$$i.dec; done
decks/td:
for i in `curl http://www.wizards.com/magic/magazine/archive.aspx?tag=topdeck | grep -o mtg/daily/td/[0-9]* | cut -d'/' -f4`; do make decks/td_$$i.dec; done
# Daily Deck
decks/dd_%.dec: scripts/dailyhtml2dec.awk
curl "http://www.wizards.com/Magic/Magazine/Article.aspx?x=mtg/daily/deck/$*" | awk -f $^ > $@
# Mike Flores
decks/mf_%.dec: scripts/dailyhtml2dec.awk
curl http://www.wizards.com/Magic/Magazine/Article.aspx?x=mtgcom/daily/mf$* | awk -f $^ > $@
# Top Decks
decks/td_%.dec: scripts/dailyhtml2dec.awk
curl http://www.wizards.com/Magic/Magazine/Article.aspx?x=mtg/daily/td/$* | awk -f $^ > $@
decks/ml_%.dec: scripts/apprentice2dec.awk
wget "http://www.magic-league.com/decks/download.php?deck=$*&index=1" -O - | flip -u - | awk -f $^ > $@
ref/rules.txt:
curl http://www.wizards.com`wget http://www.wizards.com/magic/rules -O - | grep txt | cut -d'"' -f4` | fmt -s > $@
flip -u $@
2011-06-20 18:58:22 -07:00
resources/magic/data/icons/missing_card.png:
2011-06-20 19:27:14 -07:00
convert -background gray -bordercolor black -border 5x5 -size 302x435 \
-pointsize 30 label:'\nNo card image found\n\nSelect\n\"Download images\"\nfrom Arena menu\n\nOR\n\nSwitch to text mode\nusing the Enter key' $@
2011-06-22 19:02:22 -07:00
release/Magarena/mods/%_theme.zip: release/Magarena/mods/%_theme
2011-06-22 19:02:22 -07:00
zip -j $@ $^/*
cards/evan_cube.txt:
curl http://www.cubedrafting.com/view-the-cube/ | grep jTip | sed "s/<[^>]*>//g;s/\&\#8217;/'/" > $@
cards/brett_cube.txt:
curl http://www.snazzorama.com/magic/cube/ | grep ":WizardsAutoCard" | sed "s/<\/td>.*//;s/<[^>]*>//g;s/\&\#8217;/'/" > $@
2011-06-28 19:05:50 -07:00
cards/tom_cube.txt:
wget -O - http://www.tomlapille.com/cube/tom_list.html | sed 's/<[^>]*>//g;s/^[ ]*//g;/^$$/d' > $@
cards/adam_cube.txt:
wget -O - http://www.tomlapille.com/cube/adam_list.html | sed 's/<[^>]*>//g;s/^[ ]*//g;/^$$/d' > $@
cards/AWinnarIsYou_cube.txt:
wget -O - http://www.tomlapille.com/cube/winnar_list.html | sed 's/<[^>]*>//g;s/^[ ]*//g;/^$$/d' > $@
2011-06-28 19:05:50 -07:00
2012-03-13 01:13:52 -07:00
cards/mtgo_cube.txt:
wget -O - https://www.wizards.com/magic/magazine/article.aspx?x=mtg/daily/arcana/927 | grep autoCard | sed 's/<[^<]*>//g;s/^[ ]*//g' > $@
2012-07-05 00:53:36 -07:00
cards/mtgo_cube2.txt:
wget -O - https://www.wizards.com/magic/magazine/article.aspx?x=mtg/daily/other/07032012d | grep autoCard | sed 's/<[^<]*>//g;s/^[ ]*//g' > $@
2011-06-28 19:05:50 -07:00
daily: $(EXE)
mv $^ Magarena_`hg id -n`.exe
scripts/googlecode_upload.py \
-s "build `hg id -n`" \
-p magarena \
-u melvinzhang@gmail.com \
-w `cat ~/Modules/notes/keys/googlecode_pw.txt` \
-l Deprecated \
Magarena_`hg id -n`.exe
2011-07-01 00:39:22 -07:00
upload/%: Magarena-%.zip Magarena-%.app.zip
2012-07-28 22:52:49 -07:00
make upload/Magarena-$*.app.zip
make upload/Magarena-$*.zip
upload/Magarena-%.app.zip: Magarena-%.app.zip
scripts/googlecode_upload.py \
-p magarena \
-u melvinzhang@gmail.com \
-w `cat ~/Modules/notes/keys/googlecode_pw.txt` \
-s "Magarena $* (Mac)" \
-l Featured,Type-Installer,OpSys-OSX \
2012-07-28 22:52:49 -07:00
$^
2012-07-28 22:52:49 -07:00
upload/Magarena-%.zip: Magarena-%.zip
scripts/googlecode_upload.py \
-p magarena \
-u melvinzhang@gmail.com \
-w `cat ~/Modules/notes/keys/googlecode_pw.txt` \
-s "Magarena $*" \
-l Featured,Type-Archive,OpSys-Linux,OpSys-Windows \
2012-07-28 22:52:49 -07:00
$^
2011-10-26 20:06:12 -07:00
%.up: %
scripts/googlecode_upload.py \
-p magarena \
-u melvinzhang@gmail.com \
-w `cat ~/Modules/notes/keys/googlecode_pw.txt` \
-s "$^" \
2011-10-26 20:06:12 -07:00
$^
cards/scriptable.txt: scripts/analyze_cards.scala scripts/effects.txt cards/cards.xml
scala $^ > $@
cards/magicdraftsim-sets:
curl www.magicdraftsim.com/card-ratings | \
grep Kamigawa | \
head -1 | \
sed 's/value=/\n/g' | \
sed 's/<.*//' | \
cut -d\' -f2 | \
sed '/^$$/d' > $@
cards/magicdraftsim-rating: cards/magicdraftsim-sets
for i in `cat $^`; do \
curl http://www.magicdraftsim.com/card-ratings/$$i | \
pandoc -f html -t plain | \
grep "^[ ]*[0-9]" | \
sed "s/^[ ]*[0-9]*/$$i/;s/[ ][ ][ ]*/\t/g"; \
done > $@
cards/current-magic-excel.txt:
wget http://www.magictraders.com/pricelists/current-magic-excel.txt -O $@
up:
hg pull -u
cd wiki; hg pull -u; cd ..
cards/with_card_code:
ls -1 src/magic/card/*.java | cut -d'/' -f 4 | sed 's/.java//' | sort > $@
cards/require_card_code:
grep requires_card_code release/Magarena/scripts/* | cut -d'/' -f4 | sed 's/.txt:.*//' | sort > $@
2012-03-11 08:12:49 -07:00
check_requires_card_code: cards/with_card_code cards/require_card_code
diff $^
2012-03-11 08:12:49 -07:00
code_clones:
~/App/pmd-bin-5.0-alpha/bin/run.sh cpd \
--minimum-tokens 100 \
--ignore-literals true \
--ignore-identifiers true \
--language java \
--files src/magic/card > $@
2012-04-09 07:14:14 -07:00
cards/mtg-data:
2012-07-26 01:42:56 -07:00
curl https://dl.dropbox.com/u/2771470/index.html | grep -o 'href="mtg.*.zip' | head -1 | sed 's/href="//' | xargs -I'{}' wget https://dl.dropbox.com/u/2771470/'{}'
unzip -j mtg-data*.zip -d cards
rm mtg-data*.zip
2012-04-09 07:14:14 -07:00
github/push:
hg gexport
git push origin master
unique_property:
grep "=" release/Magarena/scripts/*.txt| cut -d'=' -f1 | sort | uniq -c | sort -n
2012-07-26 01:47:15 -07:00
cards/scored_by_dd.tsv: cards/existing_tip.txt $(wildcard decks/dd*)
./scripts/score_card.awk `ls -1 decks/dd* | sort -n -t_ -k2` |\
sort -rg |\
2012-07-26 01:47:15 -07:00
./scripts/keep_unimplemented.awk $(word 1,$^) /dev/stdin > $@
2012-07-26 01:47:15 -07:00
cards/scored_by_td.tsv: cards/existing_tip.txt $(wildcard decks/td*)
./scripts/score_card.awk `ls -1 decks/td* | sort -n -t_ -k2` |\
sort -rg |\
2012-07-26 01:47:15 -07:00
./scripts/keep_unimplemented.awk $(word 1,$^) /dev/stdin > $@
cards/mtg_mana_costs:
grep -ho "\(\{[^\}]\+\}\)\+" -r cards/cards.xml | sort | uniq > $@
cards/mag_mana_costs:
grep -ho "\(\{[^\}]\+\}\)\+" -r src/magic/model/MagicManaCost.java release/Magarena/scripts | sort | uniq > $@
cards/mana_cost_graph.dot: cards/mtg_mana_costs
cat $^ |\
sed 's/{X}//g;s/{[[:digit:]]*}//g;s/{[CPQT]*}//g;/^$$/d' |\
awk -f scripts/mana_cost_graph.awk > $@
cards/mana_cost_graph.png: cards/mana_cost_graph.dot
circo $^ -Tpng -o $@
verify_mana_cost_order: cards/mtg_mana_costs cards/mag_mana_costs
join -v2 $^
# added -L to follow redirect, needed for card names without accented letters
cards/gatherer_rankings: cards/existing_tip.txt
IFS=$$'\n'; for i in `cat $^`; do\
echo -n -e "$$i\t";\
echo $$(curl -sL http://gatherer.wizards.com/pages/card/details.aspx?name=`echo $$i | sed 's/ /%20/g'` | grep "textRatingValue" | grep -o "[0-9]\.[^<]*");\
done > $@
update_value_from_rankings: cards/gatherer_rankings
for i in release/Magarena/scripts/*; do \
if grep token= $$i; then \
echo $$i; \
else \
sed -i "s/value=.*/value=$$(join -t' ' <(head -1 $$i | sed 's/name=//') $^ | cut -f2)/" $$i;\
fi \
done
%.update_value: %
if grep token= $^; then \
echo "ERROR: Not applicable to tokens"; \
else \
name=$$(grep name= $^ | sed 's/name=//' | sed 's/ /%20/g');\
value=$$(curl -sL http://gatherer.wizards.com/pages/card/details.aspx?name=$$name | grep "textRatingValue" | grep -o "[0-9]\.[^<]*");\
sed -i "s/value=.*/value=$$value/" $^;\
fi \
2012-08-18 18:05:00 -07:00
%.normalize: %
flip -u $^
make $^.update_value
vim $^
hg add $^
2012-09-07 21:18:30 -07:00
check_data: scripts/check_data.awk
for i in src/magic/card/* src/magic/model/event/* src/magic/model/trigger/* ; do \
grep "new Object\|data\[[0-9\]" $$i > /dev/null && echo $$i; \
2012-09-08 19:24:29 -07:00
grep "new Object\|data\[[0-9\]" $$i | awk -f $^ | sed 's/ //g' | sed 's/:/:\t/'; \
done > $@
2012-09-07 21:18:30 -07:00
flip -u $@
# every aura must have an enchant property
check_aura:
diff <(grep "subtype.*Aura" -lr release/Magarena/scripts | sort) <(grep enchant= -lr release/Magarena/scripts | sort)