119 lines
3.1 KiB
JavaScript
119 lines
3.1 KiB
JavaScript
var TrainingInfo = /** @class */ (function () {
|
|
function TrainingInfo() {
|
|
this._trainingId = -1;
|
|
}
|
|
TrainingInfo.prototype.update = function () {
|
|
/*if (this.isEmpty()) {
|
|
return;
|
|
}
|
|
if (this._remainTime > 0) {
|
|
this._remainTime--;
|
|
if (this._remainTime == 0) {
|
|
this.levelUp();
|
|
}
|
|
}*/
|
|
};
|
|
TrainingInfo.prototype.setup = function (actor) {
|
|
this.removeTimeGaugeEvent();
|
|
if (actor) {
|
|
this._trainingId = actor.id();
|
|
this._totalTime = this.calcTrainingTime(actor);
|
|
this._remainTime = this._totalTime;
|
|
this.addTimeGaugeEvent(this._totalTime);
|
|
} else {
|
|
this._trainingId = -1;
|
|
}
|
|
};
|
|
TrainingInfo.prototype.actor = function () {
|
|
if (this._trainingId >= 0) {
|
|
return $slg.formation().findBattleActor(this._trainingId);
|
|
} else {
|
|
return null;
|
|
}
|
|
};
|
|
TrainingInfo.prototype.calcTrainingTime = function (actor) {
|
|
var time = actor.levelUpCost() * 30;
|
|
if ($slg.facilityInfo().hasFacility(29)) {
|
|
time *= 0.8;
|
|
}
|
|
if ($slg.facilityInfo().hasFacility(30)) {
|
|
time *= 0.8;
|
|
}
|
|
if ($slg.facilityInfo().hasFacility(26)) {
|
|
time *= 0.75;
|
|
}
|
|
if ($slg.facilityInfo().hasFacility(27)) {
|
|
time *= 0.75;
|
|
}
|
|
return Math.floor(time);
|
|
};
|
|
TrainingInfo.prototype.isEmpty = function () {
|
|
return this._trainingId == -1;
|
|
};
|
|
TrainingInfo.prototype.levelUp = function () {
|
|
this.removeTimeGaugeEvent();
|
|
this.actor().levelUp();
|
|
this._trainingId = -1;
|
|
};
|
|
TrainingInfo.prototype.removeTimeGaugeEvent = function () {
|
|
for (var i = 0; i < 2; i++) {
|
|
// 不具合の修正のために2回
|
|
$slg.removeTimeGaugeEventType(TimeGaugeEventType.training);
|
|
}
|
|
};
|
|
TrainingInfo.prototype.clearTraining = function () {
|
|
this._trainingId = -1;
|
|
this.removeTimeGaugeEvent();
|
|
};
|
|
TrainingInfo.prototype.addTimeGaugeEvent = function (time) {
|
|
// チュートリアル完了
|
|
$gameSwitches.setValue(357, true);
|
|
var e = new KaijinTrainingTimeGaugeEvent(this._trainingId, time);
|
|
$slg.addTimeGaugeEvent(e);
|
|
};
|
|
TrainingInfo.prototype.actorName = function () {
|
|
var actor = this.actor();
|
|
if (actor) {
|
|
return actor.name();
|
|
} else {
|
|
return "";
|
|
}
|
|
};
|
|
TrainingInfo.prototype.level = function () {
|
|
var actor = this.actor();
|
|
if (actor) {
|
|
return actor.level();
|
|
} else {
|
|
return -1;
|
|
}
|
|
};
|
|
TrainingInfo.prototype.totalTime = function () {
|
|
return this._totalTime;
|
|
};
|
|
TrainingInfo.prototype.remainTime = function () {
|
|
return this._remainTime;
|
|
};
|
|
TrainingInfo.prototype.trainingActorId = function () {
|
|
if (!this.actor()) {
|
|
return -1;
|
|
}
|
|
return this.actor().actorId();
|
|
};
|
|
TrainingInfo.prototype.onAv = function () {
|
|
this.onGacha();
|
|
};
|
|
TrainingInfo.prototype.onGacha = function () {
|
|
if (!this.actor()) {
|
|
return -1;
|
|
}
|
|
if (!$slg.facilityInfo().hasFacility(24)) {
|
|
return;
|
|
}
|
|
var timeEvent = $slg.getTimeGaugeEvent(TimeGaugeEventType.training);
|
|
if (!timeEvent) {
|
|
return;
|
|
}
|
|
timeEvent.reduceRemain(60);
|
|
};
|
|
return TrainingInfo;
|
|
})();
|