code:
var __extends =
  (this && this.__extends) ||
  (function () {
    var extendStatics = function (d, b) {
      extendStatics =
        Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array &&
          function (d, b) {
            d.__proto__ = b;
          }) ||
        function (d, b) {
          for (var p in b)
            if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
        };
      return extendStatics(d, b);
    };
    return function (d, b) {
      if (typeof b !== "function" && b !== null)
        throw new TypeError(
          "Class extends value " + String(b) + " is not a constructor or null"
        );
      extendStatics(d, b);
      function __() {
        this.constructor = d;
      }
      d.prototype =
        b === null
          ? Object.create(b)
          : ((__.prototype = b.prototype), new __());
    };
  })();
/*:ja
 * @target MZ
 * @author ル
 *
 * @command victory
 * @text バトル勝利
 * @des バトル勝利
 */
var Nore;
(function (Nore) {
  var pluginName = "Nore_Battle";
  PluginManager.registerCommand(pluginName, "victory", function (args) {
    var troopData = $gameTemp.selectedTroop;
    $slg.battleInfo().clear(troopData.areaId(), troopData.battleId());
  });
  // Battle Processing
  Game_Interpreter.prototype.command301 = function (params) {
    var _this = this;
    if (!$gameParty.inBattle()) {
      var troopId = void 0;
      if (params[0] === 0) {
        // Direct designation
        troopId = params[1];
      } else if (params[0] === 1) {
        // Designation with a variable
        troopId = $gameVariables.value(params[1]);
      } else {
        // Same as Random Encounters
        troopId = $gamePlayer.makeEncounterTroopId();
      }
      if ($dataTroops[troopId]) {
        BattleManager.setup(troopId, params[2], params[3]);
        BattleManager.setEventCallback(function (n) {
          _this._branch[_this._indent] = n;
        });
        $gamePlayer.makeEncounterCount();
        SceneManager.push(Scene_Battle2);
      }
    }
    return true;
  };
})(Nore || (Nore = {}));
Sprite_Battleback.prototype.adjustPosition = function () {
  this.width = 1280;
  this.height = 800;
  this.x = (Graphics.width - this.width) / 2;
  if ($gameSystem.isSideView()) {
    this.y = Graphics.height - this.height;
  } else {
    this.y = 0;
  }
  var ratioX = this.width / this.bitmap.width;
  var ratioY = this.height / this.bitmap.height;
  var scale = Math.max(ratioX, ratioY, 1.0);
  this.scale.x = scale;
  this.scale.y = scale;
};
var Scene_Battle2 = /** @class */ (function (_super) {
  __extends(Scene_Battle2, _super);
  function Scene_Battle2() {
    return (_super !== null && _super.apply(this, arguments)) || this;
  }
  Scene_Battle2.prototype.createSpriteset = function () {
    this._spriteset = new Spriteset_Battle2();
    this.addChild(this._spriteset);
  };
  return Scene_Battle2;
})(Scene_Battle);
var Spriteset_Battle2 = /** @class */ (function (_super) {
  __extends(Spriteset_Battle2, _super);
  function Spriteset_Battle2() {
    return (_super !== null && _super.apply(this, arguments)) || this;
  }
  Spriteset_Battle2.prototype.createBattleField = function () {
    var width = Graphics.boxWidth;
    var height = Graphics.boxHeight;
    var x = (Graphics.width - width) / 2;
    var y = (Graphics.height - height) / 2;
    this._battleField = new Sprite();
    this._battleField.setFrame(0, 0, width, height);
    this._battleField.x = x;
    this._battleField.y = y - this.battleFieldOffsetY();
    this._baseSprite.addChild(this._battleField);
    this._effectsContainer = this._battleField;
    this._uiContainer = new Sprite();
    this._uiContainer.setFrame(0, 0, width, height);
    this._uiContainer.x = x;
    this._uiContainer.y = y - this.battleFieldOffsetY();
    this._baseSprite.addChild(this._uiContainer);
  };
  Spriteset_Battle2.prototype.createEnemies = function () {
    _super.prototype.createEnemies.call(this);
    this._enemyHpSprite = new Sprite_EnemyHp();
    this._uiContainer.addChild(this._enemyHpSprite);
  };
  return Spriteset_Battle2;
})(Spriteset_Battle);
var Sprite_EnemyHp = /** @class */ (function (_super) {
  __extends(Sprite_EnemyHp, _super);
  function Sprite_EnemyHp() {
    var _this = _super.call(this) || this;
    _this.x = 20;
    _this.y = 580;
    _this.bitmap = new Bitmap(1020, 400);
    _this.bitmap.fontSize = 26;
    _this.refresh();
    return _this;
  }
  Sprite_EnemyHp.prototype.update = function () {
    _super.prototype.update.call(this);
    if ($gameParty.isDirty()) {
      this.refresh();
    }
  };
  Sprite_EnemyHp.prototype.refresh = function () {
    return;
    $gameParty.clearDirty();
    this.bitmap.clear();
    var xxx = 100;
    var yy = 0;
    this.bitmap.drawText("戦闘員HP", xxx, yy, 100, 40);
    this.bitmap.drawText(
      "%1".format($gameParty.hp()),
      xxx,
      yy,
      200,
      40,
      "right"
    );
    xxx += 220;
    var yyy = 8;
    var h = 22;
    var w = this.gaugeWidth();
    this.bitmap.fillRect(xxx - 1, yyy - 1, w + 2, h + 2, "#000");
    this.bitmap.fillRect(
      xxx,
      yyy,
      w * $gameParty.hpRate(),
      h,
      ColorManager.hpGaugeColor1()
    );
  };
  Sprite_EnemyHp.prototype.gaugeWidth = function () {
    var w = $gameParty.combatant();
    return w;
  };
  return Sprite_EnemyHp;
})(Sprite);
BattleManager.gainExp = function () {
  var exp = this._rewards.exp;
  $gameParty.gainEnergy(exp);
};
var _BattleManager_startTurn = BattleManager.startTurn;
BattleManager.startTurn = function () {
  p("turnCount:" + $gameTroop.turnCount());
  if ($gameTroop.turnCount() >= 1) {
    this.processVictory();
    return;
  }
  _BattleManager_startTurn.call(this);
};


code:
var Nore;
(function (Nore) {
  Window_BattleLog.prototype.startAction = function (subject, action, targets) {
    $gameTemp.actionExecuted = true;
    var item = action.item();
    this.push("performActionStart", subject, action);
    this.push("waitForMovement");
    this.push("performAction", subject, action);
    this.push("showAnimation", subject, targets.clone(), item.animationId);
    this.displayAction(subject, item);
  };
  Window_BattleLog.prototype.updateWaitCount = function () {
    if (this._waitCount > 0) {
      this._waitCount -= this.isFastForward() ? 5 : 2;
      if ($gameTemp.isAutoBattle()) {
        this._waitCount -= 2;
      }
      if (this._waitCount < 0) {
        this._waitCount = 0;
      }
      return true;
    }
    return false;
  };
  Window_BattleLog.prototype.messageSpeed = function () {
    if (this.isFastForward()) {
      return 0;
    }
    return 4;
  };
  Window_BattleLog.prototype.waitForEffect = function () {
    if (this.isFastForward()) {
      return;
    }
    this.setWaitMode("effect");
  };
  Window_BattleLog.prototype.showNormalAnimation = function (
    targets,
    animationId,
    mirror
  ) {
    if (this.isFastForward()) {
      return;
    }
    var animation = $dataAnimations[animationId];
    if (animation) {
      $gameTemp.requestAnimation(targets, animationId, mirror);
    }
  };
  Scene_Battle.prototype.updateBattleProcess = function () {
    $gameTemp.actionExecuted = false;
    var speed = 10;
    if (this._logWindow && this._logWindow.isFastForward()) {
      speed = 30;
    }
    for (var i = 0; i < speed; i++) {
      BattleManager.update(this.isTimeActive());
      if ($gameTemp.actionExecuted) {
        break;
      }
    }
  };
})(Nore || (Nore = {}));

repo_name: onms/dead

license: unknown


code:
var __extends =
  (this && this.__extends) ||
  (function () {
    var extendStatics = function (d, b) {
      extendStatics =
        Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array &&
          function (d, b) {
            d.__proto__ = b;
          }) ||
        function (d, b) {
          for (var p in b)
            if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
        };
      return extendStatics(d, b);
    };
    return function (d, b) {
      if (typeof b !== "function" && b !== null)
        throw new TypeError(
          "Class extends value " + String(b) + " is not a constructor or null"
        );
      extendStatics(d, b);
      function __() {
        this.constructor = d;
      }
      d.prototype =
        b === null
          ? Object.create(b)
          : ((__.prototype = b.prototype), new __());
    };
  })();
var Nore;
(function (Nore) {
  var Scene_BattlePreparation = /** @class */ (function (_super) {
    __extends(Scene_BattlePreparation, _super);
    function Scene_BattlePreparation() {
      return (_super !== null && _super.apply(this, arguments)) || this;
    }
    Scene_BattlePreparation.prototype.create = function () {
      _super.prototype.create.call(this);
      this.createBattleWindow();
    };
    Scene_BattlePreparation.prototype.createBattleWindow = function () {
      this._battleWindow = new Window_BattlePreparation();
      this.addChild(this._battleWindow);
      this._battleWindow.select(0);
      this._battleWindow.activate();
      this._battleWindow.setHandler("ok", this.onOk.bind(this));
      this._battleWindow.setHandler("cancel", this.onCancel.bind(this));
    };
    Scene_BattlePreparation.prototype.onOk = function () {
      $gameVariables.setValue(
        Nore.BATTLE_ID_VAR,
        $gameTemp.selectedTroop.troopId()
      );
      SceneManager.popAllScene();
    };
    Scene_BattlePreparation.prototype.onCancel = function () {
      this.popScene();
    };
    Scene_BattlePreparation.prototype.popAllScene = function () {};
    return Scene_BattlePreparation;
  })(Scene_MenuBase);
  Nore.Scene_BattlePreparation = Scene_BattlePreparation;
  SceneManager.popAllScene = function () {
    if (this._stack.length > 0) {
      var num = this._stack.length;
      for (var i = 0; i < num; i++) {
        this.goto(this._stack.pop());
      }
    } else {
      this.exit();
    }
  };
})(Nore || (Nore = {}));


