If the deck has no cards left yet still exists, the deck is destroyed and Nemelexites are awarded a brownie point for using up a deck. If a stacked deck has holes in it, the holes are removed. If a stacked deck has buggy cards in it, they are discarded. If a deck had problems with it, the user is asked if s/he is sure about using the (now fixed) deck, and no turns are used if the answer is "no".
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2276 c06c8d41-db1a-0410-9941-cceddc491573
JPYDWBRN75GC6UZ26MXJTCXGORTJOWGRDEU4JFPU52LYHGK6UI2QC
WVFKGV3AMOYUZ53MWH2RWRITRRCPKKNPTO7QASA5WVKWAUGDJ2OQC
LP3U7LC6QK6TCMLAYTRGZ2CDZAHPM6VWDT6NPE5ET4WBBZVHBDXQC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
3KAINFIXO7WNWGUGZB43EUNFRS2ZPBLQZDTY456QACMRHYIJ7WDAC
RR2J4VLJCZSAKY3HNS334KI4YUAPOMSETO2HGCGEEIUCUJAYAGSQC
2ESKXYN266CEMLSL6DNCKG4REDO34FXL4ODVGMWDJTNJRKMXWCRQC
2IJDLTWK74ULETLFTIPUIY2MSG6RNONVAFNFE7MADPT6UNYSSBDAC
}
static bool check_buggy_deck(item_def& deck)
{
bool stacked_wrong = false;
bool buggy_cards = false;
if (deck.special != 0)
{
long fixed = 0;
long holes = 0;
for (int i = 0; i < 4; i++)
{
const short next_card = ((deck.special >> (8 * i)) & 0xFF);
if (next_card == 0 || next_card > NUM_CARDS)
{
if (next_card == 0)
{
#ifdef WIZARD
if (you.wizard && !stacked_wrong && !buggy_cards)
{
mpr("Stacked deck has a hole in it (1).");
if (yesno("Preserve state for debugging?"))
{
crawl_state.zero_turns_taken();
return true;
}
}
#endif
mpr("Stacked deck has a hole in it (1), fixing...");
stacked_wrong = true;
}
else if (next_card > NUM_CARDS)
{
#ifdef WIZARD
if (you.wizard && !buggy_cards && !stacked_wrong)
{
mprf("Buggy card (%d) in deck.", next_card - 1);
if (yesno("Preserve state for debugging?"))
{
crawl_state.zero_turns_taken();
return true;
}
}
#endif
mprf("Buggy card (%d) in deck, discarding it.",
next_card - 1);
buggy_cards = true;
}
holes++;
continue;
}
fixed |= next_card << (8 * (i - holes));
}
if (stacked_wrong || buggy_cards)
{
mprf("Original deck.special was 0x%x, is now 0x%x",
deck.special, fixed);
deck.special = fixed;
}
}
if (deck.plus2 == 0 && deck.special != 0)
{
#ifdef WIZARD
if (you.wizard && !stacked_wrong && !buggy_cards)
{
mpr("Stacked deck has a hole in it (2).");
if (yesno("Preserve state for debugging?"))
{
crawl_state.zero_turns_taken();
return true;
}
}
#endif
mpr("Stacked deck has a hole in it (2), fixing...");
const short next_card = (deck.special & 0xFF);
deck.special >>= 8;
deck.plus2 = next_card;
stacked_wrong = true;
}
if (deck.plus2 > NUM_CARDS)
{
#ifdef WIZARD
if (you.wizard && !buggy_cards && !stacked_wrong)
{
mprf("Buggy card (%d) in deck.", deck.plus2 - 1);
if (yesno("Preserve state for debugging?"))
{
crawl_state.zero_turns_taken();
return true;
}
}
#endif
mprf("Buggy card (%d) in deck, discarding it.", deck.plus2 - 1);
buggy_cards = true;
deck.plus2 = 0;
}
if (deck.plus <= 0)
{
crawl_state.zero_turns_taken();
mpr("Strange, that deck is already empty.");
if (deck.plus2 != 0)
mpr("And it was stacked, too. Weird.");
#ifdef WIZARD
if (you.wizard)
if (yesno("Preserve deck for debugging?"))
return true;
#endif
mpr("A swarm of software bugs snatches the deck from you and "
"carries it away.");
if ( deck.link == you.equip[EQ_WEAPON] )
unwield_item();
dec_inv_item_quantity( deck.link, 1 );
did_god_conduct(DID_CARDS, 1);
return true;
}
if (stacked_wrong || buggy_cards)
{
you.wield_change = true;
print_stats();
if(!yesno("Deck had problems; use it anyways?"))
{
return true;
crawl_state.zero_turns_taken();
}
}
return false;