# Mana Curve Statistics for gccg (Mtg). # # Copyright (C) 2005 Neil Moore . Distributed with NO WARRANTY # under the terms of the GPL, version 2 (only). # if(msg.box != NULL) { Msg("Loading {gold}Manacurve.command"); } # CountMtgMana(c,list) - Return a pair: the count of cards in list with # converted mana cost c, and the count of cards in list with higher converted # mana cost. Cards with an X in their cost are ignored. # def CountMtgMana { push(c); push(t); push(more); push(cost); t=0.0; more=0.0; for(c)(ARG[1]) { cost = Attr("cost",c); if(find("X",cost) == NULL) { if(mana(cost) == ARG[0]) { t=t+1.0; } else if(mana(cost) > ARG[0]) { more=more+1.0; } } } return((t,more)); cost=pop(); more=pop(); t=pop(); c=pop(); } def CommandManacurve { push(nc); push(tot); push(curdeck); push(i); push(n); push(count); push(s); push(s2); push(s3); push(pct); nc=length(decks{deck.name}{"deck"}); tot=0; curdeck=decks{deck.name}{"deck"}; if(deck.name!=NULL) { Msg("{orange} *** Mtg Mana Curve Statistics: {cyan}" + deck.name + "{orange} *** "); i = 0; s = "{yellow} CC:{gold}"; s2 = "{yellow} no:{white}"; s3 = "{yellow}pct:{white}"; while(i <= 16) { count=CountMtgMana(i,curdeck); n = count[0]; pct = 100.0 * n/nc; tot = tot + n*i; if(n!=0 || count[1] !=0) { if(i%2 && (n >= 10 || pct >= 9.5)) { s = s + " "; } if(pct >= 9.5 && n < 10) { s2 = s2 + " "; } else if(n >= 10 && pct < 9.5) { s3 = s3 + " "; } if(i>=10 && i%2) { s2 = s2 + " "; s3 = s3 + " "; } s = s + " " + format("%2.0f",i); s2 = s2 + " " + format("%2.0f",n); s3 = s3 + " " + format("%2.0f",100*n/nc); i=i+1; } else { # Complete the loop i=20; } } n = 0.0; # Count X cards. X = 3 for purposes of mean casting cost. for(c)(curdeck) { if(find("X",Attr("cost",c)) != NULL) { tot = tot + mana(Attr("cost",c)) + 3; n = n + 1.0; } } s = s + " X"; s2 = s2 + " " + format("%2.0f",n); s3 = s3 + " " + format("%2.0f",100*n/nc); Msg(s); Msg(s2); Msg(s3); Msg("{gold}Average casting cost: {cyan}" + format("%2.1f", tot/nc)); } pct=pop(); s3=pop(); s2=pop(); s=pop(); count=pop(); n=pop(); i=pop(); curdeck=pop(); tot=pop(); nc=pop(); } HELP{"any"}{"manacurve"}=("","analyze mana curve",NULL, "Display a table detailing the mana curve of the current deck, as well as the average casting cost of cards in the deck. For purposes of computing average casting cost, {X} is 3.");