diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-11-04 13:32:43 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-11-04 13:32:43 +0000 |
commit | ef3ec6727e3da2c7b8180df7231b6f8ed92171c4 (patch) | |
tree | 4f6095fc6593ce90b1bfc7761411aeffc205529e | |
parent | c318b4166554e5c0e113d0d192c123120ff4318d (diff) | |
download | crawl-ref-ef3ec6727e3da2c7b8180df7231b6f8ed92171c4.tar.gz crawl-ref-ef3ec6727e3da2c7b8180df7231b6f8ed92171c4.zip |
Merged 2523: triple draw works off inventory decks.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.3@2746 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/decks.cc | 39 | ||||
-rw-r--r-- | crawl-ref/source/externs.h | 2 |
2 files changed, 26 insertions, 15 deletions
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index d04d1b7c7b..eaf0070a25 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -237,26 +237,38 @@ static bool wielding_deck() return is_deck(you.inv[you.equip[EQ_WEAPON]]); } -// Select a deck from inventory and draw a card from it. -bool choose_deck_and_draw() +// Choose a deck from inventory and return its slot (or -1.) +static int choose_inventory_deck( const char* prompt ) { - int slot = prompt_invent_item( "Draw from which deck?", - MT_INVLIST, OBJ_MISCELLANY, - true, true, true, 0, NULL, - OPER_EVOKE ); + const int slot = prompt_invent_item( prompt, + MT_INVLIST, OBJ_MISCELLANY, + true, true, true, 0, NULL, + OPER_EVOKE ); + if ( slot == PROMPT_ABORT ) { canned_msg(MSG_OK); - return false; + return -1; } - item_def& deck(you.inv[slot]); - if ( !is_deck(deck) ) + if ( !is_deck(you.inv[slot]) ) { mpr("That isn't a deck!"); - return false; + return -1; } - evoke_deck(deck); + + return slot; +} + +// Select a deck from inventory and draw a card from it. +bool choose_deck_and_draw() +{ + const int slot = choose_inventory_deck( "Draw from which deck?" ); + + if ( slot == -1 ) + return false; + + evoke_deck(you.inv[slot]); return true; } @@ -389,13 +401,12 @@ bool deck_stack() // Draw the next three cards, discard two and pick one. bool deck_triple_draw() { - if ( !wielding_deck() ) + const int slot = choose_inventory_deck("Triple draw from which deck?"); + if ( slot == -1 ) { - mpr("You aren't wielding a deck!"); return false; } - const int slot = you.equip[EQ_WEAPON]; item_def& item(you.inv[slot]); if ( item.plus2 != 0 ) diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index a405cbf40d..4139cddd7b 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -712,8 +712,8 @@ public: size_type transform_size(int psize = PSIZE_TORSO) const; std::string shout_verb() const; - item_def *slot_item(equipment_type eq); const item_def *slot_item(equipment_type eq) const; + item_def *slot_item(equipment_type eq); // actor int id() const; |