code:
var __extends =
  (this && this.__extends) ||
  (function () {
    var extendStatics = function (d, b) {
      extendStatics =
        Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array &&
          function (d, b) {
            d.__proto__ = b;
          }) ||
        function (d, b) {
          for (var p in b)
            if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
        };
      return extendStatics(d, b);
    };
    return function (d, b) {
      if (typeof b !== "function" && b !== null)
        throw new TypeError(
          "Class extends value " + String(b) + " is not a constructor or null"
        );
      extendStatics(d, b);
      function __() {
        this.constructor = d;
      }
      d.prototype =
        b === null
          ? Object.create(b)
          : ((__.prototype = b.prototype), new __());
    };
  })();
var Window_BattleStatus2 = /** @class */ (function (_super) {
  __extends(Window_BattleStatus2, _super);
  function Window_BattleStatus2() {
    return (_super !== null && _super.apply(this, arguments)) || this;
  }
  return Window_BattleStatus2;
})(Window_BattleStatus);


code:
/*:ja
 * @target MZ
 * @author ル
 */
var Nore;
(function (Nore) {
  Scene_Boot.prototype.updateDocumentTitle = function () {
    var taikenbanText = "";
    if (Nore.isTaikenban()) {
      taikenbanText = " 体験版";
    }
    document.title = $dataSystem.gameTitle + "　ver." + VERSION + taikenbanText;
  };
  var _Scene_Boot_prototype_loadSystemImages =
    Scene_Boot.prototype.loadSystemImages;
  Scene_Boot.prototype.loadSystemImages = function () {
    _Scene_Boot_prototype_loadSystemImages.call(this);
    ImageManager.loadSpriteSheet("img/tachie/actor01.json");
    ImageManager.loadSpriteSheet("img/tachie/actor02.json");
    ImageManager.loadSpriteSheet("img/tachie/actor03.json");
    ImageManager.loadSpriteSheet("img/tachie/actor04.json");
    ImageManager.loadSpriteSheet("img/tachie/actor05.json");
    ImageManager.loadSpriteSheet("img/tachie/actor06.json");
    ImageManager.loadSpriteSheet("img/tachie/actor07.json");
    ImageManager.loadSpriteSheet("img/tachie/actor08.json");
    ImageManager.loadSpriteSheet("img/tachie/actor09.json");
    ImageManager.loadSpriteSheet("img/tachie/actor10.json");
    ImageManager.loadSpriteSheet("img/tachie/actor11.json");
    ImageManager.loadSpriteSheet("img/tachie/actor13.json");
    ImageManager.loadSpriteSheet("img/tachie/actor15.json");
    ImageManager.loadSpriteSheet("img/tachie/actor16.json");
    ImageManager.loadSpriteSheet("img/tachie/actor17.json");
    ImageManager.loadSpriteSheet("img/tachie/actor18.json");
    ImageManager.loadSpriteSheet("img/tachie/actor19.json");
    ImageManager.loadSpriteSheet("img/tachie/actor20.json");
    ImageManager.loadSpriteSheet("img/tachie/actor21.json");
    ImageManager.loadSpriteSheet("img/tachie/actor22.json");
    ImageManager.loadSpriteSheet("img/tachie/actor24.json");
    ImageManager.loadSpriteSheet("img/tachie/sikyu_1.json");
    //ImageManager.loadSpriteSheet('img/tachie/sikyu.json');
    ImageManager.loadSpriteSheet("img/ero/manko_1.json");
    ImageManager.loadSpriteSheet("img/ero/jacket_1.json");
    ImageManager.loadSpriteSheet("img/ero/jacket_2.json");
    ImageManager.loadSpriteSheet("img/ero/jacket_3.json");
    ImageManager.loadSystem("0213_sys");
    ImageManager.loadSystem("Frame");
    ImageManager.loadSystem("ButtonSet");
    ImageManager.loadSystem("skill_tree");
    ImageManager.loadSystem("Window2");
    ImageManager.loadSystem("Window_sumi");
    ImageManager.loadSystem("msg_window");
    ImageManager.loadSystem("msg_window_option");
    ImageManager.loadSystem("msg_window_628");
    ImageManager.loadSystem("msg_window_550");
    ImageManager.loadSystem("button2");
    ImageManager.loadSystem("main");
    ImageManager.loadSystem("number");
    ImageManager.loadCharacter("Nature");
    ImageManager.loadSystem("menu");
    ImageManager.loadSystem("menu2");
    ImageManager.loadSystem("av");
    ImageManager.loadSystem("gacha");
    ImageManager.loadSystem("dousei");
    ImageManager.loadSystem("button_overlay");
  };
  var _DataManager_createGameObjects = DataManager.createGameObjects;
  DataManager.createGameObjects = function () {
    _DataManager_createGameObjects.call(this);
    Nore.Tachie.actorCashedSprites = {};
    switch (ConfigManager.language) {
      case "en":
        initVocabEn();
        break;
      case "ch":
      default:
        initVocabJp();
        break;
    }
  };
})(Nore || (Nore = {}));


code:
var __extends =
  (this && this.__extends) ||
  (function () {
    var extendStatics = function (d, b) {
      extendStatics =
        Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array &&
          function (d, b) {
            d.__proto__ = b;
          }) ||
        function (d, b) {
          for (var p in b)
            if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
        };
      return extendStatics(d, b);
    };
    return function (d, b) {
      if (typeof b !== "function" && b !== null)
        throw new TypeError(
          "Class extends value " + String(b) + " is not a constructor or null"
        );
      extendStatics(d, b);
      function __() {
        this.constructor = d;
      }
      d.prototype =
        b === null
          ? Object.create(b)
          : ((__.prototype = b.prototype), new __());
    };
  })();
