code:
/*:
 * Yami Engine Delta - Hospital
 *
 * @plugindesc Provides hospital feature, where party spend their money for
 * recovery.
 * @author Yami Engine Delta [Dr.Yami]
 *
 * @param [Default Price]
 * @default
 *
 * @param HP Price
 * @desc Needed money for each missing HP point.
 * @default 10
 *
 * @param MP Price
 * @desc Needed money for each missing MP point.
 * @default 20
 *
 * @param State Price
 * @desc Needed money for removing each state.
 * @default 100
 *
 * @param [Visual Setting]
 * @default
 *
 * @param Nurse Face
 * @desc Nurse Face in Hospital Scene.
 * Faceset, Index
 * @default People4, 1
 *
 * @param Nurse Name
 * @desc Nurse Name, uses for displaying message.
 * @default Loli
 *
 * @param Nurse Message
 * @desc Nurse Greeting Message
 * @default Hello,\nHow can I halp you?
 *
 * @param Heal One Help
 * @desc Text to display on Help Window for Heal One command.
 * @default Heals members individually.
 *
 * @param Heal All Help (Treat)
 * @desc Text to display on Help Window for Heal All command if
 * someone needs treatment.
 * @default Heals all members at cost %1G.
 *
 * @param Heal All Help (Healthy)
 * @desc Text to display on Help Window for Heal All command if the
 * party is healthy.
 * @default All members are healthy.
 *
 * @param Exit Help
 * @desc Text to display on Help Window for Exit command.
 * @default Go out.
 *
 * @param Actor Help (Treat)
 * @desc Text to display on Help Window for actor selection if needs
 * treatment.
 * @default %1 needs treatment.
 *
 * @param Actor Help (Healthy)
 * @desc Text to display on Help Window for actor selection if
 * is healthy.
 * @default %1 is healthy.
 *
 * @param Heal One Command
 * @desc Text to display for Heal One Command.
 * @default Heal One
 *
 * @param Heal All Command
 * @desc Text to display for Heal All Command.
 * @default Heal All
 *
 * @param Exit Command
 * @desc Text to display for Exit Command.
 * @default Exit
 *
 * @param Text Alignment
 * @desc How to align the text for the command window.
 * left     center     right
 * @default center
 *
 * @help
 * The following are Plugin Commands you may use with events.
 *
 * Plugin Command:
 *   OpenHospital       Opens up the Hospital Scene from the field.
 */

/**
 * @namespace Hospital
 * @memberof YED
 */
/*:ja
 * Yami Engine Delta - Hospital
 *
 * @plugindesc パーティの回復、支払などの
 * 病院機能を追加することができます。
 * @author Yami Engine Delta [Dr.Yami]
 *
 * @param [Default Price]
 * @default
 *
 * @param HP Price
 * @desc HPを1回復するためにかかる費用
 * @default 10
 *
 * @param MP Price
 * @desc MPを1回復するためにかかる費用
 * @default 20
 *
 * @param State Price
 * @desc 状態異常を回復するためにかかる費用
 * @default 100
 *
 * @param [Visual Setting]
 * @default
 *
 * @param Nurse Face
 * @desc 病院のシーンで用いられるナースの顔グラフィック
 * Faceset, Index
 * @default People4, 1
 *
 * @param Nurse Name
 * @desc 表示されるナースの名前
 * @default Loli
 *
 * @param Nurse Message
 * @desc ナースの挨拶のセリフ
 * @default こんにちは、今日はどうされましたか？
 *
 * @param Heal One Help
 * @desc 個別回復のヘルプウィンドウに表示されるテキスト
 * @default メンバーを個別に回復させます
 *
 * @param Heal All Help (Treat)
 * @desc 全員回復のヘルプウィンドウに表示されるテキスト
 * @default %1Gを払ってメンバー全員を回復させます
 *
 * @param Heal All Help (Healthy)
 * @desc 全員が回復不要な際、全員回復のヘルプウィンドウに表示されるテキスト
 * @default 回復が必要なメンバーが居ません
 *
 * @param Exit Help
 * @desc 退出時のヘルプウィンドウに表示されるテキスト
 * @default 外に出る
 *
 * @param Actor Help (Treat)
 * @desc 回復が必要なアクター選択時のヘルプウィンドウに表示されるテキスト
 * @default %1は回復が必要だ
 *
 * @param Actor Help (Healthy)
 * @desc 回復が不要なアクター選択時のヘルプウィンドウに表示されるテキスト
 * @default %1は回復の必要はない
 *
 * @param Heal One Command
 * @desc 個別回復のコマンドテキスト
 * @default 1人を回復する
 *
 * @param Heal All Command
 * @desc 全員回復のコマンドテキスト
 * @default 全員を回復する
 *
 * @param Exit Command
 * @desc 退出のコマンドテキスト
 * @default Exit
 *
 * @param Text Alignment
 * @desc コマンドウィンドウでのテキストの表示位置を調整します
 * left(左)     center(中央)     right(右)
 * @default center
 *
 * @help
 * 以下は、イベントで使えるプラグインコマンドです。
 *
 * Plugin Command:
 *   OpenHospital      →フィールドから病院のシーンを開きます
 */

/**
 * @namespace Hospital
 * @memberof YED
 */

var YED = YED || {};

// init Hospital module
YED.Hospital = {};

/**
 * Contains Windows for module.
 *
 * @namespace Windows
 * @memberof YED.Hospital
 */
YED.Hospital.Windows = {};

/**
 * Contains Scenes for module.
 *
 * @namespace Scenes
 * @memberof YED.Hospital
 */
YED.Hospital.Scenes = {};

/* globals YED: false */

(function () {
  /**
   * Contains utility tools for module.
   *
   * @namespace Utils
   * @memberof YED.Hospital
   */
  var Utils = {};

  /**
   * Contains module parsed parameters.
   *
   * @type {Object}
   * @memberOf  YED.Hospital.Utils
   */
  Utils.parameters = {};

  /**
   * Process parameters function.
   * Should be called with DataManager as current object.
   *
   * @function processParameters
   * @memberof YED.Hospital.Utils
   */
  Utils.processParameters = function () {
    var parameters = PluginManager.parameters("YED_Hospital"),
      result = Utils.parameters,
      nurseFaceStr = String(parameters["Nurse Face"] || "People4, 1"),
      nurseFace = [];

    nurseFace = nurseFaceStr.split(",");

    result["HP Price"] = Number(parameters["HP Price"] || 0);
    result["MP Price"] = Number(parameters["MP Price"] || 0);
    result["State Price"] = Number(parameters["State Price"] || 0);

    result["Nurse Face"] = [nurseFace[0], Number(nurseFace[1])];
    result["Nurse Name"] = String(parameters["Nurse Name"] || "Nurse");
    result["Nurse Message"] = String(parameters["Nurse Message"] || "Hello!");

    result["Heal One Help"] = String(parameters["Heal One Help"] || "");
    result["Heal All Help (Treat)"] = //
      String(parameters["Heal All Help (Treat)"] || "");
    result["Heal All Help (Healthy)"] = //
      String(parameters["Heal All Help (Healthy)"] || "");
    result["Exit Help"] = String(parameters["Exit Help"] || "");

    result["Actor Help (Treat)"] = String(
      parameters["Actor Help (Treat)"] || ""
    );
    result["Actor Help (Healthy)"] = String(
      parameters["Actor Help (Healthy)"] || ""
    );

    result["Heal One Command"] = String(
      parameters["Heal One Command"] || "Heal One"
    );
    result["Heal All Command"] = String(
      parameters["Heal All Command"] || "Heal All"
    );
    result["Exit Command"] = String(parameters["Exit Command"] || "Exit");

    result["Text Alignment"] = String(parameters["Text Alignment"] || "center");
    result["Text Alignment"] = result["Text Alignment"].toLowerCase();
  };

  /**
   * Go to Hospital Scene.
   * Should be called with Game_Interpreter object as current object.
   *
   * @function gotoHospitalScene
   * @memberof YED.Hospital.Utils
   */
  Utils.gotoHospitalScene = function () {
    var scene = YED.Hospital.Scenes.Hospital;

    SceneManager.push(scene);
  };

  YED.Hospital.Utils = Utils;
})();

/* globals YED: false */

/**
 * Pre-processes and notetag parsing
 */
(function () {
  // shorten dependencies
  var Utils = YED.Hospital.Utils;
  // Aliasing: Scene_Boot.start
  var _Scene_Boot_start = Scene_Boot.prototype.start;

  /**
   * Extending: Scene_Boot.prototype.start
   *
   * Add notetags processing for module.
   */
  Scene_Boot.prototype.start = function () {
    _Scene_Boot_start.call(this);

    Utils.processParameters.call(DataManager);
  };
})();

/* globals YED: false */

(function () {
  /**
   * Shorten Dependencies
   */
  var Utils = YED.Hospital.Utils;

  /**
   * Calculate hospital fees for actor.
   *
   * @function external:Game_Actor#hospitalFee
   * @return {number} Total hospital fees
   */
  Game_Actor.prototype.hospitalFee = function () {
    var lostHp = Math.max(this.mhp - this._hp, 0),
      lostMp = Math.max(this.mmp - this._mp, 0),
      fee = 0,
      states = this.getHospitalStates();

    fee = lostHp * this.getHospitalHpFeeRate();
    fee += lostMp * this.getHospitalMpFeeRate();

    for (var i = 0; i < states.length; i++) {
      fee += this.getHospitalStateFeeRate(states[i].id);
    }

    return fee;
  };

  /**
   * Get hospital fee for each HP lost.
   *
   * @function external:Game_Actor#getHospitalHpFeeRate
   * @return {number} Hospital HP Fee Rate
   */
  Game_Actor.prototype.getHospitalHpFeeRate = function () {
    return Utils.parameters["HP Price"];
  };

  /**
   * Get hospital fee for each MP lost.
   *
   * @function external:Game_Actor#getHospitalMpFeeRate
   * @return {number} Hospital MP Fee Rate
   */
  Game_Actor.prototype.getHospitalMpFeeRate = function () {
    return Utils.parameters["MP Price"];
  };

  /**
   * Get hospital fee for each state to be removed.
   *
   * @function external:Game_Actor#getHospitalStateFeeRate
   * @return {number} Hospital State Fee Rate
   */
  Game_Actor.prototype.getHospitalStateFeeRate = function (stateId) {
    /* jshint unused:vars */
    return Utils.parameters["State Price"];
  };

  /**
   * Get states need to be hospitalized.
   *
   * @function external:Game_Actor#getHospitalStates
   * @return {Object[]} States Array
   */
  Game_Actor.prototype.getHospitalStates = function () {
    return this.states();
  };

  /**
   * Recover and pay the hospital fee.
   *
   * @function external:Game_Actor#hospitalize
   */
  Game_Actor.prototype.hospitalize = function () {
    this._hospitalPay();
    this._hospitalRecover();
  };

  /**
   * Check if actor is healthy.
   *
   * @function external:Game_Actor#isHealthy
   * @return {Boolean} Is healthy
   */
  Game_Actor.prototype.isHealthy = function () {
    return (
      this._hp >= this.mhp &&
      this._mp >= this.mmp &&
      this.getHospitalStates().length === 0
    );
  };

  /**
   * Check if actor needs to be hospitalized.
   *
   * @function external:Game_Actor#isHospitalizable
   * @return {Boolean} Need hospitalize
   */
  Game_Actor.prototype.isHospitalizable = function () {
    var notHealthy = !this.isHealthy(),
      enoughMoney = $gameParty.gold() >= this.hospitalFee();

    return notHealthy && enoughMoney;
  };

  /**
   * Hospital Recover method.
   *
   * @function external:Game_Actor#_hospitalRecover
   * @private
   */
  Game_Actor.prototype._hospitalRecover = function () {
    var states = this.getHospitalStates();

    for (var i = 0; i < states.length; i++) {
      this.removeState(states[i].id);
    }

    this._hp = this.mhp;
    this._mp = this.mmp;
  };

  /**
   * Hospital Paying Fee method.
   *
   * @function external:Game_Actor#_hospitalPay
   * @private
   */
  Game_Actor.prototype._hospitalPay = function () {
    $gameParty.loseGold(this.hospitalFee());
  };
})();

