# Sell Extras command 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}Sellextras.command"); } # sellextra(c) - Sell all extra copies of card number c. # # Returns the number of extras that were put for sale (possibly zero) def sellextra { push(c); push(sell); push(have); push(myprice); push(price); push(rarity); c = ARG; have = (book_entry(card.book,c))[0]; price = (book_entry(card.book,c))[1]; myprice = (book_entry(card.book,c))[3]; sell = (book_entry(card.book,c))[4]; rarity = Attr("rarity",c); if(sell >= 0 && (have-sell) > 4) { # Don't set the price to zero if(myprice == 0.0) { if(price > 0.0) { BookSetPrice(c, DefaultInitialPrice(c)); } else if(has_entry(rarity, price.default)) { BookSetPrice(c, price.default{rarity}); } else { BookSetPrice(c, 32768.00); } } BookChangeForsale(c, (have-sell-4)); return(have-sell-4); } else { return(0); } rarity = pop(); price = pop(); myprice = pop(); have = pop(); sell = pop(); c = pop(); } # Sell all extra cards on the current page. # def ChatCommandSellextras { push(cards); push(c); push(i); push(sold); push(plural); if(length(ARG) == 0) { cards = book_cards(card.book,book_page(card.book)); } else if(length(ARG) == 1) { if(ARG[0] == "all") { cards = select( "Attr(\"type\",#) != \"Basic Land\" && name(#) != \"Relentless Rats\"", book.filter{"default"} ); } else { cards = select( "set_of(#)==\"" + uc(ARG[0]) + "\"", book.filter{"default"} ); if(length(cards) == 0) { Msg("{red}No cards found in set {gold}" + uc(ARG[0]) + "{red}."); } } } else { Msg("{red}Command {gold}sellextras {red}requires one or fewer arguments."); return(); } i = 0; for(c)(cards) { sold = sellextra(c); if(sold) { if(sold == 1) { plural = ""; } else { plural = "s"; } Msg("{gold}Selling {white}" + canonical_name(c) + "{gold}: {cyan}" + sold + " {gold}extra" + plural); i = i + 1; # Pause every three cards, and turn off screen updates between pauses. if(i % 3 == 0) { refresh(1); sleep(1); refresh(0); } } } refresh(1); plural = pop(); sold = pop(); i = pop(); c = pop(); cards = pop(); } HELP{"chat"}{"sellextras"}=("[ set | {orange}all{yellow} ]","sell extra cards", NULL, "Sell copies beyond the fourth of all the cards on the current page of the collection. If {yellow}{white} is specified, instead sell extra cards from that set, ignoring the current page. Finally, if {yellow}{white} is {orange}\"all\"{white}, sell all extra cards other than basic lands and {gold}Relentless Rats{white}.");