# Per-set statistics for gccg. # # 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}Setstats.command"); } def setcount { push(set); push(c); push(have); set = ARG; c = select("set_of(#)==set", book.filter{"default"}); have = select("(book_entry(card.book, #))[0] > 0", c); return((length(have),length(c))); have = pop(); c = pop(); set = pop(); } def setcount4 { push(set); push(l); push(needed); push(nn); push(c); set = ARG; nn = 0; l = select("set_of(#)==set", book.filter{"default"}); needed = select("(book_entry(card.book, #))[0] < 4", l); for(c)(needed) { nn = nn + 4 - (book_entry(card.book,c))[0]; } return(nn,4*length(l)); c = pop(); nn = pop(); needed = pop(); l = pop(); set = pop(); } def cashneeded4 { push(set); push(l); push(needed); push(nn); push(nc); push(n); push(c); set = ARG; nn = 0; nc = 0; l = select("set_of(#)==set", book.filter{"default"}); needed = select("(book_entry(card.book, #))[0] < 4", l); for(c)(needed) { n = 4 - (book_entry(card.book,c))[0]; nn = nn + n; nc = nc + n * (book_entry(card.book,c))[1]; } return(nc, nn, 4*length(l)); c = pop(); n = pop(); nc = pop(); nn = pop(); needed = pop(); l = pop(); set = pop(); } def cashneeded1 { push(set); push(l); push(needed); push(nn); push(nc); push(n); push(c); set = ARG; nn = 0; nc = 0; l = select("set_of(#)==set", book.filter{"default"}); needed = select("(book_entry(card.book, #))[0] < 1", l); for(c)(needed) { nn = nn + 1; nc = nc + (book_entry(card.book,c))[1]; } return(nc, nn, length(l)); c = pop(); n = pop(); nc = pop(); nn = pop(); needed = pop(); l = pop(); set = pop(); } def CommandNeeded { push(set); push(counts); push(have); push(total); push(str); push(sets); push(skip); str = ""; if(length(ARG) == 0) { sets = sets(); skip = 1; } else { sets = ARG; skip = 0; } for(set)(sets) { counts = setcount(uc(set)); have = counts[0]; total = counts[1]; if(total==0.0 || (have==total && skip)) { } else { str = str + "{yellow}" + uc(set) + "{white}: {white}" + (total - have) + "/{cyan}" + total + " {gold}(" + ((total-have)*100)/total + "%) "; } } Msg(str); skip=pop(); sets=pop(); str=pop(); total=pop(); have=pop(); counts=pop(); set=pop(); } def CommandNeedcash { push(set); push(counts); push(needed); push(total); push(str); push(sets); push(skip); push(cash); push(cashtot); str = ""; if(length(ARG) == 0) { sets = sets(); skip = 1; } else { sets = ARG; skip = 0; } cashtot = 0.0; for(set)(sets) { counts = cashneeded1(uc(set)); cash = counts[0]; needed = counts[1]; total = counts[2]; if(total==0.0 || (needed==0 && skip)) { } else { str = str + "{yellow}" + uc(set) + "{white}: {white}" + (needed) + "/{cyan}" + total + " {gold}($" + format("%.2f", cash) + ") "; } cashtot = cashtot + cash; } Msg(str); Msg("{cyan}Total cash required: {gold}$" + format("%.2f", cashtot)); cashtot=pop(); cash=pop(); skip=pop(); sets=pop(); str=pop(); total=pop(); needed=pop(); counts=pop(); set=pop(); } def CommandNeedcash4 { push(set); push(counts); push(needed); push(total); push(str); push(sets); push(skip); push(cash); push(cashtot); str = ""; if(length(ARG) == 0) { sets = sets(); skip = 1; } else { sets = ARG; skip = 0; } cashtot = 0.0; for(set)(sets) { counts = cashneeded4(uc(set)); cash = counts[0]; needed = counts[1]; total = counts[2]; if(total==0.0 || (needed==0 && skip)) { } else { str = str + "{yellow}" + uc(set) + "{white}: {white}" + (needed) + "/{cyan}" + total + " {gold}($" + format("%.2f", cash) + ") "; } cashtot = cashtot + cash; } Msg(str); Msg("{cyan}Total cash required: {gold}$" + format("%.2f", cashtot)); cashtot=pop(); cash=pop(); skip=pop(); sets=pop(); str=pop(); total=pop(); needed=pop(); counts=pop(); set=pop(); } def CommandNeeded4 { push(set); push(counts); push(needed); push(total); push(str); push(sets); push(skip); str = ""; if(length(ARG) == 0) { sets = sets(); skip = 1; } else { sets = ARG; skip = 0; } for(set)(sets) { counts = setcount4(uc(set)); needed = counts[0]; total = counts[1]; if(total==0.0 || (needed==0 && skip)) { } else { str = str + "{yellow}" + uc(set) + "{white}: {white}" + (needed) + "/{cyan}" + total + " {gold}(" + (needed*100)/total + "%) "; } } Msg(str); skip=pop(); sets=pop(); str=pop(); total=pop(); needed=pop(); counts=pop(); set=pop(); } HELP{"chat"}{"needed"}=("[set1],[set2],...","list number of needed cards",NULL, "For each listed set, list the number of unowned cards in that set, the total number of cards in that set, and the percentage of unowned cards. If no sets are specified, all sets are listed, but sets with no unowned cards are omitted.");