# Buy cards commands for gccg. # # Copyright (C) 2004, 2005 Michael Slone . # # Some modifications (C) 2005 Neil Moore . # # Distributed under the terms of the GNU GPL, version 2. See COPYING # for details. if(msg.box != NULL) { Msg("Loading {gold}Buy.command"); } # buy(c) - Buy the card c at the lowest selling price. def buy { push(p); p = (book_entry(card.book, ARG))[1]; if(p != NULL) { SendMeta("BuyCard", (ARG, p)); } p = pop(); } def ChatCommandBuycard { if(length(ARG) < 1) { Msg("{red}Command {gold}buycard{red} requires an argument."); } else { buy(RecognizeCard(join(ARG, " "))); } } def ChatCommandBuycards { push(c); push(i); if(length(ARG) < 1) { Msg("{red}Command {gold}buycards{red} requires an argument."); } else { i = 0; for(c)(split(join(ARG, " "), "+")) { buy(RecognizeCard(c)); i = i+1; # Pause every five cards, and turn off screen updates between pauses. if(i % 5 == 0) { refresh(1); sleep(1); refresh(0); } } } refresh(1); i = pop(); c = pop(); } HELP{"chat"}{"buycard"}=("card","buy a card",NULL, "Buy the card named {yellow}{white} at the lowest selling price"); HELP{"chat"}{"buycards"}=("[card1] {cyan}+{yellow} [card2] {cyan}+{yellow} ...", "buy cards",NULL,"Buy cards at the lowest selling price.");