(function () {
  /**
   * Calculate hospital fees for the whole party.
   *
   * @function external:Game_Party#hospitalFee
   * @return {number} Total hospital fees
   */
  Game_Party.prototype.hospitalFee = function () {
    var members = this.members(),
      fee = 0;

    for (var i = 0; i < members.length; i++) {
      fee += members[i].hospitalFee();
    }

    return fee;
  };

  /**
   * Recover and pay the hospital fee.
   *
   * @function external:Game_Party#hospitalize
   */
  Game_Party.prototype.hospitalize = function () {
    var members = this.members();

    for (var i = 0; i < members.length; i++) {
      members[i].hospitalize();
    }
  };

  /**
   * Check if party is healthy.
   *
   * @function external:Game_Party#isHealthy
   * @return {Boolean} Is healthy
   */
  Game_Party.prototype.isHealthy = function () {
    var members = this.members();

    for (var i = 0; i < members.length; i++) {
      if (!members[i].isHealthy()) {
        return false;
      }
    }

    return true;
  };

  /**
   * Check if party needs to be hospitalized.
   *
   * @function external:Game_Party#isHospitalizable
   * @return {Boolean} Need hospitalize
   */
  Game_Party.prototype.isHospitalizable = function () {
    var members = this.members();

    if ($gameParty.gold() < this.hospitalFee()) {
      return false;
    }

    for (var i = 0; i < members.length; i++) {
      if (members[i].isHospitalizable()) {
        return true;
      }
    }

    return false;
  };
})();

/* globals YED: false */

(function () {
  /**
   * Window shows actors list for hospital.
   *
   * @class
   * @extends external:Window_Selectable
   * @memberof YED.Hospital.Windows
   *
   * @param {number} wx Window X
   * @param {number} wy Window Y
   * @param {number} [ww] Window Width
   * @param {number} wh Window Height
   */
  var HospitalActors = function () {
    this.initialize.apply(this, arguments);
  };

  /**
   * Inherits from Window_Base
   */
  HospitalActors.prototype = Object.create(Window_Selectable.prototype);
  HospitalActors.prototype.constructor = HospitalActors;

  /**
   * Initialize
   *
   * @constructs HospitalActors
   */
  HospitalActors.prototype.initialize = function (wx, wy, ww, wh) {
    ww = ww || this.windowWidth();

    Window_Selectable.prototype.initialize.call(this, wx, wy, ww, wh);
    this.refresh();
  };

  /**
   * Window height for initialize.
   *
   * @return {number} Window Height
   */
  HospitalActors.prototype.windowWidth = function () {
    return Graphics.boxWidth;
  };

  /**
   * Refresh Window contents.
   */
  HospitalActors.prototype.refresh = function () {
    this.makeItemList();
    this.createContents();
    this.drawAllItems();
  };

  /**
   * Get actors list.
   */
  HospitalActors.prototype.makeItemList = function () {
    this._data = $gameParty.members();
  };

  /**
   * Get current actor.
   *
   * @return {Game_Actor} Current select actor
   */
  HospitalActors.prototype.actor = function () {
    return this._data[this.index()];
  };

  /**
   * Check if current actor is hospitalizable.
   *
   * @return {Boolean} Enabled Flag
   */
  HospitalActors.prototype.isCurrentItemEnabled = function () {
    return this.isEnabled(this.actor());
  };

  /**
   * Check if current actor is hospitalizable.
   *
   * @return {Boolean} Enabled Flag
   */
  HospitalActors.prototype.isEnabled = function (actor) {
    return !!actor ? actor.isHospitalizable() : false;
  };

  /**
   * Get party current size.
   *
   * @return {number} Total actors
   */
  HospitalActors.prototype.maxItems = function () {
    return this._data ? this._data.length : 1;
  };

  /**
   * Draw actor status.
   *
   * @param  {number} index Actor Index
   */
  HospitalActors.prototype.drawItem = function (index) {
    var actor = this._data[index],
      rect = this.itemRect(index),
      gaugeWidth = 0,
      offsetX = 0;

    if (!actor) {
      return;
    }

    gaugeWidth =
      this.contentsWidth() -
      (168 * 2 + Window_Base._iconWidth * 3 + this.textPadding() * 2);
    gaugeWidth = gaugeWidth / 2 - 8;

    offsetX = this.textPadding();
    this.drawActorName(actor, rect.x + offsetX, rect.y, 168);

    offsetX = offsetX + 168;
    this.drawActorIcons(
      actor,
      rect.x + offsetX,
      rect.y,
      Window_Base._iconWidth * 3
    );

    offsetX = offsetX + Window_Base._iconWidth * 3;
    this.drawActorHp(actor, rect.x + offsetX, rect.y, gaugeWidth);

    offsetX = offsetX + gaugeWidth + 8;
    this.drawActorMp(actor, rect.x + offsetX, rect.y, gaugeWidth);

    offsetX = offsetX + gaugeWidth;
    this.drawActorHospital(actor, rect.x + offsetX, rect.y, 168);
  };

  /**
   * Draw actor hospital fees.
   *
   * @param  {Game_Actor} actor Actor
   * @param  {number} x     Draw at X
   * @param  {number} y     Draw at Y
   * @param  {number} width Limit Text Width
   */
  HospitalActors.prototype.drawActorHospital = function (actor, x, y, width) {
    width = width || 168;
    this.drawCurrencyValue(
      actor.hospitalFee(),
      this.currencyUnit(),
      x,
      y,
      width
    );
  };

  /**
   * Get currency unit.
   *
   * @return {String} Currency Unit
   */
  HospitalActors.prototype.currencyUnit = function () {
    return TextManager.currencyUnit;
  };

  /**
   * Update help window
   */
  HospitalActors.prototype.updateHelp = function () {
    var symbol = "";

    if (!this.actor()) {
      return;
    }

    symbol = this._getHelpSymbol();
    this._helpWindow.setSymbol(symbol, this.actor());
  };

  /**
   * Get text symbol for displaying help
   *
   * @private
   */
  HospitalActors.prototype._getHelpSymbol = function () {
    var symbol = "";

    if (this.actor().isHealthy()) {
      symbol = "Actor Help (Healthy)";
    } else {
      symbol = "Actor Help (Treat)";
    }

    return symbol;
  };

  YED.Hospital.Windows.HospitalActors = HospitalActors;
})();

/* globals YED: false */

(function () {
  /**
   * Shorten Dependencies
   */
  var Utils = YED.Hospital.Utils;

  /**
   * Window shows nurse face and her messages.
   *
   * @class
   * @extends external:Window_Base
   * @memberof YED.Hospital.Windows
   *
   * @param {number} wx Window X
   * @param {number} wy Window Y
   * @param {number} ww Window Width
   * @param {number} [wh] Window Height
   */
  var HospitalNurse = function () {
    this.initialize.apply(this, arguments);
  };

  /**
   * Inherits from Window_Base
   */
  HospitalNurse.prototype = Object.create(Window_Base.prototype);
  HospitalNurse.prototype.constructor = HospitalNurse;

  /**
   * Initialize
   *
   * @constructs HospitalNurse
   */
  HospitalNurse.prototype.initialize = function (wx, wy, ww, wh) {
    wh = wh || this.windowHeight();

    Window_Base.prototype.initialize.call(this, wx, wy, ww, wh);
    this.loadImages();
    this.refresh();
  };

  /**
   * Window height for initialize.
   *
   * @return {number} Window Height
   */
  HospitalNurse.prototype.windowHeight = function () {
    return this.fittingHeight(4);
  };

  /**
   * Load and cache Faceset for Nurse Face.
   */
  HospitalNurse.prototype.loadImages = function () {
    var faceName = Utils.parameters["Nurse Face"][0];

    ImageManager.loadFace(faceName);
  };

  /**
   * Refresh window contents.
   */
  HospitalNurse.prototype.refresh = function () {
    this.contents.clear();

    this._drawNurseFace();
    this._drawNurseName();
    this._drawNurseMessage();
  };

  /**
   * Draw nurse face.
   *
   * @private
   */
  HospitalNurse.prototype._drawNurseFace = function () {
    var faceName = Utils.parameters["Nurse Face"][0],
      faceIndex = Utils.parameters["Nurse Face"][1];

    this.drawFace(faceName, faceIndex, 0, 0);
  };

  /**
   * Draw nurse name.
   *
   * @private
   */
  HospitalNurse.prototype._drawNurseName = function () {
    var nurseName = Utils.parameters["Nurse Name"],
      dx = Window_Base._faceWidth + this.textPadding();

    this.drawTextEx(nurseName, dx, 0);
  };

  /**
   * Draw nurse message.
   *
   * @private
   */
  HospitalNurse.prototype._drawNurseMessage = function () {
    var nurseMessage = Utils.parameters["Nurse Message"],
      dx = Window_Base._faceWidth + this.textPadding();

    this.drawTextEx(nurseMessage, dx, this.lineHeight());
  };

  YED.Hospital.Windows.HospitalNurse = HospitalNurse;
})();

/* globals YED: false */

