Skip to content

Commit

Permalink
Merge pull request #1952 from GiganticMinecraft/fix/fairyRecoveryMana
Browse files Browse the repository at this point in the history
  • Loading branch information
KisaragiEffective authored Apr 20, 2023
2 parents 45bb138 + 16bcc82 commit 522ca19
Showing 1 changed file with 17 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: JavaTime, G[_]: ContextCoercion
finallyAppleConsumptionAmount <- computeFinallyAppleConsumptionAmount(
appleConsumptionAmount
)
recoveryManaAmount <- computeManaRecoveryAmount(appleConsumptionAmount)
recoveryManaAmount <- computeManaRecoveryAmount(finallyAppleConsumptionAmount)

gachaRingoObject <- mineStackAPI.mineStackObjectList.findByName("gachaimo")

Expand All @@ -87,15 +87,22 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: JavaTime, G[_]: ContextCoercion
) >>
fairySpeech.speechRandomly(
player,
if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount)
if (finallyAppleConsumptionAmount == 0)
FairyManaRecoveryState.RecoveredWithoutApple
else FairyManaRecoveryState.RecoveredWithApple
) >>
mineStackAPI
.mineStackRepository
.subtractStackedAmountOf(
player,
gachaRingoObject.get,
finallyAppleConsumptionAmount
) >>
SequentialEffect(
MessageEffectF(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"),
if (appleConsumptionAmount != 0)
if (finallyAppleConsumptionAmount != 0)
MessageEffectF(
s"$RESET$YELLOW${BOLD}あっ!${appleConsumptionAmount}個のがちゃりんごが食べられてる!"
s"$RESET$YELLOW${BOLD}あっ!${finallyAppleConsumptionAmount}個のがちゃりんごが食べられてる!"
)
else MessageEffectF(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。")
).apply(player)
Expand Down Expand Up @@ -181,10 +188,6 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: JavaTime, G[_]: ContextCoercion
oldManaAmount <- ContextCoercion {
manaApi.readManaAmount(player)
}
gachaRingoObject <- mineStackAPI.mineStackObjectList.findByName("gachaimo")
mineStackedGachaRingoAmount <- mineStackAPI
.mineStackRepository
.getStackedAmountOf(player, gachaRingoObject.get)
} yield {
val isAppleOpenStateIsOpenOrOpenALittle =
appleOpenState == FairyAppleConsumeStrategy.LessConsume || appleOpenState == FairyAppleConsumeStrategy.Consume
Expand All @@ -194,33 +197,19 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: JavaTime, G[_]: ContextCoercion

val appleOpenStateDivision =
if (isAppleOpenStateIsOpenOrOpenALittle && isEnoughMana) 2
else if (appleOpenState == FairyAppleConsumeStrategy.NoConsume) 4
else if (
appleOpenState == FairyAppleConsumeStrategy.NoConsume || appleConsumptionAmount == 0
) 4
else 1

val reflectedAppleOpenStateAmount =
defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision

// minestackに入っているりんごの数を適用したマナの回復量
val mineStackBasedRegenValue =
if (appleConsumptionAmount > mineStackedGachaRingoAmount) {
if (mineStackedGachaRingoAmount == 0) {
reflectedAppleOpenStateAmount / (
if (appleOpenState == FairyAppleConsumeStrategy.Consume) 4
else if (appleOpenState == FairyAppleConsumeStrategy.LessConsume) 4
else 2
)
} else {
val multiplier = Math.max(mineStackedGachaRingoAmount / appleConsumptionAmount, 0.5)
(reflectedAppleOpenStateAmount * multiplier).toInt
}
} else reflectedAppleOpenStateAmount

val randomizedAdd =
if (mineStackBasedRegenValue >= 50)
Random.nextInt(mineStackBasedRegenValue / 50)
if (reflectedAppleOpenStateAmount >= 50)
Random.nextInt(reflectedAppleOpenStateAmount / 50)
else 0

(mineStackBasedRegenValue - mineStackBasedRegenValue / 100) + randomizedAdd
(reflectedAppleOpenStateAmount - reflectedAppleOpenStateAmount / 100) + randomizedAdd
}

}

0 comments on commit 522ca19

Please sign in to comment.