From 66d9bbd8356dca3d0b07145d1eea21de2d4789cc Mon Sep 17 00:00:00 2001 From: Matthew Cline Date: Thu, 29 Oct 2009 01:06:07 -0700 Subject: FR 2839627: notify when player has enough gold The basics of a wish-list/shopping-list. While in a shop the shopping-list can be modified, and the player is notified as soon as they have enough money to buy things on the shopping-list. --- crawl-ref/source/shopping.h | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'crawl-ref/source/shopping.h') diff --git a/crawl-ref/source/shopping.h b/crawl-ref/source/shopping.h index 0bbaae8457..b74d056899 100644 --- a/crawl-ref/source/shopping.h +++ b/crawl-ref/source/shopping.h @@ -26,4 +26,59 @@ std::string shop_name(const coord_def& where, bool add_stop); bool shoptype_identifies_stock(shop_type type); bool is_shop_item(const item_def &item); + +///////////////////////////////////////////////////////////////////// + +struct level_pos; + +class ShoppingList +{ +public: + ShoppingList(); + + bool add_thing(const item_def &item, int cost, level_pos* pos = NULL); + bool add_thing(std::string desc, std::string buy_verb, int cost, + level_pos* pos = NULL); + + bool is_on_list(const item_def &item, level_pos* pos = NULL) const; + bool is_on_list(std::string desc, level_pos* pos = NULL) const; + + bool del_thing(const item_def &item, level_pos* pos = NULL); + bool del_thing(std::string desc, level_pos* pos = NULL); + + int size() const; + + void move_things(const coord_def &src, const coord_def &dst); + + void gold_changed(int old_amount, int new_amount); + + void display_list(); + + void refresh(); + +private: + CrawlVector* list; + + int min_unbuyable_cost; + int min_unbuyable_idx; + int max_buyable_cost; + int max_buyable_idx; + +private: + int find_thing(const item_def &item, const level_pos &pos) const; + int find_thing(const std::string &desc, const level_pos &pos) const; + + static bool thing_is_item(const CrawlHashTable& thing); + static const item_def& get_thing_item(const CrawlHashTable& thing); + static std::string get_thing_desc(const CrawlHashTable& thing); + + static long thing_cost(const CrawlHashTable& thing); + static level_pos thing_pos(const CrawlHashTable& thing); + + static std::string name_thing(const CrawlHashTable& thing); + static std::string describe_thing(const CrawlHashTable& thing); +}; + +extern ShoppingList shopping_list; + #endif -- cgit v1.2.3-54-g00ecf