Skip to content

Commit

Permalink
add DIFF condition
Browse files Browse the repository at this point in the history
  • Loading branch information
planqi committed Jul 8, 2017
1 parent 3ec3ab7 commit bef9f1c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions BH/Modules/Item/ItemDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,8 @@ void Condition::BuildConditions(vector<Condition*> &conditions, string token) {
Condition::AddOperand(conditions, new AffixLevelCondition(operation, value));
} else if (key.compare(0, 4, "CLVL") == 0) {
Condition::AddOperand(conditions, new CharStatCondition(STAT_LEVEL, 0, operation, value));
} else if (key.compare(0, 4, "DIFF") == 0) {
Condition::AddOperand(conditions, new DifficultyCondition(operation, value));
} else if (key.compare(0, 4, "RUNE") == 0) {
Condition::AddOperand(conditions, new RuneCondition(operation, value));
} else if (key.compare(0, 4, "GOLD") == 0) {
Expand Down Expand Up @@ -949,6 +951,13 @@ bool CharStatCondition::EvaluateInternalFromPacket(ItemInfo *info, Condition *ar
return IntegerCompare(D2COMMON_GetUnitStat(D2CLIENT_GetPlayerUnit(), stat1, stat2), operation, targetStat);
}

bool DifficultyCondition::EvaluateInternal(UnitItemInfo *uInfo, Condition *arg1, Condition *arg2) {
return IntegerCompare(D2CLIENT_GetDifficulty(), operation, targetDiff);
}
bool DifficultyCondition::EvaluateInternalFromPacket(ItemInfo *info, Condition *arg1, Condition *arg2) {
return IntegerCompare(D2CLIENT_GetDifficulty(), operation, targetDiff);
}

bool ItemStatCondition::EvaluateInternal(UnitItemInfo *uInfo, Condition *arg1, Condition *arg2) {
return IntegerCompare(D2COMMON_GetUnitStat(uInfo->item, itemStat, itemStat2), operation, targetStat);
}
Expand Down
12 changes: 12 additions & 0 deletions BH/Modules/Item/ItemDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,18 @@ class CharStatCondition : public Condition
bool EvaluateInternalFromPacket(ItemInfo *info, Condition *arg1, Condition *arg2);
};

class DifficultyCondition : public Condition
{
public:
DifficultyCondition(BYTE op, unsigned int target)
: operation(op), targetDiff(target) { conditionType = CT_Operand; };
private:
BYTE operation;
unsigned int targetDiff;
bool EvaluateInternal(UnitItemInfo *uInfo, Condition *arg1, Condition *arg2);
bool EvaluateInternalFromPacket(ItemInfo *info, Condition *arg1, Condition *arg2);
};

class ItemStatCondition : public Condition
{
public:
Expand Down

0 comments on commit bef9f1c

Please sign in to comment.