Last active
July 21, 2022 01:52
-
-
Save elleonard/1881233b7c285d08f9c3522eed75ee24 to your computer and use it in GitHub Desktop.
行動の適用対象をステートでフィルタするプラグインのサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
'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