var Sprite_OverableButton = /** @class */ (function (_super) {
  __extends(Sprite_OverableButton, _super);
  function Sprite_OverableButton(buttonType, isSlg, disable) {
    if (isSlg === void 0) {
      isSlg = false;
    }
    if (disable === void 0) {
      disable = false;
    }
    var _this = _super.call(this, buttonType) || this;
    _this._active = true;
    _this._isSlg = isSlg;
    _this._disable = disable;
    return _this;
  }
  Sprite_OverableButton.prototype.enable = function () {
    if (!this._disable) {
      return;
    }
    this._disable = false;
  };
  Sprite_OverableButton.prototype.setupFrames = function () {
    _super.prototype.setupFrames.call(this);
    var data = this.buttonData();
    var x = data.x * this.blockWidth();
    var width = data.w * this.blockWidth();
    var height = this.blockHeight();
    this.setOverFrame(x, height * 2, width, height);
    this.setDisableFrame(x, height * 3, width, height);
  };
  Sprite_OverableButton.prototype.setOverFrame = function (
    x,
    y,
    width,
    height
  ) {
    this._overFrame = new Rectangle(x, y, width, height);
  };
  Sprite_OverableButton.prototype.setDisableFrame = function (
    x,
    y,
    width,
    height
  ) {
    this._disableFrame = new Rectangle(x, y, width, height);
  };
  Sprite_OverableButton.prototype.isActive = function () {
    if (this._disable) {
      return false;
    }
    if (!this._active) {
      return false;
    }
    if (this._isSlg) {
      return true;
    }
    if ($gameMap.isEventRunning()) {
      return false;
    }
    return true;
  };
  Sprite_OverableButton.prototype.onPress = function () {
    if (!this.isActive()) {
      this._pressed = false;
      return;
    }
  };
  Sprite_OverableButton.prototype.onMouseEnter = function () {
    if (!this.isActive()) {
      this._hovered = false;
      return;
    }
    var f = this._overFrame;
    this.setFrame(f.x, f.y, f.width, f.height);
  };
  Sprite_OverableButton.prototype.onMouseExit = function () {
    var f = this._coldFrame;
    this.setFrame(f.x, f.y, f.width, f.height);
  };
  Sprite_OverableButton.prototype.updateFrame = function () {
    var frame;
    if (this._disable) {
      frame = this._disableFrame;
    } else if (this.isPressed()) {
      frame = this._hotFrame;
    } else if (this.isOvered()) {
      frame = this._overFrame;
    } else {
      frame = this._coldFrame;
    }
    if (frame) {
      this.setFrame(frame.x, frame.y, frame.width, frame.height);
    }
  };
  Sprite_OverableButton.prototype.isOvered = function () {
    return this._hovered;
  };
  Sprite_OverableButton.prototype.updateOpacity = function () {
    this.opacity = 255;
  };
  Sprite_OverableButton.prototype.afterClick = function () {
    this._pressed = false;
  };
  return Sprite_OverableButton;
})(Sprite_Button);
var Sprite_ButtonFocusable = /** @class */ (function (_super) {
  __extends(Sprite_ButtonFocusable, _super);
  function Sprite_ButtonFocusable() {
    return (_super !== null && _super.apply(this, arguments)) || this;
  }
  Sprite_ButtonFocusable.prototype.defocus = function () {
    this._focused = false;
  };
  Sprite_ButtonFocusable.prototype.focus = function () {
    this._focused = true;
  };
  Sprite_ButtonFocusable.prototype.isOvered = function () {
    return this._focused || _super.prototype.isOvered.call(this);
  };
  Sprite_ButtonFocusable.prototype.setMouseExitHandler = function (handler) {
    this._mouseExitHandler = handler;
  };
  Sprite_ButtonFocusable.prototype.onMouseExit = function () {
    _super.prototype.onMouseEnter.call(this);
    if (this._mouseExitHandler) {
      this._mouseExitHandler.call(this);
    }
  };
  return Sprite_ButtonFocusable;
})(Sprite_OverableButton);
var Sprite_Button2 = /** @class */ (function (_super) {
  __extends(Sprite_Button2, _super);
  function Sprite_Button2() {
    return (_super !== null && _super.apply(this, arguments)) || this;
  }
  Sprite_Button2.prototype.blockWidth = function () {
    return 76;
  };
  Sprite_Button2.prototype.blockHeight = function () {
    return 90;
  };
  Sprite_Button2.prototype.loadButtonImage = function () {
    this.bitmap = ImageManager.loadSystem("button2");
  };
  Sprite_Button2.prototype.buttonData = function () {
    var buttonTable = {
      kigae: { x: 0, w: 1 },
      namida: { x: 1, w: 1 },
      face: { x: 2, w: 1 },
      hoppe: { x: 3, w: 1 },
      back: { x: 4, w: 1 },
      cancel: { x: 4, w: 1 },
      levelup: { x: 5, w: 1 },
      pageup: { x: 6, w: 1 },
      pagedown: { x: 7, w: 1 },
      ok: { x: 8, w: 1 },
    };
    return buttonTable[this._buttonType];
  };
  Sprite_Button2.prototype.checkBitmap = function () {
    if (this.bitmap.isReady() && this.bitmap.width < this.blockWidth() * 4) {
      // Probably MV image is used
      throw new Error("ButtonSet image is too small");
    }
  };
  Sprite_Button2.prototype.hitTest = function (x, y) {
    switch (this._buttonType) {
      case "levelup":
      case "pageup":
      case "pagedown":
        return this.hitTestMini(x, y);
    }
    var rect = new Rectangle(
      -this.anchor.x * (this.width - 8),
      -this.anchor.y * this.height,
      this.width - 8,
      this.height
    );
    return rect.contains(x - 2, y);
  };
  Sprite_Button2.prototype.hitTestMini = function (x, y) {
    var rect = new Rectangle(
      -this.anchor.x * (this.width - 30),
      -this.anchor.y * this.height - 5,
      this.width - 30,
      this.height - 5
    );
    return rect.contains(x - 14, y);
  };
  return Sprite_Button2;
})(Sprite_ButtonFocusable);
var Sprite_Button3 = /** @class */ (function (_super) {
  __extends(Sprite_Button3, _super);
  function Sprite_Button3(buttonType, isSlg, disable, pushed) {
    if (isSlg === void 0) {
      isSlg = false;
    }
    if (disable === void 0) {
      disable = false;
    }
    if (pushed === void 0) {
      pushed = false;
    }
    var _this = _super.call(this, buttonType, isSlg, disable) || this;
    _this._animationCount = 0;
    _this._pushed = pushed;
    _this.updateFrame();
    _this.createOverlaySprite();
    return _this;
  }
  Sprite_Button3.prototype.createOverlaySprite = function () {
    var baseTexture = Nore.getSystemBaseTexture("button_overlay");
    var t = new PIXI.Texture(baseTexture);
    var s = new PIXI.Sprite(t);
    s.blendMode = PIXI.BLEND_MODES.SCREEN;
    this.addChild(s);
    this._overlaySprite = s;
    this._overlaySprite.visible = false;
  };
  Sprite_Button3.prototype.update = function () {
    _super.prototype.update.call(this);
    this.updateOverlay();
  };
  Sprite_Button3.prototype.updateOverlay = function () {
    if (!this._overlaySprite) {
      return;
    }
    this._overlaySprite.visible = false;
    if (this._disable) {
      return;
    }
    if (this._pushed) {
      return;
    }
    if (this._selected) {
      this._animationCount++;
      this._overlaySprite.visible = true;
      this._overlaySprite.alpha = this.makeCursorAlpha();
    }
  };
  Sprite_Button3.prototype.makeCursorAlpha = function () {
    var blinkCount = this._animationCount % 40;
    var baseAlpha = 0.4;
    if (blinkCount < 20) {
      return baseAlpha - blinkCount / 32;
    } else {
      return baseAlpha - (40 - blinkCount) / 32;
    }
    return baseAlpha;
  };
  Sprite_Button3.prototype.blockWidth = function () {
    return 146;
  };
  Sprite_Button3.prototype.blockHeight = function () {
    return 69;
  };
  Sprite_Button3.prototype.loadButtonImage = function () {
    if (ConfigManager.language == "jp") {
      this.bitmap = ImageManager.loadSystem("button3");
    } else {
      this.bitmap = ImageManager.loadSystem("button3_en");
    }
  };
  Sprite_Button3.prototype.buttonData = function () {
    var buttonTable = {
      av: { x: 0, w: 1 },
      kigae: { x: 1, w: 1 },
      dousei: { x: 2, w: 1 },
      status: { x: 3, w: 1 },
      facility: { x: 4, w: 1 },
      formation: { x: 5, w: 1 },
      invasion: { x: 6, w: 1 },
      decisiveBattle: { x: 7, w: 1 },
      soupKichen: { x: 8, w: 1 },
      save: { x: 9, w: 1 },
      main: { x: 10, w: 1 },
      downLoad: { x: 11, w: 1 },
    };
    return buttonTable[this._buttonType];
  };
  Sprite_Button3.prototype.checkBitmap = function () {
    if (this.bitmap.isReady() && this.bitmap.width < this.blockWidth() * 4) {
      // Probably MV image is used
      throw new Error("ButtonSet image is too small");
    }
  };
  Sprite_Button3.prototype.hitTest = function (x, y) {
    var rect = new Rectangle(
      -this.anchor.x * (this.width - 4),
      -this.anchor.y * this.height,
      this.width - 4,
      this.height
    );
    return rect.contains(x, y);
  };
  Sprite_Button3.prototype.select = function () {
    this._selected = true;
  };
  Sprite_Button3.prototype.deselect = function () {
    this._selected = false;
  };
  Sprite_Button3.prototype.push = function () {
    if (this._disable) {
      return;
    }
    this._pushed = true;
  };
  Sprite_Button3.prototype.up = function () {
    this._pushed = false;
  };
  Sprite_Button3.prototype.isPushed = function () {
    return this._pushed;
  };
  Sprite_Button3.prototype.updateFrame = function () {
    if (this._pushed) {
      var frame = this._hotFrame;
      this.setFrame(frame.x, frame.y, frame.width, frame.height);
    } else if (this._selected && !this._disable) {
      var frame = this._overFrame;
      this.setFrame(frame.x, frame.y, frame.width, frame.height);
    } else {
      _super.prototype.updateFrame.call(this);
    }
  };
  Sprite_Button3.prototype.deactivate = function () {
    this._active = false;
  };
  Sprite_Button3.prototype.activate = function () {
    this._active = true;
  };
  Sprite_Button3.prototype.isPressed = function () {
    return _super.prototype.isPressed.call(this);
  };
  return Sprite_Button3;
})(Sprite_OverableButton);


code:
var __extends =
  (this && this.__extends) ||
  (function () {
    var extendStatics = function (d, b) {
      extendStatics =
        Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array &&
          function (d, b) {
            d.__proto__ = b;
          }) ||
        function (d, b) {
          for (var p in b)
            if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
        };
      return extendStatics(d, b);
    };
    return function (d, b) {
      if (typeof b !== "function" && b !== null)
        throw new TypeError(
          "Class extends value " + String(b) + " is not a constructor or null"
        );
      extendStatics(d, b);
      function __() {
        this.constructor = d;
      }
      d.prototype =
        b === null
          ? Object.create(b)
          : ((__.prototype = b.prototype), new __());
    };
  })();
