Skip to content

Commit

Permalink
chore: マインスタックのアイテムを纏める
Browse files Browse the repository at this point in the history
  • Loading branch information
rito528 committed Oct 14, 2023
1 parent d63e65a commit 7d8894e
Show file tree
Hide file tree
Showing 7 changed files with 430 additions and 334 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.github.unchama.seichiassist.menus.home.{ConfirmationMenuEnvironment,
import com.github.unchama.seichiassist.menus.minestack.{
CategorizedMineStackMenu,
MineStackMainMenu,
MineStackSelectItemColorMenu
MineStackSelectItemKindMenu
}
import com.github.unchama.seichiassist.menus.nicknames.NickNameMenu
import com.github.unchama.seichiassist.menus.ranking.{RankingMenu, RankingRootMenu}
Expand Down Expand Up @@ -134,9 +134,8 @@ object TopLevelRouter {
new AchievementGroupMenu.Environment
implicit lazy val passiveSkillMenuEnv: PassiveSkillMenu.Environment =
new PassiveSkillMenu.Environment
implicit lazy val mineStackSelectItemColorMenuEnv
: MineStackSelectItemColorMenu.Environment =
new MineStackSelectItemColorMenu.Environment
implicit lazy val mineStackSelectItemColorMenuEnv: MineStackSelectItemKindMenu.Environment =
new MineStackSelectItemKindMenu.Environment

implicit lazy val seichiRankingMenuEnv: RankingMenu[SeichiAmountData]#Environment =
new RankingMenu.Environment
Expand All @@ -163,7 +162,7 @@ object TopLevelRouter {

implicit lazy val ioCanOpenNickNameMenu: IO CanOpen NickNameMenu.type = _.open

implicit lazy val ioCanOpenSelectItemColorMenu: IO CanOpen MineStackSelectItemColorMenu =
implicit lazy val ioCanOpenSelectItemColorMenu: IO CanOpen MineStackSelectItemKindMenu =
_.open
implicit lazy val ioCanOpenAchievementGroupMenu: IO CanOpen AchievementGroupMenu = _.open
implicit lazy val ioCanOpenHomeConfirmationMenu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object CategorizedMineStackMenu {
class Environment(
implicit val ioCanOpenMineStackMainMenu: IO CanOpen MineStackMainMenu.type,
val ioCanOpenCategorizedMenu: IO CanOpen CategorizedMineStackMenu,
val ioCanOpenSelectItemColorMenu: IO CanOpen MineStackSelectItemColorMenu,
val ioCanOpenSelectItemColorMenu: IO CanOpen MineStackSelectItemKindMenu,
val onMainThread: OnMinecraftServerThread[IO],
val mineStackAPI: MineStackAPI[IO, Player, ItemStack],
implicit val gachaPrizeAPI: GachaPrizeAPI[IO, ItemStack, Player]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.github.unchama.seichiassist.subsystems.minestack.MineStackAPI
import com.github.unchama.seichiassist.subsystems.minestack.domain.minestackobject.{
MineStackObject,
MineStackObjectGroup,
MineStackObjectWithColorVariants
MineStackObjectWithKindVariants
}
import com.github.unchama.seichiassist.util.InventoryOperations.grantItemStacksEffect
import com.github.unchama.targetedeffect.commandsender.MessageEffect
Expand All @@ -38,7 +38,7 @@ private[minestack] case class MineStackButtons(player: Player)(
mineStackObjectGroup match {
case Left(mineStackObject) =>
mineStackObject
case Right(MineStackObjectWithColorVariants(representative, _)) =>
case Right(MineStackObjectWithKindVariants(representative, _)) =>
representative
}
}
Expand Down Expand Up @@ -69,7 +69,7 @@ private[minestack] case class MineStackButtons(player: Player)(
val mineStackObject = mineStackObjectGroup match {
case Left(mineStackObject) =>
mineStackObject
case Right(MineStackObjectWithColorVariants(representative, _)) =>
case Right(MineStackObjectWithKindVariants(representative, _)) =>
representative
}

Expand All @@ -96,7 +96,7 @@ private[minestack] case class MineStackButtons(player: Player)(
setLore {
val operationDetail =
if (mineStackObjectGroup.isRight) {
List(s"$RESET${DARK_GREEN}クリックで色選択画面を開きます")
List(s"$RESET${DARK_GREEN}クリックで種類選択画面を開きます")
} else {
List(
s"$RESET$GREEN${stackedAmount.toString.format("%,d")}",
Expand All @@ -120,7 +120,7 @@ private[minestack] case class MineStackButtons(player: Player)(
oldPage: Int
)(
implicit onMainThread: OnMinecraftServerThread[IO],
canOpenCategorizedMineStackMenu: IO CanOpen MineStackSelectItemColorMenu
canOpenCategorizedMineStackMenu: IO CanOpen MineStackSelectItemKindMenu
): IO[Button] = RecomputedButton {
for {
itemStack <- getMineStackObjectIconItemStack(mineStackObjectGroup)
Expand Down Expand Up @@ -152,7 +152,7 @@ private[minestack] case class MineStackButtons(player: Player)(
oldPage: Int
)(
implicit onMainThread: OnMinecraftServerThread[IO],
canOpenMineStackSelectItemColorMenu: IO CanOpen MineStackSelectItemColorMenu
canOpenMineStackSelectItemColorMenu: IO CanOpen MineStackSelectItemKindMenu
): Kleisli[IO, Player, Unit] = {
mineStackObjectGroup match {
case Left(mineStackObject) =>
Expand All @@ -168,7 +168,7 @@ private[minestack] case class MineStackButtons(player: Player)(
)
case Right(mineStackObjectWithColorVariants) =>
canOpenMineStackSelectItemColorMenu.open(
MineStackSelectItemColorMenu(mineStackObjectWithColorVariants, oldPage)
MineStackSelectItemKindMenu(mineStackObjectWithColorVariants, oldPage)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMain
import com.github.unchama.seichiassist.menus.CommonButtons
import com.github.unchama.seichiassist.subsystems.gachaprize.GachaPrizeAPI
import com.github.unchama.seichiassist.subsystems.minestack.MineStackAPI
import com.github.unchama.seichiassist.subsystems.minestack.domain.minestackobject.MineStackObjectWithColorVariants
import com.github.unchama.seichiassist.subsystems.minestack.domain.minestackobject.MineStackObjectWithKindVariants
import eu.timepit.refined.auto._
import org.bukkit.ChatColor.{BOLD, DARK_BLUE}
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack

object MineStackSelectItemColorMenu {
object MineStackSelectItemKindMenu {

class Environment(
implicit val canOpenCategorizedMineStackMenu: CanOpen[IO, CategorizedMineStackMenu],
Expand All @@ -26,22 +26,22 @@ object MineStackSelectItemColorMenu {

}

case class MineStackSelectItemColorMenu(
group: MineStackObjectWithColorVariants[ItemStack],
case class MineStackSelectItemKindMenu(
group: MineStackObjectWithKindVariants[ItemStack],
oldPage: Int
) extends Menu {

import com.github.unchama.menuinventory.syntax._

override type Environment = MineStackSelectItemColorMenu.Environment
override type Environment = MineStackSelectItemKindMenu.Environment
override val frame: MenuFrame =
MenuFrame(6.chestRows, s"$DARK_BLUE${BOLD}MineStack(アイテム色選択)")
MenuFrame(6.chestRows, s"$DARK_BLUE${BOLD}MineStack(アイテム種類選択)")

override def computeMenuLayout(
player: Player
)(implicit environment: Environment): IO[MenuSlotLayout] = {
import environment._
val buttonMapping = (List(group.representative) ++ group.coloredVariants).zipWithIndex.map {
val buttonMapping = (List(group.representative) ++ group.kindVariants).zipWithIndex.map {
case (inListMineStackObj, index) =>
index -> MineStackButtons(player).getMineStackObjectButtonOf(inListMineStackObj)
} ++ List(
Expand Down
Loading

0 comments on commit 7d8894e

Please sign in to comment.