Skip to content

Commit

Permalink
Merge pull request #2382 from kuroma6666/feat-display-achievements-de…
Browse files Browse the repository at this point in the history
…tail

feat: 実績を解除した際に実績の小区分を表示する機能
  • Loading branch information
rito528 authored Oct 14, 2024
2 parents c866139 + 8d21af7 commit 2669f07
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,27 @@ object AchievementGroup {
case object VoteCounts extends AchievementGroup("JMS投票数", Specials)

case object Secrets extends AchievementGroup("極秘任務", Specials)

private val achievementIdRangeToGroupNameList = List(
(1001 to 1012, BrokenBlockRanking),
(2001 to 2014, PlacedBlockAmount),
(3001 to 3019, BrokenBlockAmount),
(4001 to 4023, PlayTime),
(5101 to 5125, TotalLogins),
(5001 to 5008, ConsecutiveLogins),
(6001 to 6008, VoteCounts),
(7001 to 7027, OfficialEvent),
(7901 to 7906, OfficialEvent),
(8001 to 8003, Secrets),
(9001 to 9047, Anniversaries)
)

/**
* @return 実績IDから実績IDが属する実績グループ名を取得する
*/
def getGroupNameByEntryId(entryId: Int): Option[String] = {
achievementIdRangeToGroupNameList.collectFirst {
case (range, group) if range contains entryId => group.name
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.github.unchama.seichiassist.achievement.{
NicknameMapping,
SeichiAchievement
}
import com.github.unchama.seichiassist.achievement.hierarchy.AchievementGroup
import com.github.unchama.seichiassist.menus.ColorScheme
import com.github.unchama.targetedeffect.commandsender.MessageEffect
import com.github.unchama.targetedeffect.player.FocusedSoundEffect
Expand Down Expand Up @@ -124,7 +125,13 @@ object AchievementGroupMenuButtons {
.playermap(player.getUniqueId)
.TitleFlags
.addOne(achievement.id)
player.sendMessage(s"実績No${achievement.id}を解除しました!おめでとうございます!")
val displayGroupName =
AchievementGroup
.getGroupNameByEntryId(achievement.id)
.getOrElse("未実装")
player.sendMessage(
s"[${displayGroupName}]実績No${achievement.id}を解除しました!おめでとうございます!"
)
}
else {
MessageEffect(s"${RED}実績No${achievement.id}は条件を満たしていません。")(player)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.github.unchama.concurrent.{RepeatingRoutine, RepeatingTaskContext}
import com.github.unchama.minecraft.actions.OnMinecraftServerThread
import com.github.unchama.seichiassist.SeichiAssist
import com.github.unchama.seichiassist.achievement.SeichiAchievement
import com.github.unchama.seichiassist.achievement.hierarchy.AchievementGroup
import org.bukkit.Bukkit

import scala.concurrent.duration.FiniteDuration
Expand Down Expand Up @@ -48,13 +49,22 @@ object PlayerDataRecalculationRoutine {
.toList
.sequence
.map(_.flatMap {
case (achievementId, true) => Some(achievementId)
case _ => None
case (achievementId, true) =>
val displayGroupName =
AchievementGroup.getGroupNameByEntryId(achievementId).getOrElse("未実装")
Some((achievementId, displayGroupName))
case _ => None
})
.flatMap(unlockTargets =>
IO {
playerData.TitleFlags.addAll(unlockTargets)
unlockTargets.map("実績No" + _ + "が解除されました!おめでとうございます!").foreach(player.sendMessage)
val achievementIds = unlockTargets.map(_._1)
playerData.TitleFlags.addAll(achievementIds)
unlockTargets.foreach {
case (achievementId, displayGroupName) =>
player.sendMessage(
s"[${displayGroupName}]実績No${achievementId}が解除されました!おめでとうございます!"
)
}
}
)
.unsafeRunSync()
Expand Down

0 comments on commit 2669f07

Please sign in to comment.