(function () {
  /**
   * Shorten Dependencies
   */
  var Utils = YED.Hospital.Utils;

  /**
   * Window shows commands for Hospital Scene.
   *
   * @class
   * @extends external:Window_Command
   * @memberof YED.Hospital.Windows
   *
   * @param {number} wx Window X
   * @param {number} wy Window Y
   * @param {number} [ww] Window Width
   * @param {number} [wh] Window Height
   */
  var HospitalCommand = function () {
    this.initialize.apply(this, arguments);
  };

  /**
   * Inherits from Window_Command
   */
  HospitalCommand.prototype = Object.create(Window_Command.prototype);
  HospitalCommand.prototype.constructor = HospitalCommand;

  /**
   * Initialize Window when created.
   *
   * @constructs HospitalCommand
   */
  HospitalCommand.prototype.initialize = function (wx, wy, ww, wh) {
    ww = ww || this.windowWidth();
    wh = wh || this.windowHeight();

    Window_Command.prototype.initialize.call(this, wx, wy);

    this.width = ww;
    this.height = wh;
  };

  /**
   * Window width for initialize.
   *
   * @return {number} Window Width
   */
  HospitalCommand.prototype.windowWidth = function () {
    return 240;
  };

  /**
   * Get visible rows for height setting.
   *
   * @return {number} Rows
   */
  HospitalCommand.prototype.numVisibleRows = function () {
    return 4;
  };

  /**
   * Get text align setting.
   *
   * @return {String} Align setting
   */
  HospitalCommand.prototype.itemTextAlign = function () {
    return Utils.parameters["Text Alignment"];
  };

  /**
   * Make commands list for Window.
   */
  HospitalCommand.prototype.makeCommandList = function () {
    this._addHealCommand();
    this._addCustomCommand();
    this._addExitCommand();
  };

  /**
   * Update help window
   */
  HospitalCommand.prototype.updateHelp = function () {
    var symbol = this._getHelpSymbol();
    this._helpWindow.setSymbol(symbol);
  };

  /**
   * Add heal commands to Window.
   *
   * @private
   */
  HospitalCommand.prototype._addHealCommand = function () {
    var healOneText = Utils.parameters["Heal One Command"],
      healAllText = Utils.parameters["Heal All Command"],
      enableHealAll = $gameParty.isHospitalizable();

    this.addCommand(healOneText, "healOne", true);
    this.addCommand(healAllText, "healAll", enableHealAll);
  };

  /**
   * Add custom commands (for any add-on) to Window.
   *
   * @private
   */
  HospitalCommand.prototype._addCustomCommand = function () {
    // made for future add-ons
  };

  /**
   * Add exit command to Window.
   *
   * @private
   */
  HospitalCommand.prototype._addExitCommand = function () {
    var text = Utils.parameters["Exit Command"];

    this.addCommand(text, "cancel", true);
  };

  /**
   * Get text symbol for displaying help
   *
   * @private
   */
  HospitalCommand.prototype._getHelpSymbol = function () {
    var symbol = "";

    switch (this.currentSymbol()) {
      case "healOne":
        symbol = "Heal One Help";
        break;
      case "healAll":
        if ($gameParty.isHealthy()) {
          symbol = "Heal All Help (Healthy)";
        } else {
          symbol = "Heal All Help (Treat)";
        }
        break;
      case "cancel":
        symbol = "Exit Help";
        break;
    }

    return symbol;
  };

  YED.Hospital.Windows.HospitalCommand = HospitalCommand;
})();

/* globals YED: false */

(function () {
  /**
   * Shorten Dependencies
   */
  var Utils = YED.Hospital.Utils;

  /**
   * Window shows command help.
   *
   * @class
   * @extends external:Window_Help
   * @memberof YED.Hospital.Windows
   *
   * @param {number} wx Window X
   * @param {number} wy Window Y
   * @param {number} ww Window Width
   * @param {number} [wh] Window Height
   */
  var HospitalHelp = function () {
    this.initialize.apply(this, arguments);
  };

  /**
   * Inherits from Window_Help
   */
  HospitalHelp.prototype = Object.create(Window_Help.prototype);
  HospitalHelp.prototype.constructor = HospitalHelp;

  /**
   * Initialize
   *
   * @constructs HospitalHelp
   */
  HospitalHelp.prototype.initialize = function (wx, wy, ww, wh) {
    wh = wh || this.windowHeight();

    Window_Help.prototype.initialize.call(this, 1);

    this.x = wx;
    this.y = wy;
    this.width = ww;
    this.height = wh;

    this._textSymbol = "";
    this._windowCommand = null;
    this._windowActors = null;
  };

  /**
   * Window height for initialize.
   *
   * @return {number} Window Height
   */
  HospitalHelp.prototype.windowHeight = function () {
    return this.fittingHeight(1);
  };

  /**
   * Refresh window contents.
   */
  HospitalHelp.prototype.refresh = function () {
    this.contents.clear();
    this._drawHelpText();
  };

  /**
   * Clear window contents.
   */
  HospitalHelp.prototype.clear = function () {
    this.setSymbol("");
  };

  /**
   * Set window symbol for formatting texts.
   */
  HospitalHelp.prototype.setSymbol = function (symbol, actor) {
    this._textSymbol = symbol;
    this._actor = actor;
    this.refresh();
  };

  /**
   * Get help text.
   *
   * @return {String} Help Text
   * @private
   */
  HospitalHelp.prototype._getHelpText = function () {
    var text = Utils.parameters[this._textSymbol],
      actor = this._actor;

    switch (this._textSymbol) {
      case "Heal All Help (Treat)":
        text = text.format($gameParty.hospitalFee());
        break;
      case "Actor Help (Treat)":
        text = text.format(actor.name());
        break;
      case "Actor Help (Healthy)":
        text = text.format(actor.name());
        break;
    }

    return text;
  };

  /**
   * Draw help text.
   *
   * @private
   */
  HospitalHelp.prototype._drawHelpText = function () {
    var text = "";

    if (this._textSymbol !== "") {
      text = this._getHelpText();
      this.drawTextEx(text, this.textPadding(), 0);
    }
  };

  YED.Hospital.Windows.HospitalHelp = HospitalHelp;
})();

/* globals YED: false */

(function () {
  /**
   * Shorten Dependencies
   */
  var Windows = YED.Hospital.Windows;

  /**
   * Scene for Hospital.
   *
   * @class
   * @extends external:Scene_MenuBase
   * @memberof YED.Hospital.Scenes
   */
  var Hospital = function () {
    this.initialize.apply(this, arguments);
  };

  /**
   * Inherits from Scene_MenuBase
   */
  Hospital.prototype = Object.create(Scene_MenuBase.prototype);
  Hospital.prototype.constructor = Hospital;

  /**
   * Initialize
   *
   * @constructs Hospital
   */
  Hospital.prototype.initialize = function () {
    Scene_MenuBase.prototype.initialize.call(this);
  };

  /**
   * Create Windows.
   */
  Hospital.prototype.create = function () {
    Scene_MenuBase.prototype.create.call(this);
    this._createGoldWindow();
    this._createHelpWindow();
    this._createCommandWindow();
    this._createNurseWindow();
    this._createActorsWindow();
  };

  /**
   * Refresh Windows.
   */
  Hospital.prototype.start = function () {
    Scene_MenuBase.prototype.start.call(this);
    this._nurseWindow.refresh();
  };

  /**
   * Create Gold Window.
   *
   * @private
   */
  Hospital.prototype._createGoldWindow = function () {
    this._goldWindow = new Window_Gold(0, 0);
    this._goldWindow.x = Graphics.boxWidth - this._goldWindow.width;
    this._goldWindow.y = Graphics.boxHeight - this._goldWindow.height;
    this.addWindow(this._goldWindow);
  };

  /**
   * Create Help Window.
   *
   * @private
   */
  Hospital.prototype._createHelpWindow = function () {
    var wx = 0,
      wy = this._goldWindow.y,
      ww = Graphics.boxWidth - this._goldWindow.width;

    this._helpWindow = new Windows.HospitalHelp(wx, wy, ww);
    this.addWindow(this._helpWindow);
  };

  /**
   * Create Command Window.
   *
   * @private
   */
  Hospital.prototype._createCommandWindow = function () {
    this._commandWindow = new Windows.HospitalCommand(0, 0);
    this._commandWindow.setHelpWindow(this._helpWindow);

    this._commandWindow.setHandler("healOne", this._commandHealOne.bind(this));
    this._commandWindow.setHandler("healAll", this._commandHealAll.bind(this));
    this._commandWindow.setHandler("cancel", this.popScene.bind(this));

    this.addWindow(this._commandWindow);
  };

  /**
   * Create Nurse Window.
   *
   * @private
   */
  Hospital.prototype._createNurseWindow = function () {
    var wx = this._commandWindow.width,
      wy = this._commandWindow.y,
      ww = Graphics.boxWidth - this._commandWindow.width;

    this._nurseWindow = new Windows.HospitalNurse(wx, wy, ww);
    this.addWindow(this._nurseWindow);
  };

  /**
   * Create Actors Window.
   *
   * @private
   */
  Hospital.prototype._createActorsWindow = function () {
    var wx = 0,
      wy = this._commandWindow.height,
      wh = Graphics.boxHeight - wy - this._goldWindow.height;

    this._actorsWindow = new Windows.HospitalActors(wx, wy, null, wh);
    this._actorsWindow.setHelpWindow(this._helpWindow);

    this._actorsWindow.setHandler("ok", this._onActorOk.bind(this));
    this._actorsWindow.setHandler("cancel", this._onActorCancel.bind(this));

    this.addWindow(this._actorsWindow);
  };

  /**
   * Handler for command healOne
   *
   * @private
   */
  Hospital.prototype._commandHealOne = function () {
    this._actorsWindow.activate();
    this._actorsWindow.select(0);
  };

  /**
   * Handler for command healAll
   *
   * @private
   */
  Hospital.prototype._commandHealAll = function () {
    $gameParty.hospitalize();
    this._actorsWindow.refresh();
    this._goldWindow.refresh();
    this._commandWindow.refresh();
    this._commandWindow.activate();
  };

  /**
   * Handler for actor selection.
   *
   * @private
   */
  Hospital.prototype._onActorOk = function () {
    var actor = this._actorsWindow.actor();

    if (!!actor) {
      actor.hospitalize();

      this._actorsWindow.refresh();
      this._goldWindow.refresh();
      this._commandWindow.refresh();
      this._actorsWindow.activate();
    }
  };

  /**
   * Handler for actor cancel.
   *
   * @private
   */
  Hospital.prototype._onActorCancel = function () {
    this._commandWindow.activate();
    this._actorsWindow.deselect();
  };

  YED.Hospital.Scenes.Hospital = Hospital;
})();

/* globals YED: false */

(function () {
  /**
   * Aliasing methods
   */
  var _Game_Interpreter_pluginCommand =
    Game_Interpreter.prototype.pluginCommand;

  /**
   * Extending: Game_Interpreter.prototype.pluginCommand
   *
   * Add go to Hospital Scene Plugin Command.
   */
  Game_Interpreter.prototype.pluginCommand = function (command, args) {
    // actual initialize
    _Game_Interpreter_pluginCommand.call(this, command, args);

    // Hospital Plugin Command
    if (command === "OpenHospital") {
      YED.Hospital.Utils.gotoHospitalScene.call(this);
    }
  };
})();


code:
/*:
 * Yami Engine Delta - Invert Target
 *
 * @plugindesc v1.0.1 This plugin allows player to use skill on the other team, for example use healing on an enemy.
 * @author Yami Engine Delta [Dr.Yami]
 *
 * @param Invert Keys (Keyboard)
 * @desc A list of keyName.
 * For example: pageup pagedown
 * @default pageup pagedown shift
 *
 * @param Invert Keys (Gamepad)
 * @desc A list of keyName.
 * For example: pageup pagedown
 * @default pageup pagedown shift
 *
 * @help
 * Compatibility
 * ---
 * If you use YEP - Battle Engine Core, this plugin should be put above that.
 *
 * ==============================================
 * Item & Skill Notetags
 * ---
 * <No Invert>
 * Make the skill/item cannot be inverted.
 */

/**
 * @namespace InvertTarget
 * @memberof YED
 */

var YED = YED || {};

// init InvertTarget module
YED.InvertTarget = {};

/* globals YED: false */

(function ($InvertTarget) {
  /**
   * Enum for RegExp, used to notetags
   *
   * @readonly
   * @enum {RegExp}
   * @memberof YED.InvertTarget
   */
  var Regexp = {
    /**
     * Makes state not single ~
     */
    NOT_INVERT: /<(?:not invert)>/i,
  };

  $InvertTarget.Regexp = Regexp;
})(YED.InvertTarget);

/* globals YED: false */

(function ($InvertTarget) {
  /**
   * Shorten Dependencies
   */
  var Regexp = $InvertTarget.Regexp;

  /**
   * Contains utility tools for module.
   *
   * @namespace Utils
   * @memberof YED.InvertTarget
   */
  var Utils = {};

  /**
   * Contains module parsed parameters.
   *
   * @type {Object}
   * @memberOf  YED.InvertTarget.Utils
   */
  Utils.parameters = {};

  /**
   * Process parameters function.
   * Should be called with DataManager as current object.
   *
   * @function processParameters
   * @memberof YED.InvertTarget.Utils
   */
  Utils.processParameters = function () {
    var parameters = PluginManager.parameters("YED_InvertTarget"),
      result = Utils.parameters;

    result["Invert Keys (Keyboard)"] =
      parameters["Invert Keys (Keyboard)"].split(" ");

    result["Invert Keys (Gamepad)"] =
      parameters["Invert Keys (Gamepad)"].split(" ");
  };

  /**
   * Process notetag function.
   * Should be called with DataManager as current object.
   *
   * @function processNotetag
   * @memberof YED.InvertTarget.Utils
   */
  Utils.processNotetags = function () {
    var groups = [$dataSkills, $dataItems],
      group,
      obj,
      notedata,
      line;

    for (var j = 0; j < groups.length; j++) {
      group = groups[j];

      for (var i = 1; i < group.length; i++) {
        obj = group[i];
        notedata = obj.note.split(/[\r\n]+/);

        Utils._processProperties.call(this, obj);
        Utils._processMethods.call(this, obj);

        for (var n = 0; n < notedata.length; n++) {
          line = notedata[n];
          Utils._processNotetag.call(this, obj, line);
        }
      }
    }
  };

  /**
   * Add new properties into object.
   *
   * @function _processProperties
   * @memberof YED.InvertTarget.Utils
   * @param  {Object} obj Data object
   * @private
   */
  Utils._processProperties = function (obj) {
    obj._invertTarget = true;
  };

  /**
   * Add new methods into object.
   *
   * @function _processMethods
   * @memberof YED.InvertTarget.Utils
   * @param  {Object} obj Data object
   * @private
   */
  Utils._processMethods = function (obj) {
    obj.getInvertTarget = Utils.getInvertTarget;
  };

  /**
   * Process notetag for object.
   *
   * @function _processNotetag
   * @memberof YED.InvertTarget.Utils
   * @param  {Object} obj Data object
   * @param  {String} notetag Notetag
   * @private
   */
  Utils._processNotetag = function (obj, notetag) {
    var match;

    match = notetag.match(Regexp.NOT_INVERT);
    if (match) {
      obj._invertTarget = true;
    }
  };

  /**
   * Get invert target flag.
   *
   * @function getInvertTarget
   * @memberof YED.InvertTarget.Utils
   * @return {Boolean} Invertable!
   */
  Utils.getInvertTarget = function () {
    return !!this._invertTarget;
  };

  $InvertTarget.Utils = Utils;
})(YED.InvertTarget);

/* globals YED: false */

/**
 * Pre-processes and notetag parsing
 */
(function ($InvertTarget) {
  /**
   * Shorten Dependencies
   */
  var Utils = $InvertTarget.Utils;

  /**
   * Aliasing methods
   */
  var _DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;

  /**
   * Extending: DataManager.isDatabaseLoaded
   *
   * Add notetags and parameters processing for module.
   */
  DataManager.isDatabaseLoaded = function () {
    var loaded = _DataManager_isDatabaseLoaded.call(this);

    if (!loaded) {
      return false;
    }

    Utils.processParameters.call(DataManager);
    Utils.processNotetags.call(DataManager);

    return true;
  };
})(YED.InvertTarget);

(function () {
  /**
   * Aliasing methods
   */
  var _Game_Action_clear = Game_Action.prototype.clear;
  var _Game_Action_setSkill = Game_Action.prototype.setSkill;
  var _Game_Action_setItem = Game_Action.prototype.setItem;
  var _Game_Action_needsSelection = Game_Action.prototype.needsSelection;
  var _Game_Action_friendsUnit = Game_Action.prototype.friendsUnit;
  var _Game_Action_opponentsUnit = Game_Action.prototype.opponentsUnit;

  Game_Action.prototype.clear = function () {
    _Game_Action_clear.call(this);

    this.clearInvert();
  };

  Game_Action.prototype.clearInvert = function () {
    this._invertTarget = false;
  };

  Game_Action.prototype.toggleInvert = function () {
    if (!this.item()) {
      return false;
    }

    if (!this.item().getInvertTarget()) {
      return false;
    }

    this._invertTarget = !this._invertTarget;

    return true;
  };

  Game_Action.prototype.setSkill = function (skillId) {
    _Game_Action_setSkill.call(this, skillId);

    this.clearInvert();
  };

  Game_Action.prototype.setItem = function (itemId) {
    _Game_Action_setItem.call(this, itemId);

    this.clearInvert();
  };

  Game_Action.prototype.needsSelection = function () {
    var result = _Game_Action_needsSelection.call(this),
      forAll = this.checkItemScope([2, 8]);

    return result || forAll;
  };

  Game_Action.prototype.friendsUnit = function () {
    var friendsUnit = _Game_Action_friendsUnit.call(this),
      opponentsUnit = _Game_Action_opponentsUnit.call(this);

    if (this._invertTarget) {
      return opponentsUnit;
    }

    return friendsUnit;
  };

  Game_Action.prototype.opponentsUnit = function () {
    var friendsUnit = _Game_Action_friendsUnit.call(this),
      opponentsUnit = _Game_Action_opponentsUnit.call(this);

    if (this._invertTarget) {
      return friendsUnit;
    }

    return opponentsUnit;
  };
})();

/* globals YED: false */

(function ($InvertTarget) {
  /**
   * Aliasing methods
   */
  var _Scene_Battle_update = Scene_Battle.prototype.update;
  var _Scene_Battle_startActorCommandSelection =
    Scene_Battle.prototype.startActorCommandSelection;

  Scene_Battle.prototype.update = function () {
    _Scene_Battle_update.call(this);

    this._updateInvertTarget();
  };

  Scene_Battle.prototype.startActorCommandSelection = function () {
    _Scene_Battle_startActorCommandSelection.call(this);

    BattleManager.inputtingAction().clearInvert();
  };

  Scene_Battle.prototype._isChoosingTargets = function () {
    return this._actorWindow.active || this._enemyWindow.active;
  };

  Scene_Battle.prototype._updateInvertTarget = function () {
    var keyNameKeyboard =
        $InvertTarget.Utils.parameters["Invert Keys (Keyboard)"],
      keyNameGamepad = $InvertTarget.Utils.parameters["Invert Keys (Gamepad)"],
      triggered = function (key) {
        return Input.isTriggered(key);
      },
      input;

    input = BattleManager.inputtingAction();

    if (!input) {
      return;
    }

    if (!this._isChoosingTargets()) {
      return;
    }

    if (!input.item()) {
      return;
    }

    if (keyNameKeyboard.some(triggered) || keyNameGamepad.some(triggered)) {
      if (!input.toggleInvert()) {
        return;
      }

      if (this._actorWindow.active) {
        this._actorWindow.deactivate();
        this._actorWindow.hide();
        this.selectEnemySelection();

        return;
      }

      if (this._enemyWindow.active) {
        this._enemyWindow.deactivate();
        this._enemyWindow.hide();
        this.selectActorSelection();

        return;
      }
    }
  };
})(YED.InvertTarget);

repo_name: dazed/translations

license: unknown


code:
/**
 * @namespace LunaEngine
 */

var LunaEngine = LunaEngine || {};

/**
 * @namespace Core
 * @memberof LunaEngine
 */
/*=============================================================================
 * Luna Engine Core
 * By Archeia and Yami.
 * Version: 1.0
 *
 * Put this below Luna Engine Battle Config in the Plugin Manager.
 *
 *=============================================================================*/
/*:
 * @plugindesc Put this below Luna Engine Battle Config in the Plugin Manager.
 * @author Archeia and Yami
 *
 * @help
 * Put this below Luna Engine Battle Config in the Plugin Manager.
 */

LunaEngine.Core = {};
LunaEngine.Core.Sprite = {};

/* globals LunaEngine: false */

(function ($LunaEngine, $Window_Base) {
  var GUI = function () {
    this.initialize.apply(this, arguments);
  };

  GUI.prototype = Object.create(Sprite_Base.prototype);
  GUI.prototype.constructor = GUI;

  GUI.prototype.initialize = function () {
    Sprite_Base.prototype.initialize.call(this);

    this._windowskin = null; // for textColor
    this._config = {};
    this._attach = {};
    this._select = false;

    this._selectEnemy = false;
    this._selectAction = false;

    this._conditions = [];

    this.loadWindowskin();
  };

  GUI.prototype.setupGUI = function () {
    this.updateGUIParams();
  };

  GUI.prototype.attach = function (name, object) {
    if (!!this._attach[name] && this._attach[name] === object) {
      return;
    }

    this._attach[name] = object;
    this.updateGUIParams();

    Object.defineProperty(this, name, {
      get: function () {
        return this._attach[name];
      },
      configurable: true,
    });
  };

  GUI.prototype.select = function () {
    this._select = true;
  };

  GUI.prototype.deselect = function () {
    this._select = false;
  };

  GUI.prototype.setSelectEnemy = function (flag) {
    this._selectEnemy = flag;
  };

  GUI.prototype.setSelectAction = function (flag) {
    this._selectAction = flag;
  };

  GUI.prototype._setupConfig = function (config) {
    var result = JSON.parse(JSON.stringify(config));

    for (var key in result) {
      if (typeof result[key] === "string") {
        result[key] = this._evalConfig(result[key]);
      }
    }

    return result;
  };

  GUI.prototype._evalConfig = function (string) {
    var matches, evals, thisEval;

    if (!string) {
      return "";
    }

    thisEval = function (s) {
      return eval(s);
    };
    thisEval = thisEval.bind(this);

    matches = string.match(/\{[^{}]+\}/g);

    if (!matches) {
      return string;
    }

    evals = matches.map(thisEval);

    for (var i = 0; i < matches.length; i++) {
      string = string.replace(matches[i], evals[i]);
    }

    return string;
  };

  GUI.prototype._evalCondition = function (config) {
    var result = JSON.parse(JSON.stringify(config)),
      conditionals = result.conditional,
      cond,
      evaluate;

    if (!conditionals) {
      return result;
    }

    for (var i = 0; i < conditionals.length; i++) {
      cond = conditionals[i];

      if (!this._conditions[i]) {
        this._conditions[i] = new Function(
          "return " + cond.condition + ";"
        ).bind(this);
      }

      evaluate = this._conditions[i];

      if (!evaluate()) {
        continue;
      }

      for (var key in cond.properties) {
        result[key] = cond.properties[key];
      }
    }

    return result;
  };

  /**
   * The image used as a window skin.
   *
   * @property windowskin
   * @type Bitmap
   */
  Object.defineProperty(GUI.prototype, "windowskin", {
    get: function () {
      return this._windowskin;
    },
    set: function (value) {
      if (this._windowskin !== value) {
        this._windowskin = value;
      }
    },
    configurable: true,
  });

  /**
   * The image used as a window skin.
   *
   * @property windowskin
   * @type Bitmap
   */
  Object.defineProperty(GUI.prototype, "contents", {
    get: function () {
      return this.bitmap;
    },
    configurable: true,
  });

  Object.defineProperty(GUI.prototype, "config", {
    get: function () {
      return this._evalCondition(this._config);
    },
    set: function (value) {
      this._config = JSON.parse(JSON.stringify(value));
      this.setupGUI();
    },
    configurable: true,
  });

  GUI.prototype.update = function () {
    Sprite_Base.prototype.update.call(this);

    this.updateGUIParams();
    this.updateAnimation();
  };

  GUI.prototype.updateGUIParams = function () {
    this.updateGUIVisible();
    this.updateGUIPosition();
    this.updateGUIColor();
  };

  GUI.prototype.updateGUIVisible = function () {
    var visible = this._getVisible();

    if (this.visible !== visible) {
      this.visible = visible;
    }
  };

  GUI.prototype.updateGUIPosition = function () {
    var x = this._getX(),
      y = this._getY();

    if (this.x !== x || this.y !== y) {
      this.move(x, y);
    }
  };

  GUI.prototype.updateGUIColor = function () {
    var colorTone = this._getColorTone();

    this.setColorTone(colorTone);
  };

  GUI.prototype.updateAnimation = function () {
    if (!this.actor || !this._isShowAnimation()) {
      return;
    }

    this.setupAnimation();
  };

  GUI.prototype.setupAnimation = function () {
    while (this.actor.isLunaAnimationRequested()) {
      var data = this.actor.shiftLunaAnimation();
      var animation = $dataAnimations[data.animationId];
      var mirror = data.mirror;
      var delay = animation.position === 3 ? 0 : data.delay;
      this.startAnimation(animation, mirror, delay);
    }
  };

  GUI.prototype.refresh = function () {
    this._refreshGUI();
  };

  GUI.prototype._refreshGUI = function () {
    // polymorph!
  };

  GUI.prototype._getX = function () {
    return this.config.x || 0;
  };

  GUI.prototype._getY = function () {
    return this.config.y || 0;
  };

  GUI.prototype._getColorTone = function () {
    return this.config.tone || [0, 0, 0, 0];
  };

  GUI.prototype._getVisible = function () {
    if (this.config.visible === undefined) {
      return true;
    }

    return this.config.visible;
  };

  GUI.prototype._getConditions = function () {
    return this._config.conditional; // avoid infinite loops
  };

  GUI.prototype._isShowAnimation = function () {
    return !!this._config.showAnimation;
  };

  GUI.prototype.isSelectingActor = function () {
    return this._select;
  };

  GUI.prototype.isSelectingEnemy = function () {
    return this._selectEnemy;
  };

  GUI.prototype.isSelectingAction = function () {
    return this._selectAction;
  };

  // TODO: Try creating a hidden window sharing bitmap with Sprite.

  GUI.prototype.loadWindowskin = $Window_Base.prototype.loadWindowskin;
  GUI.prototype.lineHeight = $Window_Base.prototype.lineHeight;
  GUI.prototype.standardFontFace = $Window_Base.prototype.standardFontFace;
  GUI.prototype.standardFontSize = $Window_Base.prototype.standardFontSize;
  GUI.prototype.textPadding = $Window_Base.prototype.textPadding;
  GUI.prototype.resetFontSettings = function () {};
  GUI.prototype.resetTextColor = $Window_Base.prototype.resetTextColor;
  GUI.prototype.textColor = $Window_Base.prototype.textColor;
  GUI.prototype.normalColor = $Window_Base.prototype.normalColor;
  GUI.prototype.systemColor = $Window_Base.prototype.systemColor;
  GUI.prototype.crisisColor = $Window_Base.prototype.crisisColor;
  GUI.prototype.deathColor = $Window_Base.prototype.deathColor;
  GUI.prototype.gaugeBackColor = $Window_Base.prototype.gaugeBackColor;
  GUI.prototype.hpGaugeColor1 = $Window_Base.prototype.hpGaugeColor1;
  GUI.prototype.hpGaugeColor2 = $Window_Base.prototype.hpGaugeColor2;
  GUI.prototype.mpGaugeColor1 = $Window_Base.prototype.mpGaugeColor1;
  GUI.prototype.mpGaugeColor2 = $Window_Base.prototype.mpGaugeColor2;
  GUI.prototype.mpCostColor = $Window_Base.prototype.mpCostColor;
  GUI.prototype.powerUpColor = $Window_Base.prototype.powerUpColor;
  GUI.prototype.powerDownColor = $Window_Base.prototype.powerDownColor;
  GUI.prototype.tpGaugeColor1 = $Window_Base.prototype.tpGaugeColor1;
  GUI.prototype.tpGaugeColor2 = $Window_Base.prototype.tpGaugeColor2;
  GUI.prototype.tpCostColor = $Window_Base.prototype.tpCostColor;
  GUI.prototype.pendingColor = $Window_Base.prototype.pendingColor;
  GUI.prototype.translucentOpacity = $Window_Base.prototype.translucentOpacity;
  GUI.prototype.changeTextColor = $Window_Base.prototype.changeTextColor;
  GUI.prototype.changePaintOpacity = $Window_Base.prototype.changePaintOpacity;
  GUI.prototype.drawText = $Window_Base.prototype.drawText;
  GUI.prototype.textWidth = $Window_Base.prototype.textWidth;
  GUI.prototype.drawTextEx = $Window_Base.prototype.drawTextEx;
  GUI.prototype.convertEscapeCharacters =
    $Window_Base.prototype.convertEscapeCharacters;
  GUI.prototype.actorName = $Window_Base.prototype.actorName;
  GUI.prototype.partyMemberName = $Window_Base.prototype.partyMemberName;
  GUI.prototype.processCharacter = $Window_Base.prototype.processCharacter;
  GUI.prototype.processNormalCharacter =
    $Window_Base.prototype.processNormalCharacter;
  GUI.prototype.processNewLine = $Window_Base.prototype.processNewLine;
  GUI.prototype.obtainEscapeCode = $Window_Base.prototype.obtainEscapeCode;
  GUI.prototype.obtainEscapeParam = $Window_Base.prototype.obtainEscapeParam;
  GUI.prototype.processEscapeCharacter =
    $Window_Base.prototype.processEscapeCharacter;
  GUI.prototype.processDrawIcon = $Window_Base.prototype.processDrawIcon;
  GUI.prototype.makeFontBigger = $Window_Base.prototype.makeFontBigger;
  GUI.prototype.makeFontSmaller = $Window_Base.prototype.makeFontSmaller;
  GUI.prototype.calcTextHeight = $Window_Base.prototype.calcTextHeight;
  GUI.prototype.drawIcon = $Window_Base.prototype.drawIcon;
  GUI.prototype.drawFace = $Window_Base.prototype.drawFace;
  GUI.prototype.drawCharacter = $Window_Base.prototype.drawCharacter;
  GUI.prototype.drawGauge = $Window_Base.prototype.drawGauge;

  $LunaEngine.Core.Sprite.GUI = GUI;
})(LunaEngine, Window_Base);

/* globals LunaEngine: false */

