Skip to content

Instantly share code, notes, and snippets.

@elleonard
Last active July 21, 2022 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elleonard/1881233b7c285d08f9c3522eed75ee24 to your computer and use it in GitHub Desktop.
Save elleonard/1881233b7c285d08f9c3522eed75ee24 to your computer and use it in GitHub Desktop.
行動の適用対象をステートでフィルタするプラグインのサンプル
(() => {
'use strict';
/**
* @param {Game_Action.prototype} gameAction
*/
function Game_Action_FilterTargetMixIn(gameAction) {
const _makeTargets = gameAction.makeTargets;
gameAction.makeTargets = function () {
return this.filterTarget(_makeTargets.call(this));
};
gameAction.filterTarget = function (targets) {
if (this.isForStateAffected()) {
const stateId = Number(this.item().meta.forStateAffected);
targets = targets.filter(target => target.isStateAffected(stateId));
}
return targets;
};
gameAction.isForStateAffected = function () {
return !!this.item().meta.forStateAffected;
};
}
Game_Action_FilterTargetMixIn(Game_Action.prototype);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment