Skip to content

Commit

Permalink
fix: マインスタックから取り出したGT等の名義品アイテムに名義がない不具合を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
rito528 committed Jan 31, 2023
1 parent 603ac1f commit 7a901da
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]]]
Expand All @@ -116,7 +117,7 @@ trait GachaPrizeReadAPI[F[_], ItemStack] {
* @param itemStack 記名されていない[[ItemStack]]
* @return 通常排出ガチャ景品の中から、記名されてない`itemStack`に一致する[[GachaPrize]]を取得する作用
*/
def findOfRegularGachaPrizesByUnSignedItemStack(
def findOfRegularGachaPrizesByNotSignedItemStack(
itemStack: ItemStack
): F[Option[GachaPrize[ItemStack]]]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]]]
Expand Down

0 comments on commit 7a901da

Please sign in to comment.