# Gccg command to buy all cards on the current collection page, or to buy # all unowned such cards only. # # 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}Buyall.command"); } # Buy a card if needed def MaybeBuy { push(c); push(have); c = ARG; have = (book_entry(card.book,c))[0]; if(have == 0) { buy(c); return(1); } else { return(0); } have = pop(); c = pop(); } # Sell all extra cards on the current page. # def ChatCommandBuyall { push(cards); push(c); push(i); push(bought); push(newf); cards = book_cards(card.book,book_page(card.book)); if(length(ARG) == 0) { newf = 0; } else if(length(ARG) == 1 && (ARG[0] == "new" || ARG[0] == "n")) { newf = 1; } else { Msg("{orange}Command {white}/buyall{orange} takes one optional argument."); } i = 0; for(c)(cards) { if(newf) { bought = MaybeBuy(c); } else { buy(c); bought = 1; } i = i + bought; if(bought && (i % 5 == 0)) { refresh(1); sleep(1); refresh(0); } } refresh(1); bought = pop(); newf = pop(); i = pop(); c = pop(); cards = pop(); } HELP{"chat"}{"buyall"}=("[{orange}new{yellow}]","buy all cards on current page", NULL, "Buy one copy of each card on the current collection page. If the optional argument {orange}new{white} is given, only buy unowned cards.");