added some misc awk scripts and a test game

master
melvin 2011-06-07 11:17:51 +08:00
parent ebb9350305
commit d47b94f85b
7 changed files with 200 additions and 0 deletions

View File

@ -0,0 +1,29 @@
# convert deck magic-league.com's apprentice format to magarena format
BEGIN {
first = 0
}
# skip header
/^\/\// {
gsub("//", "# ")
print $0
next
}
/SB:/ && first == 0 {
print "# Sideboard"
first = 1
}
/SB:/ {
gsub("[ ]*SB:[ ]*", "")
print $0
next
}
{
gsub("^[ ]*", "")
print $0
}

5
scripts/download_ml.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/zsh
for i in `seq 10592 -1 10590`; do
make ml_$i.dec
sleep 1
done

View File

@ -0,0 +1,30 @@
BEGIN {
FS = "\t"
OFS = "\t"
ORS = ""
}
FILENAME ~ /candidate/ && $3 != "implemented" {
score[$2] = $1
comment[$2] = $3
next
}
{
if ($1 in score) {
print score[$1] "\t"
print "NOTE:"comment[$1] "\t"
print "NAME:"$1 "\t"
print "TEXT:" "\t"
while ($0 != "") {
getline
print $0 "\t"
}
cnt++
print "\n"
}
}
END {
print "found " cnt " card" > "/dev/stderr"
}

View File

@ -0,0 +1,29 @@
BEGIN {
FS = "\t"
}
FILENAME ~ /existing/ {
impl[$1] = 0
next
}
{
if ($1 in impl) {
found[$1] = 1
print $1
while ($0 != "") {
getline
print $0
}
cnt++
}
}
END {
print "found " cnt " card" > "/dev/stderr"
for (i in impl) {
if (!(i in found)) {
print i " not found" > "/dev/stderr"
}
}
}

44
scripts/magarena_deck.awk Normal file
View File

@ -0,0 +1,44 @@
function norm(name) {
return gensub("[^a-z]", "", "g", tolower(name))
}
BEGIN {
FS = "\t"
total = 0
inmag = 0
result = ""
}
FILENAME ~ /magarena/ {
cards[norm($0)] = $0
#print norm($0)
#print "|"$0"|" " in Magarena"
next
}
/Sideboard/ {
result = result "## " $0 " ##\n"
}
# card in deck (excluding the line containing sideboard)
/\w+ \w+/ {
s = index($0, " ")
n = substr($0, 1, s - 1)
card = substr($0, s + 1)
id = norm(card)
#print "|" card "|"
total += n
if (id in cards) {
inmag += n
result = result n " " cards[id] "\n"
} else {
result = result "# " n " " card "\n"
}
}
END {
print FILENAME "\t" inmag "/" total "\t" (inmag/total) > "/dev/stderr"
if (inmag >= 40) {
print result
}
}

12
scripts/rename_card.awk Normal file
View File

@ -0,0 +1,12 @@
BEGIN {
FS = "="
}
$1 == "primitive" {
cname = $2
}
$1 == "id" {
cid = $2
print "mv \"" cname ".jpg\" " cid
}

View File

@ -0,0 +1,51 @@
package magic.test;
import magic.model.*;
import magic.model.phase.MagicMainPhase;
class TestRecoverMR extends TestGameBuilder {
/**
* Raging Ravine changed into 3/3 RG creature cannot block Guardian of the
* Guildpack which has protection from monocolored
* Fixed by making the protection check use getColorFlags in addition to getColoredTypeg
*/
public MagicGame getGame() {
final MagicTournament tournament=new MagicTournament();
tournament.setDifficulty(6);
final MagicPlayerProfile profile=new MagicPlayerProfile("bgruw");
final MagicPlayerDefinition player1=new MagicPlayerDefinition("Player",false,profile,15);
final MagicPlayerDefinition player2=new MagicPlayerDefinition("Computer",true,profile,14);
tournament.setPlayers(new MagicPlayerDefinition[]{player1,player2});
tournament.setStartPlayer(0);
final MagicGame game=tournament.nextGame(true);
game.setPhase(MagicMainPhase.getFirstInstance());
final MagicPlayer player=game.getPlayer(0);
final MagicPlayer opponent=game.getPlayer(1);
MagicPlayer P = player;
P.setLife(4);
P.setPoison(6);
addToLibrary(P,"Plains",10);
createPermanent(game,P,"Rupture Spire",false,8);
addToHand(P,"Recover",1);
addToGraveyard(P,"Murderous Redcap",1);
addToGraveyard(P,"Ruthless Cullblade",1);
P = opponent;
P.setLife(1);
P.setPoison(8);
addToLibrary(P,"Island",10);
createPermanent(game,P,"Rupture Spire",false,8);
addToHand(P,"Stonework Puma",1);
addToHand(P,"Llanowar Elves", 1);
addToHand(P,"Prickly Boggart", 1);
addToHand(P,"Veteran Armorer",1);
return game;
}
}