diff options
-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; |