Skip to content

Commit

Permalink
1.7.0 可能な限り預ける, 可能な限り引き出すプラグインコマンドの追加
Browse files Browse the repository at this point in the history
  • Loading branch information
elleonard committed Apr 13, 2024
1 parent e2fdc7e commit 9f55999
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 1 deletion.
52 changes: 51 additions & 1 deletion src/codes/ItemStorage/DarkPlasma_ItemStorage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { orderIdSort } from '../../common/orderIdSort';
import { pluginName } from '../../common/pluginName';
import { command_openStorage, parseArgs_openStorage } from './_build/DarkPlasma_ItemStorage_commands';
import { command_fetchAll, command_openStorage, command_storeAll, parseArgs_fetchAll, parseArgs_openStorage, parseArgs_storeAll } from './_build/DarkPlasma_ItemStorage_commands';
import { settings } from './_build/DarkPlasma_ItemStorage_parameters';

PluginManager.registerCommand(pluginName, command_openStorage, function (args) {
Expand All @@ -14,6 +14,42 @@ PluginManager.registerCommand(pluginName, command_openStorage, function (args) {
SceneManager.push(Scene_ItemStorage);
});

PluginManager.registerCommand(pluginName, command_storeAll, function (args) {
const parsedArgs = parseArgs_storeAll(args);
const targets: (MZ.Item|MZ.Weapon|MZ.Armor)[] = [];
if (parsedArgs.item) {
targets.push(...$gameParty.items().filter(item => item.itypeId === 1));
}
if (parsedArgs.weapon) {
targets.push(...$gameParty.weapons());
}
if (parsedArgs.armor) {
targets.push(...$gameParty.armors());
}
if (parsedArgs.keyItem) {
targets.push(...$gameParty.items().filter(item => item.itypeId === 2));
}
$gameParty.storeAllOfItemsToStorage(targets);
});

PluginManager.registerCommand(pluginName, command_fetchAll, function (args) {
const parsedArgs = parseArgs_fetchAll(args);
const targets: (MZ.Item|MZ.Weapon|MZ.Armor)[] = [];
if (parsedArgs.item) {
targets.push(...$gameParty.storageItems().items().filter(item => item.itypeId === 1));
}
if (parsedArgs.weapon) {
targets.push(...$gameParty.storageItems().weapons());
}
if (parsedArgs.armor) {
targets.push(...$gameParty.storageItems().armors());
}
if (parsedArgs.keyItem) {
targets.push(...$gameParty.items().filter(item => item.itypeId === 2));
}
$gameParty.fetchAllOfItemsFromStorage(targets);
});

class StorageCategories {
_item: boolean;
_weapon: boolean;
Expand Down Expand Up @@ -195,6 +231,13 @@ function Game_Party_ItemStorageMixIn(gameParty: Game_Party) {
this.loseItem(item, amount, false);
};

gameParty.storeAllOfItemsToStorage = function (items) {
items.forEach(item => this.storeItemToStorage(
item,
Math.min(this.numItems(item), this.storageItems().maxItems() - this.storageItems().numItems(item)))
);
};

/**
* 倉庫からアイテムを引き出す
* @param {MZ.Item | MZ.Weapon | MZ.Armor} item
Expand All @@ -205,6 +248,13 @@ function Game_Party_ItemStorageMixIn(gameParty: Game_Party) {
this.storageItems().fetchItem(item, amount);
};

gameParty.fetchAllOfItemsFromStorage = function (items) {
items.forEach(item => this.fetchItemFromStorage(
item,
Math.min(this.storageItems().numItems(item), this.maxItems(item) - this.numItems(item))
));
};

gameParty.canStoreItemInStorage = function (item) {
return this.storageItems().canStoreItem(item);
};
Expand Down
4 changes: 4 additions & 0 deletions src/codes/ItemStorage/ItemStorage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ declare interface StorageCategories {

declare interface Game_StorageItems {
items(): MZ.Item[];
weapons(): MZ.Weapon[];
armors(): MZ.Armor[];

storeItem(item: MZ.Item|MZ.Weapon|MZ.Armor, amount: number): void;
fetchItem(item: MZ.Item|MZ.Weapon|MZ.Armor, amount: number): void;
Expand All @@ -28,7 +30,9 @@ declare interface Game_Party {
initStorageItems(): void;
storageItems(): Game_StorageItems;
storeItemToStorage(item: MZ.Item|MZ.Weapon|MZ.Armor, amount: number): void;
storeAllOfItemsToStorage(items: (MZ.Item|MZ.Weapon|MZ.Armor)[]): void;
fetchItemFromStorage(item: MZ.Item|MZ.Weapon|MZ.Armor, amount: number): void;
fetchAllOfItemsFromStorage(items: (MZ.Item|MZ.Weapon|MZ.Armor)[]): void;
canStoreItemInStorage(item: MZ.Item|MZ.Weapon|MZ.Armor): boolean;
}

Expand Down
47 changes: 47 additions & 0 deletions src/codes/ItemStorage/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ DarkPlasma_ItemStorage:
year: 2022
license: MIT
histories:
- date: 2024/04/13
version: 1.7.0
description: '可能な限り預ける, 可能な限り引き出すプラグインコマンドの追加'
- date: 2023/12/17
version: 1.6.1
description: '倉庫に預けられる判定を整理'
Expand Down Expand Up @@ -93,6 +96,50 @@ DarkPlasma_ItemStorage:
ja: カテゴリに大事なものを表示するか
type: boolean
default: false
- command: storeAll
text:
ja: 可能な限り預ける
desc:
ja: 所持しているアイテムを可能な限り倉庫に預けます。
args:
- arg: item
text:
ja: アイテムを預ける
type: boolean
- arg: weapon
text:
ja: 武器を預ける
type: boolean
- arg: armor
text:
ja: 防具を預ける
type: boolean
- arg: keyItem
text:
ja: 大事なものを預ける
type: boolean
- command: fetchAll
text:
ja: 可能な限り引き出す
desc:
ja: 倉庫に入っているアイテムを可能な限り引き出します。
args:
- arg: item
text:
ja: アイテムを引き出す
type: boolean
- arg: weapon
text:
ja: 武器を引き出す
type: boolean
- arg: armor
text:
ja: 防具を引き出す
type: boolean
- arg: keyItem
text:
ja: 大事なものを引き出す
type: boolean
structures:
dependencies:
base: []
Expand Down

0 comments on commit 9f55999

Please sign in to comment.