Guest User

Untitled

a guest
Jan 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. 'use strict';
  2.  
  3. class Predicates {
  4. static hpLessThanHalf(value, index) {
  5. return value.mhp/2 > value.hp;
  6. }
  7.  
  8. static isMaxHP(value, index) {
  9. return value.mhp === value.hp;
  10. }
  11. }
  12.  
  13. class TrapAction {
  14. static fire(actionName, predicate) {
  15. const actionMembers = $gameParty.members().filter(predicate);
  16. this[actionName](actionMembers);
  17. }
  18.  
  19. //private
  20. static killMembers(actionMembers) {
  21. actionMembers.forEach(function(value, index) {
  22. value.addState(value.deathStateId());
  23. });
  24. }
  25.  
  26. //private
  27. static addPoisonState(actionMembers) {
  28. actionMembers.forEach(function(value, index) {
  29. value.addState(4);//Poison
  30. });
  31. }
  32. }
  33.  
  34. class RewardAction {
  35. static tryFire(actionName, predicate) {
  36. const canFire = $gameParty.members().every(predicate);
  37. if(canFire) {
  38. this[actionName]();
  39. }
  40. }
  41.  
  42. //private
  43. static upToLevelFifty() {
  44. $gameParty.members().forEach(function(value, index) {
  45. value.changeLevel(50, true);
  46. });
  47. }
  48. }
  49.  
  50. /*以下はスクリプトコマンドから実行する*/
  51.  
  52. /*
  53. //HP全快のメンバーに毒を付与
  54. TrapAction.fire('addPoisonState', Predicates.isMaxHP);
  55. //HP半分未満のメンバーは死亡
  56. TrapAction.fire('killMembers', Predicates.hpLessThanHalf);
  57. //全メンバーがレベル50以下なら、全メンバー50まで上げる
  58. RewardAction.tryFire('upToLevelFifty', function(value, index) {
  59. return value.level <= 50;
  60. });
  61. */
Add Comment
Please, Sign In to add comment