var MEM_W = 185;
var CharCommand;
(function (CharCommand) {
  CharCommand["av"] = "av";
  CharCommand["kigae"] = "kigae";
  CharCommand["status"] = "status";
})(CharCommand || (CharCommand = {}));
var Window_CharacterList = /** @class */ (function (_super) {
  __extends(Window_CharacterList, _super);
  function Window_CharacterList() {
    var _this = this;
    var y = Nore.TOP_Y;
    var offset = 7 * 6;
    var rect = new Rectangle(
      140 + offset,
      y,
      1140 - offset + 8,
      Graphics.height - y + 8
    );
    _this = _super.call(this, rect) || this;
    _this.frameVisible = false;
    _this.createBackground();
    return _this;
  }
  Window_CharacterList.prototype.initialize = function (rect) {
    _super.prototype.initialize.call(this, rect);
    this.padding = 0;
    this._additionalSprites = {};
    this.contents.outlineWidth = 4;
    this.contents.outlineColor = "rgba(0, 0, 0, 0.8)";
    this.refresh();
  };
  Window_CharacterList.prototype.itemRect = function (index) {
    var rect = _super.prototype.itemRect.call(this, index);
    rect.x += 15;
    rect.y += 20;
    return rect;
  };
  Window_CharacterList.prototype.itemWidth = function () {
    var w = _super.prototype.itemWidth.call(this);
    return w - 5;
  };
  Window_CharacterList.prototype.createBackground = function () {
    var baseTexture = Nore.getSystemBaseTexture("menu");
    if (!baseTexture) {
      return;
    }
    var texture = new PIXI.Texture(
      baseTexture,
      new Rectangle(184, 0, baseTexture.width - 184, baseTexture.height)
    );
    this._bg = new PIXI.Sprite(texture);
    this._bg.x = 2;
    this._bg.y = 2;
    this._contentsBackSprite.addChild(this._bg);
  };
  Window_CharacterList.prototype.itemBackgroundSprite = function () {
    var baseTexture = Nore.getSystemBaseTexture("menu2");
    if (!baseTexture) {
      return;
    }
    var texture = new PIXI.Texture(baseTexture, new Rectangle(0, 0, 143, 715));
    var sprite = new PIXI.Sprite(texture);
    return sprite;
  };
  Window_CharacterList.prototype.itemBackgroundSprite2 = function () {
    var baseTexture = Nore.getSystemBaseTexture("menu2");
    if (!baseTexture) {
      return;
    }
    var y = 300;
    var texture = new PIXI.Texture(
      baseTexture,
      new Rectangle(143, y, 143, 715 - y)
    );
    var sprite = new PIXI.Sprite(texture);
    sprite.y = y;
    sprite.blendMode = PIXI.BLEND_MODES.HARD_LIGHT;
    sprite.alpha = 0.7;
    return sprite;
  };
  Window_CharacterList.prototype.itemMaskSprite = function () {
    var baseTexture = Nore.getSystemBaseTexture("menu2");
    if (!baseTexture) {
      return;
    }
    var y = 50;
    var texture = new PIXI.Texture(
      baseTexture,
      new Rectangle(144, y, 139, 200 - y)
    );
    var sprite = new PIXI.Sprite(texture);
    sprite.y = y;
    return sprite;
  };
  Window_CharacterList.prototype.douseiSprite = function () {
    var baseTexture = Nore.getSystemBaseTexture("menu2");
    if (!baseTexture) {
      return;
    }
    var texture = new PIXI.Texture(baseTexture, new Rectangle(150, 0, 75, 30));
    var sprite = new PIXI.Sprite(texture);
    return sprite;
  };
  Window_CharacterList.prototype.makeItems = function () {
    this._dataList = [];
    var list = this.getActorIdList();
    for (var i = 0; i < list.length; i++) {
      var actor = $gameActors.actor(list[i]);
      this._dataList.push(actor);
    }
  };
  Window_CharacterList.prototype.refresh = function () {
    this.makeItems();
    this.contents.clear();
    this._windowContentsBackSprite2.removeChildren();
    this._windowContentsSprite.removeChildren();
    _super.prototype.refresh.call(this);
    for (var i = 0; i < this._dataList.length; i++) {
      var actor = this._dataList[i];
      var rect = this.itemRect(i);
      this.drawActor(actor, rect);
    }
    //this.drawLine(486);
  };
  Window_CharacterList.prototype.drawActor = function (a, rect) {
    var actor = JsonEx.makeDeepCopy(a);
    var bg = this.itemBackgroundSprite();
    bg.x = rect.x + 4;
    bg.y = rect.y;
    this._windowContentsBackSprite.addChild(bg);
    this.changePaintOpacity(this.isEnabled(actor));
    var tachieX = rect.x + this.xPosByActor(actor.actorId()) - 74;
    var faceId = this.actorFaceId(actor);
    if (actor.getDefaultFaceId() > 1) {
      faceId = actor.getDefaultFaceId();
    }
    actor.setHoppeId(this.hoppeId(actor));
    var charRect = new Rectangle(rect.x + 16 - 22, 66, 139, 400);
    var sprite = this.drawTachieActor(
      actor,
      this._windowContentsBackSprite,
      tachieX,
      rect.y - 108,
      charRect,
      faceId,
      0.6,
      false
    );
    var mask = this.itemMaskSprite();
    mask.x = bg.x + 2;
    mask.y += bg.y + 277;
    this._windowContentsBackSprite.addChild(mask);
    var bg2 = this.itemBackgroundSprite2();
    bg2.x = bg.x;
    bg2.y += bg.y;
    this._windowContentsBackSprite.addChild(bg2);
    var yy = rect.y + 400;
    var xx = rect.x + 20;
    this.drawDousei(actor, xx, yy);
    yy += 60;
    this.drawStatus(actor, xx, yy);
    yy += 210;
    this.drawSyusan(actor, xx, yy);
    this.contents.fontSize = 22;
    this.drawActorName(actor, xx - 10, rect.y + 2);
    this.contents.fontSize = 20;
    var hpSprite = new Nore.Sprite_ActorHp(actor);
    hpSprite.x = rect.x + 24;
    hpSprite.y = rect.y + 50;
    this._windowContentsSprite.addChild(hpSprite);
  };
  Window_CharacterList.prototype.drawDousei = function (actor, x, y) {
    if (!actor.dousei().isEnabled()) {
      return;
    }
    this.contents.fontSize = 18;
    if (actor.dousei().manId() > 0) {
      if (ConfigManager.language == "jp") {
        var s = this.douseiSprite();
        s.x = x - 2;
        s.y = y - 2;
        this.addChild(s);
      } else {
        this.changeTextColor(ColorManager.crisisColor());
        this.drawText(TextManager.cohabiting, x, y, 104);
      }
      this.changeTextColor(ColorManager.normalColor());
      var manName = actor.dousei().manName();
      this.drawText(manName, x, y + 24, 108, "right");
      var friendshipLevel = actor.friendshipLevel(actor.dousei().manId());
      var text = actor.getFriendshipLevelText(friendshipLevel);
      this.drawText(text, x + 4, y + 24, 104, "left");
    } else {
      this.changeTextColor(ColorManager.normalColor());
      //this.drawText('', x, y, 120);
    }
  };
  Window_CharacterList.prototype.lineHeight = function () {
    return 30;
  };
  Window_CharacterList.prototype.drawBackgroundRect = function (rect) {
    _super.prototype.drawBackgroundRect.call(this, rect);
  };
  Window_CharacterList.prototype.placeBasicGauges = function (actor, x, y) {
    this.placeGauge(actor, "hp", x, y);
    this.placeGauge(actor, "mp", x, y + this.gaugeLineHeight());
  };
  Window_CharacterList.prototype.gaugeLineHeight = function () {
    return 24;
  };
  Window_CharacterList.prototype.drawLabel = function (label, x, y) {
    var baseTexture2 = Nore.getSystemBaseTexture("Battle");
    var rect = new Rectangle(0, 0, 48, 24);
    if (label == "HP") {
      rect.y = 24;
    }
    if (label == "MP") {
      rect.y = 48;
    }
    var texture = new PIXI.Texture(baseTexture2, rect);
    var sprite = new PIXI.Sprite(texture);
    sprite.x = x;
    sprite.y = y + 22;
    this._windowContentsSprite.addChild(sprite);
  };
  Window_CharacterList.prototype.getBgSprite = function (index, rect) {
    var baseTexture2 = Nore.getSystemBaseTexture("back" + index);
    var texture = new PIXI.Texture(
      baseTexture2,
      new Rectangle(0, 0, rect.width, 480)
    );
    var sprite = new PIXI.Sprite(texture);
    return sprite;
  };
  Window_CharacterList.prototype.maxItems = function () {
    if (!this._dataList) {
      return 0;
    }
    return this._dataList.length;
  };
  Window_CharacterList.prototype.maxCols = function () {
    return 7;
  };
  Window_CharacterList.prototype.itemHeight = function () {
    return this.height - 30;
  };
  Window_CharacterList.prototype.drawSyusan = function (actor, xx, yy) {
    this.drawIcon(Icon.baby, xx, yy);
    this.drawText(actor.countSyusan(), xx + 50, yy, 52, "right");
  };
  Window_CharacterList.prototype.drawStatus = function (actor, xx, yy) {
    this.changeTextColor(ColorManager.normalColor());
    var list = Nore.$avParamManager.list();
    for (var i = 0; i < list.length; i++) {
      this.drawStatusOne(actor, xx, yy, i, list[i]);
    }
  };
  Window_CharacterList.prototype.drawStatusOne = function (
    actor,
    x,
    y,
    index,
    info
  ) {
    this.contents.fontSize = 24;
    var yy = y + index * 32;
    var xx = x;
    this.drawIcon(info.iconIndex(), xx, yy);
    this.drawText(
      Math.floor(actor.eroParam(info.type()) / 10),
      xx + 50,
      yy,
      52,
      "right"
    );
  };
  Window_CharacterList.prototype.placeGauge = function (actor, type, x, y) {
    var key = "actor%1-gauge-%2".format(actor.actorId(), type);
    var sprite = this.createInnerSprite(key, Sprite_Gauge);
    sprite.setup(actor, type);
    sprite.move(x, y);
    sprite.show();
  };
  Window_CharacterList.prototype.createInnerSprite = function (
    key,
    spriteClass
  ) {
    var dict = this._additionalSprites;
    if (dict[key]) {
      return dict[key];
    } else {
      var sprite = new spriteClass();
      dict[key] = sprite;
      this.addInnerChild(sprite);
      return sprite;
    }
  };
  Window_CharacterList.prototype.selectedActor = function () {
    return this._dataList[this.index()];
  };
  Window_CharacterList.prototype.selectActor = function (actorId) {
    for (var i = 0; i < this._dataList.length; i++) {
      var actor = this._dataList[i];
      if (actor.actorId() == actorId) {
        this.select(i);
        return;
      }
    }
  };
  Window_CharacterList.prototype.setSlgType = function (type) {
    this._slgType = type;
  };
  Window_CharacterList.prototype.isCurrentItemEnabled = function () {
    var actor = this.selectedActor();
    return this.isEnabled(actor);
  };
  Window_CharacterList.prototype.isEnabled = function (actor) {
    if (this._slgType != Nore.SlgCommand.dousei) {
      return true;
    }
    return actor.dousei().isEnabled();
  };
  Window_CharacterList.prototype.refreshCursor = function () {
    if (this._cursorAll) {
      this.refreshCursorForAll();
    } else if (this.index() >= 0) {
      var rect = this.itemRect(this.index());
      this.setCursorRect(
        rect.x - 6,
        rect.y - 16,
        rect.width + 4 + 8,
        rect.height + 16
      );
    } else {
      this.setCursorRect(0, 0, 0, 0);
    }
  };
  Window_CharacterList.prototype.colSpacing = function () {
    return 3;
  };
  return Window_CharacterList;
})(Nore.Window_MembersBase);


code:
/*:ja
 * @target MZ
 * @author ル
 *
 * @command start
 * @text バトルスタート
 * @des バトルスタート
 * @arg stageId
 * @type number
 * @text stageId
 * @desc stageId
 *
 * @command end
 * @text バトル終了
 * @des バトル終了
 */
