From 0f5193339b7aabf891c1d4523715995390e00475 Mon Sep 17 00:00:00 2001 From: melvin Date: Sun, 25 Mar 2012 15:05:43 +0800 Subject: [PATCH] determines type and subtype and print out abilities as it is listed in oracle --- Makefile | 2 +- scripts/analyze_cards.scala | 46 ++++++++++++++++++++++++------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 7a7632cd43..f1c1c4be4d 100644 --- a/Makefile +++ b/Makefile @@ -273,7 +273,7 @@ download/Magarena-%.zip: $^ cards/scriptable.txt: scripts/analyze_cards.scala scripts/effects.txt cards/cards.xml - scala $^ > $@ 2> cards/others.txt + scala $^ > $@ cards/magicdraftsim-rating: cards/card-ratings for i in `cat $^`; do \ diff --git a/scripts/analyze_cards.scala b/scripts/analyze_cards.scala index c7e49c6c9d..d9dad276b7 100644 --- a/scripts/analyze_cards.scala +++ b/scripts/analyze_cards.scala @@ -16,26 +16,40 @@ for (card <- src \ "card") { val pow = (card \ "pow").text val tgh = (card \ "tgh").text - val types = card \ "typelist" - val rules = card \ "rulelist" + val types = card \ "typelist" \ "type" + val rules = card \ "rulelist" \ "rule" + + var scriptable = rules + .filter(_.text.trim() != "") + .forall(x => isScriptable(name, x.text)) - var scriptable = (rules \ "rule").filter(_.text.trim() != "").forall(x => isScriptable(name, x.text)) if (scriptable) { Console.println(">" + name); - /* Console.println("value=?") Console.println("rarity=?") - Console.println("type=Creature") - Console.println("subtype=Beast,Human") - Console.println("color=g") - Console.println("converted=6") - Console.println("cost={4}{G}{G}") - Console.println("power=6") - Console.println("toughness=5") - Console.println("timing=main") - */ - for (rule <- rules \ "rule" if rule.text.trim != "") { - Console.println(rule.text) + + val typeStr = types + .filter(x => (x \ "@type").text == "card" || (x \ "@type").text == "super") + .map(_.text) + .mkString(",") + + Console.println("type=" + typeStr); + + val subtypeStr = types + .filter(x => (x \ "@type").text == "sub") + .map(_.text) + .mkString(",") + + Console.println("subtype=" + subtypeStr) + + Console.println("color=?") + Console.println("converted=?") + Console.println("cost=" + cost) + Console.println("power=" + pow ) + Console.println("toughness=" + tgh) + Console.println("timing=?") + for (rule <- rules if rule.text.trim != "") { + Console.println("ability=" + rule.text) } Console.println() } @@ -54,7 +68,7 @@ def isScriptable(name:String, rule:String):Boolean = { } //if not, print it out - Console.err.println(norm + "\t" + name); + //Console.err.println(norm + "\t" + name); return false }