//-----------------------------------------------------------------------------
// Game_ActionResult
//
// The game object class for a result of a battle action. For convinience, all
// member variables in this class are public.
/**
* The game object class for a result of a battle action. For convenience, all member variables in this class are public.
*
* @class
*/
function Game_ActionResult() {
this.initialize(...arguments);
}
/**
* Initialize the action result object
*/
Game_ActionResult.prototype.initialize = function() {
this.clear();
};
/**
* Clear the action result
*/
Game_ActionResult.prototype.clear = function() {
this.used = false;
this.missed = false;
this.evaded = false;
this.physical = false;
this.drain = false;
this.critical = false;
this.success = false;
this.hpAffected = false;
this.hpDamage = 0;
this.mpDamage = 0;
this.tpDamage = 0;
this.addedStates = [];
this.removedStates = [];
this.addedBuffs = [];
this.addedDebuffs = [];
this.removedBuffs = [];
};
/**
* Get added state data objects
*
* @return {Object[]} The data objects for added states
*/
Game_ActionResult.prototype.addedStateObjects = function() {
return this.addedStates.map(id => $dataStates[id]);
};
/**
* Get removed state data objects
*
* @return {Object[]} The data objects for removed states
*/
Game_ActionResult.prototype.removedStateObjects = function() {
return this.removedStates.map(id => $dataStates[id]);
};
/**
* Check if any status effects
*
* @return {boolean} True if any status effects exist
*/
Game_ActionResult.prototype.isStatusAffected = function() {
return (
this.addedStates.length > 0 ||
this.removedStates.length > 0 ||
this.addedBuffs.length > 0 ||
this.addedDebuffs.length > 0 ||
this.removedBuffs.length > 0
);
};
/**
* Check if the result was a hit
*
* @return {boolean} True if hit
*/
Game_ActionResult.prototype.isHit = function() {
return this.used && !this.missed && !this.evaded;
};
/**
* Check if the given state is added
*
* @param {number} stateId - The id of the state to check for adding
* @return {boolean} True if added
*/
Game_ActionResult.prototype.isStateAdded = function(stateId) {
return this.addedStates.includes(stateId);
};
/**
* Add the state id to the added states list
*
* @param {number} stateId - The id of the state to add
*/
Game_ActionResult.prototype.pushAddedState = function(stateId) {
if (!this.isStateAdded(stateId)) {
this.addedStates.push(stateId);
}
};
/**
* Check if the given state is removed
*
* @param {number} stateId - The id of the state to check for removal
* @return {boolean} True if removed
*/
Game_ActionResult.prototype.isStateRemoved = function(stateId) {
return this.removedStates.includes(stateId);
};
/**
* Add the state id to the removed states list
*
* @param {number} stateId - The id of the state to remove
*/
Game_ActionResult.prototype.pushRemovedState = function(stateId) {
if (!this.isStateRemoved(stateId)) {
this.removedStates.push(stateId);
}
};
/**
* Check if the given param has a buff added
*
* @param {number} paramId - The id of the param to check for buff adding
* @return {boolean} True if added
*/
Game_ActionResult.prototype.isBuffAdded = function(paramId) {
return this.addedBuffs.includes(paramId);
};
/**
* Add the given param to the added buffs
*
* @param {number} paramId - The id of the param to add a buff for
*/
Game_ActionResult.prototype.pushAddedBuff = function(paramId) {
if (!this.isBuffAdded(paramId)) {
this.addedBuffs.push(paramId);
}
};
/**
* Check if the given param has a debuff added
*
* @param {number} paramId - The id of the param to check for debuff adding
* @return {boolean} True if added
*/
Game_ActionResult.prototype.isDebuffAdded = function(paramId) {
return this.addedDebuffs.includes(paramId);
};
/**
* Add the given param to the added debuffs
*
* @param {number} paramId - The id of the param to add a debuff for
*/
Game_ActionResult.prototype.pushAddedDebuff = function(paramId) {
if (!this.isDebuffAdded(paramId)) {
this.addedDebuffs.push(paramId);
}
};
/**
* Check if the given param has a buff removed
*
* @param {number} paramId - The id of the param to check for buff removal
* @return {boolean} True if removed
*/
Game_ActionResult.prototype.isBuffRemoved = function(paramId) {
return this.removedBuffs.includes(paramId);
};
/**
* Remove the given param from the added buffs
*
* @param {number} paramId - The id of the param to remove a buff for
*/
Game_ActionResult.prototype.pushRemovedBuff = function(paramId) {
if (!this.isBuffRemoved(paramId)) {
this.removedBuffs.push(paramId);
}
};