Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rawrmage/saiph into experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Karl committed Jan 28, 2012
2 parents 22a78de + 6856377 commit bb74399
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion TODO.rawrmage
Expand Up @@ -9,7 +9,8 @@ TODO list for rawrmage
this was observed in Sokoban.
- fixed, we didn't make the necessary check
- We can't kick when stressed or above, either...
- Make saiph understand "You cannot wear a shield while wielding a two-handed weapon."
X Make saiph understand "You cannot wear a shield while wielding a two-handed weapon."
? Make saiph understand "The very idea of praying to a lawful god is repugnant to you."
- Adopt a more "defensive" combat strategy.
- Are we walking into vault teleporters? Why?
- Don't go up stairs when stressed, don't try.
Expand Down
11 changes: 11 additions & 0 deletions src/Actions/Pray.cpp
@@ -1,9 +1,12 @@
#include "Actions/Pray.h"
#include "Data/Monster.h"

#include "Saiph.h"
#include "World.h"
#include "Item.h"

using namespace action;
using namespace std;

/* constructors/destructor */
Pray::Pray(analyzer::Analyzer* analyzer, int priority) : Action(analyzer, TIME_NOMUL), _pray("#pray\n", priority) {
Expand All @@ -14,10 +17,18 @@ Pray::~Pray() {

/* methods */
bool Pray::isSafeToPray() {
if (Saiph::polymorphed()) {
if (data::Monster::monster(Saiph::race())->symbol() == S_DEMON)
return false;
}
return World::turn() - PRAY_PRAYER_TIMEOUT > Saiph::lastPrayed();
}

bool Pray::isSafeToPrayMajorTrouble() {
if (Saiph::polymorphed()) {
if (data::Monster::monster(Saiph::race())->symbol() == S_DEMON)
return false;
}
return World::turn() - PRAY_MAJOR_TROUBLE > Saiph::lastPrayed();
}

Expand Down
3 changes: 3 additions & 0 deletions src/Analyzers/Armor.cpp
Expand Up @@ -9,6 +9,7 @@
#include "Actions/Answer.h"
#include "Actions/TakeOff.h"
#include "Actions/Wear.h"
#include "Actions/Wield.h"
#include "Data/Armor.h"
#include "Events/Beatify.h"
#include "Events/Event.h"
Expand Down Expand Up @@ -65,6 +66,8 @@ void Armor::analyze() {
if (a != data::Armor::armors().end() && betterThanCurrent(best_wear)) {
if (((a->second->slot() == SLOT_SHIRT || a->second->slot() == SLOT_SUIT) && Inventory::keyForSlot(SLOT_CLOAK) != ILLEGAL_ITEM))
World::setAction(new action::TakeOff(this, Inventory::keyForSlot(SLOT_CLOAK), ARMOR_WEAR_PRIORITY));
else if (a->second->slot() == SLOT_SHIELD && Inventory::keyForSlot(SLOT_WEAPON) != ILLEGAL_ITEM)
World::setAction(new action::Wield(this, '-', ARMOR_WEAR_PRIORITY));
else if (a->second->slot() == SLOT_SHIRT && Inventory::keyForSlot(SLOT_SUIT) != ILLEGAL_ITEM)
World::setAction(new action::TakeOff(this, Inventory::keyForSlot(SLOT_SUIT), ARMOR_WEAR_PRIORITY));
else if (Inventory::keyForSlot(a->second->slot()) != ILLEGAL_ITEM)
Expand Down
3 changes: 3 additions & 0 deletions src/Analyzers/Weapon.cpp
Expand Up @@ -206,6 +206,9 @@ void Weapon::setBestWeapons() {
int best_score = INT_MIN;
int best_key = ILLEGAL_ITEM;
for (map<unsigned char, int>::iterator m = _melee_weapons.begin(); m != _melee_weapons.end(); ++m) {
map<const string, const data::Weapon*>::const_iterator w = data::Weapon::weapons().find(Inventory::itemAtKey(m->first).name());
if (!w->second->oneHanded() && Inventory::keyForSlot(SLOT_SHIELD) != ILLEGAL_ITEM)
continue;
int score = Inventory::itemAtKey(m->first).beatitude() == BEATITUDE_UNKNOWN ? m->second / 2 : m->second;
if (score > best_score) {
best_score = score;
Expand Down
4 changes: 4 additions & 0 deletions tests/two_handed_shield.t
@@ -0,0 +1,4 @@
inventory
+3 small shield
worn +1 dwarven mattock
.

0 comments on commit bb74399

Please sign in to comment.