Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- class Predicates {
- static hpLessThanHalf(value, index) {
- return value.mhp/2 > value.hp;
- }
- static isMaxHP(value, index) {
- return value.mhp === value.hp;
- }
- }
- class TrapAction {
- static fire(actionName, predicate) {
- const actionMembers = $gameParty.members().filter(predicate);
- this[actionName](actionMembers);
- }
- //private
- static killMembers(actionMembers) {
- actionMembers.forEach(function(value, index) {
- value.addState(value.deathStateId());
- });
- }
- //private
- static addPoisonState(actionMembers) {
- actionMembers.forEach(function(value, index) {
- value.addState(4);//Poison
- });
- }
- }
- class RewardAction {
- static tryFire(actionName, predicate) {
- const canFire = $gameParty.members().every(predicate);
- if(canFire) {
- this[actionName]();
- }
- }
- //private
- static upToLevelFifty() {
- $gameParty.members().forEach(function(value, index) {
- value.changeLevel(50, true);
- });
- }
- }
- /*以下はスクリプトコマンドから実行する*/
- /*
- //HP全快のメンバーに毒を付与
- TrapAction.fire('addPoisonState', Predicates.isMaxHP);
- //HP半分未満のメンバーは死亡
- TrapAction.fire('killMembers', Predicates.hpLessThanHalf);
- //全メンバーがレベル50以下なら、全メンバー50まで上げる
- RewardAction.tryFire('upToLevelFifty', function(value, index) {
- return value.level <= 50;
- });
- */
Add Comment
Please, Sign In to add comment