Game_Action.prototype.evaluate = function() {
var value = 0;
this.itemTargetCandidates().forEach(function(target) {
var targetValue = this.evaluateWithTarget(target);
if (this.isForAll()) {
value += targetValue;
} else if (targetValue > value) {
value = targetValue;
this._targetIndex = target.index;
}
}, this);
value *= this.numRepeats();
if (value > 0) {
value += Math.random();
}
return value;
};
Game_Action.prototype.evaluateWithTarget = function(target) {
if (this.isHpEffect()) {
var value = this.makeDamageValue(target, false);
if (this.isForOpponent()) {
return value / Math.max(target.hp, 1);
} else {
var recovery = Math.min(-value, target.mhp - target.hp);
return recovery / target.mhp;
}
}
};
Game_Action.prototype.evaluate = function() {
var value = 0;
this.itemTargetCandidates().forEach(function(target) {
var targetValue = this.evaluateWithTarget(target);
if (this.isForAll()) {
value += targetValue;
} else if (targetValue > value) {
value = targetValue;
this._targetIndex = target.index;
}
}, this);
value *= this.numRepeats();
if (value > 0) {
value += Math.random();
}
return value;
};
Game_Action.prototype.evaluateWithTarget = function(target) {
if (this.isHpEffect()) {
var value = this.makeDamageValue(target, false);
if (this.isForOpponent()) {
return value / Math.max(target.hp, 1);
} else {
var recovery = Math.min(-value, target.mhp - target.hp);
return recovery / target.mhp;
}
}
};