2011-06-28 20:07:40 -07:00
|
|
|
import scala.xml.pull._
|
|
|
|
import scala.xml._
|
|
|
|
import scala.io.Source
|
|
|
|
|
2011-07-01 19:05:57 -07:00
|
|
|
Console.err.println("loading effects from " + args(0))
|
|
|
|
val effects = Source.fromFile(args(0)).getLines.toList
|
2011-07-01 00:39:22 -07:00
|
|
|
|
2011-07-01 19:05:57 -07:00
|
|
|
Console.err.println("loading cards from " + args(1))
|
|
|
|
val src = XML.load(args(1))
|
2011-06-28 20:07:40 -07:00
|
|
|
|
2013-07-16 02:16:44 -07:00
|
|
|
Console.err.println("loading existing from " + args(2))
|
|
|
|
val existing = Source.fromFile(args(2)).getLines.toSet
|
|
|
|
|
2011-07-01 19:05:57 -07:00
|
|
|
Console.err.println("begin analysis")
|
2011-06-28 20:07:40 -07:00
|
|
|
for (card <- src \ "card") {
|
2013-07-16 02:16:44 -07:00
|
|
|
val name = (card \ "name").text.replace("Æ", "AE").replace("û","u").replace("ö","o");
|
2011-07-01 19:05:57 -07:00
|
|
|
val cost = (card \ "cost").text
|
|
|
|
val loyalty = (card \ "loyalty").text
|
|
|
|
val pow = (card \ "pow").text
|
|
|
|
val tgh = (card \ "tgh").text
|
|
|
|
|
2012-03-25 00:05:43 -07:00
|
|
|
val types = card \ "typelist" \ "type"
|
|
|
|
val rules = card \ "rulelist" \ "rule"
|
|
|
|
|
|
|
|
var scriptable = rules
|
|
|
|
.filter(_.text.trim() != "")
|
|
|
|
.forall(x => isScriptable(name, x.text))
|
2011-07-01 19:05:57 -07:00
|
|
|
|
2013-07-16 02:16:44 -07:00
|
|
|
if (existing contains name) {
|
|
|
|
Console.println("name=" + name);
|
|
|
|
//Console.println("value=3")
|
|
|
|
//Console.println("rarity=C")
|
2012-03-25 00:05:43 -07:00
|
|
|
|
|
|
|
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(",")
|
|
|
|
|
2013-07-16 02:16:44 -07:00
|
|
|
if (subtypeStr.length > 0) {
|
|
|
|
Console.println("subtype=" + subtypeStr)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cost.length > 0) {
|
|
|
|
Console.println("cost=" + cost)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pow.length > 0 && tgh.length > 0) {
|
|
|
|
Console.println("pt=" + pow + "/" + tgh)
|
|
|
|
}
|
|
|
|
//Console.println("timing=main")
|
2012-03-25 00:05:43 -07:00
|
|
|
for (rule <- rules if rule.text.trim != "") {
|
2013-07-16 02:16:44 -07:00
|
|
|
//Console.println("ability=" + rule.text)
|
2011-07-01 00:39:22 -07:00
|
|
|
}
|
2011-07-01 19:51:19 -07:00
|
|
|
Console.println()
|
2011-07-01 00:39:22 -07:00
|
|
|
}
|
|
|
|
}
|
2013-07-16 02:16:44 -07:00
|
|
|
Console.err.println("end analysis")
|
2011-07-01 00:39:22 -07:00
|
|
|
|
|
|
|
def isScriptable(name:String, rule:String):Boolean = {
|
2011-07-01 19:05:57 -07:00
|
|
|
//normalize the rule text
|
2011-07-10 20:01:39 -07:00
|
|
|
|
|
|
|
//replace name with @
|
|
|
|
//remove cost
|
|
|
|
val norm = rule.trim.replace(name, "@").replaceAll("^[^\\\"]*: ", "")
|
2011-07-01 19:05:57 -07:00
|
|
|
|
|
|
|
//check if this is in the engine
|
|
|
|
if (effects.exists(x => x.equalsIgnoreCase(norm))) {
|
2011-07-01 00:39:22 -07:00
|
|
|
return true
|
2011-06-28 20:07:40 -07:00
|
|
|
}
|
2011-07-01 19:05:57 -07:00
|
|
|
|
|
|
|
//if not, print it out
|
2012-03-25 00:05:43 -07:00
|
|
|
//Console.err.println(norm + "\t" + name);
|
2011-07-01 00:39:22 -07:00
|
|
|
return false
|
2011-06-28 20:07:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Contains the information about the cards that is needed to play the
|
|
|
|
game.
|
|
|
|
|
|
|
|
<cardlist>
|
|
|
|
<card>
|
|
|
|
<name></name>
|
|
|
|
<cost></cost>
|
|
|
|
<loyalty></loyalty>
|
|
|
|
<typelist>
|
|
|
|
<type></type>
|
|
|
|
...
|
|
|
|
</typelist>
|
|
|
|
<pow></pow>
|
|
|
|
<tgh></tgh>
|
|
|
|
<hand></hand>
|
|
|
|
<life></life>
|
|
|
|
<rulelist>
|
|
|
|
<rule reminder=""></rule>
|
|
|
|
...
|
|
|
|
</rulelist>
|
|
|
|
<multi type="">
|
|
|
|
...
|
|
|
|
</multi>
|
|
|
|
</card>
|
|
|
|
...
|
|
|
|
</cardlist>
|
|
|
|
*/
|