Skip to content

Commit

Permalink
1.2.0 復元による装備可能判定のインターフェース追加
Browse files Browse the repository at this point in the history
  • Loading branch information
elleonard committed Jul 7, 2023
1 parent 0166b81 commit fd07acb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/codes/SaveEquipSet/DarkPlasma_SaveEquipSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Game_EquipSlot {
* @param {number} slotId
* @param {MZ.Weapon | MZ.Armor} item
*/
constructor(slotId: number, item: MZ.Weapon|MZ.Armor) {
constructor(slotId: number, item: MZ.Weapon|MZ.Armor|null) {
this._slotId = slotId;
this.initIdAndKind(item);
}
Expand Down Expand Up @@ -99,7 +99,7 @@ class Game_EquipSlot {
}
}

initIdAndKind(item: MZ.Weapon|MZ.Armor) {
initIdAndKind(item: MZ.Weapon|MZ.Armor|null) {
this._itemId = item ? item.id : null;
this._kind = item
? (() => {
Expand Down Expand Up @@ -136,6 +136,14 @@ function Game_Actor_SaveEquipSetMixIn(gameActor: Game_Actor) {
return this._equipSets;
};

gameActor.canEquipByLoad = function (equipSlot) {
return !equipSlot.item ||
$gameParty.hasItem(equipSlot.item) &&
this.canEquip(equipSlot.item) &&
this.isEquipChangeOk(equipSlot.slotId);
};


gameActor.equipSetAt = function (index) {
return this.equipSets()[index];
};
Expand All @@ -158,13 +166,7 @@ function Game_Actor_SaveEquipSetMixIn(gameActor: Game_Actor) {
const equipSet = this.equipSetAt(index);
if (settings.equipSetCount > index && equipSet) {
equipSet
.filter(
(equipSlot: Game_EquipSlot) =>
!equipSlot.item ||
$gameParty.hasItem(equipSlot.item) &&
this.canEquip(equipSlot.item) &&
this.isEquipChangeOk(equipSlot.slotId)
)
.filter((equipSlot: Game_EquipSlot) => this.canEquipByLoad(equipSlot))
.forEach((equipSlot: Game_EquipSlot) => this.changeEquip(equipSlot.slotId, equipSlot.item));
}
};
Expand Down
1 change: 1 addition & 0 deletions src/codes/SaveEquipSet/SaveEquipSet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ declare interface Game_Actor {
_equipSet?: Game_EquipSlot[];
_equipSets: Game_EquipSlot[][];

canEquipByLoad(equipSlot: Game_EquipSlot): boolean;
equipSets(): Game_EquipSlot[][];
equipSetAt(index: number): Game_EquipSlot[];
saveEquipSet(): void;
Expand Down
3 changes: 3 additions & 0 deletions src/codes/SaveEquipSet/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ DarkPlasma_SaveEquipSet:
year: 2022
license: MIT
histories:
- date: 2023/07/07
version: 1.2.0
description: '復元による装備可能判定のインターフェース追加'
- date: 2022/11/13
version: 1.1.2
description: 'typescript移行'
Expand Down

0 comments on commit fd07acb

Please sign in to comment.