dead-bunny/js/plugins/Nore_Gacha.js
2025-01-12 01:21:39 -06:00

712 lines
22 KiB
JavaScript

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 gacha
*
* @command decideGachaHalo
* @text ガチャ背景IDを変数78番に代入
*
* @command showGachaResult
* @text ガチャリザルト表示
* @des ガチャリザルト表示
* @arg battleActorId
* @type number
* @text battleActorId
* @desc battleActorId
*
* @command showGachaResultList
* @text ガチャリザルト5連表示
* @des ガチャリザルト5連表示
*
* @command showGachaResultCharacter
* @text ガチャリザルトキャラ表示
* @des ガチャリザルトキャラ表示
*
* @command hideGachaResult
* @text ガチャリザルト非表示
* @des ガチャリザルト非表示
*
* @command joinActor
* @text 怪人を追加
* @des 怪人を追加
* @arg actorId
* @type number
* @text actorId
* @desc actorId
* @arg level
* @type number
* @text level
* @desc level
*
* @command showGachaRate
* @text ガチャ確率表示
* @des ガチャ確率表示
*
* @command hideGachaRate
* @text ガチャ確率消す
* @des ガチャ確率消す
*
* @command getGachaTicket
* @text ガチャチケットを獲得
* @des ガチャチケットを獲得
*
* @command showMonsterBonus
* @text 怪人ボーナステキスト表示
*
* @command hideMonsterBonus
* @text 怪人ボーナステキスト非表示
*/
var KAIJIN_ACTOR_ID_VAR = 64;
var Nore;
(function (Nore) {
var pluginName = "Nore_Gacha";
PluginManager.registerCommand(pluginName, "decideGachaHalo", function (args) {
if ($gameSwitches.value(19)) {
// 5連
var list = $gameTemp.lastJoinBattleActorIdList;
var varId = 76;
for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
var battleActorId = list_1[_i];
var actor = $slg.formation().findBattleActor(battleActorId);
if (!actor) {
return;
}
if (actor.element() == MonsterElement.flame) {
$gameVariables.setValue(varId, 2);
}
if (actor.element() == MonsterElement.water) {
$gameVariables.setValue(varId, 1);
}
if (actor.element() == MonsterElement.wood) {
$gameVariables.setValue(varId, 3);
}
varId++;
}
} else {
var battleActorId = $gameTemp.lastJoinBattleActorId;
var actor = $slg.formation().findBattleActor(battleActorId);
if (!actor) {
return;
}
var varId = 78;
if (actor.element() == MonsterElement.flame) {
$gameVariables.setValue(varId, 2);
}
if (actor.element() == MonsterElement.water) {
$gameVariables.setValue(varId, 1);
}
if (actor.element() == MonsterElement.wood) {
$gameVariables.setValue(varId, 3);
}
}
});
PluginManager.registerCommand(
pluginName,
"showGachaResultList",
function (args) {
var list = $gameTemp.lastJoinBattleActorIdList;
var newList = $gameTemp.lastJoinBattleActorNewList;
SceneManager._scene.showGachaResultList(list, newList);
}
);
PluginManager.registerCommand(pluginName, "showGachaResult", function (args) {
var battleActorId = parseInt(args.battleActorId);
var isNew = false;
if (isNaN(battleActorId) || battleActorId <= 0) {
battleActorId = $gameTemp.lastJoinBattleActorId;
isNew = $gameTemp.lastJoinBattleActorNew;
}
SceneManager._scene.showGachaResult(battleActorId, isNew);
});
PluginManager.registerCommand(
pluginName,
"showGachaResultCharacter",
function (args) {
var battleActorId = $gameTemp.lastJoinBattleActorId;
var actor = $slg.formation().findBattleActor(battleActorId);
if (!actor) {
console.error(battleActorId + "のキャラが存在しません");
return;
}
$gameVariables.setValue(KAIJIN_ACTOR_ID_VAR, actor.actorId());
}
);
PluginManager.registerCommand(pluginName, "hideGachaResult", function (args) {
SceneManager._scene.hideGachaResult();
});
PluginManager.registerCommand(pluginName, "joinActor", function (args) {
var actorId = parseInt(args.actorId);
var level = parseInt(args.level);
var battleActorId = $slg.formation().addMember(actorId, level);
$gameTemp.lastJoinBattleActorId = battleActorId;
});
PluginManager.registerCommand(pluginName, "showGachaRate", function (args) {
var rareList = new Gacha().rareRate();
SceneManager._scene.showGachaRate(rareList);
});
PluginManager.registerCommand(pluginName, "hideGachaRate", function (args) {
SceneManager._scene.hideGachaRate();
});
PluginManager.registerCommand(pluginName, "getGachaTicket", function (args) {
$gameSwitches.setValue(339, false);
$gameSwitches.setValue(353, false);
var actorId = $slg.formation().selectRandomMonster();
p("ガチャチケ獲得:" + $gameActors.actor(actorId).name());
var t = new GachaTicket(actorId);
$gameParty.addGachaTicket(t);
});
PluginManager.registerCommand(
pluginName,
"showMonsterBonus",
function (args) {
var types = [
FriendshipBonusType.atkFlame,
FriendshipBonusType.atkWater,
FriendshipBonusType.atkWood,
FriendshipBonusType.hpFlame,
FriendshipBonusType.hpWater,
FriendshipBonusType.hpWood,
];
for (var _i = 0, types_1 = types; _i < types_1.length; _i++) {
var type = types_1[_i];
var bonus = $gameParty.friendshipBonus(type);
if (bonus) {
$gameSwitches.setValue(20, true);
SceneManager._scene.showMonsterBonus();
return;
}
}
}
);
PluginManager.registerCommand(
pluginName,
"hideMonsterBonus",
function (args) {
SceneManager._scene.hideMonsterBonus();
}
);
var Sprite_GachaResult = /** @class */ (function (_super) {
__extends(Sprite_GachaResult, _super);
function Sprite_GachaResult(actor, isNew) {
var _this = _super.call(this) || this;
_this.x = Graphics.width / 2 - 100;
_this.y = 236;
var back = _this.getSprite(0, 0, 240, 230);
back.y = 160;
_this.addChild(back);
var contents = new Sprite_GachaResultContents(actor);
_this.addChild(contents);
if (isNew) {
var x = 0;
switch (actor.rare()) {
case MonsterRare.rare:
x = 60;
break;
case MonsterRare.sr:
x = 120;
break;
case MonsterRare.ssr:
x = 180;
break;
}
var newSprite = _this.getSprite(x, 230, 60, 30);
newSprite.x = 79;
newSprite.y = 0;
_this.addChild(newSprite);
}
return _this;
}
Sprite_GachaResult.prototype.getSprite = function (x, y, w, h) {
var baseTexture = Nore.getSystemBaseTexture("gacha");
var r = new Rectangle(x, y, w, h);
var texture = new PIXI.Texture(baseTexture, r);
var s = new PIXI.Sprite(texture);
return s;
};
return Sprite_GachaResult;
})(Sprite);
Nore.Sprite_GachaResult = Sprite_GachaResult;
var Sprite_GachaResultContents = /** @class */ (function (_super) {
__extends(Sprite_GachaResultContents, _super);
function Sprite_GachaResultContents(actor) {
var _this = _super.call(this) || this;
_this.bitmap = new Bitmap(300, 400);
_this._actor = actor;
_this.refresh();
return _this;
}
Sprite_GachaResultContents.prototype.refresh = function () {
this.bitmap.clear();
this.bitmap.outlineWidth = 5;
var yy = 170;
this.bitmap.textColor = ColorManager.normalColor();
//this.bitmap.fillRect(0, yy, 200, 270, '#00000088');
var actor = this._actor;
this.bitmap.fontSize = 18;
var frameX = 13;
var frameY = 13;
if (actor.rare() > 0) {
var sprite = getFrameSprite(actor.rare(), actor.element());
sprite.x = 50 + frameX;
sprite.y = 16 + frameY;
this.addChild(sprite);
}
this.drawRare(actor, yy);
//this.bitmap.drawText(this.rareText(actor.rare()), 10, 0 + yy, 200, 40, 'left');
this.bitmap.drawText(actor.name(), 50, yy - 4, 160, 40, "center");
this.drawParam(0, "HP", this._actor.mhp(), yy);
this.drawParam(1, "ATK", this._actor.atk(), yy);
this.drawParam(2, TextManager.interval, this._actor.agi(), yy);
this.drawSkill(actor.learnings(), yy);
var u = new BattleUnitDir2(actor, false);
var s = new Sprite_SlotUnit(u, new Rectangle(82, 100, 100, 100));
this.addChild(s);
};
Sprite_GachaResultContents.prototype.drawRare = function (actor, y) {
var x = 30;
if (actor.rare() == MonsterRare.sr) {
x -= 10;
}
if (actor.rare() == MonsterRare.ssr) {
x -= 12;
}
this.drawIcon(this.rareIcon(actor.rare()), x, y);
};
Sprite_GachaResultContents.prototype.drawParam = function (
index,
title,
param,
yyy
) {
var xx = 20;
var yy = 40 + index * 33 + yyy;
this.bitmap.fontSize = 22;
// this.bitmap.drawText(title, xx, yy, 100, 30);
this.bitmap.drawText(param + "", xx, yy, 150, 30, "right");
};
Sprite_GachaResultContents.prototype.rareIcon = function (rare) {
switch (rare) {
case MonsterRare.common:
return Icon.n;
case MonsterRare.rare:
return Icon.r;
case MonsterRare.sr:
return Icon.sr;
case MonsterRare.ssr:
return Icon.ssr;
}
};
Sprite_GachaResultContents.prototype.drawSkill = function (learnings, yyy) {
if (learnings.length == 0) {
return;
}
var learning = learnings[0];
var skill = $dataSkills[learning.skillId];
var xx = 30;
this.bitmap.fontSize = 18;
this.bitmap.textColor = ColorManager.normalColor();
this.bitmap.drawText(
this.skillName(skill),
xx,
135 + yyy + 46,
140,
30,
"right"
);
};
Sprite_GachaResultContents.prototype.skillName = function (skill) {
if (ConfigManager.language == "en") {
if (skill.meta["nameEn"]) {
return skill.meta["nameEn"];
}
}
return skill.name;
};
return Sprite_GachaResultContents;
})(Sprite);
Nore.Sprite_GachaResultContents = Sprite_GachaResultContents;
var Sprite_GachaResult5Ren = /** @class */ (function (_super) {
__extends(Sprite_GachaResult5Ren, _super);
function Sprite_GachaResult5Ren(actor, isNew, index) {
var _this = _super.call(this) || this;
var point = _this.positionByIndex(index);
_this.x = point.x;
_this.y = point.y;
_this.bitmap = new Bitmap(300, 300);
_this._actor = actor;
_this._isNew = isNew;
_this.refresh();
return _this;
}
Sprite_GachaResult5Ren.prototype.positionByIndex = function (index) {
switch (index) {
case 0:
return new Point(Graphics.width / 2 - 100 - 200, 236);
case 1:
return new Point(Graphics.width / 2 - 100 - 100, 286);
case 2:
return new Point(Graphics.width / 2 - 100, 236);
case 3:
return new Point(Graphics.width / 2 - 100 + 100, 286);
case 4:
return new Point(Graphics.width / 2 - 100 + 200, 236);
}
return new Point(0, 0);
};
Sprite_GachaResult5Ren.prototype.refresh = function () {
this.bitmap.clear();
var actor = this._actor;
if (this._isNew) {
this.drawNew(actor.rare());
}
this.bitmap.fontSize = 20;
var frameX = 13;
var frameY = 13;
if (actor.rare() > 0) {
var sprite = getFrameSprite(actor.rare(), actor.element());
sprite.x = 50 + frameX;
sprite.y = 16 + frameY;
this.addChild(sprite);
}
var u = new BattleUnitDir2(actor, false);
var s = new Sprite_SlotUnit(u, new Rectangle(82, 100, 100, 100));
this.addChild(s);
};
Sprite_GachaResult5Ren.prototype.drawNew = function (rare) {
var x = 0;
switch (rare) {
case MonsterRare.rare:
x = 60;
break;
case MonsterRare.sr:
x = 120;
break;
case MonsterRare.ssr:
x = 180;
break;
}
var newSprite = this.getSprite(x, 230, 60, 30);
newSprite.x = 79;
newSprite.y = 0;
this.addChild(newSprite);
};
Sprite_GachaResult5Ren.prototype.getSprite = function (x, y, w, h) {
var baseTexture = Nore.getSystemBaseTexture("gacha");
var r = new Rectangle(x, y, w, h);
var texture = new PIXI.Texture(baseTexture, r);
var s = new PIXI.Sprite(texture);
return s;
};
return Sprite_GachaResult5Ren;
})(Sprite);
Nore.Sprite_GachaResult5Ren = Sprite_GachaResult5Ren;
var Sprite_GachaRate = /** @class */ (function (_super) {
__extends(Sprite_GachaRate, _super);
function Sprite_GachaRate(rate) {
var _this = _super.call(this) || this;
_this.x = Graphics.width / 2 + 66 + $gameVariables.value(9);
_this.y = 256;
var back = _this.getSprite(238, 0, 205, 200);
_this.addChild(back);
var y = 200;
if (ConfigManager.language == "en") {
y += 30;
}
var text = _this.getSprite(238, y, 200, 30);
text.y = 8;
_this.addChild(text);
_this._contents = new Sprite_GachaRateContents(rate);
_this.addChild(_this._contents);
return _this;
}
Sprite_GachaRate.prototype.getSprite = function (x, y, w, h) {
var baseTexture = Nore.getSystemBaseTexture("gacha");
var r = new Rectangle(x, y, w, h);
var texture = new PIXI.Texture(baseTexture, r);
var s = new PIXI.Sprite(texture);
return s;
};
return Sprite_GachaRate;
})(Sprite);
Nore.Sprite_GachaRate = Sprite_GachaRate;
var Sprite_GachaRateContents = /** @class */ (function (_super) {
__extends(Sprite_GachaRateContents, _super);
function Sprite_GachaRateContents(rate) {
var _this = _super.call(this) || this;
_this.bitmap = new Bitmap(200, 200);
_this._rateList = rate;
_this.refresh();
return _this;
}
Sprite_GachaRateContents.prototype.refresh = function () {
this.bitmap.clear();
this.bitmap.fontSize = 22;
this.bitmap.outlineWidth = 5;
//this.bitmap.fillRect(0, yy, 196, 180, '#00000088');
var yy = 46;
var xx = 20;
for (var i = 0; i < this._rateList.length; i++) {
var text = this.rareText(i + 1);
var rate = this._rateList[i];
//this.bitmap.drawText(text, xx, yy, 100, 30);
this.bitmap.drawText(rate + "%", xx, yy, 140, 30, "right");
yy += 34;
}
};
Sprite_GachaRateContents.prototype.rareText = function (rare) {
switch (rare) {
case MonsterRare.common:
return "N";
case MonsterRare.rare:
return "R";
case MonsterRare.sr:
return "SR";
case MonsterRare.ssr:
return "SSR";
}
};
return Sprite_GachaRateContents;
})(Sprite);
Nore.Sprite_GachaRateContents = Sprite_GachaRateContents;
var BomusItem = /** @class */ (function () {
function BomusItem(_type, _value) {
this._type = _type;
this._value = _value;
}
BomusItem.prototype.type = function () {
return this._type;
};
BomusItem.prototype.value = function () {
return this._value;
};
return BomusItem;
})();
var Sprite_MonsterBonus = /** @class */ (function (_super) {
__extends(Sprite_MonsterBonus, _super);
function Sprite_MonsterBonus(h) {
var _this = this;
var r = new Rectangle(300, 200, 360, 100);
_this = _super.call(this, r) || this;
_this.makeItems();
_this.height = _this._items.length * _this.itemHeight() + 24;
_this.createContents();
_this.refresh();
return _this;
}
Sprite_MonsterBonus.prototype.makeItems = function () {
this._items = [];
var types = [
FriendshipBonusType.atkFlame,
FriendshipBonusType.atkWater,
FriendshipBonusType.atkWood,
FriendshipBonusType.hpFlame,
FriendshipBonusType.hpWater,
FriendshipBonusType.hpWood,
];
for (var _i = 0, types_2 = types; _i < types_2.length; _i++) {
var type = types_2[_i];
var bonus =
$gameParty.friendshipBonus(type) *
$gameParty.friendshipBonusRate(type);
if (bonus) {
this._items.push(new BomusItem(type, bonus));
}
}
};
Sprite_MonsterBonus.prototype.maxItems = function () {
if (this._items) {
return this._items.length;
}
return 0;
};
Sprite_MonsterBonus.prototype.maxCols = function () {
return 1;
};
Sprite_MonsterBonus.prototype.resetFontSettings = function () {
_super.prototype.resetFontSettings.call(this);
this.contents.fontSize = 24;
};
Sprite_MonsterBonus.prototype.drawItem = function (index) {
var item = this._items[index];
var rect = this.itemRect(index);
var text = this.makeBonusLabel(item.type());
this.drawTextEx(text, rect.x, rect.y, rect.width);
this.drawText(
"+ " + item.value(),
rect.x,
rect.y,
rect.width - 20,
"right"
);
};
Sprite_MonsterBonus.prototype.makeBonusLabel = function (type) {
switch (type) {
case FriendshipBonusType.atkFlame:
return TextManager.atkFlame2;
case FriendshipBonusType.atkWater:
return TextManager.atkWater2;
case FriendshipBonusType.atkWood:
return TextManager.atkWood2;
case FriendshipBonusType.hpFlame:
return TextManager.hpFlame2;
case FriendshipBonusType.hpWater:
return TextManager.hpWater2;
case FriendshipBonusType.hpWood:
return TextManager.hpWood2;
}
};
Sprite_MonsterBonus.prototype.itemHeight = function () {
return 40;
};
return Sprite_MonsterBonus;
})(Window_Selectable);
Nore.Sprite_MonsterBonus = Sprite_MonsterBonus;
})(Nore || (Nore = {}));
var Gacha = /** @class */ (function () {
function Gacha() {}
Gacha.prototype.decideRare = function () {
var rareRate = this.rareRate();
var dice = Math.randomInt(100);
var remain = dice;
for (var rare = 0; rare < rareRate.length; rare++) {
var value = rareRate[rare];
if (remain <= value) {
return rare + 1;
}
remain -= value;
}
console.error("不正なレア度です:" + dice);
console.error(rareRate);
return MonsterRare.common;
};
Gacha.prototype.rareRate = function () {
if ($gameSwitches.value(339)) {
// SRボーナスガチャ
return [0, 0, 100, 0];
}
if ($gameSwitches.value(353)) {
// SSRボーナスガチャ
return [0, 0, 0, 100];
}
if ($slg.facilityInfo().hasFacility(77)) {
// 研究所LV5
return [23, 31, 28, 18];
}
if ($slg.facilityInfo().hasFacility(74)) {
// 研究所LV4
return [34, 33, 23, 10];
}
if ($slg.facilityInfo().hasFacility(73)) {
// 研究所LV3
return [42, 33, 20, 5];
}
if ($slg.facilityInfo().hasFacility(72)) {
// 研究所LV2
return [55, 35, 10, 0];
}
if ($slg.facilityInfo().hasFacility(71)) {
// 研究所LV1
return [64, 33, 3, 0];
}
return [80, 20, 0, 0];
};
return Gacha;
})();
function isKaijinEvent(event) {
if (!event) {
return false;
}
if (!event.event()) {
return false;
}
return event.event().meta["kaijin"] != null;
}
var Sprite_Kaijin = /** @class */ (function (_super) {
__extends(Sprite_Kaijin, _super);
function Sprite_Kaijin(event) {
return _super.call(this, event) || this;
}
Sprite_Kaijin.prototype.updateBitmap = function () {
if (this.isImageChanged()) {
this._tilesetId = $gameMap.tilesetId();
this._tileId = this._character.tileId();
this._characterName = this.characterName();
this._characterIndex = this.characterIndex();
if (this._tileId > 0) {
this.setTileBitmap();
} else {
this.setCharacterBitmap();
}
}
};
Sprite_Kaijin.prototype.characterName = function () {
var id = $gameVariables.value(KAIJIN_ACTOR_ID_VAR);
if (id <= 0) {
return "";
}
var actor = $gameActors.actor(id);
return actor.characterName();
};
Sprite_Kaijin.prototype.characterIndex = function () {
var id = $gameVariables.value(KAIJIN_ACTOR_ID_VAR);
if (id <= 0) {
return 0;
}
var actor = $gameActors.actor(id);
return actor.characterIndex();
};
Sprite_Kaijin.prototype.isImageChanged = function () {
return (
this._characterName !== this.characterName() ||
this._characterIndex !== this.characterIndex()
);
};
Sprite_Kaijin.prototype.characterBlockX = function () {
if (this._isBigCharacter) {
return 0;
} else {
var index = this.characterIndex();
return (index % 4) * 3;
}
};
Sprite_Kaijin.prototype.characterBlockY = function () {
var index = this.characterIndex();
return Math.floor(index / 4) * 4;
};
Sprite_Kaijin.prototype.characterPatternX = function () {
return 1;
};
return Sprite_Kaijin;
})(Sprite_Character);