var Nore;
(function (Nore) {
  var pluginName = "Nore_Clicker";
  PluginManager.registerCommand(pluginName, "start", function (args) {
    var stageId = parseInt(args.stageId);
    $slg.clicker().start(stageId);
    $slg.showSideBattle();
    var spriteset = SceneManager._scene._spriteset;
    if (spriteset) {
      if (spriteset._clickerWindow) {
        spriteset._clickerWindow.setup($slg.clickerStage());
      }
    }
  });
  PluginManager.registerCommand(pluginName, "end", function (args) {
    $slg.clicker().setCurrentStage(-1);
  });
})(Nore || (Nore = {}));
var WEAK_DAMAGE_RATE = 1.5;
var DEBUFF_DAMAGE_RATE = 1.5;
var ClickerPhase;
(function (ClickerPhase) {
  ClickerPhase["battle"] = "battle";
  ClickerPhase["win"] = "win";
})(ClickerPhase || (ClickerPhase = {}));
var LAST_STAGE_VAR = 66;
var IN_BATTLE_SW = 48;
var Clicker = /** @class */ (function () {
  function Clicker() {
    this._stageMap = {};
    this._currentStageId = 1;
  }
  Clicker.prototype.getStage = function (enemyId) {
    if (!this._stageMap[enemyId]) {
      this._stageMap[enemyId] = new ClickerStage(enemyId);
    }
    return this._stageMap[enemyId];
  };
  Clicker.prototype.restoreStages = function () {
    for (var key in this._stageMap) {
      var stage = this._stageMap[key];
      stage.findMaxStep();
    }
  };
  Clicker.prototype.currentStage = function () {
    return this.getStage(this._currentStageId);
  };
  Clicker.prototype.update = function () {
    if (!$gameSwitches.value(211)) {
      return;
    }
    this.currentStage().update();
    if (this.currentStage().isDefeat()) {
      $gameVariables.setValue(LAST_STAGE_VAR, this.currentStage().enemyId());
      $gameParty.addCommonEvent(255, -1);
      $slg.formation().recoverAll();
      this.setCurrentStage(-1);
      return;
    }
    if (this.currentStage().isDead()) {
      this.nextStage();
    }
    if (this._currentStageId > 0) {
      this.updateSkill();
    }
  };
  Clicker.prototype.updateSkill = function () {
    this.skill().setSpeed(this.skillSpeed());
    this.skill().update();
  };
  Clicker.prototype.skillSpeed = function () {
    if (this.currentStage().enemyId() == 55) {
      // マリナ戦
      return 2;
    }
    if (this.currentStage().enemyId() == 53) {
      // サキ戦
      return 2;
    }
    if (this.currentStage().enemyId() == 54) {
      // ココナ戦
      return 2;
    }
    if (this.currentStage().enemyId() == 100) {
      // コクリュウ戦
      return 2;
    }
    return 1;
  };
  Clicker.prototype.skill = function () {
    this._skill = this._skill || new ClickerSkill(ClickerSkillType.attack);
    return this._skill;
  };
  Clicker.prototype.nextStage = function () {
    if (this.currentStage().isFinalStep()) {
      this.reserveCommonEvent();
      this.setCurrentStage(-1);
      this.currentStage().update();
    } else {
      this.setCurrentStage(this._currentStageId + 1);
      this.currentStage().start();
      this.currentStage().update();
    }
  };
  Clicker.prototype.selectNextStage = function () {
    for (var i = 1; i < 30; i++) {
      var e = $dataEnemies[this._currentStageId + i];
      if (e && e.name.length > 0) {
        this._currentStageId = e.id;
        this.currentStage().update();
        break;
      }
    }
  };
  Clicker.prototype.start = function (id) {
    var reserveCommon = -1;
    if (id == 51) {
      if (!$gameSwitches.value(226)) {
        $gameParty.addCommonEvent(237, -1);
        reserveCommon = 237;
      }
    }
    this.setCurrentStage(id);
    this.currentStage().start();
    return reserveCommon;
  };
  Clicker.prototype.updateBattleSwitch = function () {
    if (this._currentStageId > 0) {
      $gameSwitches.setValue(IN_BATTLE_SW, true);
    } else {
      $gameSwitches.setValue(IN_BATTLE_SW, false);
    }
  };
  Clicker.prototype.setCurrentStage = function (id) {
    this._currentStageId = id;
    this.updateBattleSwitch();
  };
  /*setCurrentStage(id: number) {
        this._currentStageId = id;
        this.currentStage().update();
    }*/
  Clicker.prototype.currentStageId = function () {
    return this._currentStageId;
  };
  Clicker.prototype.reserveCommonEvent = function () {
    var commonId = this.currentStage().enemy().meta["commonId"];
    if (commonId) {
      $gameParty.addCommonEvent(parseInt(commonId), -1);
    }
    this.currentStage().finishAfterEvent();
  };
  Clicker.prototype.escape = function () {
    this.setCurrentStage(-1);
    $gameTemp.reserveCommonEvent(141);
  };
  Clicker.prototype.waitTimeRate = function () {
    return 3;
    /*
        switch ($slg.stage()) {
        case 1:
            return 3;
        }
        return 4;*/
  };
  return Clicker;
})();
var TargetType;
(function (TargetType) {
  TargetType["left"] = "left";
  TargetType["minHp"] = "minHp";
  TargetType["maxHp"] = "maxHp";
  TargetType["priority"] = "priority";
})(TargetType || (TargetType = {}));
var ClickerEnemy = /** @class */ (function () {
  function ClickerEnemy(enemyId) {
    this._enemyId = enemyId;
    this._turn = 1;
    this.recoverAll();
    this.prepareAttack();
  }
  ClickerEnemy.prototype.recoverAll = function () {
    this._hp = this.mhp();
    if (this.enemy().meta["hpRate"]) {
      var hpRate = parseInt(this.enemy().meta["hpRate"]);
      this._hp *= hpRate / 100;
      this._hp = Math.floor(this._hp);
    }
    this._wait = 0;
    this._turn = 1;
  };
  ClickerEnemy.prototype.mhp = function () {
    var n = this.enemy().params[0];
    var rate = 1;
    if ($gameSwitches.value(255)) {
      // 防衛施設占拠
      rate -= 0.05;
    }
    rate -= 0.1; // バランス調整
    return Math.round(n * rate);
  };
  ClickerEnemy.prototype.hp = function () {
    return this._hp;
  };
  ClickerEnemy.prototype.isAlive = function () {
    return this._hp > 0;
  };
  ClickerEnemy.prototype.damage = function (n) {
    if (this._hp <= 0) {
      return;
    }
    this._hp -= n;
    if (this._hp < 0) {
      this._hp = 0;
      this.invokeDeathSkill();
    }
  };
  ClickerEnemy.prototype.addDebuff = function (skill) {
    if (skill.meta["damageDebuff"]) {
      this._damageDebuff = true;
    }
    if (skill.meta["defDebuff"]) {
      this._defDebuff = true;
    }
    if (skill.meta["spdDown"]) {
      this._wait -= 25;
      if (this._wait < 0) {
        this._wait = 0;
      }
    }
  };
  ClickerEnemy.prototype.invokeDeathSkill = function () {};
  ClickerEnemy.prototype.battlerName = function () {
    return this.enemy().battlerName;
  };
  ClickerEnemy.prototype.update = function () {
    if (!this.isAlive()) {
      return null;
    }
    this._wait++;
    if (this._wait >= this._maxWait) {
      this.prepareAttack();
      var skill = this.invokeAttackSkill();
      this._turn++;
      return skill;
    }
    return null;
  };
  ClickerEnemy.prototype.invokeAttackSkill = function () {
    for (var _i = 0, _a = this.skills(); _i < _a.length; _i++) {
      var skill = _a[_i];
      if (skill.stypeId == 1) {
        if (this.isSkillEnabled(skill)) {
          if (this.checkInvokeSkill(skill)) {
            return skill;
          }
        }
      }
    }
    return $dataSkills[1];
  };
  ClickerEnemy.prototype.isSkillEnabled = function (skill) {
    if (this.isSkillConditionTurnDisabled(skill)) {
      return false;
    }
    if (this.isSkillConditionTurnIntervalDisabled(skill)) {
      return false;
    }
    return true;
  };
  ClickerEnemy.prototype.isSkillConditionTurnIntervalDisabled = function (
    skill
  ) {
    var turn = parseInt(skill.meta["turnInterval"]);
    if (isNaN(turn)) {
      return false;
    }
    if (this._turn % turn == 0) {
      return false;
    }
    return true;
  };
  ClickerEnemy.prototype.isSkillConditionTurnDisabled = function (skill) {
    var turn = parseInt(skill.meta["turn"]);
    if (isNaN(turn)) {
      return false;
    }
    if (this._turn != turn) {
      return true;
    }
    return false;
  };
  ClickerEnemy.prototype.calcDamage = function (skill) {
    var atk = this.atk();
    if (this._damageDebuff) {
      atk /= 2;
    }
    var damageRate = skill.meta["damage"];
    if (!damageRate) {
      return Math.round(atk);
    }
    return Math.round((atk * parseInt(damageRate)) / 100);
  };
  ClickerEnemy.prototype.onAfterAttack = function () {
    this._damageDebuff = false;
  };
  ClickerEnemy.prototype.onAfterDamage = function () {
    this._defDebuff = false;
  };
  ClickerEnemy.prototype.isDefDebuff = function () {
    return this._defDebuff;
  };
  ClickerEnemy.prototype.atk = function () {
    return this.enemy().params[2];
  };
  ClickerEnemy.prototype.spd = function () {
    return Math.floor(AGI_BASE_VALUE / this.enemy().params[6]);
  };
  ClickerEnemy.prototype.prepareAttack = function () {
    this._maxWait = this.calcMaxWait();
    if (this.isInvokeDoubleAttack()) {
      this._maxWait = 16;
    }
    this._wait = 0;
  };
  ClickerEnemy.prototype.enemy = function () {
    return $dataEnemies[this.enemyId()];
  };
  ClickerEnemy.prototype.enemyId = function () {
    return this._enemyId;
  };
  ClickerEnemy.prototype.calcMaxWait = function () {
    return this.enemy().params[6] * this.waitTimeRate();
  };
  ClickerEnemy.prototype.wait = function () {
    return this._wait;
  };
  ClickerEnemy.prototype.maxWait = function () {
    return this._maxWait;
  };
  ClickerEnemy.prototype.waitTimeRate = function () {
    return $slg.clicker().waitTimeRate();
  };
  ClickerEnemy.prototype.targetType = function () {
    return TargetType.priority;
  };
  ClickerEnemy.prototype.element = function () {
    for (var _i = 0, _a = this.enemy().traits; _i < _a.length; _i++) {
      var t = _a[_i];
      if (t.code == 11) {
        if (t.dataId == 2) {
          return MonsterElement.flame;
        }
        if (t.dataId == 3) {
          return MonsterElement.water;
        }
        if (t.dataId == 4) {
          return MonsterElement.wood;
        }
      }
    }
    return MonsterElement.none;
  };
  ClickerEnemy.prototype.isWeak = function (element) {
    switch (this.element()) {
      case MonsterElement.flame:
        return element == MonsterElement.water;
      case MonsterElement.water:
        return element == MonsterElement.wood;
      case MonsterElement.wood:
        return element == MonsterElement.flame;
    }
    return false;
  };
  ClickerEnemy.prototype.skills = function () {
    var actions = this.enemy().actions;
    var result = [];
    for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) {
      var action = actions_1[_i];
      if (action.skillId > 10) {
        result.push($dataSkills[action.skillId]);
      }
    }
    return result;
  };
  ClickerEnemy.prototype.getSkill = function (skillType) {
    for (var _i = 0, _a = this.skills(); _i < _a.length; _i++) {
      var skill = _a[_i];
      if (skill.meta[skillType]) {
        return skill;
      }
    }
    return null;
  };
  ClickerEnemy.prototype.isInvokeDoubleAttack = function () {
    var skill = this.getSkill(SkillType.doubleAttack);
    if (!skill) {
      return false;
    }
    return this.checkInvokeSkill(skill);
  };
  ClickerEnemy.prototype.checkInvokeSkill = function (skill) {
    return Math.randomInt(100) <= skill.successRate;
  };
  return ClickerEnemy;
})();
var SkillType;
(function (SkillType) {
  SkillType["doubleAttack"] = "doubleAttack";
  SkillType["targetAll"] = "targetAll";
  SkillType["deathRecover"] = "deathRecover";
  SkillType["recoverHp"] = "recoverHp";
  SkillType["recoverHpAll"] = "recoverHpAll";
})(SkillType || (SkillType = {}));
var ClickerStage = /** @class */ (function () {
  function ClickerStage(enemyId) {
    this._damageList = [];
    this._enemyDamageList = [];
    this._enemyId = enemyId;
    this.findMaxStep();
  }
  ClickerStage.prototype.start = function () {
    this._defeatWait = 0;
    this._enemyList = [];
    var troop = $dataTroops[this._enemyId];
    for (var _i = 0, _a = troop.members; _i < _a.length; _i++) {
      var t = _a[_i];
      var enemy = new ClickerEnemy(t.enemyId);
      this._enemyList.push(enemy);
    }
    $slg.formation().recoverAll();
    $slg.clicker().skill().onSetup();
  };
  ClickerStage.prototype.initialHpRate = function () {
    var hpRate = this.enemy().meta["hpRate"];
    if (!hpRate) {
      return 1;
    }
    return parseInt(hpRate) / 100;
  };
  ClickerStage.prototype.findMaxStep = function () {
    if (this._enemyId < 0) {
      return;
    }
    var name = $dataEnemies[this._enemyId].name;
    var max = parseInt($dataEnemies[this._enemyId].meta["step"]);
    for (var i = 1; i <= 10; i++) {
      var e = $dataEnemies[this._enemyId + i];
      if (e.name == name) {
        max = parseInt(e.meta["step"]);
      } else {
        break;
      }
    }
    this._maxStep = max;
  };
  ClickerStage.prototype.mapId = function () {
    var map = this.enemy().meta["map"];
    if (map) {
      return parseInt(map);
    }
    return 1;
  };
  ClickerStage.prototype.enemyList = function () {
    return this._enemyList;
  };
  ClickerStage.prototype.enemyId = function () {
    return this._enemyId;
  };
  ClickerStage.prototype.enemy = function () {
    return $dataEnemies[this.enemyId()];
  };
  ClickerStage.prototype.update = function () {
    if (this._enemyId < 0) {
      return;
    }
    this.saveLastUnits();
    this.updateUnits();
    this.updateEnemy();
  };
  ClickerStage.prototype.saveLastUnits = function () {
    this._lastUnits = $slg.formation().battleMemberIds();
  };
  ClickerStage.prototype.isFormationChanged = function () {
    if (!this._lastUnits) {
      return false;
    }
    var units = $slg.formation().battleMemberIds();
    if (this._lastUnits.length != units.length) {
      return true;
    }
    for (var _i = 0, units_1 = units; _i < units_1.length; _i++) {
      var u = units_1[_i];
      if (!this._lastUnits.contains(u)) {
        return true;
      }
    }
    return false;
  };
  ClickerStage.prototype.clearDamage = function () {
    this._damageList = [];
  };
  ClickerStage.prototype.clearEnemyDamage = function () {
    this._enemyDamageList = [];
  };
  ClickerStage.prototype.updateUnits = function () {
    for (
      var _i = 0, _a = $slg.formation().existBattleMembers();
      _i < _a.length;
      _i++
    ) {
      var a = _a[_i];
      if (a.updateWait()) {
        this.attack(a);
      }
    }
    /*const leader = $slg.formation().leader();
        if (leader.updateWait()) {
            this.attack(leader);
        }*/
  };
  ClickerStage.prototype.updateEnemy = function () {
    for (var _i = 0, _a = this._enemyList; _i < _a.length; _i++) {
      var e = _a[_i];
      var skill = e.update();
      if (!skill) {
        continue;
      }
      var targets = this.makeEnemyTargets(e, skill);
      for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
        var a = targets_1[_b];
        if (!a) {
          continue;
        }
        var damage = e.calcDamage(skill);
        e.onAfterAttack();
        a.damage(damage);
        a.addDebuff(skill);
        this._enemyDamageList.push(new EnemyClickerDamage(damage, a, e, skill));
      }
    }
  };
  ClickerStage.prototype.makeEnemyTargets = function (e, skill) {
    if (skill.meta["targetAll"]) {
      return $slg.formation().aliveTargets();
    }
    if (skill.meta["target2"]) {
      return $slg.formation().aliveTargetNum(2);
    }
    if (skill.meta["target3"]) {
      return $slg.formation().aliveTargetNum(3);
    }
    if (skill.meta["targetFront3"]) {
      return $slg.formation().aliveTargetFrontNum(3);
    }
    if (skill.meta["target"] == "top") {
      return $slg.formation().aliveTargetTop();
    }
    if (skill.meta["target"] == "bottom") {
      return $slg.formation().aliveTargetBottom();
    }
    switch (e.targetType()) {
      case TargetType.priority:
        return [$slg.formation().priorityTarget()];
      case TargetType.left:
        return [$slg.formation().leftTarget()];
      default:
        console.error("不正なターゲットです" + e.targetType());
    }
  };
  ClickerStage.prototype.attackLeader = function () {
    if (this.isDead()) {
      return;
    }
    var target = this._enemyList[0];
    var damage = this.calcLeaderDamage();
    target.damage(damage);
    target.onAfterDamage();
    var skill = $dataSkills[162];
    this._damageList.push(
      new ClickerDamage(
        damage,
        new BattleActor(-1, 10, 1),
        target,
        skill,
        false
      )
    );
  };
  ClickerStage.prototype.calcLeaderDamage = function () {
    var n = 0;
    for (
      var _i = 0, _a = $slg.formation().battleMembers();
      _i < _a.length;
      _i++
    ) {
      var b = _a[_i];
      n += b.atk();
    }
    return n;
  };
  ClickerStage.prototype.attack = function (a) {
    if (this.isDead()) {
      return;
    }
    var skill = a.attackSkill();
    var damage = a.atk() * this.skillDamageRate(skill);
    if ($gameSwitches.value(323)) {
      // 怪人王の研究所ボーナス
      damage *= 1.05;
    }
    damage *= a.damageRate();
    damage *= $gameSystem.difficultyDamageRate();
    a.increaseTurn();
    var targets = this.makeTargets(a, skill);
    if (targets.length == 0) {
      return;
    }
    for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) {
      var target = targets_2[_i];
      if (target.isWeak(a.element())) {
        damage *= WEAK_DAMAGE_RATE;
      }
      var isDebuff = false;
      if (target.isDefDebuff()) {
        damage *= DEBUFF_DAMAGE_RATE;
        isDebuff = true;
      }
      damage = Math.round(damage);
      a.onAfterAttack();
      target.damage(damage);
      target.onAfterDamage();
      target.addDebuff(skill);
      this._damageList.push(
        new ClickerDamage(damage, a, target, skill, isDebuff)
      );
    }
  };
  ClickerStage.prototype.skillDamageRate = function (skill) {
    var damageRate = skill.meta["damage"];
    if (!damageRate) {
      return 1;
    }
    return parseInt(damageRate) / 100;
  };
  ClickerStage.prototype.makeTargets = function (a, skill) {
    if (skill && skill.meta["targetAll"]) {
      var result = [];
      for (var _i = 0, _a = this._enemyList; _i < _a.length; _i++) {
        var a_1 = _a[_i];
        if (a_1.isAlive()) {
          result.push(a_1);
        }
      }
      return result;
    }
    var target = this.makeTarget(a, skill);
    if (target) {
      return [target];
    }
    return [];
  };
  ClickerStage.prototype.makeTarget = function (a, skill) {
    var candidates = [];
    for (var _i = 0, _a = this._enemyList; _i < _a.length; _i++) {
      var a_2 = _a[_i];
      if (a_2.isAlive()) {
        candidates.push(a_2);
      }
    }
    if (candidates.length == 0) {
      return null;
    }
    var dice = Math.randomInt(candidates.length);
    return candidates[dice];
  };
  ClickerStage.prototype.gainReward = function () {
    var gold = this.enemy().gold;
    if (gold > 0) {
      AudioManager.playSe({ name: "Coin", volume: 80, pitch: 100, pan: 0 });
      $gameParty.gainGold(gold);
    }
  };
  ClickerStage.prototype.isWaitVictory = function () {
    return this._victoryWait > 0;
  };
  ClickerStage.prototype.isDead = function () {
    if (this._clear) {
      return true;
    }
    if (this._victoryWait > 0) {
      this._victoryWait--;
      if (this._victoryWait == 0) {
        this._clear = true;
        this.gainReward();
        return true;
      }
      return false;
    }
    if (!this._enemyList) {
      return false;
    }
    for (var _i = 0, _a = this._enemyList; _i < _a.length; _i++) {
      var e = _a[_i];
      if (e.isAlive()) {
        return false;
      }
    }
    this._victoryWait = 70;
    return false;
  };
  ClickerStage.prototype.finishAfterEvent = function () {
    this._finishAfterEvent = true;
  };
  ClickerStage.prototype.isBattleEnd = function () {
    return this._clear || this._victoryWait > 0 || this._defeatWait > 0;
  };
  ClickerStage.prototype.isClear = function () {
    if (this.hasCommonEvent()) {
      if (this._finishAfterEvent) {
        return true;
      } else {
        if (this.isClearSwOn()) {
          return true;
        }
        return false;
      }
    } else {
      if (this._clear) {
        return true;
      }
    }
    if (!this._enemyList) {
      return false;
    }
    for (var _i = 0, _a = this._enemyList; _i < _a.length; _i++) {
      var e = _a[_i];
      if (e.isAlive()) {
        return false;
      }
    }
    return true;
  };
  ClickerStage.prototype.hasCommonEvent = function () {
    if (!this.enemy()) {
      return false;
    }
    var commonId = this.enemy().meta["commonId"];
    return commonId != null;
  };
  ClickerStage.prototype.isClearSwOn = function () {
    // 過去のバージョンですでにクリア済だった場合の処理
    var clearSw = this.enemy().meta["clearSw"];
    if (clearSw == null) {
      return false;
    }
    return $gameSwitches.value(parseInt(clearSw));
  };
  ClickerStage.prototype.isDefeat = function () {
    if (this._defeatWait > 0) {
      this._defeatWait--;
      if (this._defeatWait == 0) {
        return true;
      }
      return false;
    }
    if ($slg.formation().isAllDead()) {
      this._defeatWait = 50;
    }
    return false;
  };
  ClickerStage.prototype.damageList = function () {
    return this._damageList;
  };
  ClickerStage.prototype.enemyDamageList = function () {
    return this._enemyDamageList;
  };
  ClickerStage.prototype.name = function () {
    if (!this.enemy()) {
      return "";
    }
    var enemy = this.enemy();
    var name = this.enemy().name;
    switch (ConfigManager.language) {
      case "en":
        if (enemy.meta["nameEn"]) {
          name = enemy.meta["nameEn"];
        }
        break;
      case "ch":
      case "jp":
        break;
    }
    if (this.maxStep() == 1) {
      return name;
    }
    return name + this.currentStep() + "/" + this.maxStep();
  };
  ClickerStage.prototype.currentStep = function () {
    if (!this.enemy()) {
      return 1;
    }
    return parseInt(this.enemy().meta["step"]);
  };
  ClickerStage.prototype.maxStep = function () {
    if (!this._maxStep) {
      this.findMaxStep();
    }
    return this._maxStep;
  };
  ClickerStage.prototype.isFinalStep = function () {
    return this.currentStep() == this.maxStep();
  };
  ClickerStage.prototype.calcLeaderAttack = function () {
    var max = $slg.facilityInfo().findMaxFacilityLevel(FacilityType.weapon);
    switch (max) {
      case 0:
        return 2;
      case 1:
        return 5;
      case 2:
        return 10;
      case 3:
        return 15;
    }
    return 2;
    var attack = 0;
    for (
      var _i = 0, _a = $slg.formation().battleMembers();
      _i < _a.length;
      _i++
    ) {
      var a = _a[_i];
      attack += a.atk();
    }
    return Math.floor(attack / 2);
  };
  ClickerStage.prototype.friendHp = function () {
    var n = 0;
    for (
      var _i = 0, _a = $slg.formation().battleMembers();
      _i < _a.length;
      _i++
    ) {
      var a = _a[_i];
      n += a.hp();
    }
    return n;
  };
  ClickerStage.prototype.friendMhp = function () {
    var n = 0;
    for (
      var _i = 0, _a = $slg.formation().battleMembers();
      _i < _a.length;
      _i++
    ) {
      var a = _a[_i];
      n += a.mhp();
    }
    return n;
  };
  ClickerStage.prototype.leaderName = function () {
    return $gameActors.actor(10).name();
  };
  ClickerStage.prototype.inBattle = function () {
    if (this._enemyId <= 0) {
      return false;
    }
    if (this._defeatWait > 0) {
      return false;
    }
    if (!this.enemyList()) {
      return false;
    }
    return true;
  };
  ClickerStage.prototype.enemyAttackAnimeId = function () {
    var anime = this.enemy().meta["anime"];
    if (anime) {
      return parseInt(anime);
    }
    return 197;
  };
  ClickerStage.prototype.isLastBoss = function () {
    switch (this._enemyId) {
      case 100:
        return true;
    }
    return false;
  };
  ClickerStage.prototype.isBoss = function () {
    switch (this._enemyId) {
      case 6:
        return true;
      case 50:
        return true;
      case 55:
        return true;
      case 53:
        return true;
      case 54:
        return true;
      case 70:
        return true;
      case 71:
        return true;
      case 72:
        return true;
    }
    return false;
  };
  return ClickerStage;
})();
var ClickerDamage = /** @class */ (function () {
  function ClickerDamage(damage, battleActor, enemy, skill, isDebuff) {
    this._damage = damage;
    this._battleActor = battleActor;
    this._enemy = enemy;
    this._weak = enemy.isWeak(this._battleActor.element()) || isDebuff;
    this._skill = skill;
  }
  ClickerDamage.prototype.damage = function () {
    return this._damage;
  };
  ClickerDamage.prototype.battleActor = function () {
    return this._battleActor;
  };
  ClickerDamage.prototype.enemy = function () {
    return this._enemy;
  };
  ClickerDamage.prototype.isWeak = function () {
    return this._weak;
  };
  ClickerDamage.prototype.element = function () {
    return this._battleActor.element();
  };
  ClickerDamage.prototype.animationId = function () {
    if (this._skill.id == 1) {
    }
    return this._skill.animationId;
  };
  return ClickerDamage;
})();
var EnemyClickerDamage = /** @class */ (function () {
  function EnemyClickerDamage(damage, battleActor, enemy, skill) {
    this._damage = damage;
    this._battleActor = battleActor;
    this._enemy = enemy;
    this._weak = false; // 敵の攻撃は弱点なし
    this._skill = skill;
    //this._weak = battleActor.isWeak(enemy.element());
  }
  EnemyClickerDamage.prototype.damage = function () {
    return this._damage;
  };
  EnemyClickerDamage.prototype.battleActor = function () {
    return this._battleActor;
  };
  EnemyClickerDamage.prototype.enemy = function () {
    return this._enemy;
  };
  EnemyClickerDamage.prototype.element = function () {
    return this._enemy.element();
  };
  EnemyClickerDamage.prototype.isWeak = function () {
    return this._weak;
  };
  EnemyClickerDamage.prototype.animeId = function () {
    if (this._skill) {
      return this._skill.animationId;
    }
    return this.defaultAnimeId();
  };
  EnemyClickerDamage.prototype.defaultAnimeId = function () {
    return 197;
  };
  return EnemyClickerDamage;
})();
var ClickerSkillType;
(function (ClickerSkillType) {
  ClickerSkillType["speedUp"] = "speedUp";
  ClickerSkillType["attack"] = "attack";
})(ClickerSkillType || (ClickerSkillType = {}));
var ClickerSkill = /** @class */ (function () {
  function ClickerSkill(type) {
    this._remain = 0;
    this._type = type;
    this._remain = this.time();
  }
  ClickerSkill.prototype.setSpeed = function (s) {
    this._speed = s;
  };
  ClickerSkill.prototype.update = function () {
    if (this._active) {
      this.updateActive();
    } else {
      this.updateCooling();
    }
  };
  ClickerSkill.prototype.onSetup = function () {
    this._active = false;
    this._remain = this.time() / 2;
  };
  ClickerSkill.prototype.updateActive = function () {};
  ClickerSkill.prototype.updateCooling = function () {
    this._remain -= this._speed;
    if (this._remain <= 0) {
      this._active = true;
    }
  };
  ClickerSkill.prototype.type = function () {
    return this._type;
  };
  ClickerSkill.prototype.invoke = function () {
    if (!this.isActive()) {
      return false;
    }
    this._remain = this.time();
    this._active = false;
    return true;
  };
  ClickerSkill.prototype.time = function () {
    return 1200;
  };
  ClickerSkill.prototype.isActive = function () {
    return this._active;
  };
  ClickerSkill.prototype.remain = function () {
    return this._remain;
  };
  ClickerSkill.prototype.timeRate = function () {
    return (this.time() - this._remain) / this.time();
  };
  return ClickerSkill;
})();


