summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/describe.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-30 22:29:10 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-30 22:29:10 +0000
commita57cca76a917863b82323b0c61d3dae2dfe8d64a (patch)
tree2072041bc2386c8bb0dc1298dc42000735282312 /crawl-ref/source/describe.cc
parent6fa5b18a9ef1bb0656923fa3bf9e1118e1e2ecef (diff)
downloadcrawl-ref-a57cca76a917863b82323b0c61d3dae2dfe8d64a.tar.gz
crawl-ref-a57cca76a917863b82323b0c61d3dae2dfe8d64a.zip
'v' now describes decks properly.
There is a small information leak: if you know (from Peek Deck) that the deck contains a card X somewhere, and then you draw card X which happens not to be the seen card X in the internal structure, you can still see from the 'v' output that there is another X card hiding in there. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2692 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/describe.cc')
-rw-r--r--crawl-ref/source/describe.cc51
1 files changed, 43 insertions, 8 deletions
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 350c7a51f4..a75966984c 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -2971,6 +2971,10 @@ static std::string describe_staff( const item_def &item )
return (description);
}
+static bool compare_card_names(card_type a, card_type b)
+{
+ return std::string(card_name(a)) < std::string(card_name(b));
+}
//---------------------------------------------------------------
//
@@ -3186,16 +3190,47 @@ static std::string describe_misc_item( const item_def &item )
description += "$";
- if ( is_deck(item) && item.plus2 != 0 )
+ if ( is_deck(item) )
{
- description += "$Next card(s): ";
- description += card_name(static_cast<card_type>(item.plus2 - 1));
- long spec = item.special;
- while ( spec )
+ const int num_cards = cards_in_deck(item);
+ if ( top_card_is_known(item) )
{
- description += ", ";
- description += card_name(static_cast<card_type>((spec & 0xFF)-1));
- spec >>= 8;
+ description += "Next card(s): ";
+ for ( int i = 0; i < num_cards; ++i )
+ {
+ unsigned char flags;
+ const card_type card = get_card_and_flags(item, -i-1, flags);
+ if ( flags & CFLAG_MARKED )
+ {
+ if ( i != 0 )
+ description += ", ";
+ description += card_name(card);
+ }
+ else
+ break;
+ }
+ }
+
+ std::vector<card_type> seen_cards;
+ for ( int i = 0; i < num_cards; ++i )
+ {
+ unsigned char flags;
+ const card_type card = get_card_and_flags(item, -i-1, flags);
+ // This *might* leak a bit of information...oh well.
+ if ( (flags & CFLAG_SEEN) && !(flags & CFLAG_MARKED) )
+ seen_cards.push_back(card);
+ }
+ if ( !seen_cards.empty() )
+ {
+ std::sort(seen_cards.begin(), seen_cards.end(),
+ compare_card_names);
+ description += "$Seen cards: ";
+ for ( unsigned int i = 0; i < seen_cards.size(); ++i )
+ {
+ if ( i != 0 )
+ description += ", ";
+ description += card_name(seen_cards[i]);
+ }
}
description += "$";
}