From 7a901da8a7287c7ddf8f917b8e1f2749a9c6712c Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 31 Jan 2023 18:48:36 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=83=9E=E3=82=A4=E3=83=B3=E3=82=B9?= =?UTF-8?q?=E3=82=BF=E3=83=83=E3=82=AF=E3=81=8B=E3=82=89=E5=8F=96=E3=82=8A?= =?UTF-8?q?=E5=87=BA=E3=81=97=E3=81=9FGT=E7=AD=89=E3=81=AE=E5=90=8D?= =?UTF-8?q?=E7=BE=A9=E5=93=81=E3=82=A2=E3=82=A4=E3=83=86=E3=83=A0=E3=81=AB?= =?UTF-8?q?=E5=90=8D=E7=BE=A9=E3=81=8C=E3=81=AA=E3=81=84=E4=B8=8D=E5=85=B7?= =?UTF-8?q?=E5=90=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listener/BlockLineUpTriggerListener.scala | 5 ++++- .../listener/TilingSkillTriggerListener.scala | 2 +- .../subsystems/gachaprize/GachaPrizeAPI.scala | 5 +++-- .../subsystems/gachaprize/System.scala | 19 ++++++++----------- .../bukkit/BukkitMineStackObjectList.scala | 4 ++-- .../bukkit/BukkitMineStackRepository.scala | 2 +- .../minestackobject/MineStackObject.scala | 2 +- .../minestackobject/MineStackObjectList.scala | 3 ++- 8 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/main/scala/com/github/unchama/buildassist/listener/BlockLineUpTriggerListener.scala b/src/main/scala/com/github/unchama/buildassist/listener/BlockLineUpTriggerListener.scala index c021903c20..6ecd1281c6 100644 --- a/src/main/scala/com/github/unchama/buildassist/listener/BlockLineUpTriggerListener.scala +++ b/src/main/scala/com/github/unchama/buildassist/listener/BlockLineUpTriggerListener.scala @@ -101,7 +101,10 @@ class BlockLineUpTriggerListener[ val mineStackObjectToBeUsed = if (buildAssistData.line_up_minestack_flg == 1) { - mineStackAPI.mineStackObjectList.findByItemStack(mainHandItem, player).unsafeRunSync() + mineStackAPI + .mineStackObjectList + .findBySignedItemStack(mainHandItem, player) + .unsafeRunSync() } else None val maxBlockUsage = { diff --git a/src/main/scala/com/github/unchama/buildassist/listener/TilingSkillTriggerListener.scala b/src/main/scala/com/github/unchama/buildassist/listener/TilingSkillTriggerListener.scala index 2f98266097..c9ac328763 100644 --- a/src/main/scala/com/github/unchama/buildassist/listener/TilingSkillTriggerListener.scala +++ b/src/main/scala/com/github/unchama/buildassist/listener/TilingSkillTriggerListener.scala @@ -71,7 +71,7 @@ class TilingSkillTriggerListener[G[_]: ConcurrentEffect, F[ val minestackObjectToUse = mineStackAPI .mineStackObjectList - .findByItemStack(offHandItem, player) + .findBySignedItemStack(offHandItem, player) .toIO .unsafeRunSync() .filter(_ => buildAssistPlayerData.zs_minestack_flag) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/GachaPrizeAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/GachaPrizeAPI.scala index 3c5060edeb..7c23423c1d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/GachaPrizeAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/GachaPrizeAPI.scala @@ -105,9 +105,10 @@ trait GachaPrizeReadAPI[F[_], ItemStack] { def staticGachaPrizeFactory: StaticGachaPrizeFactory[ItemStack] /** + * @param itemStack 記名されている[[ItemStack]] * @return 通常排出ガチャ景品の中から`name`が記名された`itemStack`に一致する[[GachaPrize]]を取得する作用 */ - def findOfRegularPrizesByItemStack( + def findOfRegularPrizesBySignedItemStack( itemStack: ItemStack, name: String ): F[Option[GachaPrize[ItemStack]]] @@ -116,7 +117,7 @@ trait GachaPrizeReadAPI[F[_], ItemStack] { * @param itemStack 記名されていない[[ItemStack]] * @return 通常排出ガチャ景品の中から、記名されてない`itemStack`に一致する[[GachaPrize]]を取得する作用 */ - def findOfRegularGachaPrizesByUnSignedItemStack( + def findOfRegularGachaPrizesByNotSignedItemStack( itemStack: ItemStack ): F[Option[GachaPrize[ItemStack]]] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala index 13d3e53bf9..163077308f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala @@ -146,24 +146,21 @@ object System { override def canBeSignedAsGachaPrize: CanBeSignedAsGachaPrize[ItemStack] = _canBeSignedAsGachaPrize - override def findOfRegularPrizesByItemStack( - itemStack: ItemStack, // 記名されていないitemStack + override def findOfRegularPrizesBySignedItemStack( + itemStack: ItemStack, name: String ): F[Option[GachaPrize[ItemStack]]] = for { prizes <- allGachaPrizesListReference.get defaultGachaPrizes = prizes.filter(_.gachaEventName.isEmpty) - } yield { - defaultGachaPrizes.find { gachaPrize => - if (gachaPrize.signOwner) { - val signedItemStack = canBeSignedAsGachaPrize - gachaPrize.materializeWithOwnerSignature(name).isSimilar() - } else { - gachaPrize.itemStack.isSimilar(itemStack) - } + } yield defaultGachaPrizes.find { gachaPrize => + if (gachaPrize.signOwner) { + gachaPrize.materializeWithOwnerSignature(name).isSimilar(itemStack) + } else { + gachaPrize.itemStack.isSimilar(itemStack) } } - override def findOfRegularGachaPrizesByUnSignedItemStack( + override def findOfRegularGachaPrizesByNotSignedItemStack( itemStack: ItemStack ): F[Option[GachaPrize[ItemStack]]] = for { prizes <- allGachaPrizesListReference.get diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/bukkit/BukkitMineStackObjectList.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/bukkit/BukkitMineStackObjectList.scala index b041a3ad2f..e3ce06a60d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/bukkit/BukkitMineStackObjectList.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/bukkit/BukkitMineStackObjectList.scala @@ -658,11 +658,11 @@ class BukkitMineStackObjectList[F[_]: Sync]( allMineStackGroups.map(_.filter { group => categoryOf(group) == category }) } - override def findByItemStack( + override def findBySignedItemStack( itemStack: ItemStack, player: Player ): F[Option[MineStackObject[ItemStack]]] = for { - foundGachaPrizeOpt <- gachaPrizeAPI.findOfRegularPrizesByItemStack( + foundGachaPrizeOpt <- gachaPrizeAPI.findOfRegularPrizesBySignedItemStack( itemStack, player.getName ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/bukkit/BukkitMineStackRepository.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/bukkit/BukkitMineStackRepository.scala index f1ba322115..80e77fded1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/bukkit/BukkitMineStackRepository.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/bukkit/BukkitMineStackRepository.scala @@ -68,7 +68,7 @@ class BukkitMineStackRepository[F[_]: Sync]( override def tryIntoMineStack(player: Player, itemStack: ItemStack, amount: Int): F[Boolean] = for { - foundMineStackObject <- mineStackObjectList.findByItemStack(itemStack, player) + foundMineStackObject <- mineStackObjectList.findBySignedItemStack(itemStack, player) _ <- foundMineStackObject.traverse(addStackedAmountOf(player, _, amount)) } yield foundMineStackObject.isDefined } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/domain/minestackobject/MineStackObject.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/domain/minestackobject/MineStackObject.scala index cd16dd87ef..c67a91cafa 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/domain/minestackobject/MineStackObject.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/domain/minestackobject/MineStackObject.scala @@ -31,7 +31,7 @@ case class MineStackObject[ItemStack: Cloneable]( gachaPrizeAPI.canBeSignedAsGachaPrize for { - foundGachaPrize <- gachaPrizeAPI.findOfRegularPrizesByItemStack(itemStack, name) + foundGachaPrize <- gachaPrizeAPI.findOfRegularGachaPrizesByNotSignedItemStack(itemStack) } yield { println(s"foundGachaPrize: ${foundGachaPrize.isDefined}") foundGachaPrize.map { gachaPrize => gachaPrize.materializeWithOwnerSignature(name) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/domain/minestackobject/MineStackObjectList.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/domain/minestackobject/MineStackObjectList.scala index 60669261a3..bd30603044 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/domain/minestackobject/MineStackObjectList.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/domain/minestackobject/MineStackObjectList.scala @@ -10,9 +10,10 @@ trait MineStackObjectList[F[_], ItemStack, Player] { def allMineStackObjects: F[Vector[MineStackObject[ItemStack]]] /** + * @param itemStack 記名することのできるアイテムは、既に記名されていることを想定している * @return [[ItemStack]]から[[MineStackObject]]を取得しようとする作用 */ - def findByItemStack( + def findBySignedItemStack( itemStack: ItemStack, player: Player ): F[Option[MineStackObject[ItemStack]]]