code:
var AGI_BASE_VALUE = 2500;
var BattleActor = /** @class */ (function () {
  function BattleActor(id, actorId, level) {
    this._recoverHp = 0;
    this._turn = 0;
    this._id = id;
    this._actorId = actorId;
    this._level = level;
  }
  BattleActor.prototype.id = function () {
    return this._id;
  };
  BattleActor.prototype.actor = function () {
    return $gameActors.actor(this._actorId);
  };
  BattleActor.prototype.characterName = function () {
    return this.actor().actor().characterName;
  };
  BattleActor.prototype.characterIndex = function () {
    return this.actor().actor().characterIndex;
  };
  BattleActor.prototype.level = function () {
    if (this.isZako()) {
      //return this.actor().level;
      return $slg
        .facilityInfo()
        .findMaxFacility(FacilityType.combatant)
        .level();
    }
    return this._level;
  };
  BattleActor.prototype.isZako = function () {
    return this.actorId() >= 187 && this.actorId() <= 191;
  };
  BattleActor.prototype.name = function () {
    return this.actor().name();
  };
  BattleActor.prototype.power = function () {
    return this.atk() + this.mhp();
  };
  BattleActor.prototype.kaijinParam = function (index) {
    var param = KAIJIN_PARAMS[this._actorId];
    return param[index];
  };
  BattleActor.prototype.mhp = function () {
    return this.mhpBase() + this.mhpPlus();
  };
  BattleActor.prototype.mhpBase = function () {
    return Math.round(this.kaijinParam(2) * this.levelRate()) + this.mhpBonus();
  };
  BattleActor.prototype.mhpBonus = function () {
    switch (this.element()) {
      case MonsterElement.flame:
        return (
          $gameParty.friendshipBonus(FriendshipBonusType.hpFlame) *
          $gameParty.friendshipBonusRate(FriendshipBonusType.hpFlame)
        );
      case MonsterElement.water:
        return (
          $gameParty.friendshipBonus(FriendshipBonusType.hpWater) *
          $gameParty.friendshipBonusRate(FriendshipBonusType.hpWater)
        );
      case MonsterElement.wood:
        return (
          $gameParty.friendshipBonus(FriendshipBonusType.hpWood) *
          $gameParty.friendshipBonusRate(FriendshipBonusType.hpWood)
        );
    }
    return 0;
  };
  BattleActor.prototype.mhpPlus = function () {
    if (!this._passiveSkills) {
      return 0;
    }
    return this._passiveSkills.mhpPlus(this);
  };
  BattleActor.prototype.atk = function () {
    return this.atkBase() + this.atkPlus() + this.deathAtk();
  };
  BattleActor.prototype.atkBonus = function () {
    switch (this.element()) {
      case MonsterElement.flame:
        return $gameParty.friendshipBonus(FriendshipBonusType.atkFlame);
      case MonsterElement.water:
        return $gameParty.friendshipBonus(FriendshipBonusType.atkWater);
      case MonsterElement.wood:
        return $gameParty.friendshipBonus(FriendshipBonusType.atkWood);
    }
    return 0;
  };
  BattleActor.prototype.deathAtk = function () {
    if (!this._passiveSkills) {
      return 0;
    }
    return this._passiveSkills.deathAtk(this, this.atkBase());
  };
  BattleActor.prototype.atkBase = function () {
    return Math.round(this.kaijinParam(3) * this.levelRate()) + this.atkBonus();
  };
  BattleActor.prototype.atkPlus = function () {
    if (!this._passiveSkills) {
      return 0;
    }
    return this._passiveSkills.atkPlus(this);
  };
  BattleActor.prototype.actorId = function () {
    return this._actorId;
  };
  BattleActor.prototype.agi = function () {
    return this.agiBase() - this.agiPlus();
  };
  BattleActor.prototype.agiBase = function () {
    return this.kaijinParam(4);
  };
  BattleActor.prototype.agiPlus = function () {
    if (!this._passiveSkills) {
      return 0;
    }
    return this._passiveSkills.agiPlus(this);
  };
  BattleActor.prototype.agiText = function () {
    return Math.floor(AGI_BASE_VALUE / this.agi());
  };
  BattleActor.prototype.agiPlusText = function () {
    return this.agiText() - Math.floor(AGI_BASE_VALUE / this.agiBase());
  };
  BattleActor.prototype.levelUpCost = function () {
    var key = this.rare() + "_" + this.level();
    var cost = KAIJIN_LVUP_COSTS[key];
    return cost || 0;
  };
  BattleActor.prototype.levelUp = function () {
    if (this._level == this.maxLevel()) {
      return;
    }
    this._level++;
  };
  BattleActor.prototype.maxLevel = function () {
    return 5;
  };
  BattleActor.prototype.levelRate = function () {
    var rate = 5;
    if (this.isZako()) {
      rate = 30;
    }
    return (100 + (this.level() - 1) * rate) / 100;
  };
  BattleActor.prototype.isCombatant = function () {
    if (this._actorId >= 187) {
      if (this._actorId <= 192) {
        return true;
      }
    }
    return false;
  };
  BattleActor.prototype.updateWait = function () {
    if (this.isDead()) {
      return;
    }
    if (this._wait > 0) {
      this._wait--;
      if (this._wait == 0) {
        return true;
      }
    } else {
      this._maxWait = this.waitTime();
      if (this.isInvokeDoubleAttack()) {
        this._maxWait = 12;
      }
      this.invokeTurnSkill();
      this._wait = this._maxWait;
    }
    return false;
  };
  BattleActor.prototype.invokeTurnSkill = function () {
    this.invokeRecoverHp();
    this.invokeRecoverHpAll();
  };
  BattleActor.prototype.invokeRecoverHpAll = function () {
    var skill = this.getSkill(SkillType.recoverHpAll);
    if (!skill) {
      return false;
    }
    var value = parseInt(skill.meta[SkillType.recoverHpAll]);
    for (
      var _i = 0, _a = $slg.formation().aliveTargets();
      _i < _a.length;
      _i++
    ) {
      var b = _a[_i];
      b.recoverHp(value);
    }
  };
  BattleActor.prototype.invokeRecoverHp = function () {
    var skill = this.getSkill(SkillType.recoverHp);
    if (!skill) {
      return false;
    }
    var value = parseInt(skill.meta[SkillType.recoverHp]);
    this.recoverHp(value);
  };
  BattleActor.prototype.isInvokeDoubleAttack = function () {
    var skill = this.getSkill(SkillType.doubleAttack);
    if (!skill) {
      return false;
    }
    return this.checkInvokeSkill(skill);
  };
  BattleActor.prototype.getSkill = function (skillType) {
    for (var _i = 0, _a = this.skills(); _i < _a.length; _i++) {
      var skill = _a[_i];
      if (skill.meta[skillType]) {
        return skill;
      }
    }
    return null;
  };
  BattleActor.prototype.wait = function () {
    return this._wait;
  };
  BattleActor.prototype.maxWait = function () {
    return this._maxWait;
  };
  BattleActor.prototype.waitTime = function () {
    return (this.agi() + Math.randomInt(10)) * this.waitTimeRate();
  };
  BattleActor.prototype.waitTimeRate = function () {
    return $slg.clicker().waitTimeRate();
  };
  BattleActor.prototype.recoverAll = function () {
    this._hp = this.mhp();
    this._recoverHp = 0;
    this._turn = 1;
    this._maxWait = this.waitTime();
    this._wait = this._maxWait - this.agi() * 2;
  };
  BattleActor.prototype.hp = function () {
    return this._hp;
  };
  BattleActor.prototype.damage = function (n) {
    if (this._hp <= 0) {
      return;
    }
    this._hp -= n;
    if (this._hp < 0) {
      this._hp = 0;
      this.invokeDeathSkill();
    }
  };
  BattleActor.prototype.invokeDeathSkill = function () {
    var skill = this.getSkill(SkillType.deathRecover);
    if (skill) {
      var value = parseInt(skill.meta[SkillType.deathRecover]);
      for (
        var _i = 0, _a = $slg.formation().aliveTargets();
        _i < _a.length;
        _i++
      ) {
        var t = _a[_i];
        t.recoverHp(value);
      }
    }
  };
  BattleActor.prototype.recoverHp = function (n) {
    if (this._hp <= 0) {
      return;
    }
    this._hp += n;
    this._recoverHp += n;
    if (this._hp > this.mhp()) {
      this._hp = this.mhp();
    }
  };
  BattleActor.prototype.isDead = function () {
    return this._hp <= 0;
  };
  BattleActor.prototype.rare = function () {
    return this.kaijinParam(0);
  };
  BattleActor.prototype.element = function () {
    return this.kaijinParam(1);
  };
  BattleActor.prototype.isWeak = function (element) {
    switch (this.element()) {
      case MonsterElement.flame:
        return element == MonsterElement.water;
      case MonsterElement.water:
        return element == MonsterElement.wood;
      case MonsterElement.wood:
        return element == MonsterElement.flame;
    }
    return false;
  };
  BattleActor.prototype.learnings = function () {
    var c = this.actor().currentClass();
    return c.learnings;
  };
  BattleActor.prototype.increaseTurn = function () {
    this._turn++;
  };
  BattleActor.prototype.skills = function () {
    var result = [];
    var c = this.actor().currentClass();
    for (var _i = 0, _a = c.learnings; _i < _a.length; _i++) {
      var l = _a[_i];
      if (l.level <= this.level()) {
        result.push($dataSkills[l.skillId]);
      }
    }
    return result;
  };
  BattleActor.prototype.attackSkill = function () {
    var skill = this.checkTurnSkill();
    if (skill) {
      return skill;
    }
    skill = this.checkRandomSkill();
    if (skill) {
      return skill;
    }
    return $dataSkills[1];
  };
  BattleActor.prototype.checkTurnSkill = function () {
    for (var _i = 0, _a = this.skills(); _i < _a.length; _i++) {
      var skill = _a[_i];
      if (skill.stypeId == 1) {
        var turn = skill.meta["turn"];
        if (turn) {
          if (parseInt(turn) == this._turn) {
            return skill;
          }
        }
        var turnInterval = skill.meta["turnInterval"];
        if (turnInterval) {
          if (this._turn % parseInt(turnInterval) == 0) {
            return skill;
          }
        }
      }
    }
    return null;
  };
  BattleActor.prototype.checkRandomSkill = function () {
    for (var _i = 0, _a = this.skills(); _i < _a.length; _i++) {
      var skill = _a[_i];
      if (skill.stypeId == 1) {
        if (this.checkInvokeSkill(skill)) {
          return skill;
        }
      }
    }
    return null;
  };
  BattleActor.prototype.checkInvokeSkill = function (skill) {
    if (skill.meta["turn"]) {
      return false;
    }
    if (skill.meta["turnInterval"]) {
      return false;
    }
    return Math.randomInt(100) <= this.skillRate(skill);
  };
  BattleActor.prototype.createPassiveSkillList = function (battleMembers) {
    var list = this.passiveSkills();
    if (list.length == 0) {
      return [];
    }
    var result = [];
    for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
      var skill = list_1[_i];
      var passiveSkills = new PassiveMaker().make(this, skill, battleMembers);
      for (
        var _a = 0, passiveSkills_1 = passiveSkills;
        _a < passiveSkills_1.length;
        _a++
      ) {
        var passiveSkill = passiveSkills_1[_a];
        result.push(passiveSkill);
      }
    }
    return result;
  };
  BattleActor.prototype.passiveSkills = function () {
    var result = [];
    for (var _i = 0, _a = this.skills(); _i < _a.length; _i++) {
      var skill = _a[_i];
      if (skill.stypeId == 2) {
        result.push(skill);
      }
    }
    return result;
  };
  BattleActor.prototype.setPassiveSkills = function (passiveSkills) {
    this._passiveSkills = passiveSkills;
  };
  BattleActor.prototype.skillRate = function (skill) {
    return skill.successRate + this.skillRatePlus();
  };
  BattleActor.prototype.skillRatePlus = function () {
    if (!this._passiveSkills) {
      return 0;
    }
    return this._passiveSkills.skillRatePlus(this);
  };
  BattleActor.prototype.isMaxLevel = function () {
    if (this.isZako()) {
      return true;
    }
    return this._level >= this.maxLevel();
  };
  BattleActor.prototype.getRecoverHp = function () {
    return this._recoverHp;
  };
  BattleActor.prototype.clearRecoverHp = function () {
    this._recoverHp = 0;
  };
  BattleActor.prototype.addDebuff = function (skill) {
    if (skill.meta["damageDebuff"]) {
      this._damageDebuff = true;
    }
  };
  BattleActor.prototype.onAfterAttack = function () {
    this._damageDebuff = false;
  };
  BattleActor.prototype.damageRate = function () {
    if (this._damageDebuff) {
      return 0.5;
    }
    return 1;
  };
  BattleActor.prototype.onLeaderSkill = function (waitPlus) {
    this._wait = 1 + waitPlus * 4;
  };
  return BattleActor;
})();