// DarkPlasma_NotifyWishList 1.0.0 // Copyright (c) 2025 DarkPlasma // This software is released under the MIT license. // http://opensource.org/licenses/mit-license.php /** * 2025/02/23 1.0.0 公開 */ /*: * @plugindesc ウィッシュリスト通知 * @author DarkPlasma * @license MIT * * @target MZ * @url https://github.com/elleonard/DarkPlasma-MZ-Plugins/tree/release * * @base DarkPlasma_StoreWishList * @base TorigoyaMZ_NotifyMessage * @orderAfter DarkPlasma_StoreWishList * @orderAfter TorigoyaMZ_NotifyMessage * * @param message * @desc 通知する文章を設定します。{item}が成果物アイテムの名前に置換されます。 * @text 通知文 * @type string * @default {item}の素材が揃いました。 * * @help * version: 1.0.0 * ウィッシュリストに登録したアイテムの * 素材が揃ったタイミングで通知を出します。 * * 最近通知されたアイテムには通知を出しません。 * 最近通知されたアイテムからは、以下の条件で除外されます。 * - セーブデータをロードする * - そのアイテムがウィッシュリストから外れる * * 本プラグインの利用には下記プラグインを必要とします。 * DarkPlasma_StoreWishList version:1.0.0 * TorigoyaMZ_NotifyMessage version:1.6.1 * 下記プラグインと共に利用する場合、それよりも下に追加してください。 * DarkPlasma_StoreWishList * TorigoyaMZ_NotifyMessage */ (() => { 'use strict'; function isSameKindItem(data1, data2) { return ( (DataManager.isItem(data1) && DataManager.isItem(data2)) || (DataManager.isWeapon(data1) && DataManager.isWeapon(data2)) || (DataManager.isArmor(data1) && DataManager.isArmor(data2)) ); } const pluginName = document.currentScript.src.replace(/^.*\/(.*).js$/, function () { return arguments[1]; }); const pluginParametersOf = (pluginName) => PluginManager.parameters(pluginName); const pluginParameters = pluginParametersOf(pluginName); const settings = { message: String(pluginParameters.message || `{item}の素材が揃いました。`), }; function Game_Temp_NotifyWishListMixIn(gameTemp) { gameTemp.clearRecentNotifiedWishListItems = function () { this._recentNotifiedWishListItems = []; }; gameTemp.pushRecentNotifiedWishListItem = function (item) { if (!this._recentNotifiedWishListItems) { this._recentNotifiedWishListItems = []; } this._recentNotifiedWishListItems.push(item); }; gameTemp.removeRecentNotifiedWishListItem = function (item) { if (!this._recentNotifiedWishListItems) { this._recentNotifiedWishListItems = []; } this._recentNotifiedWishListItems = this._recentNotifiedWishListItems.filter( (i) => i.id !== item.id || !isSameKindItem(i, item), ); }; gameTemp.isRecentNotifiedWishListItem = function (item) { if (!this._recentNotifiedWishListItems) { this._recentNotifiedWishListItems = []; } return this._recentNotifiedWishListItems.some((i) => i.id === item.id && isSameKindItem(i, item)); }; gameTemp.reservedWishListNotifyItems = function () { if (!this._reservedWishListNotifyItems) { this._reservedWishListNotifyItems = []; } return this._reservedWishListNotifyItems; }; gameTemp.reserveWishListNotification = function (notifyItem) { this.reservedWishListNotifyItems().push(notifyItem); }; gameTemp.shiftReservedWishListNotification = function () { return this.reservedWishListNotifyItems().shift(); }; } Game_Temp_NotifyWishListMixIn(Game_Temp.prototype); function Game_WishList_NotifyMixIn(gameWishList) { gameWishList.mustNotifyCompletion = function (data) { const result = this.toItemWeaponArmorId(data); const wishListItem = this.items.find( (item) => item.result.dataId === result.dataId && item.result.kind === result.kind, ); if (!wishListItem) { return false; } return !$gameTemp.isRecentNotifiedWishListItem(data) && this.isMaterialCompleted(data); }; gameWishList.notifyCompletionByGainMaterial = function (material) { const targets = this.itemsHaveMaterial(material); targets .filter((target) => this.mustNotifyCompletion(DataManager.dataObject(target.result.kind, target.result.dataId))) .forEach((target) => { const data = DataManager.dataObject(target.result.kind, target.result.dataId); if (data) { $gameTemp.reserveWishListNotification( new Torigoya.NotifyMessage.NotifyItem({ message: settings.message.replaceAll('{item}', `${data.name}`), icon: data.iconIndex, }), ); $gameTemp.pushRecentNotifiedWishListItem(data); } }); }; const _delete = gameWishList.delete; gameWishList.delete = function (item) { _delete.call(this, item); $gameTemp.removeRecentNotifiedWishListItem(item); }; } Game_WishList_NotifyMixIn(Game_WishList.prototype); function Game_Party_NotifyWishListMixIn(gameParty) { const _gainItem = gameParty.gainItem; gameParty.gainItem = function (item, amount, includeEquip) { _gainItem.call(this, item, amount, includeEquip); if (item && amount > 0) { /** * そのアイテムを素材とする成果物の素材が揃っていれば通知する */ this.wishList().notifyCompletionByGainMaterial(item); } }; } Game_Party_NotifyWishListMixIn(Game_Party.prototype); function Scene_NotifyWishListMixIn(sceneClass) { sceneClass.notifyWishListItem = function () { const notifyItem = $gameTemp.shiftReservedWishListNotification(); if (notifyItem) { Torigoya.NotifyMessage.Manager.notify(notifyItem); } }; sceneClass.canNotifyWishListItem = function () { return false; }; const _update = sceneClass.update; sceneClass.update = function () { _update.call(this); if (this.canNotifyWishListItem()) { this.notifyWishListItem(); } }; } Scene_NotifyWishListMixIn(Scene_Base.prototype); function Scene_CanNotifyWishListMixIn(sceneClass) { sceneClass.canNotifyWishListItem = function () { return this._fadeDuration <= 0; }; } Scene_CanNotifyWishListMixIn(Scene_Map.prototype); Torigoya.NotifyMessage.parameter.advancedAppendScenes .filter((scene) => scene in globalThis) .forEach((scene) => Scene_CanNotifyWishListMixIn(window[scene].prototype)); })();