Skip to content

Commit

Permalink
fix: ガチャ景品リストを出力するコマンドで合計確率がおかしくなる不具合を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
rito528 committed Oct 22, 2023
1 parent adea1b2 commit f142cec
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,13 @@ class GachaCommand[F[_]: OnMinecraftServerThread: ConcurrentEffect](
ContextualExecutorBuilder.beginConfiguration.buildWithExecutionCSEffect { context =>
val eventName = context.args.yetToBeParsed.headOption.map(GachaEventName)
Kleisli.liftF(gachaPrizeAPI.allGachaPrizeList).flatMap { gachaPrizes =>
val gachaPrizeInformation = gachaPrizes
.filter { gachaPrize =>
if (eventName.isEmpty) gachaPrize.nonGachaEventItem
else
gachaPrize.gachaEvent.map(_.eventName) == eventName
}
val eventGachaPrizes = gachaPrizes.filter { gachaPrize =>
if (eventName.isEmpty) gachaPrize.nonGachaEventItem
else
gachaPrize.gachaEvent.map(_.eventName) == eventName
}

val gachaPrizeInformation = eventGachaPrizes
.sortBy(_.id.id)
.map { gachaPrize =>
val itemStack = gachaPrize.itemStack
Expand All @@ -261,7 +262,7 @@ class GachaCommand[F[_]: OnMinecraftServerThread: ConcurrentEffect](
}
.toList

val totalProbability = gachaPrizes.map(_.probability.value).sum
val totalProbability = eventGachaPrizes.map(_.probability.value).sum
MessageEffectF(
List(s"${RED}アイテム番号|アイテム名|アイテム数|出現確率") ++ gachaPrizeInformation ++ List(
s"${RED}合計確率: $totalProbability(${totalProbability * 100}%)",
Expand Down

0 comments on commit f142cec

Please sign in to comment.