<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>Actions/Drop.h</filename>
    </added>
    <added>
      <filename>Events/Beatify.h</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -3,6 +3,7 @@
 #include &quot;Apply.h&quot;
 #include &quot;ApplyInDirection.h&quot;
 #include &quot;Call.h&quot;
+#include &quot;Drop.h&quot;
 #include &quot;Eat.h&quot;
 #include &quot;EatCorpse.h&quot;
 #include &quot;Engrave.h&quot;
@@ -56,6 +57,7 @@ const int Throw::ID = 23;
 const int Unlock::ID = 24;
 const int FarLook::ID = 25;
 const int Enhance::ID = 26;
+const int Drop::ID = 27;
 
 /* constructors/destructor */
 Action::Action(analyzer::Analyzer* analyzer) : _sequence(0), _analyzer(analyzer) {</diff>
      <filename>Actions/Action.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
 #include &quot;Amulet.h&quot;
+
 #include &quot;../EventBus.h&quot;
 #include &quot;../Globals.h&quot;
 #include &quot;../Inventory.h&quot;
@@ -8,6 +9,7 @@
 #include &quot;../Actions/Remove.h&quot;
 #include &quot;../Actions/Select.h&quot;
 #include &quot;../Data/Amulet.h&quot;
+#include &quot;../Events/Beatify.h&quot;
 #include &quot;../Events/Event.h&quot;
 #include &quot;../Events/ChangedInventoryItems.h&quot;
 #include &quot;../Events/ReceivedItems.h&quot;
@@ -31,8 +33,18 @@ void Amulet::onEvent(Event * const event) {
 		ChangedInventoryItems* e = static_cast&lt;ChangedInventoryItems*&gt; (event);
 		wearAmulet(e-&gt;keys());
 	} else if (event-&gt;id() == ReceivedItems::ID) {
+		ReceivedItems* e = static_cast&lt;ReceivedItems*&gt; (event);
+		for (map&lt;unsigned char, Item&gt;::iterator i = e-&gt;items().begin(); i != e-&gt;items().end(); ++i) {
+			if (data::Amulet::amulets().find(i-&gt;second.name()) != data::Amulet::amulets().end()) {
+				if (i-&gt;second.beatitude() == BEATITUDE_UNKNOWN) {
+					/* beatify amulet */
+					Beatify b(i-&gt;first, 100);
+					EventBus::broadcast(&amp;b);
+				}
+			}
+
+		}
 		// FIXME
-		//ReceivedItems* e = static_cast&lt;ReceivedItems*&gt;(event);
 		//wearAmulet(e-&gt;items);
 	} else if (event-&gt;id() == WantItems::ID) {
 		WantItems* e = static_cast&lt;WantItems*&gt; (event);</diff>
      <filename>Analyzers/Amulet.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,7 @@
 #include &quot;Analyzer.h&quot;
 
 #include &quot;Amulet.h&quot;
+#include &quot;Beatitude.h&quot;
 #include &quot;Elbereth.h&quot;
 #include &quot;Enhance.h&quot;
 #include &quot;Explore.h&quot;
@@ -26,6 +27,7 @@ Analyzer::~Analyzer() {
 void Analyzer::init() {
 	/* init analyzers */
 	World::registerAnalyzer(new Amulet());
+	World::registerAnalyzer(new Beatitude());
 	World::registerAnalyzer(new Door());
 	World::registerAnalyzer(new Elbereth());
 	World::registerAnalyzer(new Enhance());</diff>
      <filename>Analyzers/Analyzer.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -1,81 +1,79 @@
 #include &quot;Beatitude.h&quot;
+
 #include &quot;../Globals.h&quot;
 #include &quot;../Item.h&quot;
-#include &quot;../Player.h&quot;
-#include &quot;../Request.h&quot;
 #include &quot;../Saiph.h&quot;
 #include &quot;../World.h&quot;
+#include &quot;../Actions/Drop.h&quot;
+#include &quot;../Actions/Move.h&quot;
+#include &quot;../Events/Beatify.h&quot;
+#include &quot;../Events/WantItems.h&quot;
 
 using namespace analyzer;
+using namespace event;
 using namespace std;
 
 /* constructors/destructor */
-Beatitude::Beatitude(Saiph* saiph) : Analyzer(&quot;Beatitude&quot;), saiph(saiph), check_beatitude(false) {
+Beatitude::Beatitude() : Analyzer(&quot;Beatitude&quot;) {
 }
 
 /* methods */
 void Beatitude::analyze() {
-	if (!check_beatitude)
-		return; // noone has requested beatifying items
-	else if (priority &gt;= PRIORITY_BEATITUDE_DROP_ALTAR)
+	if (_beatify.size() &lt;= 0)
+		return; // no items to beatify
+	else if (Saiph::blind() || Saiph::confused() || Saiph::stunned())
+		return; // no buc-testing while blind/confused/stunned
+	else if (_max_priority &lt; World::currentPriority())
 		return; // got something more important to do
-	else if (saiph-&gt;world-&gt;player.blind)
-		return; // no buc-testing while blind
 
 	/* path to nearest altar */
-	const PathNode&amp; node = saiph-&gt;shortestPath(ALTAR);
-	if (node.cost &gt;= UNPASSABLE)
-		return; // don't know of any altars
-	else if (node.dir == NOWHERE)
-		command = DROP_MENU; // we're standing on the altar, drop items
+	Tile tile = World::shortestPath(ALTAR);
+	if (tile.cost() &gt;= UNPASSABLE)
+		return; // can't path to altar
+	if (tile.direction() == NOWHERE)
+		World::setAction(static_cast&lt;action::Action*&gt; (new action::Drop(this, _max_priority)));
 	else
-		command = node.dir; // move towards altar
-	priority = PRIORITY_BEATITUDE_DROP_ALTAR;
+		World::setAction(static_cast&lt;action::Action*&gt; (new action::Move(this, tile.direction(), _max_priority)));
 }
 
-void Beatitude::parseMessages(const string&amp; messages) {
-	if (saiph-&gt;got_drop_menu &amp;&amp; saiph-&gt;getDungeonSymbol() == ALTAR) {
-		/* drop stuff we don't know beatitude of */
-		for (map&lt;unsigned char, Item&gt;::iterator d = saiph-&gt;drop.begin(); d != saiph-&gt;drop.end(); ++d) {
-			if (!beatify(d-&gt;second))
-				continue;
-			/* mark this */
-			command = d-&gt;first;
-			priority = PRIORITY_SELECT_ITEM;
-			return;
+void Beatitude::onEvent(event::Event * const event) {
+	if (event-&gt;id() == Beatify::ID) {
+		Beatify* e = static_cast&lt;Beatify*&gt; (event);
+		set&lt;unsigned char&gt;::iterator b = _beatify.find(e-&gt;key());
+		_beatify.insert(e-&gt;key());
+		if (e-&gt;priority() &gt; _max_priority)
+			_max_priority = e-&gt;priority();
+	} else if (event-&gt;id() == WantItems::ID &amp;&amp; World::level().tile().symbol() == ALTAR) {
+		/* looting or picking up items at an altar */
+		WantItems* e = static_cast&lt;WantItems*&gt; (event);
+		if (e-&gt;dropping()) {
+			for (map&lt;unsigned char, Item&gt;::iterator i = e-&gt;items().begin(); i != e-&gt;items().end(); ++i) {
+				if (dropItem(i-&gt;second))
+					i-&gt;second.count(0); // setting count to 0 to force dropping the item
+			}
+			_beatify.clear();
+			_max_priority = ILLEGAL_PRIORITY;
 		}
-		/* if we got this far, we've selected everything we don't know beatitude of (on this page) */
-		check_beatitude = false;
-		command = CLOSE_PAGE;
-		priority = PRIORITY_CLOSE_PAGE;
-	}
-}
-
-bool Beatitude::request(const Request&amp; request) {
-	if (request.request == REQUEST_BEATIFY_ITEMS) {
-		check_beatitude = true;
-		return true;
 	}
-	return false;
 }
 
 /* private methods */
-bool Beatitude::beatify(const Item&amp; item) {
-	if (item.beatitude != BEATITUDE_UNKNOWN)
+bool Beatitude::dropItem(const Item&amp; item) {
+	if (item.beatitude() != BEATITUDE_UNKNOWN)
 		return false;
-	if (item.name == &quot;gold piece&quot;)
+	if (item.name() == &quot;gold piece&quot;)
 		return false;
-	if (item.additional == &quot;being worn&quot;)
+	if (item.additional() == &quot;being worn&quot;)
 		return false;
-	if (item.additional == &quot;embedded in your skin&quot;)
+	if (item.additional() == &quot;embedded in your skin&quot;)
 		return false;
-	if (item.additional == &quot;in use&quot;)
+	if (item.additional() == &quot;in use&quot;)
 		return false;
-	if (item.additional == &quot;wielded&quot;)
+	if (item.additional() == &quot;wielded&quot;)
 		return false;
-	if (item.additional.find(&quot;weapon in &quot;, 0) == 0 || item.additional.find(&quot;wielded in other &quot;, 0) == 0)
+	if (item.additional().find(&quot;weapon in &quot;, 0) == 0 || item.additional().find(&quot;wielded in other &quot;, 0) == 0)
 		return false;
-	if (item.additional.find(&quot;on left &quot;, 0) == 0 || item.additional.find(&quot;on right &quot;, 0) == 0)
+	if (item.additional().find(&quot;on left &quot;, 0) == 0 || item.additional().find(&quot;on right &quot;, 0) == 0)
 		return false;
 	return true;
 }</diff>
      <filename>Analyzers/Beatitude.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -1,27 +1,25 @@
 #ifndef ANALYZER_BEATITUDE_H
 #define ANALYZER_BEATITUDE_H
 
-#include &lt;string&gt;
+#include &lt;set&gt;
 #include &quot;Analyzer.h&quot;
 
 class Item;
-class Request;
-class Saiph;
 
 namespace analyzer {
+
 	class Beatitude : public Analyzer {
 	public:
-		Beatitude(Saiph* saiph);
+		Beatitude();
 
 		void analyze();
-		void parseMessages(const std::string&amp; messages);
-		bool request(const Request&amp; request);
+		void onEvent(event::Event * const event);
 
 	private:
-		Saiph* saiph;
-		bool check_beatitude;
+		std::set&lt;unsigned char&gt; _beatify;
+		int _max_priority;
 
-		bool beatify(const Item&amp; item);
+		bool dropItem(const Item&amp; item);
 	};
 }
 #endif</diff>
      <filename>Analyzers/Beatitude.h</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
 #include &quot;Food.h&quot;
+
 #include &quot;../Debug.h&quot;
 #include &quot;../EventBus.h&quot;
 #include &quot;../Saiph.h&quot;</diff>
      <filename>Analyzers/Food.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,7 @@
+#include &quot;Loot.h&quot;
+
 #include &lt;sstream&gt;
 #include &lt;stdlib.h&gt;
-#include &quot;Loot.h&quot;
 #include &quot;../Debug.h&quot;
 #include &quot;../EventBus.h&quot;
 #include &quot;../Inventory.h&quot;
@@ -86,6 +87,7 @@ void Loot::parseMessages(const string&amp; messages) {
 				_wi.addItem(messages[pos - 4], Item(messages.substr(pos, length), 0));
 			pos += length;
 		}
+		_wi.dropping(false);
 		/* broadcast event */
 		EventBus::broadcast(static_cast&lt;Event*&gt; (&amp;_wi));
 		/* pick up stuff that was wanted by analyzers */
@@ -136,6 +138,7 @@ void Loot::parseMessages(const string&amp; messages) {
 			}
 			pos += length;
 		}
+		_wi.dropping(true);
 		/* broadcast event */
 		EventBus::broadcast(static_cast&lt;Event*&gt; (&amp;_wi));
 		/* drop stuff no analyzer wanted */</diff>
      <filename>Analyzers/Loot.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,7 @@
 CXX = g++
 RM = rm -f
 CXXFLAGS = -O0 -Wall -Wextra -g3 -gdwarf-2
-OBJECTS = Analyzer.o Amulet.o Door.o Elbereth.o Enhance.o Explore.o Fight.o Food.o Health.o Loot.o MonsterInfo.o Shop.o
+OBJECTS = Analyzer.o Amulet.o Beatitude.o Door.o Elbereth.o Enhance.o Explore.o Fight.o Food.o Health.o Loot.o MonsterInfo.o Shop.o
 
 analyzers: $(OBJECTS)
 </diff>
      <filename>Analyzers/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,6 @@
 #include &quot;Event.h&quot;
+
+#include &quot;Beatify.h&quot;
 #include &quot;ChangedInventoryItems.h&quot;
 #include &quot;EatItem.h&quot;
 #include &quot;ElberethQuery.h&quot;
@@ -20,6 +22,7 @@ const int ReceivedItems::ID = 4;
 const int StashChanged::ID = 5;
 const int TakeMeThere::ID = 6;
 const int WantItems::ID = 7;
+const int Beatify::ID = 8;
 
 /* constructors/destructor */
 Event::Event(const std::string&amp; name) : _name(name) {</diff>
      <filename>Events/Event.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -19,7 +19,7 @@ namespace event {
 	public:
 		static const int ID;
 
-		WantItems() : Event(&quot;WantItems&quot;), _items() {
+		WantItems() : Event(&quot;WantItems&quot;), _items(), _dropping(false) {
 		}
 
 		virtual ~WantItems() {
@@ -46,8 +46,18 @@ namespace event {
 			_items[key] = item;
 		}
 
+		virtual bool dropping() {
+			return _dropping;
+		}
+
+		virtual bool dropping(const bool&amp; dropping) {
+			_dropping = dropping;
+			return this-&gt;dropping();
+		}
+
 	private:
 		std::map&lt;unsigned char, Item&gt; _items;
+		bool _dropping;
 	};
 }
 #endif</diff>
      <filename>Events/WantItems.h</filename>
    </modified>
    <modified>
      <diff>@@ -6,13 +6,13 @@
         &lt;in&gt;Action.cpp&lt;/in&gt;
         &lt;in&gt;Action.h&lt;/in&gt;
         &lt;in&gt;Answer.h&lt;/in&gt;
-        &lt;in&gt;Answer_1.h&lt;/in&gt;
         &lt;in&gt;Apply.h&lt;/in&gt;
         &lt;in&gt;ApplyInDirection.h&lt;/in&gt;
         &lt;in&gt;Call.h&lt;/in&gt;
         &lt;in&gt;Eat.h&lt;/in&gt;
         &lt;in&gt;EatCorpse.h&lt;/in&gt;
         &lt;in&gt;Engrave.h&lt;/in&gt;
+        &lt;in&gt;Enhance.h&lt;/in&gt;
         &lt;in&gt;FarLook.h&lt;/in&gt;
         &lt;in&gt;Fight.h&lt;/in&gt;
         &lt;in&gt;Kick.h&lt;/in&gt;
@@ -197,6 +197,7 @@
         &lt;in&gt;Whip.h&lt;/in&gt;
       &lt;/df&gt;
       &lt;df name=&quot;Events&quot;&gt;
+        &lt;in&gt;Beatify.h&lt;/in&gt;
         &lt;in&gt;ChangedInventoryItems.h&lt;/in&gt;
         &lt;in&gt;EatItem.h&lt;/in&gt;
         &lt;in&gt;ElberethQuery.h&lt;/in&gt;
@@ -302,14 +303,6 @@
       &lt;/item&gt;
       &lt;item path=&quot;/home/canidae/projects/saiph/Analyzers/Armor.h&quot; ex=&quot;true&quot; tool=&quot;3&quot;&gt;
       &lt;/item&gt;
-      &lt;item path=&quot;/home/canidae/projects/saiph/Analyzers/Beatitude.cpp&quot;
-            ex=&quot;true&quot;
-            tool=&quot;1&quot;&gt;
-      &lt;/item&gt;
-      &lt;item path=&quot;/home/canidae/projects/saiph/Analyzers/Beatitude.h&quot;
-            ex=&quot;true&quot;
-            tool=&quot;3&quot;&gt;
-      &lt;/item&gt;
       &lt;item path=&quot;/home/canidae/projects/saiph/Analyzers/Blind.cpp&quot;
             ex=&quot;true&quot;
             tool=&quot;1&quot;&gt;</diff>
      <filename>nbproject/configurations.xml</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>caf76a8036570b5aea396ca8fd5fe4026a30d975</id>
    </parent>
  </parents>
  <author>
    <name>Vidar Wahlberg</name>
    <email>canidae@exent.net</email>
  </author>
  <url>http://github.com/canidae/saiph/commit/4fc8d978572d6f67e682ce90403429b5e3dfc957</url>
  <id>4fc8d978572d6f67e682ce90403429b5e3dfc957</id>
  <committed-date>2009-10-31T05:07:43-07:00</committed-date>
  <authored-date>2009-10-31T05:07:43-07:00</authored-date>
  <message>she should now know how to beatify items</message>
  <tree>4442df0f8414545e2d4212f45be37d6e862591c7</tree>
  <committer>
    <name>Vidar Wahlberg</name>
    <email>canidae@exent.net</email>
  </committer>
</commit>