(function ($LunaEngine, $Window_Base, $Bitmap) {
  // dependencies
  var GUI = $LunaEngine.Core.Sprite.GUI;

  var GUIIcons = function () {
    this.initialize.apply(this, arguments);

    this._iconIds = [];

    this._maxIcons = 1;
    this._direction = "horizontal";

    this._fnGetIcons = null;
  };

  GUIIcons.prototype = Object.create(GUI.prototype);
  GUIIcons.prototype.constructor = GUIIcons;

  GUIIcons.prototype.initialize = function () {
    GUI.prototype.initialize.call(this);
  };

  Object.defineProperty(GUIIcons.prototype, "iconIds", {
    get: function () {
      return this._iconIds;
    },
    set: function (value) {
      if (!this._iconIds.equals(value)) {
        this._iconIds = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  Object.defineProperty(GUIIcons.prototype, "maxIcons", {
    get: function () {
      return this._maxIcons;
    },
    set: function (value) {
      if (this._maxIcons !== value) {
        this._maxIcons = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  Object.defineProperty(GUIIcons.prototype, "direction", {
    get: function () {
      return this._direction.toLowerCase();
    },
    set: function (value) {
      if (this._direction !== value) {
        this._direction = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  GUIIcons.prototype.updateGUIParams = function () {
    GUI.prototype.updateGUIParams.call(this);

    this.iconIds = this._getIconIds();
    this.maxIcons = this._getMaxIcons();
    this.direction = this._getDirection();
  };

  GUIIcons.prototype._refreshGUI = function () {
    var width = $Window_Base._iconWidth,
      height = $Window_Base._iconHeight,
      x = 0,
      y = 0;

    if (this.direction === "horizontal") {
      x = width;
      width = width * this.maxIcons;
    }

    if (this.direction === "vertical") {
      y = height;
      height = height * this.maxIcons;
    }

    this.bitmap = new $Bitmap(width, height);

    for (var i = 0; i < this.iconIds.length; i++) {
      this.drawIcon(this.iconIds[i], x * i, y * i);
    }
  };

  GUIIcons.prototype._getIconIds = function () {
    var iconIds = this.config.iconIds;

    if (!this._fnGetIcons && !!this.actor) {
      this._fnGetIcons = new Function("return " + iconIds + ";").bind(this);
    }

    if (!!this._fnGetIcons) {
      return this._fnGetIcons();
    }

    return [];
  };

  GUIIcons.prototype._getMaxIcons = function () {
    return this.config.maxIcons || 1;
  };

  GUIIcons.prototype._getDirection = function () {
    return this.config.direction || "horizontal";
  };

  $LunaEngine.Core.Sprite.GUIIcons = GUIIcons;
})(LunaEngine, Window_Base, Bitmap);

/* globals LunaEngine: false */

(function ($LunaEngine, $Bitmap) {
  // dependencies
  var GUI = $LunaEngine.Core.Sprite.GUI;

  var GUIText = function () {
    this.initialize.apply(this, arguments);
  };

  GUIText.prototype = Object.create(GUI.prototype);
  GUIText.prototype.constructor = GUIText;

  GUIText.prototype.initialize = function () {
    GUI.prototype.initialize.call(this);

    this.bitmap = new $Bitmap(1, 1);

    this._text = "";
  };

  Object.defineProperty(GUIText.prototype, "text", {
    get: function () {
      return this._text;
    },
    set: function (value) {
      if (this._text !== value) {
        this._text = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  Object.defineProperty(GUIText.prototype, "fontFace", {
    get: function () {
      return this.contents.fontFace;
    },
    set: function (value) {
      if (this.contents.fontFace !== value) {
        this.contents.fontFace = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  Object.defineProperty(GUIText.prototype, "fontSize", {
    get: function () {
      return this.contents.fontSize;
    },
    set: function (value) {
      if (this.contents.fontSize !== value) {
        this.contents.fontSize = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  Object.defineProperty(GUIText.prototype, "color", {
    get: function () {
      return this.contents.textColor;
    },
    set: function (value) {
      if (this.contents.textColor !== value) {
        this.contents.textColor = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  Object.defineProperty(GUIText.prototype, "outlineColor", {
    get: function () {
      return this._outlineColor;
    },
    set: function (value) {
      if (this.contents.outlineColor !== value) {
        this.contents.outlineColor = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  GUIText.prototype.updateGUIParams = function () {
    GUI.prototype.updateGUIParams.call(this);

    this.text = this._getText();

    this.fontFace = this._getFontFace();
    this.fontSize = this._getFontSize();

    this.color = this._getTextColor();
    this.outlineColor = this._getOutlineColor();
  };

  GUIText.prototype._refreshGUI = function () {
    var text = this.text,
      lines = text.split("\n"),
      lineNumber = lines.length,
      width = 0,
      height = 0;

    for (var i = 0; i < lineNumber; i++) {
      if (width < this.textWidth(lines[i])) {
        width = this.textWidth(lines[i]);
      }
    }

    width = width + this.textPadding() * 2;
    height = this.lineHeight() * lineNumber;

    this.bitmap = new $Bitmap(width, height);
    this.drawTextEx(text, this.textPadding(), 0);
  };

  GUIText.prototype._getText = function () {
    return this._evalConfig(this.config.text) || "Test";
  };

  GUIText.prototype._getFontFace = function () {
    return this._evalConfig(this.config.fontFace) || this.standardFontFace();
  };

  GUIText.prototype._getFontSize = function () {
    return this._evalConfig(this.config.fontSize) || this.standardFontSize();
  };

  GUIText.prototype._getTextColor = function () {
    return this._evalConfig(this.config.textColor) || this.normalColor();
  };

  GUIText.prototype._getOutlineColor = function () {
    return this._evalConfig(this.config.outlineColor) || "rgba(0,0,0,0.5)";
  };

  GUIText.prototype.resetFontSettings = function () {
    this.contents.fontFace = this._getFontFace();
    this.contents.fontSize = this._getFontSize();

    this.contents.textColor = this._getTextColor();
    this.contents.outlineColor = this._getOutlineColor();
  };

  GUIText.prototype.textPadding = function () {
    return 2;
  };

  $LunaEngine.Core.Sprite.GUIText = GUIText;
})(LunaEngine, Bitmap);

/* globals LunaEngine: false */

(function ($LunaEngine, $Window_Base, $Bitmap) {
  // dependencies
  var GUI = $LunaEngine.Core.Sprite.GUI;

  var GUIFace = function () {
    this.initialize.apply(this, arguments);
  };

  GUIFace.prototype = Object.create(GUI.prototype);
  GUIFace.prototype.constructor = GUIFace;

  GUIFace.prototype.initialize = function () {
    GUI.prototype.initialize.call(this);

    this.bitmap = new $Bitmap(
      $Window_Base._faceWidth,
      $Window_Base._faceHeight
    );

    this._faceName = "";
    this._faceIndex = 0;
  };

  GUIFace.prototype.setupGUI = function () {
    GUI.prototype.setupGUI.call(this);

    this.faceName = this._getFaceName();
    this.faceIndex = this._getFaceIndex();

    ImageManager.loadFace(this.faceName);
  };

  Object.defineProperty(GUIFace.prototype, "faceName", {
    get: function () {
      return this._faceName;
    },
    set: function (value) {
      if (this._faceName !== value) {
        this._faceName = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  Object.defineProperty(GUIFace.prototype, "faceIndex", {
    get: function () {
      return this._faceIndex;
    },
    set: function (value) {
      if (this._faceIndex !== value) {
        this._faceIndex = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  GUIFace.prototype.updateGUIParams = function () {
    GUI.prototype.updateGUIParams.call(this);

    this.faceName = this._getFaceName();
    this.faceIndex = this._getFaceIndex();
  };

  GUIFace.prototype._refreshGUI = function () {
    var faceName = this.faceName,
      faceIndex = this.faceIndex;

    this.bitmap.clear();
    this.drawFace(faceName, faceIndex, 0, 0);
  };

  GUIFace.prototype._getFaceName = function () {
    return this._evalConfig(this.config.faceName) || "";
  };

  GUIFace.prototype._getFaceIndex = function () {
    return this._evalConfig(this.config.faceIndex) || 0;
  };

  $LunaEngine.Core.Sprite.GUIFace = GUIFace;
})(LunaEngine, Window_Base, Bitmap);

/* globals LunaEngine: false */

(function ($LunaEngine, $ImageManager) {
  // dependencies
  var GUI = $LunaEngine.Core.Sprite.GUI;

  var GUIImage = function () {
    this.initialize.apply(this, arguments);

    this._path = "";
    this._hue = 0;
  };

  GUIImage.prototype.setupGUI = function () {
    GUI.prototype.setupGUI.call(this);

    this.path = this._getPath();
    this.hue = this._getHue();

    $ImageManager.loadNormalBitmap(this.path, this.hue);
  };

  GUIImage.prototype = Object.create(GUI.prototype);
  GUIImage.prototype.constructor = GUIImage;

  GUIImage.prototype.initialize = function () {
    GUI.prototype.initialize.call(this);
  };

  Object.defineProperty(GUIImage.prototype, "path", {
    get: function () {
      return this._path;
    },
    set: function (value) {
      if (this._path !== value) {
        this._path = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  Object.defineProperty(GUIImage.prototype, "hue", {
    get: function () {
      return this._hue;
    },
    set: function (value) {
      if (this._hue !== value) {
        this._hue = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  GUIImage.prototype.updateGUIParams = function () {
    GUI.prototype.updateGUIParams.call(this);

    this.path = this._getPath();
    this.hue = this._getHue();
  };

  GUIImage.prototype._refreshGUI = function () {
    var path = this._path,
      hue = this._hue;

    this.bitmap = $ImageManager.loadNormalBitmap(path, hue);
  };

  GUIImage.prototype._getPath = function () {
    return this._evalConfig(this.config.imagePath) || "";
  };

  GUIImage.prototype._getHue = function () {
    return this.config.hue || 0;
  };

  $LunaEngine.Core.Sprite.GUIImage = GUIImage;
})(LunaEngine, ImageManager);

/* globals LunaEngine: false */

(function ($LunaEngine, $Bitmap) {
  // dependencies
  var GUI = $LunaEngine.Core.Sprite.GUI;

  var GUIGauge = function () {
    this.initialize.apply(this, arguments);

    this._gaugeWidth = 0;
    this._gaugeHeight = 0;

    this._rate = 0;

    this._color1 = "";
    this._color2 = "";

    this._backColor = "";
    this._outlineColor = "";

    this._direction = "horizontal";
  };

  GUIGauge.prototype = Object.create(GUI.prototype);
  GUIGauge.prototype.constructor = GUIGauge;

  GUIGauge.prototype.initialize = function () {
    GUI.prototype.initialize.call(this);
  };

  Object.defineProperty(GUIGauge.prototype, "gaugeWidth", {
    get: function () {
      return this._gaugeWidth;
    },
    set: function (value) {
      if (this._gaugeWidth !== value) {
        this._gaugeWidth = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  Object.defineProperty(GUIGauge.prototype, "gaugeHeight", {
    get: function () {
      return this._gaugeHeight;
    },
    set: function (value) {
      if (this._gaugeHeight !== value) {
        this._gaugeHeight = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  Object.defineProperty(GUIGauge.prototype, "color1", {
    get: function () {
      return this._color1;
    },
    set: function (value) {
      if (this._color1 !== value) {
        this._color1 = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  Object.defineProperty(GUIGauge.prototype, "color2", {
    get: function () {
      return this._color2;
    },
    set: function (value) {
      if (this._color2 !== value) {
        this._color2 = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  Object.defineProperty(GUIGauge.prototype, "rate", {
    get: function () {
      return this._rate;
    },
    set: function (value) {
      if (
        Math.round(this._rate * 100) / 100 !==
        Math.round(value * 100) / 100
      ) {
        this._rate = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  Object.defineProperty(GUIGauge.prototype, "backColor", {
    get: function () {
      return this._backColor;
    },
    set: function (value) {
      if (this._backColor !== value) {
        this._backColor = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  Object.defineProperty(GUIGauge.prototype, "outlineColor", {
    get: function () {
      return this._outlineColor;
    },
    set: function (value) {
      if (this._outlineColor !== value) {
        this._outlineColor = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  Object.defineProperty(GUIGauge.prototype, "direction", {
    get: function () {
      return this._direction;
    },
    set: function (value) {
      if (this._direction !== value) {
        this._direction = value;
        this._refreshGUI();
      }
    },
    configurable: true,
  });

  GUIGauge.prototype.updateGUIParams = function () {
    GUI.prototype.updateGUIParams.call(this);

    this.gaugeWidth = this._getGaugeWidth();
    this.gaugeHeight = this._getGaugeHeight();

    this.rate = this._getRate();

    this.color1 = this._getColor1();
    this.color2 = this._getColor2();

    this.backColor = this._getBackColor();
    this.outlineColor = this._getOutlineColor();

    this.direction = this._getDirection();
  };

  GUIGauge.prototype._refreshGUI = function () {
    if (this.gaugeWidth === 0 || this.gaugeHeight === 0) {
      return;
    }

    this.bitmap = new $Bitmap(this.gaugeWidth, this.gaugeHeight);
    this.drawGauge(0, 0, this.gaugeWidth, this.rate, this.color1, this.color2);
  };

  GUIGauge.prototype.drawGauge = function (x, y, width, rate, color1, color2) {
    var fillW,
      fillH,
      height = this.gaugeHeight;

    if (this.direction === "horizontal") {
      fillW = Math.floor(width * rate);
      fillH = height;
    }

    if (this.direction === "vertical") {
      fillH = Math.floor(height * rate);
      fillW = width;
    }

    this.contents.fillRect(x, y, width, height, this.outlineColor);
    this.contents.fillRect(x + 1, y + 1, width - 2, height - 2, this.backColor);
    this.contents.gradientFillRect(
      x + 1,
      y + 1,
      fillW - 2,
      fillH - 2,
      color1,
      color2
    );
  };

  GUIGauge.prototype._getGaugeWidth = function () {
    return this.config.width || 0;
  };

  GUIGauge.prototype._getGaugeHeight = function () {
    return this.config.height || 0;
  };

  GUIGauge.prototype._getRate = function () {
    return eval(this.config.rate) || 1.0;
  };

  GUIGauge.prototype._getColor1 = function () {
    return this._evalConfig(this.config.color1) || "#000000";
  };

  GUIGauge.prototype._getColor2 = function () {
    return this._evalConfig(this.config.color2) || "#000000";
  };

  GUIGauge.prototype._getBackColor = function () {
    return this._evalConfig(this.config.backColor) || "#000000";
  };

  GUIGauge.prototype._getOutlineColor = function () {
    return this._evalConfig(this.config.outlineColor) || "#000000";
  };

  GUIGauge.prototype._getDirection = function () {
    return this.config.direction || "horizontal";
  };

  $LunaEngine.Core.Sprite.GUIGauge = GUIGauge;
})(LunaEngine, Bitmap);

/* globals LunaEngine: false */

(function () {
  var Config = LunaEngine.Battle.Config.HUD;
  var _Window_BattleStatus_update = Window_BattleStatus.prototype.update;

  Window_BattleStatus.prototype.windowWidth = function () {
    return Config.background.window.width;
  };

  Window_BattleStatus.prototype.windowHeight = function () {
    return Config.background.window.height;
  };

  Window_BattleStatus.prototype.refresh = function () {
    this.contents.clear();

    this.x = Config.x + Config.background.offsetX;
    this.y = Config.y + Config.background.offsetY;

    if (Config.background.type === "image") {
      this._refreshImageBackground();
    }
    // this.drawAllItems();
  };

  Window_BattleStatus.prototype._refreshImageBackground = function () {
    var bitmap = ImageManager.loadSystem(Config.background.image.filename);

    this.opacity = 0;
    this._backgroundSprite = this._backgroundSprite || new Sprite(bitmap);
    this._backgroundSprite.bitmap = bitmap;

    this.addChild(this._backgroundSprite);
  };

  Window_BattleStatus.prototype.drawItem = function (index) {
    // destroy
  };

  Window_BattleStatus.prototype.updateCursor = function () {
    // destroy cursor
    this.setCursorRect(0, 0, 0, 0);
  };

  Window_BattleStatus.prototype.update = function () {
    _Window_BattleStatus_update.call(this);

    this._updateBackgroundSprite();
  };

  Window_BattleStatus.prototype._updateBackgroundSprite = function () {
    if (!this._backgroundSprite) {
      return;
    }

    this._backgroundSprite.visible = this.openness === 255;
  };
})();

/* globals LunaEngine: false */

(function () {
  var SpriteClasses = LunaEngine.Core.Sprite;

  var GUIBase = function () {
    this.initialize.apply(this, arguments);
  };

  GUIBase.prototype = Object.create(Sprite.prototype);
  GUIBase.prototype.constructor = GUIBase;

  GUIBase.prototype.initialize = function () {
    Sprite.prototype.initialize.call(this);

    this._config = {};
    this._actor = null;
    this._guiSprites = [];
  };

  Object.defineProperty(GUIBase.prototype, "config", {
    get: function () {
      return this._config;
    },
    set: function (value) {
      if (this._config !== value) {
        this._config = value;
        this.setupGUI();
      }
    },
    configurable: true,
  });

  Object.defineProperty(GUIBase.prototype, "actor", {
    get: function () {
      return this._actor;
    },
    set: function (value) {
      if (this._actor !== value) {
        this._actor = value;
        this.onActorChange();
      }
    },
    configurable: true,
  });

  GUIBase.prototype.setupGUI = function () {
    this._createSprites();
  };

  GUIBase.prototype.refresh = function () {
    var sprite;

    for (var i = 0; i < this._guiSprites.length; i++) {
      sprite = this._guiSprites[i];
      sprite.refresh();
    }
  };

  GUIBase.prototype.select = function () {
    var sprite;

    for (var i = 0; i < this._guiSprites.length; i++) {
      sprite = this._guiSprites[i];
      sprite.select();
    }
  };

  GUIBase.prototype.deselect = function () {
    var sprite;

    for (var i = 0; i < this._guiSprites.length; i++) {
      sprite = this._guiSprites[i];
      sprite.deselect();
    }
  };

  GUIBase.prototype.setSelectEnemy = function (flag) {
    var sprite;

    for (var i = 0; i < this._guiSprites.length; i++) {
      sprite = this._guiSprites[i];
      sprite.setSelectEnemy(flag);
    }
  };

  GUIBase.prototype.setSelectAction = function (flag) {
    var sprite;

    for (var i = 0; i < this._guiSprites.length; i++) {
      sprite = this._guiSprites[i];
      sprite.setSelectAction(flag);
    }
  };

  GUIBase.prototype.onActorChange = function () {
    var sprite;

    for (var i = 0; i < this._guiSprites.length; i++) {
      sprite = this._guiSprites[i];
      sprite.attach("actor", this.actor);
    }
  };

  GUIBase.prototype._createSprites = function () {
    var spriteConfig, Class, sprite;

    for (var key in this.config) {
      spriteConfig = this.config[key];

      Class = this._getSpriteClass(spriteConfig);
      sprite = new Class();

      sprite.attach("actor", this.actor);
      sprite.config = spriteConfig;

      this._guiSprites.push(sprite);
      this.addChild(sprite);

      sprite.setupGUI();
    }
  };

  GUIBase.prototype._getSpriteClass = function (config) {
    var Class;

    Class = SpriteClasses[config.class];
    return Class;
  };

  LunaEngine.Battle.GUIBase = GUIBase;
})();

/* globals LunaEngine: false */

(function () {
  var Config = LunaEngine.Battle.Config.HUD,
    GUIConfig = LunaEngine.Battle.Config.GUISprites,
    GUIBase = LunaEngine.Battle.GUIBase;

  var HUD = function () {
    this.initialize.apply(this, arguments);
  };

  HUD.prototype = Object.create(Sprite.prototype);
  HUD.prototype.constructor = HUD;

  HUD.prototype.initialize = function () {
    Sprite.prototype.initialize.call(this);

    this._guiSpritesets = [];
    this._actor = null;
    this._selectEnemy = false;
    this._selectAction = false;

    this.setupGUI();
  };

  HUD.prototype.setupGUI = function () {
    var battlers = $gameParty.battleMembers(),
      guiBase;

    for (var i = 0; i < battlers.length; i++) {
      guiBase = new GUIBase();

      guiBase.x = this._getGUIX(i);
      guiBase.y = this._getGUIY(i);

      guiBase.actor = battlers[i];
      guiBase.config = this._getGUIConfig();

      this._guiSpritesets.push(guiBase);
      this.addChild(guiBase);
    }
  };

  HUD.prototype.select = function (actor) {
    this._actor = actor;
  };

  HUD.prototype.setSelectEnemy = function (flag) {
    this._selectEnemy = flag;
  };

  HUD.prototype.setSelectAction = function (flag) {
    this._selectAction = flag;
  };

  HUD.prototype.refresh = function () {
    var spriteset;

    for (var i = 0; i < this._guiSpritesets.length; i++) {
      spriteset = this._guiSpritesets[i];
      spriteset.refresh();
    }
  };

  HUD.prototype.update = function () {
    Sprite.prototype.update.call(this);

    this.updateActors();
    this.updatePosition();
    this.updateSelecting();
  };

  HUD.prototype.updateActors = function () {
    var battlers = $gameParty.battleMembers(),
      spriteset;

    for (var i = 0; i < this._guiSpritesets.length; i++) {
      spriteset = this._guiSpritesets[i];

      if (!battlers[i]) {
        this.removeChild(spriteset);
      }

      spriteset.actor = battlers[i];
    }
  };

  HUD.prototype.updatePosition = function () {
    var spriteset;

    this.x = this._getX();
    this.y = this._getY();

    for (var i = 0; i < this._guiSpritesets.length; i++) {
      spriteset = this._guiSpritesets[i];

      spriteset.x = this._getGUIX(i);
      spriteset.y = this._getGUIY(i);
    }
  };

  HUD.prototype.updateSelecting = function () {
    var spriteset;

    for (var i = 0; i < this._guiSpritesets.length; i++) {
      spriteset = this._guiSpritesets[i];
      spriteset.deselect();

      spriteset.setSelectEnemy(this._selectEnemy);
      spriteset.setSelectAction(this._selectAction);

      if (spriteset.actor === this._actor) {
        spriteset.select();
      }
    }
  };

  HUD.prototype._getX = function () {
    return Config.x || 0;
  };

  HUD.prototype._getY = function () {
    return Config.y || 0;
  };

  HUD.prototype._getGUIX = function (index) {
    if (Config.direction === "horizontal") {
      return Math.round((Config.width / Config.grid) * index);
    }

    return 0;
  };

  HUD.prototype._getGUIY = function (index) {
    if (Config.direction === "vertical") {
      return Math.round((Config.height / Config.grid) * index);
    }

    return 0;
  };

  HUD.prototype._getGUIConfig = function () {
    return GUIConfig;
  };

  LunaEngine.Battle.HUD = HUD;
})();

/* globals LunaEngine: false */

(function () {
  // dependencies
  var HUD = LunaEngine.Battle.HUD,
    HUDConfig = LunaEngine.Battle.Config.HUD;

  // alias
  var _Sprite_Actor_initMembers = Sprite_Actor.prototype.initMembers,
    _Sprite_Actor_setActorHome = Sprite_Actor.prototype.setActorHome,
    _Window_BattleActor_maxCols = Window_BattleActor.prototype.maxCols,
    _Scene_Battle_createDisplayObjects =
      Scene_Battle.prototype.createDisplayObjects,
    _Scene_Battle_start = Scene_Battle.prototype.start,
    _Scene_Battle_stop = Scene_Battle.prototype.stop,
    _Scene_Battle_updateStatusWindow =
      Scene_Battle.prototype.updateStatusWindow;

  Game_Actor.prototype.isSpriteVisible = function () {
    if (!HUDConfig.showAnimation) {
      return false;
    }

    return true;
  };

  Sprite_Actor.prototype.initMembers = function () {
    _Sprite_Actor_initMembers.call(this);
    this._setupLuna();
  };

  Sprite_Actor.prototype._setupLuna = function () {
    if ($gameSystem.isSideView()) {
      return;
    }

    this.opacity = 0;
  };

  Sprite_Actor.prototype.setActorHome = function (index) {
    if ($gameSystem.isSideView()) {
      _Sprite_Actor_setActorHome.call(this, index);
      return;
    }

    this.setHome(this._getGUIX(index), this._getGUIY(index));
  };

  Sprite_Actor.prototype._getGUIX = function (index) {
    var x = 0;

    if (HUDConfig.direction === "horizontal") {
      x = Math.round((HUDConfig.width / HUDConfig.grid) * index);
      x += HUDConfig.width / HUDConfig.grid / 2;
    }

    x += HUDConfig.x;

    return x;
  };

  Sprite_Actor.prototype._getGUIY = function (index) {
    var y = 0;

    if (HUDConfig.direction === "vertical") {
      y = Math.round((HUDConfig.height / HUDConfig.grid) * index);
    }

    y += HUDConfig.y;

    return y;
  };

  Window_BattleActor.prototype.maxCols = function () {
    if (HUDConfig.direction === "horizontal") {
      return $gameParty.battleMembers().length;
    }

    return _Window_BattleActor_maxCols.call(this);
  };

  Scene_Battle.prototype.createDisplayObjects = function () {
    _Scene_Battle_createDisplayObjects.call(this);
    this._createBattleLuna();
  };

  Scene_Battle.prototype._createBattleLuna = function () {
    this._lunaHUD = new HUD();
    this.addWindow(this._lunaHUD);
  };

  Scene_Battle.prototype.start = function () {
    _Scene_Battle_start.call(this);
    this._setupLuna();
  };

  Scene_Battle.prototype._setupLuna = function () {
    this._lunaHUD.refresh();
    // this._statusWindow.y = 9999;
    this._actorWindow.y = 9999;
  };

  Scene_Battle.prototype.stop = function () {
    _Scene_Battle_stop.call(this);
    this._lunaHUD.visible = false;
  };

  Scene_Battle.prototype.updateStatusWindow = function () {
    _Scene_Battle_updateStatusWindow.call(this);

    if ($gameMessage.isBusy()) {
      this._lunaHUD.visible = false;
    } else if (this.isActive() && !this._messageWindow.isClosing()) {
      this._lunaHUD.visible = this._statusWindow.isOpen();
    }

    this._updateLuna();
  };

  Scene_Battle.prototype.updateWindowPositions = function () {
    // destroy
  };

  Scene_Battle.prototype._updateLuna = function () {
    this._updateSelectingActor();
    this._updateSelectingEnemy();
    this._updateSelectingAction();
  };

  Scene_Battle.prototype._updateSelectingActor = function () {
    this._lunaHUD.select(BattleManager.actor());

    if (this._actorWindow.active) {
      this._lunaHUD.select(this._actorWindow.actor());
    }
  };

  Scene_Battle.prototype._updateSelectingEnemy = function () {
    this._lunaHUD.setSelectEnemy(this._enemyWindow.active);
  };

  Scene_Battle.prototype._updateSelectingAction = function () {
    var flag = this._skillWindow.active || this._itemWindow.active;

    this._lunaHUD.setSelectAction(flag);
  };
})();


code:
/*:
 * Yami Engine Delta - Retain States On Death
 *
 * @plugindesc Makes some kinds of state to be retained on actors
 * even when they die.
 * @author Yami Engine Delta [Dr.Yami]
 *
 * @help
 * There is no Configuration and Plugin Command.
 *
 * ============================================================================
 *
 * States
 * To make a state to be retained on death, use the following notetag:
 *   <retain on death>
 *
 * ============================================================================
 */
/*:ja
 * Yami Engine Delta - Retain States On Death
 *
 * @plugindesc キャラクターの死後も、アクターのステートを維持させます
 * @author Yami Engine Delta [Dr.Yami]
 *
 * @help
 * このプラグインには、コンフィグやプラグインコマンドはありません。
 *
 * ============================================================================
 *
 * States
 * キャラクターの死後もステートの維持を行いたい場合は、
 * 下記のNotetagを使用してください。
 *   <retain on death>
 *
 * ============================================================================
 */

/**
 * @namespace RetainStateOnDeath
 * @memberof YED
 */

var YED = YED || {};

// init RetainStateOnDeath module
YED.RetainStateOnDeath = {};

/* globals YED: false */

(function () {
  /**
   * Enum for RegExp, used to notetags
   *
   * @readonly
   * @enum {RegExp}
   * @memberof YED.RetainStateOnDeath
   */
  var Regexp = {
    /**
     * Retain on death notetag for state
     */
    RETAIN: /<(?:retain on death)>/i,
  };

  YED.RetainStateOnDeath.Regexp = Regexp;
})();

/* globals YED: false */

(function () {
  /**
   * Shorten Dependencies
   */
  var Regexp = YED.RetainStateOnDeath.Regexp;

  /**
   * Contains utility tools for module.
   *
   * @namespace Utils
   * @memberof YED.RetainStateOnDeath
   */
  var Utils = {};

  /**
   * Process notetag function.
   * Should be called with DataManager as current object.
   *
   * @function processNotetag
   * @memberof YED.RetainStateOnDeath.Utils
   */
  Utils.processNotetags = function () {
    var group = $dataStates, // shorten group name
      obj,
      notedata,
      line;

    for (var i = 1; i < group.length; i++) {
      obj = group[i];
      notedata = obj.note.split(/[\r\n]+/);

      Utils._processMethods.call(this, obj);

      for (var n = 0; n < notedata.length; n++) {
        line = notedata[n];
        Utils._processNotetag.call(this, obj, line);
      }
    }
  };

  /**
   * Add new methods into object.
   *
   * @function _processMethods
   * @memberof YED.RetainStateOnDeath.Utils
   * @param  {Object} obj Data object
   * @private
   */
  Utils._processMethods = function (obj) {
    obj.isRetainStateOnDeath = Utils.isRetainStateOnDeath;
  };

  /**
   * Process notetag for object.
   *
   * @function _processNotetag
   * @memberof YED.RetainStateOnDeath.Utils
   * @param  {Object} obj Data object
   * @param  {String} notetag Notetag
   * @private
   */
  Utils._processNotetag = function (obj, notetag) {
    if (notetag.match(Regexp.RETAIN)) {
      obj._retainStateOnDeath = true;
    }
  };

  /**
   * Check if the state is retained on death.
   * Should be attached to state object.
   *
   * @function isRetainStateOnDeath
   * @memberof YED.RetainStateOnDeath.Utils
   * @return {Boolean} Retain flag
   */
  Utils.isRetainStateOnDeath = function () {
    return !!this._retainStateOnDeath;
  };

  YED.RetainStateOnDeath.Utils = Utils;
})();

/* globals YED: false */

/**
 * Pre-processes and notetag parsing
 */
(function () {
  /**
   * Shorten Dependencies
   */
  var Utils = YED.RetainStateOnDeath.Utils;
  /**
   * Aliasing methods
   */
  var _Scene_Boot_start = Scene_Boot.prototype.start;

  /**
   * Extending: Scene_Boot.prototype.start
   *
   * Add notetags processing for module.
   */
  Scene_Boot.prototype.start = function () {
    _Scene_Boot_start.call(this);

    Utils.processNotetags.call(DataManager);
  };
})();

(function () {
  /**
   * Aliasing methods
   */
  var _Game_Actor_initialize = Game_Actor.prototype.initialize;
  var _Game_Actor_die = Game_Actor.prototype.die;

  /**
   * Extending: Game_Actor.prototype.initialize
   *
   * Add setup retain state on death for Game_Actor.
   */
  Game_Actor.prototype.initialize = function (actorId) {
    // actual initialize
    _Game_Actor_initialize.call(this, actorId);

    // setup retain states on death
    this.setupRetainStateOnDeath();
  };

  /**
   * Setup retain state on death for Game Actor
   *
   * @function external:Game_Actor#setupRetainStateOnDeath
   */
  Game_Actor.prototype.setupRetainStateOnDeath = function () {
    this._retainStateOnDeath = [];
  };

  /**
   * Extending: Game_Actor.prototype.die
   *
   * Add store and restore states methods.
   */
  Game_Actor.prototype.die = function () {
    // store states
    this.storeRetainStateOnDeath();

    // actual die
    _Game_Actor_die.call(this);

    // restore states
    this.restoreRetainStateOnDeath();
  };

  /**
   * Store current states that need to be retained on death.
   *
   * @function external:Game_Actor#storeRetainStateOnDeath
   */
  Game_Actor.prototype.storeRetainStateOnDeath = function () {
    var state, // for iterator
      storeData, // data hash
      states = this.states();

    for (var i = 0; i < states.length; i++) {
      state = states[i];

      if (state.isRetainStateOnDeath()) {
        storeData = {};
        storeData.id = state.id;
        storeData.turn = this._stateTurns[state.id];
        storeData.step = this._stateSteps[state.id];

        this._retainStateOnDeath.push(storeData);
      }
    }
  };

  /**
   * Restore the retained on death states.
   *
   * @function external:Game_Actor#restoreRetainStateOnDeath
   */
  Game_Actor.prototype.restoreRetainStateOnDeath = function () {
    var storeData; // data hash

    for (var i = 0; i < this._retainStateOnDeath.length; i++) {
      storeData = this._retainStateOnDeath[i];

      this.addNewState(storeData.id);
      this._stateTurns[storeData.id] = storeData.turn;
      this._stateSteps[storeData.id] = storeData.step;
    }

    this._retainStateOnDeath = [];
  };
})();