From d10a3f9b350e184fc9592dc2bad945904b3cca06 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 23 Jul 2022 17:48:58 +0900 Subject: [PATCH 001/482] =?UTF-8?q?[Add]VoteAPI=E3=82=92=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/VoteAPI.scala | 42 +++++++++++++++++++ .../subsystems/vote/domain/VotePoint.scala | 12 ++++++ 2 files changed, 54 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePoint.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala new file mode 100644 index 0000000000..1c4dbfc405 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -0,0 +1,42 @@ +package com.github.unchama.seichiassist.subsystems.vote + +import com.github.unchama.seichiassist.subsystems.vote.domain.VotePoint + +import java.util.UUID + +trait VoteWriteAPI[F[_]] { + + /** + * 投票ポイントをインクリメントする作用 + */ + def incrementVotePoint(uuid: UUID): F[Unit] + + /** + * 連続投票を更新する作用 + */ + def updateChainVote(uuid: UUID): F[Unit] + +} + +object VoteWriteAPI { + + def apply[F[_]](implicit voteWriteAPI: VoteWriteAPI[F]): VoteWriteAPI[F] = implicitly + +} + +trait VoteReadAPI[F[_]] { + + /** + * 投票ポイントを返す作用 + */ + def votePoint(uuid: UUID): VotePoint + +} + +object VoteReadAPI { + + def apply[F[_]](implicit voteReadAPI: VoteReadAPI[F]): VoteReadAPI[F] = implicitly + +} + +trait VoteAPI[F[_]] extends VoteReadAPI[F[_]] with VoteWriteAPI[F[_]] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePoint.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePoint.scala new file mode 100644 index 0000000000..3c34aec1fb --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePoint.scala @@ -0,0 +1,12 @@ +package com.github.unchama.seichiassist.subsystems.vote.domain + +case class VotePoint private (point: Int) + +object VotePoint { + + def ofNonNegative(point: Int): VotePoint = { + require(point >= 0, "votePointは非負である必要があります。") + VotePoint(point) + } + +} From a630aeb313941db673df04d6b5dc8d12c70004a5 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 23 Jul 2022 18:01:32 +0900 Subject: [PATCH 002/482] =?UTF-8?q?[Add]=E5=90=84=E7=A8=AEPersistence?= =?UTF-8?q?=E3=82=92=E7=94=9F=E3=82=84=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/domain/ChainVoteDayNumber.scala | 12 ++++++++++++ .../vote/domain/ChainVotePersistence.scala | 11 +++++++++++ .../vote/domain/VotePointPersistence.scala | 11 +++++++++++ 3 files changed, 34 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVoteDayNumber.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVotePersistence.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePointPersistence.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVoteDayNumber.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVoteDayNumber.scala new file mode 100644 index 0000000000..2011a18509 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVoteDayNumber.scala @@ -0,0 +1,12 @@ +package com.github.unchama.seichiassist.subsystems.vote.domain + +case class ChainVoteDayNumber private (dayNumber: Int) + +object ChainVoteDayNumber { + + def ofNonNegative(dayNumber: Int): ChainVoteDayNumber = { + require(dayNumber >= 0, "投票日数は非負である必要があります。") + ChainVoteDayNumber(dayNumber) + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVotePersistence.scala new file mode 100644 index 0000000000..03ddee00b7 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVotePersistence.scala @@ -0,0 +1,11 @@ +package com.github.unchama.seichiassist.subsystems.vote.domain + +import java.util.UUID + +trait ChainVotePersistence[F[_]] { + + def updateChainVote(uuid: UUID): F[Unit] + + def getChainVoteDays(uuid: UUID): F[ChainVoteDayNumber] + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePointPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePointPersistence.scala new file mode 100644 index 0000000000..ea4cadbb63 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePointPersistence.scala @@ -0,0 +1,11 @@ +package com.github.unchama.seichiassist.subsystems.vote.domain + +import java.util.UUID + +trait VotePointPersistence[F[_]] { + + def increment(uuid: UUID): F[Unit] + + def votePoint(uuid: UUID): F[VotePoint] + +} From 9f78a3050dd35fa5fed955f5935ff314c0693655 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 23 Jul 2022 18:24:56 +0900 Subject: [PATCH 003/482] =?UTF-8?q?[Add]updateChainVote=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JdbcChainVotePersistence.scala | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala new file mode 100644 index 0000000000..e20eaedd68 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala @@ -0,0 +1,31 @@ +package com.github.unchama.seichiassist.subsystems.vote.infrastructure + +import cats.effect.Sync +import com.github.unchama.seichiassist.subsystems.vote.domain.{ + ChainVoteDayNumber, + ChainVotePersistence +} +import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} + +import java.util.UUID + +class JdbcChainVotePersistence[F[_]: Sync] extends ChainVotePersistence[F] { + // NOTE: 連続投票許容幅を変更する場合はここを変更してください。 + private val chainVoteAllowableWidth = 4 + + override def updateChainVote(uuid: UUID): F[Unit] = Sync[F].delay { + DB.localTx { implicit session => + /* + NOTE: 最終投票日時より(連続投票許容幅 - 1)した日時よりも + 小さかった場合に連続投票を0に戻します。 + */ + sql"""UPDATE playerdata SET chainvote = + | CASE WHEN DATEDIFF(last_vote, NOW()) <= ${-chainVoteAllowableWidth - 1} + | THEN 0 + | ELSE chainvote + 1 + | END""".stripMargin.execute().apply() + } + } + + override def getChainVoteDays(uuid: UUID): F[ChainVoteDayNumber] = {} +} From 8a199236e59250f8a30d4fa77fbd8786e2909918 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 23 Jul 2022 18:52:57 +0900 Subject: [PATCH 004/482] =?UTF-8?q?[Add]getChainVoteDays=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/JdbcChainVotePersistence.scala | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala index e20eaedd68..84737678c0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala @@ -23,9 +23,19 @@ class JdbcChainVotePersistence[F[_]: Sync] extends ChainVotePersistence[F] { | CASE WHEN DATEDIFF(last_vote, NOW()) <= ${-chainVoteAllowableWidth - 1} | THEN 0 | ELSE chainvote + 1 - | END""".stripMargin.execute().apply() + | END + | WHERE uuid = ${uuid.toString}""".stripMargin.execute().apply() } } - override def getChainVoteDays(uuid: UUID): F[ChainVoteDayNumber] = {} + override def getChainVoteDays(uuid: UUID): F[ChainVoteDayNumber] = Sync[F].delay { + DB.readOnly { implicit session => + val chainVoteDays = sql"SELECT chainvote FROM playerdata WHERE uuid = ${uuid.toString}" + .map(_.int("chainvote")) + .single() + .apply() + .get + ChainVoteDayNumber.ofNonNegative(chainVoteDays) + } + } } From 6e0c0beb78ee3b55e4e97441194ff9171fddca03 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 23 Jul 2022 19:00:11 +0900 Subject: [PATCH 005/482] =?UTF-8?q?[add]votePoint=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/domain/ChainVoteDayNumber.scala | 11 ++------ .../subsystems/vote/domain/VotePoint.scala | 11 ++------ .../JdbcChainVotePersistence.scala | 2 +- .../JdbcVotePointPersistence.scala | 28 +++++++++++++++++++ 4 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePointPersistence.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVoteDayNumber.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVoteDayNumber.scala index 2011a18509..f2232fcba7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVoteDayNumber.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVoteDayNumber.scala @@ -1,12 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.domain -case class ChainVoteDayNumber private (dayNumber: Int) - -object ChainVoteDayNumber { - - def ofNonNegative(dayNumber: Int): ChainVoteDayNumber = { - require(dayNumber >= 0, "投票日数は非負である必要があります。") - ChainVoteDayNumber(dayNumber) - } - +case class ChainVoteDayNumber(dayNumber: Int) extends AnyVal { + require(dayNumber >= 0, "投票日数は非負である必要があります。") } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePoint.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePoint.scala index 3c34aec1fb..a5789c9f2d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePoint.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePoint.scala @@ -1,12 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.domain -case class VotePoint private (point: Int) - -object VotePoint { - - def ofNonNegative(point: Int): VotePoint = { - require(point >= 0, "votePointは非負である必要があります。") - VotePoint(point) - } - +case class VotePoint(point: Int) extends AnyVal { + require(point >= 0, "votePointは非負である必要があります。") } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala index 84737678c0..04d5188101 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala @@ -35,7 +35,7 @@ class JdbcChainVotePersistence[F[_]: Sync] extends ChainVotePersistence[F] { .single() .apply() .get - ChainVoteDayNumber.ofNonNegative(chainVoteDays) + ChainVoteDayNumber(chainVoteDays) } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePointPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePointPersistence.scala new file mode 100644 index 0000000000..1f18e0e5a7 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePointPersistence.scala @@ -0,0 +1,28 @@ +package com.github.unchama.seichiassist.subsystems.vote.infrastructure + +import cats.effect.Sync +import com.github.unchama.seichiassist.subsystems.vote.domain.{VotePoint, VotePointPersistence} +import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} + +import java.util.UUID + +class JdbcVotePointPersistence[F[_]: Sync] extends VotePointPersistence[F] { + override def increment(uuid: UUID): F[Unit] = Sync[F].delay { + DB.localTx { implicit session => + sql"UPDATE playerdata SET p_vote = p_vote + 1 WHERE uuid = ${uuid.toString}" + .execute() + .apply() + } + } + + override def votePoint(uuid: UUID): F[VotePoint] = Sync[F].delay { + DB.readOnly { implicit session => + val votePoint = sql"SELECT p_vote FROM playerdata WHERE uuid = ${uuid.toString}" + .map(_.int("p_vote")) + .single() + .apply() + .get + VotePoint(votePoint) + } + } +} From fbe8bddc13fdeb2166ec3e0e49a6c2d9c3b697c5 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 23 Jul 2022 19:07:57 +0900 Subject: [PATCH 006/482] =?UTF-8?q?[Add]System=E3=82=92=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/System.scala | 41 +++++++++++++++++++ .../subsystems/vote/VoteAPI.scala | 11 +++-- 2 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala new file mode 100644 index 0000000000..84333c402e --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -0,0 +1,41 @@ +package com.github.unchama.seichiassist.subsystems.vote + +import cats.effect.Sync +import com.github.unchama.minecraft.actions.OnMinecraftServerThread +import com.github.unchama.seichiassist.meta.subsystem.Subsystem +import com.github.unchama.seichiassist.subsystems.vote.domain.{ChainVoteDayNumber, VotePoint} +import com.github.unchama.seichiassist.subsystems.vote.infrastructure.{ + JdbcChainVotePersistence, + JdbcVotePointPersistence +} + +import java.util.UUID + +trait System[F[_]] extends Subsystem[F] { + val api: VoteAPI[F] +} + +object System { + + def wired[F[_]: Sync: OnMinecraftServerThread]: System[F] = { + val chainVotePersistence = new JdbcChainVotePersistence[F] + val votePointPersistence = new JdbcVotePointPersistence[F] + + new System[F] { + override val api: VoteAPI[F] = new VoteAPI[F] { + override def incrementVotePoint(uuid: UUID): F[Unit] = + votePointPersistence.increment(uuid) + + override def updateChainVote(uuid: UUID): F[Unit] = + chainVotePersistence.updateChainVote(uuid) + + override def votePoint(uuid: UUID): F[VotePoint] = + votePointPersistence.votePoint(uuid) + + override def chainVoteDayNumber(uuid: UUID): F[ChainVoteDayNumber] = + chainVotePersistence.getChainVoteDays(uuid) + } + } + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index 1c4dbfc405..ae3e320de7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote -import com.github.unchama.seichiassist.subsystems.vote.domain.VotePoint +import com.github.unchama.seichiassist.subsystems.vote.domain.{ChainVoteDayNumber, VotePoint} import java.util.UUID @@ -29,7 +29,12 @@ trait VoteReadAPI[F[_]] { /** * 投票ポイントを返す作用 */ - def votePoint(uuid: UUID): VotePoint + def votePoint(uuid: UUID): F[VotePoint] + + /** + * 連続投票日数を返す作用 + */ + def chainVoteDayNumber(uuid: UUID): F[ChainVoteDayNumber] } @@ -39,4 +44,4 @@ object VoteReadAPI { } -trait VoteAPI[F[_]] extends VoteReadAPI[F[_]] with VoteWriteAPI[F[_]] +trait VoteAPI[F[_]] extends VoteReadAPI[F] with VoteWriteAPI[F] From efd7506518d4089d7712140b71c20a2707da9d94 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 23 Jul 2022 19:23:09 +0900 Subject: [PATCH 007/482] =?UTF-8?q?[Add]VoteCommand=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/System.scala | 14 +++--- .../subsystems/vote/VoteAPI.scala | 10 +++-- .../vote/bukkit/command/VoteCommand.scala | 45 +++++++++++++++++++ .../vote/domain/ChainVotePersistence.scala | 2 +- .../subsystems/vote/domain/PlayerName.scala | 5 +++ .../vote/domain/VotePointPersistence.scala | 2 +- .../JdbcChainVotePersistence.scala | 7 +-- .../JdbcVotePointPersistence.scala | 12 ++--- 8 files changed, 79 insertions(+), 18 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/PlayerName.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index 84333c402e..498f2b959d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -3,7 +3,11 @@ package com.github.unchama.seichiassist.subsystems.vote import cats.effect.Sync import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem -import com.github.unchama.seichiassist.subsystems.vote.domain.{ChainVoteDayNumber, VotePoint} +import com.github.unchama.seichiassist.subsystems.vote.domain.{ + ChainVoteDayNumber, + PlayerName, + VotePoint +} import com.github.unchama.seichiassist.subsystems.vote.infrastructure.{ JdbcChainVotePersistence, JdbcVotePointPersistence @@ -23,11 +27,11 @@ object System { new System[F] { override val api: VoteAPI[F] = new VoteAPI[F] { - override def incrementVotePoint(uuid: UUID): F[Unit] = - votePointPersistence.increment(uuid) + override def incrementVotePoint(playerName: PlayerName): F[Unit] = + votePointPersistence.increment(playerName) - override def updateChainVote(uuid: UUID): F[Unit] = - chainVotePersistence.updateChainVote(uuid) + override def updateChainVote(playerName: PlayerName): F[Unit] = + chainVotePersistence.updateChainVote(playerName) override def votePoint(uuid: UUID): F[VotePoint] = votePointPersistence.votePoint(uuid) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index ae3e320de7..0a7f47e8f4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -1,6 +1,10 @@ package com.github.unchama.seichiassist.subsystems.vote -import com.github.unchama.seichiassist.subsystems.vote.domain.{ChainVoteDayNumber, VotePoint} +import com.github.unchama.seichiassist.subsystems.vote.domain.{ + ChainVoteDayNumber, + PlayerName, + VotePoint +} import java.util.UUID @@ -9,12 +13,12 @@ trait VoteWriteAPI[F[_]] { /** * 投票ポイントをインクリメントする作用 */ - def incrementVotePoint(uuid: UUID): F[Unit] + def incrementVotePoint(playerName: PlayerName): F[Unit] /** * 連続投票を更新する作用 */ - def updateChainVote(uuid: UUID): F[Unit] + def updateChainVote(playerName: PlayerName): F[Unit] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala new file mode 100644 index 0000000000..b02208618c --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala @@ -0,0 +1,45 @@ +package com.github.unchama.seichiassist.subsystems.vote.bukkit.command + +import cats.effect.ConcurrentEffect +import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps +import com.github.unchama.contextualexecutor.builder.ContextualExecutorBuilder +import com.github.unchama.contextualexecutor.executors.{BranchedExecutor, EchoExecutor} +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI +import com.github.unchama.seichiassist.subsystems.vote.domain.PlayerName +import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} +import com.github.unchama.targetedeffect.commandsender.MessageEffect +import org.bukkit.ChatColor._ +import org.bukkit.command.TabExecutor + +class VoteCommand[F[_]: ConcurrentEffect](implicit voteAPI: VoteAPI[F]) { + + private val usageEchoExecutor: EchoExecutor = EchoExecutor( + MessageEffect(List(s"$RED/vote record <プレイヤー名>", "投票特典配布用コマンドです")) + ) + + private val recordExecutor = + ContextualExecutorBuilder + .beginConfiguration() + .executionCSEffect { context => + val lowerCasePlayerName = context.args.yetToBeParsed.head + + SequentialEffect( + MessageEffect(s"$YELLOW${lowerCasePlayerName}の特典配布処理開始…"), + UnfocusedEffect { + val playerName = PlayerName(lowerCasePlayerName) + voteAPI.incrementVotePoint(playerName).toIO.unsafeRunAsyncAndForget() + voteAPI.updateChainVote(playerName).toIO.unsafeRunAsyncAndForget() + } + ) + } + .build() + + val executor: TabExecutor = { + BranchedExecutor( + Map("record" -> recordExecutor), + whenBranchNotFound = Some(usageEchoExecutor), + whenArgInsufficient = Some(usageEchoExecutor) + ) + }.asNonBlockingTabExecutor() + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVotePersistence.scala index 03ddee00b7..8660ca47d1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVotePersistence.scala @@ -4,7 +4,7 @@ import java.util.UUID trait ChainVotePersistence[F[_]] { - def updateChainVote(uuid: UUID): F[Unit] + def updateChainVote(playerName: PlayerName): F[Unit] def getChainVoteDays(uuid: UUID): F[ChainVoteDayNumber] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/PlayerName.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/PlayerName.scala new file mode 100644 index 0000000000..95477b8548 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/PlayerName.scala @@ -0,0 +1,5 @@ +package com.github.unchama.seichiassist.subsystems.vote.domain + +case class PlayerName(name: String) extends AnyVal { + require(name.forall(_.isLower)) +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePointPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePointPersistence.scala index ea4cadbb63..7a0b0141cf 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePointPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePointPersistence.scala @@ -4,7 +4,7 @@ import java.util.UUID trait VotePointPersistence[F[_]] { - def increment(uuid: UUID): F[Unit] + def increment(playerName: PlayerName): F[Unit] def votePoint(uuid: UUID): F[VotePoint] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala index 04d5188101..787b6d264d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala @@ -3,7 +3,8 @@ package com.github.unchama.seichiassist.subsystems.vote.infrastructure import cats.effect.Sync import com.github.unchama.seichiassist.subsystems.vote.domain.{ ChainVoteDayNumber, - ChainVotePersistence + ChainVotePersistence, + PlayerName } import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} @@ -13,7 +14,7 @@ class JdbcChainVotePersistence[F[_]: Sync] extends ChainVotePersistence[F] { // NOTE: 連続投票許容幅を変更する場合はここを変更してください。 private val chainVoteAllowableWidth = 4 - override def updateChainVote(uuid: UUID): F[Unit] = Sync[F].delay { + override def updateChainVote(playerName: PlayerName): F[Unit] = Sync[F].delay { DB.localTx { implicit session => /* NOTE: 最終投票日時より(連続投票許容幅 - 1)した日時よりも @@ -24,7 +25,7 @@ class JdbcChainVotePersistence[F[_]: Sync] extends ChainVotePersistence[F] { | THEN 0 | ELSE chainvote + 1 | END - | WHERE uuid = ${uuid.toString}""".stripMargin.execute().apply() + | WHERE name = $playerName""".stripMargin.execute().apply() } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePointPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePointPersistence.scala index 1f18e0e5a7..ed8804be30 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePointPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePointPersistence.scala @@ -1,17 +1,19 @@ package com.github.unchama.seichiassist.subsystems.vote.infrastructure import cats.effect.Sync -import com.github.unchama.seichiassist.subsystems.vote.domain.{VotePoint, VotePointPersistence} +import com.github.unchama.seichiassist.subsystems.vote.domain.{ + PlayerName, + VotePoint, + VotePointPersistence +} import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} import java.util.UUID class JdbcVotePointPersistence[F[_]: Sync] extends VotePointPersistence[F] { - override def increment(uuid: UUID): F[Unit] = Sync[F].delay { + override def increment(playerName: PlayerName): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET p_vote = p_vote + 1 WHERE uuid = ${uuid.toString}" - .execute() - .apply() + sql"UPDATE playerdata SET p_vote = p_vote + 1 WHERE name = $playerName".execute().apply() } } From e98f3be9377b99121e044907099aafbea2cc03f8 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 23 Jul 2022 19:24:25 +0900 Subject: [PATCH 008/482] =?UTF-8?q?[Add]System=E3=81=ABvote=E3=82=B3?= =?UTF-8?q?=E3=83=9E=E3=83=B3=E3=83=89=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/System.scala | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index 498f2b959d..8bf72a6c33 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -1,8 +1,9 @@ package com.github.unchama.seichiassist.subsystems.vote -import cats.effect.Sync +import cats.effect.ConcurrentEffect import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem +import com.github.unchama.seichiassist.subsystems.vote.bukkit.command.VoteCommand import com.github.unchama.seichiassist.subsystems.vote.domain.{ ChainVoteDayNumber, PlayerName, @@ -12,6 +13,7 @@ import com.github.unchama.seichiassist.subsystems.vote.infrastructure.{ JdbcChainVotePersistence, JdbcVotePointPersistence } +import org.bukkit.command.TabExecutor import java.util.UUID @@ -21,12 +23,12 @@ trait System[F[_]] extends Subsystem[F] { object System { - def wired[F[_]: Sync: OnMinecraftServerThread]: System[F] = { + def wired[F[_]: ConcurrentEffect: OnMinecraftServerThread]: System[F] = { val chainVotePersistence = new JdbcChainVotePersistence[F] val votePointPersistence = new JdbcVotePointPersistence[F] new System[F] { - override val api: VoteAPI[F] = new VoteAPI[F] { + override implicit val api: VoteAPI[F] = new VoteAPI[F] { override def incrementVotePoint(playerName: PlayerName): F[Unit] = votePointPersistence.increment(playerName) @@ -39,6 +41,10 @@ object System { override def chainVoteDayNumber(uuid: UUID): F[ChainVoteDayNumber] = chainVotePersistence.getChainVoteDays(uuid) } + + override val commands: Map[String, TabExecutor] = Map( + "vote" -> new VoteCommand[F].executor + ) } } From e933e0b1512d1a075b8252fd690f8c6b080246b5 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 23 Jul 2022 19:26:06 +0900 Subject: [PATCH 009/482] =?UTF-8?q?[Remove]=E6=97=A7VoteCommand=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/SeichiAssist.scala | 1 - .../seichiassist/commands/VoteCommand.scala | 45 ------------------ .../manipulators/PlayerDataManipulator.scala | 47 ------------------- 3 files changed, 93 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/commands/VoteCommand.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 683bd89677..822f294882 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -584,7 +584,6 @@ class SeichiAssist extends JavaPlugin() { // コマンドの登録 Map( "gacha" -> new GachaCommand(), - "vote" -> VoteCommand.executor, "donation" -> new DonationCommand, "map" -> MapCommand.executor, "ef" -> new EffectCommand(fastDiggingEffectSystem.settingsApi).executor, diff --git a/src/main/scala/com/github/unchama/seichiassist/commands/VoteCommand.scala b/src/main/scala/com/github/unchama/seichiassist/commands/VoteCommand.scala deleted file mode 100644 index 4d9eddb4dc..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/commands/VoteCommand.scala +++ /dev/null @@ -1,45 +0,0 @@ -package com.github.unchama.seichiassist.commands - -import com.github.unchama.contextualexecutor.builder.ContextualExecutorBuilder -import com.github.unchama.contextualexecutor.executors.{BranchedExecutor, EchoExecutor} -import com.github.unchama.seichiassist.SeichiAssist -import com.github.unchama.targetedeffect.commandsender.MessageEffect -import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} -import org.bukkit.ChatColor.{RED, YELLOW} -import org.bukkit.command.TabExecutor - -object VoteCommand { - private val usageEchoExecutor: EchoExecutor = EchoExecutor( - MessageEffect(List(s"$RED/vote record <プレイヤー名>", "投票特典配布用コマンドです")) - ) - - private val recordExecutor = - ContextualExecutorBuilder - .beginConfiguration() - .executionCSEffect(context => { - val playerName: String = context.args.yetToBeParsed.head - val lowerCasePlayerName = playerName.toLowerCase - - SequentialEffect( - MessageEffect(s"$YELLOW${lowerCasePlayerName}の投票特典配布処理開始…"), - UnfocusedEffect { - SeichiAssist - .databaseGateway - .playerDataManipulator - .incrementVotePoint(lowerCasePlayerName) - }, - UnfocusedEffect { - SeichiAssist.databaseGateway.playerDataManipulator.addChainVote(lowerCasePlayerName) - } - ) - }) - .build() - - val executor: TabExecutor = { - BranchedExecutor( - Map("record" -> recordExecutor), - whenBranchNotFound = Some(usageEchoExecutor), - whenArgInsufficient = Some(usageEchoExecutor) - ).asNonBlockingTabExecutor() - } -} diff --git a/src/main/scala/com/github/unchama/seichiassist/database/manipulators/PlayerDataManipulator.scala b/src/main/scala/com/github/unchama/seichiassist/database/manipulators/PlayerDataManipulator.scala index f4aca6bc43..0547a99a03 100644 --- a/src/main/scala/com/github/unchama/seichiassist/database/manipulators/PlayerDataManipulator.scala +++ b/src/main/scala/com/github/unchama/seichiassist/database/manipulators/PlayerDataManipulator.scala @@ -123,18 +123,6 @@ class PlayerDataManipulator(private val gateway: DatabaseGateway) { numberToGrant } - /** - * 投票ポイントをインクリメントするメソッド。 - * - * @param playerName - * プレーヤー名 - */ - def incrementVotePoint(playerName: String): Unit = { - DB.localTx { implicit session => - sql"update playerdata set p_vote = p_vote + 1 where name = $playerName".update().apply() - } - } - // 指定されたプレイヤーにガチャ券を送信する def addPlayerBug(playerName: String, num: Int): IO[ResponseEffectOrResult[Player, Unit]] = { val executeQuery = IO { @@ -152,41 +140,6 @@ class PlayerDataManipulator(private val gateway: DatabaseGateway) { ) } - def addChainVote(name: String): Unit = - DB.localTx { implicit session => - val calendar = Calendar.getInstance() - val dateFormat = new SimpleDateFormat("yyyy/MM/dd") - - val lastVote = - sql"SELECT lastvote FROM playerdata WHERE name = $name" - .map(_.string("lastvote")) - .single() - .apply() - .getOrElse(dateFormat.format(calendar.getTime)) - - sql"UPDATE playerdata SET lastvote = ${dateFormat.format(calendar.getTime)} WHERE name = $name" - .update() - .apply() - - val TodayDate = dateFormat.parse(dateFormat.format(calendar.getTime)) - val LastDate = dateFormat.parse(lastVote) - val TodayLong = TodayDate.getTime - val LastLong = LastDate.getTime - - val dateDiff = (TodayLong - LastLong) / (1000 * 60 * 60 * 24) - val shouldIncrementChainVote = dateDiff <= 4L - - val newCount = if (shouldIncrementChainVote) { - sql"""select chainvote from playerdata where name = $name""" - .map(_.int("chainvote")) - .first() - .apply() - .get + 1 - } else 1 - - sql"""update playerdata set chainvote = $newCount where name = $name""" - } - // anniversary変更 def setAnniversary(anniversary: Boolean, uuid: Option[UUID]): Boolean = { val command = s"UPDATE $tableReference SET anniversary = $anniversary" + From cc3a9fd4bb5e36c3ebcab9ca62d9293598c8f664 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 23 Jul 2022 21:25:01 +0900 Subject: [PATCH 010/482] =?UTF-8?q?[Add]System=E3=81=AB=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E3=81=AA=E6=83=85=E5=A0=B1=E3=82=92=E5=8F=97=E3=81=91=E5=8F=96?= =?UTF-8?q?=E3=82=8C=E3=82=8BAPI=E3=82=92=E7=94=9F=E3=82=84=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/data/MenuInventoryData.java | 1 - .../unchama/seichiassist/menus/VoteMenu.scala | 49 +++++++ .../seichiassist/subsystems/vote/System.scala | 36 ++++-- .../subsystems/vote/VoteAPI.scala | 30 ++++- .../vote/bukkit/command/VoteCommand.scala | 15 ++- .../vote/domain/ChainVoteDayNumber.scala | 4 +- .../vote/domain/ChainVotePersistence.scala | 11 -- .../subsystems/vote/domain/EffectPoint.scala | 5 + .../subsystems/vote/domain/VoteBenefit.scala | 5 + .../subsystems/vote/domain/VoteCounter.scala | 5 + .../vote/domain/VotePersistence.scala | 47 +++++++ .../subsystems/vote/domain/VotePoint.scala | 5 - .../vote/domain/VotePointPersistence.scala | 11 -- .../JdbcChainVotePersistence.scala | 42 ------ .../infrastructure/JdbcVotePersistence.scala | 120 ++++++++++++++++++ .../JdbcVotePointPersistence.scala | 30 ----- 16 files changed, 294 insertions(+), 122 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVotePersistence.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/EffectPoint.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteBenefit.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCounter.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePoint.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePointPersistence.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePointPersistence.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java b/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java index 096632d924..14986ef4bd 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java +++ b/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java @@ -8,7 +8,6 @@ import com.github.unchama.seichiassist.task.VotingFairyTask; import com.github.unchama.seichiassist.util.AsyncInventorySetter; import com.github.unchama.seichiassist.util.ItemMetaFactory; -import com.github.unchama.seichiassist.util.TypeConverter; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala new file mode 100644 index 0000000000..da08d8218d --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -0,0 +1,49 @@ +package com.github.unchama.seichiassist.menus + +import cats.effect.IO +import com.github.unchama.itemstackbuilder.IconItemStackBuilder +import com.github.unchama.menuinventory.slot.button.Button +import com.github.unchama.menuinventory.syntax.IntInventorySizeOps +import com.github.unchama.menuinventory.{Menu, MenuFrame, MenuSlotLayout} +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI +import org.bukkit.entity.Player +import org.bukkit.ChatColor._ +import org.bukkit.Material + +import java.util.UUID + +object VoteMenu extends Menu { + + class Environment(implicit val voteAPI: VoteAPI[IO]) + + /** + * メニューのサイズとタイトルに関する情報 + */ + override val frame: MenuFrame = MenuFrame(4.chestRows, s"$DARK_PURPLE${BOLD}投票ptメニュー") + + /** + * @return + * `player`からメニューの[[MenuSlotLayout]]を計算する[[IO]] + */ + override def computeMenuLayout(player: Player)( + implicit environment: Environment + ): IO[MenuSlotLayout] = {} + + private object ConstantButtons { + + def receiveVoteBenefits(uuid: UUID): Button = Button( + new IconItemStackBuilder(Material.DIAMOND) + .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}クリックで投票特典を受け取れます") + .lore( + List( + s"$RESET${GRAY}投票特典を受け取るには", + s"$RESET${GRAY}投票ページで投票した後", + s"$RESET${AQUA}特典受け取り済み投票回数: ", + s"$RESET${AQUA}特典未受け取り投票係数", + s"$RESET${AQUA}所有pt: " + ) + ) + ) + + } +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index 8bf72a6c33..52dc7c00af 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -6,13 +6,12 @@ import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.vote.bukkit.command.VoteCommand import com.github.unchama.seichiassist.subsystems.vote.domain.{ ChainVoteDayNumber, + EffectPoint, PlayerName, - VotePoint -} -import com.github.unchama.seichiassist.subsystems.vote.infrastructure.{ - JdbcChainVotePersistence, - JdbcVotePointPersistence + VoteBenefit, + VoteCounter } +import com.github.unchama.seichiassist.subsystems.vote.infrastructure.JdbcVotePersistence import org.bukkit.command.TabExecutor import java.util.UUID @@ -24,22 +23,33 @@ trait System[F[_]] extends Subsystem[F] { object System { def wired[F[_]: ConcurrentEffect: OnMinecraftServerThread]: System[F] = { - val chainVotePersistence = new JdbcChainVotePersistence[F] - val votePointPersistence = new JdbcVotePointPersistence[F] + val votePersistence = new JdbcVotePersistence[F] new System[F] { override implicit val api: VoteAPI[F] = new VoteAPI[F] { - override def incrementVotePoint(playerName: PlayerName): F[Unit] = - votePointPersistence.increment(playerName) + override def voteCounterIncrement(playerName: PlayerName): F[Unit] = + votePersistence.voteCounterIncrement(playerName) override def updateChainVote(playerName: PlayerName): F[Unit] = - chainVotePersistence.updateChainVote(playerName) + votePersistence.updateChainVote(playerName) - override def votePoint(uuid: UUID): F[VotePoint] = - votePointPersistence.votePoint(uuid) + override def voteCounter(uuid: UUID): F[VoteCounter] = + votePersistence.voteCounter(uuid) override def chainVoteDayNumber(uuid: UUID): F[ChainVoteDayNumber] = - chainVotePersistence.getChainVoteDays(uuid) + votePersistence.chainVoteDays(uuid) + + override def increaseEffectPointsByTen(playerName: PlayerName): F[Unit] = + votePersistence.increaseEffectPointsByTen(playerName) + + override def effectPoints(uuid: UUID): F[EffectPoint] = + votePersistence.effectPoints(uuid) + + override def increaseVoteBenefits(uuid: UUID, benefit: VoteBenefit): F[Unit] = + votePersistence.increaseVoteBenefits(uuid, benefit) + + override def receivedVoteBenefits(uuid: UUID): F[VoteBenefit] = + votePersistence.receivedVoteBenefits(uuid) } override val commands: Map[String, TabExecutor] = Map( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index 0a7f47e8f4..ca92fa5071 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -2,8 +2,10 @@ package com.github.unchama.seichiassist.subsystems.vote import com.github.unchama.seichiassist.subsystems.vote.domain.{ ChainVoteDayNumber, + EffectPoint, PlayerName, - VotePoint + VoteBenefit, + VoteCounter } import java.util.UUID @@ -13,13 +15,23 @@ trait VoteWriteAPI[F[_]] { /** * 投票ポイントをインクリメントする作用 */ - def incrementVotePoint(playerName: PlayerName): F[Unit] + def voteCounterIncrement(playerName: PlayerName): F[Unit] /** * 連続投票を更新する作用 */ def updateChainVote(playerName: PlayerName): F[Unit] + /** + * effectPointを10増加させる作用 + */ + def increaseEffectPointsByTen(playerName: PlayerName): F[Unit] + + /** + * 投票特典を受け取った回数を増加させる作用 + */ + def increaseVoteBenefits(uuid: UUID, benefit: VoteBenefit): F[Unit] + } object VoteWriteAPI { @@ -31,15 +43,25 @@ object VoteWriteAPI { trait VoteReadAPI[F[_]] { /** - * 投票ポイントを返す作用 + * 投票回数を返す作用 */ - def votePoint(uuid: UUID): F[VotePoint] + def voteCounter(uuid: UUID): F[VoteCounter] /** * 連続投票日数を返す作用 */ def chainVoteDayNumber(uuid: UUID): F[ChainVoteDayNumber] + /** + * effectPointを返す作用 + */ + def effectPoints(uuid: UUID): F[EffectPoint] + + /** + * 投票特典を受け取った回数を返す作用 + */ + def receivedVoteBenefits(uuid: UUID): F[VoteBenefit] + } object VoteReadAPI { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala index b02208618c..88548743f6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala @@ -1,5 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.bukkit.command +import cats.Monad import cats.effect.ConcurrentEffect import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import com.github.unchama.contextualexecutor.builder.ContextualExecutorBuilder @@ -17,7 +18,11 @@ class VoteCommand[F[_]: ConcurrentEffect](implicit voteAPI: VoteAPI[F]) { MessageEffect(List(s"$RED/vote record <プレイヤー名>", "投票特典配布用コマンドです")) ) - private val recordExecutor = + import cats.implicits._ + + private val recordExecutor = { + implicit val F: Monad[F] = Monad[F] + ContextualExecutorBuilder .beginConfiguration() .executionCSEffect { context => @@ -27,12 +32,16 @@ class VoteCommand[F[_]: ConcurrentEffect](implicit voteAPI: VoteAPI[F]) { MessageEffect(s"$YELLOW${lowerCasePlayerName}の特典配布処理開始…"), UnfocusedEffect { val playerName = PlayerName(lowerCasePlayerName) - voteAPI.incrementVotePoint(playerName).toIO.unsafeRunAsyncAndForget() - voteAPI.updateChainVote(playerName).toIO.unsafeRunAsyncAndForget() + val eff = for { + _ <- voteAPI.voteCounterIncrement(playerName) + _ <- voteAPI.updateChainVote(playerName) + } yield () + eff.toIO } ) } .build() + } val executor: TabExecutor = { BranchedExecutor( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVoteDayNumber.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVoteDayNumber.scala index f2232fcba7..c18ce82a21 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVoteDayNumber.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVoteDayNumber.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.domain -case class ChainVoteDayNumber(dayNumber: Int) extends AnyVal { - require(dayNumber >= 0, "投票日数は非負である必要があります。") +case class ChainVoteDayNumber(value: Int) extends AnyVal { + require(value >= 0, "投票日数は非負である必要があります。") } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVotePersistence.scala deleted file mode 100644 index 8660ca47d1..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVotePersistence.scala +++ /dev/null @@ -1,11 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.domain - -import java.util.UUID - -trait ChainVotePersistence[F[_]] { - - def updateChainVote(playerName: PlayerName): F[Unit] - - def getChainVoteDays(uuid: UUID): F[ChainVoteDayNumber] - -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/EffectPoint.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/EffectPoint.scala new file mode 100644 index 0000000000..b5e54305ba --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/EffectPoint.scala @@ -0,0 +1,5 @@ +package com.github.unchama.seichiassist.subsystems.vote.domain + +case class EffectPoint(value: Int) extends AnyVal { + require(value >= 0) +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteBenefit.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteBenefit.scala new file mode 100644 index 0000000000..dae9912b95 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteBenefit.scala @@ -0,0 +1,5 @@ +package com.github.unchama.seichiassist.subsystems.vote.domain + +case class VoteBenefit(value: Int) extends AnyVal { + require(value >= 0) +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCounter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCounter.scala new file mode 100644 index 0000000000..8fe1936814 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCounter.scala @@ -0,0 +1,5 @@ +package com.github.unchama.seichiassist.subsystems.vote.domain + +case class VoteCounter(value: Int) extends AnyVal { + require(value >= 0, "votePointは非負である必要があります。") +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala new file mode 100644 index 0000000000..8b0954bf11 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala @@ -0,0 +1,47 @@ +package com.github.unchama.seichiassist.subsystems.vote.domain + +import java.util.UUID + +trait VotePersistence[F[_]] { + + /** + * 投票回数をインクリメントする作用 + */ + def voteCounterIncrement(playerName: PlayerName): F[Unit] + + /** + * 投票回数を返す作用 + */ + def voteCounter(uuid: UUID): F[VoteCounter] + + /** + * 連続投票回数を更新する作用 + */ + def updateChainVote(playerName: PlayerName): F[Unit] + + /** + * 連続投票日数を返す作用 + */ + def chainVoteDays(uuid: UUID): F[ChainVoteDayNumber] + + /** + * effectPointを10増加させる作用 + */ + def increaseEffectPointsByTen(playerName: PlayerName): F[Unit] + + /** + * effectPointを返す作用 + */ + def effectPoints(uuid: UUID): F[EffectPoint] + + /** + * 投票特典を受け取った回数を増加させる作用 + */ + def increaseVoteBenefits(uuid: UUID, amount: VoteBenefit): F[Unit] + + /** + * 投票特典を受け取った回数を返す作用 + */ + def receivedVoteBenefits(uuid: UUID): F[VoteBenefit] + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePoint.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePoint.scala deleted file mode 100644 index a5789c9f2d..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePoint.scala +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.domain - -case class VotePoint(point: Int) extends AnyVal { - require(point >= 0, "votePointは非負である必要があります。") -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePointPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePointPersistence.scala deleted file mode 100644 index 7a0b0141cf..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePointPersistence.scala +++ /dev/null @@ -1,11 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.domain - -import java.util.UUID - -trait VotePointPersistence[F[_]] { - - def increment(playerName: PlayerName): F[Unit] - - def votePoint(uuid: UUID): F[VotePoint] - -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala deleted file mode 100644 index 787b6d264d..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcChainVotePersistence.scala +++ /dev/null @@ -1,42 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.infrastructure - -import cats.effect.Sync -import com.github.unchama.seichiassist.subsystems.vote.domain.{ - ChainVoteDayNumber, - ChainVotePersistence, - PlayerName -} -import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} - -import java.util.UUID - -class JdbcChainVotePersistence[F[_]: Sync] extends ChainVotePersistence[F] { - // NOTE: 連続投票許容幅を変更する場合はここを変更してください。 - private val chainVoteAllowableWidth = 4 - - override def updateChainVote(playerName: PlayerName): F[Unit] = Sync[F].delay { - DB.localTx { implicit session => - /* - NOTE: 最終投票日時より(連続投票許容幅 - 1)した日時よりも - 小さかった場合に連続投票を0に戻します。 - */ - sql"""UPDATE playerdata SET chainvote = - | CASE WHEN DATEDIFF(last_vote, NOW()) <= ${-chainVoteAllowableWidth - 1} - | THEN 0 - | ELSE chainvote + 1 - | END - | WHERE name = $playerName""".stripMargin.execute().apply() - } - } - - override def getChainVoteDays(uuid: UUID): F[ChainVoteDayNumber] = Sync[F].delay { - DB.readOnly { implicit session => - val chainVoteDays = sql"SELECT chainvote FROM playerdata WHERE uuid = ${uuid.toString}" - .map(_.int("chainvote")) - .single() - .apply() - .get - ChainVoteDayNumber(chainVoteDays) - } - } -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala new file mode 100644 index 0000000000..76c2779a37 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -0,0 +1,120 @@ +package com.github.unchama.seichiassist.subsystems.vote.infrastructure + +import cats.effect.Sync +import com.github.unchama.seichiassist.subsystems.vote.domain._ +import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} + +import java.util.UUID + +class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { + + // NOTE: 連続投票許容幅を変更する場合はここを変更してください。 + private val chainVoteAllowableWidth = 4 + + /** + * 投票回数をインクリメントする作用 + */ + override def voteCounterIncrement(playerName: PlayerName): F[Unit] = Sync[F].delay { + DB.localTx { implicit session => + sql"UPDATE playerdata SET p_vote = p_vote + 1 WHERE name = ${playerName.name}" + .execute() + .apply() + } + } + + /** + * 投票回数を返す作用 + */ + override def voteCounter(uuid: UUID): F[VoteCounter] = Sync[F].delay { + DB.readOnly { implicit session => + val votePoint = sql"SELECT p_vote FROM playerdata WHERE uuid = ${uuid.toString}" + .map(_.int("p_vote")) + .single() + .apply() + .get + VoteCounter(votePoint) + } + } + + /** + * 連続投票回数を更新する作用 + */ + override def updateChainVote(playerName: PlayerName): F[Unit] = Sync[F].delay { + DB.localTx { implicit session => + /* + NOTE: 最終投票日時より(連続投票許容幅 - 1)した日時よりも + 小さかった場合に連続投票を0に戻します。 + */ + sql"""UPDATE playerdata SET chainvote = + | CASE WHEN DATEDIFF(last_vote, NOW()) <= ${-chainVoteAllowableWidth - 1} + | THEN 0 + | ELSE chainvote + 1 + | END + | WHERE name = ${playerName.name}""".stripMargin.execute().apply() + } + } + + /** + * 連続投票日数を返す作用 + */ + override def chainVoteDays(uuid: UUID): F[ChainVoteDayNumber] = Sync[F].delay { + DB.readOnly { implicit session => + val chainVoteDays = sql"SELECT chainvote FROM playerdata WHERE uuid = ${uuid.toString}" + .map(_.int("chainvote")) + .single() + .apply() + .get + ChainVoteDayNumber(chainVoteDays) + } + } + + /** + * effectPointを10増加させる作用 + */ + override def increaseEffectPointsByTen(playerName: PlayerName): F[Unit] = Sync[F].delay { + DB.localTx { implicit session => + sql"UPDATE playerdata SET effectpoint = 10 WHERE name = ${playerName.name}" + .execute() + .apply() + } + } + + /** + * effectPointを返す作用 + */ + override def effectPoints(uuid: UUID): F[EffectPoint] = Sync[F].delay { + DB.readOnly { implicit session => + val effectPoints = sql"SELECT effectpoint FROM playerdata WHERE name = ${uuid.toString}" + .map(_.int("effectpoint")) + .single() + .apply() + .get + EffectPoint(effectPoints) + } + } + + /** + * 投票特典を受け取った回数を増加させる作用 + */ + override def increaseVoteBenefits(uuid: UUID, benefit: VoteBenefit): F[Unit] = Sync[F].delay { + DB.localTx { implicit session => + sql"UPDATE playerdata SET p_givenvote = p_givenvote + ${benefit.value} WHERE uuid = ${uuid.toString}" + .execute() + .apply() + } + } + + /** + * 投票特典を受け取った回数を返す作用 + */ + override def receivedVoteBenefits(uuid: UUID): F[VoteBenefit] = Sync[F].delay { + DB.readOnly { implicit session => + val benefits = sql"SELECT p_givenvote FROM playerdata WHERE uuid = ${uuid.toString}" + .map(_.int("p_givenvote")) + .single() + .apply() + .get + VoteBenefit(benefits) + } + } +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePointPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePointPersistence.scala deleted file mode 100644 index ed8804be30..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePointPersistence.scala +++ /dev/null @@ -1,30 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.infrastructure - -import cats.effect.Sync -import com.github.unchama.seichiassist.subsystems.vote.domain.{ - PlayerName, - VotePoint, - VotePointPersistence -} -import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} - -import java.util.UUID - -class JdbcVotePointPersistence[F[_]: Sync] extends VotePointPersistence[F] { - override def increment(playerName: PlayerName): F[Unit] = Sync[F].delay { - DB.localTx { implicit session => - sql"UPDATE playerdata SET p_vote = p_vote + 1 WHERE name = $playerName".execute().apply() - } - } - - override def votePoint(uuid: UUID): F[VotePoint] = Sync[F].delay { - DB.readOnly { implicit session => - val votePoint = sql"SELECT p_vote FROM playerdata WHERE uuid = ${uuid.toString}" - .map(_.int("p_vote")) - .single() - .apply() - .get - VotePoint(votePoint) - } - } -} From 05b8238842ac164adb885561d84a934d3de2db9f Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 23 Jul 2022 22:31:34 +0900 Subject: [PATCH 011/482] =?UTF-8?q?[Add]BukkitReceiveVoteBenefits=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 33 +++++++----- .../seichiassist/subsystems/vote/System.scala | 11 +++- .../subsystems/vote/VoteAPI.scala | 15 +++--- .../actions/ReceiveVoteBenefits.scala | 20 ++++++++ .../actions/BukkitReceiveVoteBenefits.scala | 51 +++++++++++++++++++ .../vote/domain/VotePersistence.scala | 2 +- .../infrastructure/JdbcVotePersistence.scala | 4 +- 7 files changed, 111 insertions(+), 25 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index da08d8218d..24d6d880c1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -3,6 +3,7 @@ package com.github.unchama.seichiassist.menus import cats.effect.IO import com.github.unchama.itemstackbuilder.IconItemStackBuilder import com.github.unchama.menuinventory.slot.button.Button +import com.github.unchama.menuinventory.slot.button.action.LeftClickButtonEffect import com.github.unchama.menuinventory.syntax.IntInventorySizeOps import com.github.unchama.menuinventory.{Menu, MenuFrame, MenuSlotLayout} import com.github.unchama.seichiassist.subsystems.vote.VoteAPI @@ -31,19 +32,27 @@ object VoteMenu extends Menu { private object ConstantButtons { - def receiveVoteBenefits(uuid: UUID): Button = Button( - new IconItemStackBuilder(Material.DIAMOND) - .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}クリックで投票特典を受け取れます") - .lore( - List( - s"$RESET${GRAY}投票特典を受け取るには", - s"$RESET${GRAY}投票ページで投票した後", - s"$RESET${AQUA}特典受け取り済み投票回数: ", - s"$RESET${AQUA}特典未受け取り投票係数", - s"$RESET${AQUA}所有pt: " + def receiveVoteBenefits(uuid: UUID)(implicit voteAPI: VoteAPI[IO]): Button = for { + benefits <- voteAPI.receivedVoteBenefits(uuid) + voteCounter <- voteAPI.voteCounter(uuid) + effectPoint <- voteAPI.effectPoints(uuid) + } yield { + Button( + new IconItemStackBuilder(Material.DIAMOND) + .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}クリックで投票特典を受け取れます") + .lore( + List( + s"$RESET${GRAY}投票特典を受け取るには", + s"$RESET${GRAY}投票ページで投票した後", + s"$RESET${AQUA}特典受け取り済み投票回数: ${benefits.value}", + s"$RESET${AQUA}特典未受け取り投票係数: ${voteCounter.value - benefits.value}", + s"$RESET${AQUA}所有pt: ${effectPoint.value}" + ) ) - ) - ) + .build(), + LeftClickButtonEffect {} + ) + } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index 52dc7c00af..83e3d57742 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -39,8 +39,8 @@ object System { override def chainVoteDayNumber(uuid: UUID): F[ChainVoteDayNumber] = votePersistence.chainVoteDays(uuid) - override def increaseEffectPointsByTen(playerName: PlayerName): F[Unit] = - votePersistence.increaseEffectPointsByTen(playerName) + override def increaseEffectPointsByTen(uuid: UUID): F[Unit] = + votePersistence.increaseEffectPointsByTen(uuid) override def effectPoints(uuid: UUID): F[EffectPoint] = votePersistence.effectPoints(uuid) @@ -50,6 +50,13 @@ object System { override def receivedVoteBenefits(uuid: UUID): F[VoteBenefit] = votePersistence.receivedVoteBenefits(uuid) + + import cats.implicits._ + + override def notReceivedVoteBenefits(uuid: UUID): F[VoteBenefit] = for { + voteCounter <- voteCounter(uuid) + receivedVote <- receivedVoteBenefits(uuid) + } yield voteCounter.value - receivedVote.value } override val commands: Map[String, TabExecutor] = Map( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index ca92fa5071..6dcc3d8b9f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -1,12 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote -import com.github.unchama.seichiassist.subsystems.vote.domain.{ - ChainVoteDayNumber, - EffectPoint, - PlayerName, - VoteBenefit, - VoteCounter -} +import com.github.unchama.seichiassist.subsystems.vote.domain._ import java.util.UUID @@ -25,7 +19,7 @@ trait VoteWriteAPI[F[_]] { /** * effectPointを10増加させる作用 */ - def increaseEffectPointsByTen(playerName: PlayerName): F[Unit] + def increaseEffectPointsByTen(uuid: UUID): F[Unit] /** * 投票特典を受け取った回数を増加させる作用 @@ -62,6 +56,11 @@ trait VoteReadAPI[F[_]] { */ def receivedVoteBenefits(uuid: UUID): F[VoteBenefit] + /** + * 投票特典を受け取っていない回数を返す作用 + */ + def notReceivedVoteBenefits(uuid: UUID): F[VoteBenefit] + } object VoteReadAPI { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala new file mode 100644 index 0000000000..daeadd24fb --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala @@ -0,0 +1,20 @@ +package com.github.unchama.seichiassist.subsystems.vote.application.actions + +import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI + +trait ReceiveVoteBenefits[F[_], G[_], Player] { + + def receive( + player: Player + )(implicit voteAPI: VoteAPI[F], breakCountAPI: BreakCountAPI[F, G, Player]): F[Unit] + +} + +object ReceiveVoteBenefits { + + def apply[F[_], G[_], Player]( + implicit ev: ReceiveVoteBenefits[F, G, Player] + ): ReceiveVoteBenefits[F, G, Player] = ev + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala new file mode 100644 index 0000000000..611e83de7f --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -0,0 +1,51 @@ +package com.github.unchama.seichiassist.subsystems.vote.bukkit.actions + +import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps +import cats.effect.{ConcurrentEffect, Sync} +import com.github.unchama.generic.ContextCoercion +import com.github.unchama.minecraft.actions.OnMinecraftServerThread +import com.github.unchama.seichiassist.data.{GachaSkullData, ItemData} +import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI +import com.github.unchama.seichiassist.subsystems.vote.application.actions.ReceiveVoteBenefits +import com.github.unchama.seichiassist.util.InventoryOperations.grantItemStacksEffect +import org.bukkit.entity.Player + +object BukkitReceiveVoteBenefits { + + import cats.implicits._ + + def apply[F[_]: OnMinecraftServerThread: ConcurrentEffect, G[_]: Sync: ContextCoercion[*[ + _ + ], F]]: ReceiveVoteBenefits[F, G, Player] = + new ReceiveVoteBenefits[F, G, Player] { + override def receive( + player: Player + )(implicit voteAPI: VoteAPI[F], breakCountAPI: BreakCountAPI[F, G, Player]): F[Unit] = { + val uuid = player.getUniqueId + for { + notReceivedBenefits <- voteAPI.notReceivedVoteBenefits(uuid) // 受け取っていない投票特典数 + } yield { + if (notReceivedBenefits.value == 0) return Sync[F].pure() + + voteAPI.increaseVoteBenefits(uuid, notReceivedBenefits).toIO.unsafeRunAsyncAndForget() + + val playerLevel = + ContextCoercion(breakCountAPI.seichiAmountDataRepository[G](player).read.map { + _.levelCorrespondingToExp.level + }).toIO.unsafeRunSync() + + val items = (0 until notReceivedBenefits.value).map { _ => + voteAPI.increaseEffectPointsByTen(uuid).toIO.unsafeRunAsyncAndForget() + Seq.fill(10)(GachaSkullData.gachaForVoting) ++ + Seq( + if (playerLevel < 50) ItemData.getSuperPickaxe(1) else ItemData.getVotingGift(1) + ) + } + + grantItemStacksEffect[F](items.flatten: _*) + } + } + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala index 8b0954bf11..6749e52650 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala @@ -27,7 +27,7 @@ trait VotePersistence[F[_]] { /** * effectPointを10増加させる作用 */ - def increaseEffectPointsByTen(playerName: PlayerName): F[Unit] + def increaseEffectPointsByTen(uuid: UUID): F[Unit] /** * effectPointを返す作用 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index 76c2779a37..07cd0c87ea 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -71,9 +71,9 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { /** * effectPointを10増加させる作用 */ - override def increaseEffectPointsByTen(playerName: PlayerName): F[Unit] = Sync[F].delay { + override def increaseEffectPointsByTen(uuid: UUID): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET effectpoint = 10 WHERE name = ${playerName.name}" + sql"UPDATE playerdata SET effectpoint = 10 WHERE uuid = ${uuid.toString}" .execute() .apply() } From 3c2af7597c3921d8b233329a565865083f8d4338 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 23 Jul 2022 22:49:12 +0900 Subject: [PATCH 012/482] =?UTF-8?q?[Add]receiveVoteBenefits=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 65 ++++++++++++------- .../actions/BukkitReceiveVoteBenefits.scala | 15 +++-- 2 files changed, 51 insertions(+), 29 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 24d6d880c1..535417cc36 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -1,21 +1,29 @@ package com.github.unchama.seichiassist.menus -import cats.effect.IO +import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.itemstackbuilder.IconItemStackBuilder import com.github.unchama.menuinventory.slot.button.Button import com.github.unchama.menuinventory.slot.button.action.LeftClickButtonEffect import com.github.unchama.menuinventory.syntax.IntInventorySizeOps import com.github.unchama.menuinventory.{Menu, MenuFrame, MenuSlotLayout} +import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts +import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMainThread +import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI -import org.bukkit.entity.Player +import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits +import com.github.unchama.targetedeffect.{DeferredEffect, SequentialEffect, TargetedEffect} import org.bukkit.ChatColor._ import org.bukkit.Material +import org.bukkit.entity.Player import java.util.UUID object VoteMenu extends Menu { - class Environment(implicit val voteAPI: VoteAPI[IO]) + class Environment( + implicit val voteAPI: VoteAPI[IO], + breakCountAPI: BreakCountAPI[IO, SyncIO, Player] + ) /** * メニューのサイズとタイトルに関する情報 @@ -32,27 +40,38 @@ object VoteMenu extends Menu { private object ConstantButtons { - def receiveVoteBenefits(uuid: UUID)(implicit voteAPI: VoteAPI[IO]): Button = for { - benefits <- voteAPI.receivedVoteBenefits(uuid) - voteCounter <- voteAPI.voteCounter(uuid) - effectPoint <- voteAPI.effectPoints(uuid) - } yield { - Button( - new IconItemStackBuilder(Material.DIAMOND) - .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}クリックで投票特典を受け取れます") - .lore( - List( - s"$RESET${GRAY}投票特典を受け取るには", - s"$RESET${GRAY}投票ページで投票した後", - s"$RESET${AQUA}特典受け取り済み投票回数: ${benefits.value}", - s"$RESET${AQUA}特典未受け取り投票係数: ${voteCounter.value - benefits.value}", - s"$RESET${AQUA}所有pt: ${effectPoint.value}" + def receiveVoteBenefits(uuid: UUID)( + implicit voteAPI: VoteAPI[IO], + breakCountAPI: BreakCountAPI[IO, SyncIO, Player] + ): Button = { + for { + benefits <- voteAPI.receivedVoteBenefits(uuid) + voteCounter <- voteAPI.voteCounter(uuid) + effectPoint <- voteAPI.effectPoints(uuid) + } yield { + Button( + new IconItemStackBuilder(Material.DIAMOND) + .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}クリックで投票特典を受け取れます") + .lore( + List( + s"$RESET${GRAY}投票特典を受け取るには", + s"$RESET${GRAY}投票ページで投票した後", + s"$RESET${AQUA}特典受け取り済み投票回数: ${benefits.value}", + s"$RESET${AQUA}特典未受け取り投票係数: ${voteCounter.value - benefits.value}", + s"$RESET${AQUA}所有pt: ${effectPoint.value}" + ) ) - ) - .build(), - LeftClickButtonEffect {} - ) - } + .build(), + LeftClickButtonEffect { + implicit val ioCE: ConcurrentEffect[IO] = + IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) + TargetedEffect.delay { player => + BukkitReceiveVoteBenefits[IO, SyncIO].receive(player).unsafeRunAsyncAndForget() + } + } + ) + } + }.unsafeRunSync() } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 611e83de7f..3450e70015 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -1,7 +1,7 @@ package com.github.unchama.seichiassist.subsystems.vote.bukkit.actions import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps -import cats.effect.{ConcurrentEffect, Sync} +import cats.effect.{ConcurrentEffect, Sync, SyncEffect} import com.github.unchama.generic.ContextCoercion import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.data.{GachaSkullData, ItemData} @@ -15,9 +15,13 @@ object BukkitReceiveVoteBenefits { import cats.implicits._ - def apply[F[_]: OnMinecraftServerThread: ConcurrentEffect, G[_]: Sync: ContextCoercion[*[ - _ - ], F]]: ReceiveVoteBenefits[F, G, Player] = + /** + * 投票特典を配布する + */ + def apply[F[_]: OnMinecraftServerThread: ConcurrentEffect, G[_]: SyncEffect: ContextCoercion[ + *[_], + F + ]]: ReceiveVoteBenefits[F, G, Player] = new ReceiveVoteBenefits[F, G, Player] { override def receive( player: Player @@ -25,11 +29,10 @@ object BukkitReceiveVoteBenefits { val uuid = player.getUniqueId for { notReceivedBenefits <- voteAPI.notReceivedVoteBenefits(uuid) // 受け取っていない投票特典数 + _ <- voteAPI.increaseVoteBenefits(uuid, notReceivedBenefits) // 受け取ってない分を受け取ったことにする } yield { if (notReceivedBenefits.value == 0) return Sync[F].pure() - voteAPI.increaseVoteBenefits(uuid, notReceivedBenefits).toIO.unsafeRunAsyncAndForget() - val playerLevel = ContextCoercion(breakCountAPI.seichiAmountDataRepository[G](player).read.map { _.levelCorrespondingToExp.level From dbac37fd5457c0f3b7c76cefe7361e7349abb494 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 23 Jul 2022 23:04:16 +0900 Subject: [PATCH 013/482] =?UTF-8?q?[Add]showVoteURL=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 48 +++++++++++++++++-- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 535417cc36..4fc0079ebd 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -11,9 +11,13 @@ import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMain import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits -import com.github.unchama.targetedeffect.{DeferredEffect, SequentialEffect, TargetedEffect} +import com.github.unchama.seichiassist.util.SendSoundEffect +import com.github.unchama.targetedeffect.commandsender.MessageEffect +import com.github.unchama.targetedeffect.player.FocusedSoundEffect +import com.github.unchama.targetedeffect.player.PlayerEffects.closeInventoryEffect +import com.github.unchama.targetedeffect.{SequentialEffect, TargetedEffect} import org.bukkit.ChatColor._ -import org.bukkit.Material +import org.bukkit.{Material, Sound} import org.bukkit.entity.Player import java.util.UUID @@ -61,17 +65,51 @@ object VoteMenu extends Menu { s"$RESET${AQUA}所有pt: ${effectPoint.value}" ) ) + .enchanted() .build(), LeftClickButtonEffect { implicit val ioCE: ConcurrentEffect[IO] = IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) - TargetedEffect.delay { player => - BukkitReceiveVoteBenefits[IO, SyncIO].receive(player).unsafeRunAsyncAndForget() - } + SequentialEffect( + TargetedEffect.delay { player => + BukkitReceiveVoteBenefits[IO, SyncIO].receive(player).unsafeRunAsyncAndForget() + }, + MessageEffect( + s"${GOLD}投票特典$WHITE(${voteCounter.value - benefits.value}票分)を受け取りました" + ) + ) } ) } }.unsafeRunSync() + val showVoteURL: Button = Button( + new IconItemStackBuilder(Material.BOOK_AND_QUILL) + .title(s"$YELLOW$UNDERLINE${BOLD}投票ページにアクセス") + .lore( + List( + s"$RESET${GREEN}投票すると様々な特典が!", + s"$RESET${GREEN}1日1回投票できます", + s"$RESET${DARK_GRAY}クリックするとチャット欄に", + s"$RESET${DARK_GRAY}URLが表示されますので", + s"$RESET${DARK_GRAY}Tキーを押してから", + s"$RESET${DARK_GRAY}そのURLをクリックしてください" + ) + ) + .build(), + LeftClickButtonEffect { + SequentialEffect { + MessageEffect( + List( + s"$RED${UNDERLINE}https://minecraft.jp/servers/54d3529e4ddda180780041a7/vote", + s"$RED${UNDERLINE}https://monocraft.net/servers/Cf3BffNIRMERDNbAfWQm" + ) + ) + FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) + closeInventoryEffect + } + } + ) + } } From 4278c23e9e3ab376d50395f6dd752336f82b8722 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 23 Jul 2022 23:27:44 +0900 Subject: [PATCH 014/482] =?UTF-8?q?[Add]fairySummonTimeToggleButton?= =?UTF-8?q?=E3=82=92=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 4fc0079ebd..820efa684a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -6,19 +6,20 @@ import com.github.unchama.menuinventory.slot.button.Button import com.github.unchama.menuinventory.slot.button.action.LeftClickButtonEffect import com.github.unchama.menuinventory.syntax.IntInventorySizeOps import com.github.unchama.menuinventory.{Menu, MenuFrame, MenuSlotLayout} +import com.github.unchama.seichiassist.SeichiAssist import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMainThread import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits -import com.github.unchama.seichiassist.util.SendSoundEffect +import com.github.unchama.seichiassist.task.VotingFairyTask import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.player.PlayerEffects.closeInventoryEffect -import com.github.unchama.targetedeffect.{SequentialEffect, TargetedEffect} +import com.github.unchama.targetedeffect.{SequentialEffect, TargetedEffect, UnfocusedEffect} import org.bukkit.ChatColor._ -import org.bukkit.{Material, Sound} import org.bukkit.entity.Player +import org.bukkit.{Material, Sound} import java.util.UUID @@ -44,7 +45,7 @@ object VoteMenu extends Menu { private object ConstantButtons { - def receiveVoteBenefits(uuid: UUID)( + def receiveVoteBenefitsButton(uuid: UUID)( implicit voteAPI: VoteAPI[IO], breakCountAPI: BreakCountAPI[IO, SyncIO, Player] ): Button = { @@ -83,7 +84,7 @@ object VoteMenu extends Menu { } }.unsafeRunSync() - val showVoteURL: Button = Button( + val showVoteURLButton: Button = Button( new IconItemStackBuilder(Material.BOOK_AND_QUILL) .title(s"$YELLOW$UNDERLINE${BOLD}投票ページにアクセス") .lore( @@ -111,5 +112,32 @@ object VoteMenu extends Menu { } ) + def fairySummonTimeToggleButton(uuid: UUID): Button = { + val playerData = SeichiAssist.playermap(uuid) + Button( + new IconItemStackBuilder(Material.WATCH) + .title(s"$AQUA$UNDERLINE${BOLD}マナ妖精 時間設定") + .lore( + List( + s"$RESET$GREEN$BOLD${VotingFairyTask.dispToggleVFTime(playerData.toggleVotingFairy)}", + "", + s"$RESET${GRAY}コスト", + s"$RESET$RED$BOLD${playerData.toggleVotingFairy * 2}投票pt", + "", + s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え" + ) + ) + .build(), + LeftClickButtonEffect { + SequentialEffect { + FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) + UnfocusedEffect { + playerData.toggleVotingFairy = playerData.toggleVotingFairy % 4 + 1 + } + } + } + ) + } + } } From 42eef6723ca026863108f82d4eeedaf8cfb8a38f Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 24 Jul 2022 10:34:55 +0900 Subject: [PATCH 015/482] =?UTF-8?q?[Add]FailryLoreTable=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 5 +++ .../subsystems/fairy/domain/FairyLore.scala | 5 +++ .../fairy/domain/bukkit/FairyLoreTable.scala | 37 +++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyLore.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/bukkit/FairyLoreTable.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 820efa684a..d61f27b486 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -139,5 +139,10 @@ object VoteMenu extends Menu { ) } + def fairyContractSettingToggle(uuid: UUID): Button = { + val playerData = SeichiAssist.playermap(uuid) + Button(new IconItemStackBuilder(Material.PAPER).title(s"$GOLD$UNDERLINE${BOLD}妖精とのお約束")) + } + } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyLore.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyLore.scala new file mode 100644 index 0000000000..13048a7121 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyLore.scala @@ -0,0 +1,5 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +import cats.data.NonEmptyList + +case class FairyLore(lore: NonEmptyList[String]) {} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/bukkit/FairyLoreTable.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/bukkit/FairyLoreTable.scala new file mode 100644 index 0000000000..498156ee84 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/bukkit/FairyLoreTable.scala @@ -0,0 +1,37 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit + +import cats.data.NonEmptyList +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyLore +import org.bukkit.ChatColor._ + +object FairyLoreTable { + + val loreTable: List[FairyLore] = List( + FairyLore( + NonEmptyList.of( + s"$RED$UNDERLINE${BOLD}ガンガンたべるぞ", + s"$RESET${GRAY}とにかく妖精さんにりんごを開放します。", + s"$RESET${GRAY}めっちゃ喜ばれます。" + ) + ), + FairyLore( + NonEmptyList.of( + s"$YELLOW$UNDERLINE${BOLD}バッチリたべよう", + s"$RESET${GRAY}食べ過ぎないように注意しつつ", + s"$RESET${GRAY}妖精さんにりんごを開放します。", + s"$RESET${GRAY}喜ばれます。" + ) + ), + FairyLore( + NonEmptyList.of( + s"$GREEN$UNDERLINE${BOLD}リンゴだいじに", + s"$RESET${GRAY}少しだけ妖精さんにりんごを開放します。", + s"$RESET${GRAY}伝えると大抵落ち込みます。" + ) + ), + FairyLore( + NonEmptyList.of(s"$BLUE$UNDERLINE${BOLD}リンゴつかうな", s"$RESET${GRAY}絶対にりんごを開放しません。", "") + ) + ) + +} From 28422d60f7d1b5c4071d1c11edd2601a2ccf4f5f Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 24 Jul 2022 13:09:03 +0900 Subject: [PATCH 016/482] =?UTF-8?q?[Fix]SequentialEffect=E3=81=AE=E3=81=8B?= =?UTF-8?q?=E3=81=A3=E3=81=93=E3=82=92=E4=B8=B8=E6=8B=AC=E5=BC=A7=E3=81=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index d61f27b486..68a1163903 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -99,16 +99,16 @@ object VoteMenu extends Menu { ) .build(), LeftClickButtonEffect { - SequentialEffect { + SequentialEffect( MessageEffect( List( s"$RED${UNDERLINE}https://minecraft.jp/servers/54d3529e4ddda180780041a7/vote", s"$RED${UNDERLINE}https://monocraft.net/servers/Cf3BffNIRMERDNbAfWQm" ) - ) - FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) + ), + FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), closeInventoryEffect - } + ) } ) @@ -129,12 +129,10 @@ object VoteMenu extends Menu { ) .build(), LeftClickButtonEffect { - SequentialEffect { - FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) - UnfocusedEffect { - playerData.toggleVotingFairy = playerData.toggleVotingFairy % 4 + 1 - } - } + SequentialEffect( + FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), + UnfocusedEffect(playerData.toggleVotingFairy = playerData.toggleVotingFairy % 4 + 1) + ) } ) } From 3601e32f44a989467c30d903eb248ec206b5d349 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 24 Jul 2022 13:58:34 +0900 Subject: [PATCH 017/482] =?UTF-8?q?[Remove]=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E3=82=AB=E3=83=83=E3=82=B3=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/domain/FairyLore.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyLore.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyLore.scala index 13048a7121..d87b01fd17 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyLore.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyLore.scala @@ -2,4 +2,4 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain import cats.data.NonEmptyList -case class FairyLore(lore: NonEmptyList[String]) {} +case class FairyLore(lore: NonEmptyList[String]) From 7dc2816484610a29b1648103b6338c1c68cb299e Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 24 Jul 2022 15:21:11 +0900 Subject: [PATCH 018/482] =?UTF-8?q?[Add]FairyAPI=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/FairyAPI.scala | 38 ++++++++++++++++++ .../vote/subsystems/fairy/System.scala | 30 ++++++++++++++ .../fairy/domain/AppleOpenState.scala | 19 +++++++++ .../fairy/domain/FairyPersistence.scala | 17 ++++++++ .../infrastructure/JdbcFairyPersistence.scala | 40 +++++++++++++++++++ 5 files changed, 144 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/AppleOpenState.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala new file mode 100644 index 0000000000..05de2ed8be --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -0,0 +1,38 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy + +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.AppleOpenState + +import java.util.UUID + +trait FairyWriteAPI[F[_]] { + + /** + * 妖精にあげるりんごの開放状態を変更する + * ※妖精にあげるりんごの数を変更する + */ + def updateAppleOpenState(uuid: UUID, appleOpenState: AppleOpenState): F[Unit] + +} + +object FairyWriteAPI { + + def apply[F[_]](implicit ev: FairyWriteAPI[F]): FairyWriteAPI[F] = ev + +} + +trait FairyReadAPI[F[_]] { + + /** + * 妖精にあげるりんごの開放状態を取得する + */ + def appleOpenState(uuid: UUID): F[AppleOpenState] + +} + +object FairyReadAPI { + + def apply[F[_]](implicit ev: FairyReadAPI[F]): FairyReadAPI[F] = ev + +} + +trait FairyAPI[F[_]] extends FairyReadAPI[F] with FairyWriteAPI[F] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala new file mode 100644 index 0000000000..46aa351ed8 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -0,0 +1,30 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy + +import cats.effect.Sync +import com.github.unchama.minecraft.actions.OnMinecraftServerThread +import com.github.unchama.seichiassist.meta.subsystem.Subsystem +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.AppleOpenState +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence + +import java.util.UUID + +trait System[F[_]] extends Subsystem[F] { + val api: FairyAPI[F] +} + +object System { + + def wired[F[_]: Sync: OnMinecraftServerThread]: System[F] = { + val persistence = new JdbcFairyPersistence[F] + new System[F] { + override val api: FairyAPI[F] = new FairyAPI[F] { + override def appleOpenState(uuid: UUID): F[AppleOpenState] = + persistence.appleOpenState(uuid) + + override def updateAppleOpenState(uuid: UUID, appleOpenState: AppleOpenState): F[Unit] = + persistence.changeAppleOpenState(uuid, appleOpenState) + } + } + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/AppleOpenState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/AppleOpenState.scala new file mode 100644 index 0000000000..d1181f9f1e --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/AppleOpenState.scala @@ -0,0 +1,19 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +import enumeratum._ + +sealed class AppleOpenState(val amount: Int) extends EnumEntry + +case object AppleOpenState extends Enum[AppleOpenState] { + + override val values: IndexedSeq[AppleOpenState] = findValues + + case object OpenAnyway extends AppleOpenState(4) + + case object Open extends AppleOpenState(3) + + case object OpenALittle extends AppleOpenState(2) + + case object NotOpen extends AppleOpenState(1) + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala new file mode 100644 index 0000000000..df02952cd9 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -0,0 +1,17 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +import java.util.UUID + +trait FairyPersistence[F[_]] { + + /** + * 妖精に開放するりんごの状態を変更する + */ + def changeAppleOpenState(uuid: UUID, openState: AppleOpenState): F[Unit] + + /** + * 妖精に開放するりんごの状態を取得する + */ + def appleOpenState(uuid: UUID): F[AppleOpenState] + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala new file mode 100644 index 0000000000..7e7c21aea8 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -0,0 +1,40 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure + +import cats.effect.Sync +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + AppleOpenState, + FairyPersistence +} +import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} + +import java.util.UUID + +class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { + + /** + * 妖精に開放するりんごの状態を変更する + */ + override def changeAppleOpenState(uuid: UUID, openState: AppleOpenState): F[Unit] = + Sync[F].delay { + DB.localTx { implicit session => + sql"UPDATE playerdata SET toggleGiveApple = ${openState.amount} WHERE uuid = ${uuid.toString}" + .execute() + .apply() + } + } + + /** + * 妖精に開放するりんごの状態を取得する + */ + override def appleOpenState(uuid: UUID): F[AppleOpenState] = + Sync[F].delay { + val appleAmount = DB.readOnly { implicit session => + sql"SELECT toggleGiveApple FROM playerdata WHERE uuid = ${uuid.toString}" + .map(_.int("toggleGiveApple")) + .single() + .apply() + .get + } + AppleOpenState.values.find(_.amount == appleAmount).get + } +} From a8666c0e007dd72a8774b4664aefc7eec9fa0d87 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 24 Jul 2022 15:46:56 +0900 Subject: [PATCH 019/482] =?UTF-8?q?[Add]fairyContractSettingToggle?= =?UTF-8?q?=E3=82=92=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 29 +++++++++++++++++-- .../vote/subsystems/fairy/FairyAPI.scala | 10 ++++++- .../vote/subsystems/fairy/System.scala | 18 ++++++++++-- 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 68a1163903..4de768f7d0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -12,6 +12,8 @@ import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMain import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.AppleOpenState import com.github.unchama.seichiassist.task.VotingFairyTask import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect @@ -27,6 +29,7 @@ object VoteMenu extends Menu { class Environment( implicit val voteAPI: VoteAPI[IO], + fairyAPI: FairyAPI[IO], breakCountAPI: BreakCountAPI[IO, SyncIO, Player] ) @@ -137,9 +140,29 @@ object VoteMenu extends Menu { ) } - def fairyContractSettingToggle(uuid: UUID): Button = { - val playerData = SeichiAssist.playermap(uuid) - Button(new IconItemStackBuilder(Material.PAPER).title(s"$GOLD$UNDERLINE${BOLD}妖精とのお約束")) + def fairyContractSettingToggle(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { + Button( + new IconItemStackBuilder(Material.PAPER) + .title(s"$GOLD$UNDERLINE${BOLD}妖精とのお約束") + .lore(fairyAPI.getFairyLore(uuid).unsafeRunSync().lore.toList) + .build(), + LeftClickButtonEffect { + SequentialEffect( + UnfocusedEffect { + fairyAPI.updateAppleOpenState( + uuid, + AppleOpenState + .values + .find( + _.amount == fairyAPI.appleOpenState(uuid).unsafeRunSync().amount % 4 + 1 + ) + .get + ) + }, + FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) + ) + } + ) } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 05de2ed8be..9fe8b9ac4e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -1,6 +1,9 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.AppleOpenState +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + AppleOpenState, + FairyLore +} import java.util.UUID @@ -27,6 +30,11 @@ trait FairyReadAPI[F[_]] { */ def appleOpenState(uuid: UUID): F[AppleOpenState] + /** + * `FairyLoreTable`からLoreを取得する + */ + def getFairyLore(uuid: UUID): F[FairyLore] + } object FairyReadAPI { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 46aa351ed8..ba1d1dbb7d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -1,9 +1,13 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy -import cats.effect.Sync +import cats.effect.ConcurrentEffect import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.AppleOpenState +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit.FairyLoreTable +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + AppleOpenState, + FairyLore +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import java.util.UUID @@ -14,7 +18,7 @@ trait System[F[_]] extends Subsystem[F] { object System { - def wired[F[_]: Sync: OnMinecraftServerThread]: System[F] = { + def wired[F[_]: ConcurrentEffect: OnMinecraftServerThread]: System[F] = { val persistence = new JdbcFairyPersistence[F] new System[F] { override val api: FairyAPI[F] = new FairyAPI[F] { @@ -23,6 +27,14 @@ object System { override def updateAppleOpenState(uuid: UUID, appleOpenState: AppleOpenState): F[Unit] = persistence.changeAppleOpenState(uuid, appleOpenState) + + import cats.implicits._ + + override def getFairyLore(uuid: UUID): F[FairyLore] = for { + state <- appleOpenState(uuid) + } yield { + FairyLoreTable.loreTable(state.amount) + } } } } From 4c4e1e0b08d9e5c8d5fc123fbf932d902d0d552b Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 24 Jul 2022 15:56:07 +0900 Subject: [PATCH 020/482] =?UTF-8?q?[Add]FairySummonCost=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 4 ++++ .../vote/subsystems/fairy/domain/FairySummonCost.scala | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 9fe8b9ac4e..8930e86b8a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -15,6 +15,10 @@ trait FairyWriteAPI[F[_]] { */ def updateAppleOpenState(uuid: UUID, appleOpenState: AppleOpenState): F[Unit] + /** + * 妖精を召喚するコストを変更します。 + */ + } object FairyWriteAPI { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala new file mode 100644 index 0000000000..c0d5a43a41 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala @@ -0,0 +1,5 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +case class FairySummonCost(value: Int) { + require(0 < value && value < 5) +} From 0408b703959f1b6969e223eb2fb30230c924edd2 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 24 Jul 2022 16:11:21 +0900 Subject: [PATCH 021/482] =?UTF-8?q?[Fix]VoteMenu=E3=81=AEplayerMap?= =?UTF-8?q?=E3=82=92API=E3=81=AB=E7=BD=AE=E3=81=8D=E6=8F=9B=E3=81=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 17 +++++++---- .../vote/subsystems/fairy/FairyAPI.scala | 9 +++++- .../vote/subsystems/fairy/System.scala | 12 +++++++- .../fairy/domain/FairyPersistence.scala | 10 +++++++ .../fairy/domain/FairySummonCost.scala | 2 +- .../infrastructure/JdbcFairyPersistence.scala | 29 ++++++++++++++++++- 6 files changed, 69 insertions(+), 10 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 4de768f7d0..b95be4de00 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -13,7 +13,10 @@ import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.AppleOpenState +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + AppleOpenState, + FairySummonCost +} import com.github.unchama.seichiassist.task.VotingFairyTask import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect @@ -115,17 +118,17 @@ object VoteMenu extends Menu { } ) - def fairySummonTimeToggleButton(uuid: UUID): Button = { - val playerData = SeichiAssist.playermap(uuid) + def fairySummonTimeToggleButton(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { + val cost = fairyAPI.fairySummonCost(uuid).unsafeRunSync() Button( new IconItemStackBuilder(Material.WATCH) .title(s"$AQUA$UNDERLINE${BOLD}マナ妖精 時間設定") .lore( List( - s"$RESET$GREEN$BOLD${VotingFairyTask.dispToggleVFTime(playerData.toggleVotingFairy)}", + s"$RESET$GREEN$BOLD${VotingFairyTask.dispToggleVFTime(cost.value)}", "", s"$RESET${GRAY}コスト", - s"$RESET$RED$BOLD${playerData.toggleVotingFairy * 2}投票pt", + s"$RESET$RED$BOLD${cost.value * 2}投票pt", "", s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え" ) @@ -134,7 +137,9 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), - UnfocusedEffect(playerData.toggleVotingFairy = playerData.toggleVotingFairy % 4 + 1) + UnfocusedEffect( + fairyAPI.updateFairySummonCost(uuid, FairySummonCost(cost.value % 4 + 1)) + ) ) } ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 8930e86b8a..e43793ef24 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -2,7 +2,8 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, - FairyLore + FairyLore, + FairySummonCost } import java.util.UUID @@ -18,6 +19,7 @@ trait FairyWriteAPI[F[_]] { /** * 妖精を召喚するコストを変更します。 */ + def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] } @@ -34,6 +36,11 @@ trait FairyReadAPI[F[_]] { */ def appleOpenState(uuid: UUID): F[AppleOpenState] + /** + * 妖精を召喚するコストを取得します + */ + def fairySummonCost(uuid: UUID): F[FairySummonCost] + /** * `FairyLoreTable`からLoreを取得する */ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index ba1d1dbb7d..739e3e90c4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -6,7 +6,8 @@ import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit.FairyLoreTable import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, - FairyLore + FairyLore, + FairySummonCost } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence @@ -35,6 +36,15 @@ object System { } yield { FairyLoreTable.loreTable(state.amount) } + + override def updateFairySummonCost( + uuid: UUID, + fairySummonCost: FairySummonCost + ): F[Unit] = + persistence.updateFairySummonCost(uuid, fairySummonCost) + + override def fairySummonCost(uuid: UUID): F[FairySummonCost] = + persistence.fairySummonCost(uuid) } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index df02952cd9..45b79d0216 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -14,4 +14,14 @@ trait FairyPersistence[F[_]] { */ def appleOpenState(uuid: UUID): F[AppleOpenState] + /** + * 妖精を召喚するコストを変更します。 + */ + def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] + + /** + * 妖精を召喚するコストを取得します + */ + def fairySummonCost(uuid: UUID): F[FairySummonCost] + } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala index c0d5a43a41..10f98e1298 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain case class FairySummonCost(value: Int) { - require(0 < value && value < 5) + require(1 <= value && value <= 4, "FairySummonCostは1~4の間で指定してください。") } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 7e7c21aea8..fb4644518b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -3,7 +3,8 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrast import cats.effect.Sync import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, - FairyPersistence + FairyPersistence, + FairySummonCost } import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} @@ -37,4 +38,30 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } AppleOpenState.values.find(_.amount == appleAmount).get } + + /** + * 妖精を召喚するコストを変更します。 + */ + override def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] = + Sync[F].delay { + DB.localTx { implicit session => + sql"UPDATE playerdata SET toggleVotingFairy = ${fairySummonCost.value} WHERE uuid = ${uuid.toString}" + .execute() + .apply() + } + } + + /** + * `FairyLoreTable`からLoreを取得する + */ + override def fairySummonCost(uuid: UUID): F[FairySummonCost] = Sync[F].delay { + DB.readOnly { implicit session => + val cost = sql"SELECT toggleVotingFairy FROM playerdata WHERE uuid = ${uuid.toString}" + .map(_.int("toggleVotingFairy")) + .single() + .apply() + .get + FairySummonCost(cost) + } + } } From e04feb1a32441429d99b5ce58290fb9e0a77b66f Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 24 Jul 2022 16:58:16 +0900 Subject: [PATCH 022/482] tmpCommit --- .../unchama/seichiassist/menus/VoteMenu.scala | 19 ++++++++++++++++++- .../FairyPlaySoundRepositoryDefinition.scala | 18 ++++++++++++++++++ .../fairy/domain/FairyPlaySound.scala | 3 +++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyPlaySoundRepositoryDefinition.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPlaySound.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index b95be4de00..844e7df6b7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -145,7 +145,7 @@ object VoteMenu extends Menu { ) } - def fairyContractSettingToggle(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { + def fairyContractSettingToggle(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = Button( new IconItemStackBuilder(Material.PAPER) .title(s"$GOLD$UNDERLINE${BOLD}妖精とのお約束") @@ -168,6 +168,23 @@ object VoteMenu extends Menu { ) } ) + + def fairyPlaySoundToggleButton(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { + val playSoundOnLore = List( + s"$RESET${GREEN}現在音が鳴る設定になっています。", + s"$RESET${DARK_GRAY}※この機能はデフォルトでONです。", + s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え" + ) + val playSoundOffLore = List( + s"$RESET${GREEN}現在音が鳴らない設定になっています。", + s"$RESET${DARK_GRAY}※この機能はデフォルトでONです。", + s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え" + ) + + Button( + new IconItemStackBuilder(Material.JUKEBOX).title(s"$GOLD$UNDERLINE${BOLD}マナ妖精の音トグル") + .lore(if (fairyAPI)) + ) } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyPlaySoundRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyPlaySoundRepositoryDefinition.scala new file mode 100644 index 0000000000..1c73c073d4 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyPlaySoundRepositoryDefinition.scala @@ -0,0 +1,18 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository + +import cats.effect.concurrent.Ref +import com.github.unchama.datarepository.definitions.RefDictBackedRepositoryDefinition +import com.github.unchama.datarepository.template.RepositoryDefinition +import com.github.unchama.minecraft.algebra.HasUuid +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPlaySound + +object FairyPlaySoundRepositoryDefinition { + + case class RepositoryValue[F[_]](playSoundRef: Ref[F, FairyPlaySound]) + + def withContext[F[_], Player: HasUuid]: RepositoryDefinition[F, Player, RepositoryValue[F]] = + RefDictBackedRepositoryDefinition.usingUuidRefDict[F, Player, FairyPlaySound]()( + FairyPlaySound(true) + ) + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPlaySound.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPlaySound.scala new file mode 100644 index 0000000000..2d5c037d56 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPlaySound.scala @@ -0,0 +1,3 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +case class FairyPlaySound(isPlaySound: Boolean) From 386d88d087fbbd976ce5740a25806fc0556d20de Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 24 Jul 2022 18:15:15 +0900 Subject: [PATCH 023/482] =?UTF-8?q?[Add]fairyPlaySoundToggleButton?= =?UTF-8?q?=E3=82=92=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 33 ++++++++++++------- .../vote/subsystems/fairy/FairyAPI.scala | 22 +++++++++++++ .../vote/subsystems/fairy/System.scala | 23 +++++++++++-- .../FairyPlaySoundRepositoryDefinition.scala | 18 ---------- .../fairy/domain/FairyPlaySound.scala | 10 +++++- 5 files changed, 72 insertions(+), 34 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyPlaySoundRepositoryDefinition.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 844e7df6b7..f37d2783c1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -15,6 +15,7 @@ import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitRece import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, + FairyPlaySound, FairySummonCost } import com.github.unchama.seichiassist.task.VotingFairyTask @@ -170,20 +171,28 @@ object VoteMenu extends Menu { ) def fairyPlaySoundToggleButton(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { - val playSoundOnLore = List( - s"$RESET${GREEN}現在音が鳴る設定になっています。", - s"$RESET${DARK_GRAY}※この機能はデフォルトでONです。", - s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え" - ) - val playSoundOffLore = List( - s"$RESET${GREEN}現在音が鳴らない設定になっています。", - s"$RESET${DARK_GRAY}※この機能はデフォルトでONです。", - s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え" - ) + val description = + List(s"$RESET${DARK_GRAY}※この機能はデフォルトでONです。", s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え") + val playSoundOnLore = List(s"$RESET${GREEN}現在音が鳴る設定になっています。") ++ description + val playSoundOffLore = List(s"$RESET${GREEN}現在音が鳴らない設定になっています。") ++ description Button( - new IconItemStackBuilder(Material.JUKEBOX).title(s"$GOLD$UNDERLINE${BOLD}マナ妖精の音トグル") - .lore(if (fairyAPI)) + new IconItemStackBuilder(Material.JUKEBOX) + .title(s"$GOLD$UNDERLINE${BOLD}マナ妖精の音トグル") + .lore( + if (fairyAPI.fairyPlaySound(uuid).unsafeRunSync() == FairyPlaySound.play) + playSoundOnLore + else playSoundOffLore + ) + .build(), + LeftClickButtonEffect { + SequentialEffect( + FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), + UnfocusedEffect { + fairyAPI.fairyPlaySoundToggle(uuid).unsafeRunAsyncAndForget() + } + ) + } ) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index e43793ef24..d8e5395d63 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -1,8 +1,11 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy +import cats.effect.concurrent.Ref +import com.github.unchama.datarepository.KeyedDataRepository import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, FairyLore, + FairyPlaySound, FairySummonCost } @@ -21,6 +24,16 @@ trait FairyWriteAPI[F[_]] { */ def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] + /** + * fairyPlaySoundRepositoryから音を鳴らすかどうかを取得する + */ + def fairyPlaySound(uuid: UUID): F[FairyPlaySound] + + /** + * fairyPlaySoundRepositoryの音を鳴らすかどうかの設定を切り替える + */ + def fairyPlaySoundToggle(uuid: UUID): F[Unit] + } object FairyWriteAPI { @@ -46,6 +59,15 @@ trait FairyReadAPI[F[_]] { */ def getFairyLore(uuid: UUID): F[FairyLore] + /** + * 妖精の音を鳴らすかどうか保持するようのリポジトリ + * ※永続化は必要ない + */ + protected[this] val fairyPlaySoundRepository: KeyedDataRepository[ + UUID, + Ref[F, FairyPlaySound] + ] + } object FairyReadAPI { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 739e3e90c4..d90e4b4d80 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -1,12 +1,15 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.ConcurrentEffect +import cats.effect.concurrent.Ref +import com.github.unchama.datarepository.KeyedDataRepository import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit.FairyLoreTable import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, FairyLore, + FairyPlaySound, FairySummonCost } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence @@ -33,9 +36,7 @@ object System { override def getFairyLore(uuid: UUID): F[FairyLore] = for { state <- appleOpenState(uuid) - } yield { - FairyLoreTable.loreTable(state.amount) - } + } yield FairyLoreTable.loreTable(state.amount) override def updateFairySummonCost( uuid: UUID, @@ -45,6 +46,22 @@ object System { override def fairySummonCost(uuid: UUID): F[FairySummonCost] = persistence.fairySummonCost(uuid) + + override protected val fairyPlaySoundRepository + : KeyedDataRepository[UUID, Ref[F, FairyPlaySound]] = + KeyedDataRepository.unlift[UUID, Ref[F, FairyPlaySound]](_ => + Some(Ref.unsafe(FairyPlaySound.play)) + ) + + override def fairyPlaySound(uuid: UUID): F[FairyPlaySound] = fairyPlaySoundRepository( + uuid + ).get + + override def fairyPlaySoundToggle(uuid: UUID): F[Unit] = for { + nowSetting <- fairyPlaySound(uuid) + } yield fairyPlaySoundRepository(uuid).set( + if (nowSetting == FairyPlaySound.play) FairyPlaySound.notPlay else FairyPlaySound.play + ) } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyPlaySoundRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyPlaySoundRepositoryDefinition.scala deleted file mode 100644 index 1c73c073d4..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyPlaySoundRepositoryDefinition.scala +++ /dev/null @@ -1,18 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository - -import cats.effect.concurrent.Ref -import com.github.unchama.datarepository.definitions.RefDictBackedRepositoryDefinition -import com.github.unchama.datarepository.template.RepositoryDefinition -import com.github.unchama.minecraft.algebra.HasUuid -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPlaySound - -object FairyPlaySoundRepositoryDefinition { - - case class RepositoryValue[F[_]](playSoundRef: Ref[F, FairyPlaySound]) - - def withContext[F[_], Player: HasUuid]: RepositoryDefinition[F, Player, RepositoryValue[F]] = - RefDictBackedRepositoryDefinition.usingUuidRefDict[F, Player, FairyPlaySound]()( - FairyPlaySound(true) - ) - -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPlaySound.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPlaySound.scala index 2d5c037d56..c0971c16c9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPlaySound.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPlaySound.scala @@ -1,3 +1,11 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain -case class FairyPlaySound(isPlaySound: Boolean) +sealed trait FairyPlaySound + +object FairyPlaySound { + + case object play extends FairyPlaySound + + case object notPlay extends FairyPlaySound + +} From 5190394404582943bae797d75739bfe3f84d3424 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 24 Jul 2022 19:40:49 +0900 Subject: [PATCH 024/482] [Rename]SummonCost -> SummonState --- .../unchama/seichiassist/menus/VoteMenu.scala | 18 +++++++++++++----- .../vote/subsystems/fairy/FairyAPI.scala | 10 +++++----- .../vote/subsystems/fairy/System.scala | 12 ++++++------ .../fairy/domain/FairyPersistence.scala | 8 ++++---- .../fairy/domain/FairySummonCost.scala | 5 ----- .../fairy/domain/FairySummonState.scala | 5 +++++ .../infrastructure/JdbcFairyPersistence.scala | 12 ++++++------ 7 files changed, 39 insertions(+), 31 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonState.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index f37d2783c1..987deb590c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -16,7 +16,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, FairyPlaySound, - FairySummonCost + FairySummonState } import com.github.unchama.seichiassist.task.VotingFairyTask import com.github.unchama.targetedeffect.commandsender.MessageEffect @@ -120,16 +120,16 @@ object VoteMenu extends Menu { ) def fairySummonTimeToggleButton(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { - val cost = fairyAPI.fairySummonCost(uuid).unsafeRunSync() + val summonState = fairyAPI.fairySummonState(uuid).unsafeRunSync() Button( new IconItemStackBuilder(Material.WATCH) .title(s"$AQUA$UNDERLINE${BOLD}マナ妖精 時間設定") .lore( List( - s"$RESET$GREEN$BOLD${VotingFairyTask.dispToggleVFTime(cost.value)}", + s"$RESET$GREEN$BOLD${VotingFairyTask.dispToggleVFTime(summonState.value)}", "", s"$RESET${GRAY}コスト", - s"$RESET$RED$BOLD${cost.value * 2}投票pt", + s"$RESET$RED$BOLD${summonState.value * 2}投票pt", "", s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え" ) @@ -139,7 +139,7 @@ object VoteMenu extends Menu { SequentialEffect( FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), UnfocusedEffect( - fairyAPI.updateFairySummonCost(uuid, FairySummonCost(cost.value % 4 + 1)) + fairyAPI.updateFairySummonState(uuid, FairySummonState(summonState.value % 4 + 1)) ) ) } @@ -196,5 +196,13 @@ object VoteMenu extends Menu { ) } + def fairySummonButton(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { + Button( + new IconItemStackBuilder(Material.GHAST_TEAR) + .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}マナ妖精 召喚") + .lore(List(s"$RESET$GRAY${}")) + ) + } + } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index d8e5395d63..e546a44363 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -6,7 +6,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, FairyLore, FairyPlaySound, - FairySummonCost + FairySummonState } import java.util.UUID @@ -20,9 +20,9 @@ trait FairyWriteAPI[F[_]] { def updateAppleOpenState(uuid: UUID, appleOpenState: AppleOpenState): F[Unit] /** - * 妖精を召喚するコストを変更します。 + * 妖精を召喚する状態を変更します。 */ - def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] + def updateFairySummonState(uuid: UUID, fairySummonCost: FairySummonState): F[Unit] /** * fairyPlaySoundRepositoryから音を鳴らすかどうかを取得する @@ -50,9 +50,9 @@ trait FairyReadAPI[F[_]] { def appleOpenState(uuid: UUID): F[AppleOpenState] /** - * 妖精を召喚するコストを取得します + * 妖精を召喚する状態を取得します */ - def fairySummonCost(uuid: UUID): F[FairySummonCost] + def fairySummonState(uuid: UUID): F[FairySummonState] /** * `FairyLoreTable`からLoreを取得する diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index d90e4b4d80..78fa28d0f2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -10,7 +10,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, FairyLore, FairyPlaySound, - FairySummonCost + FairySummonState } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence @@ -38,14 +38,14 @@ object System { state <- appleOpenState(uuid) } yield FairyLoreTable.loreTable(state.amount) - override def updateFairySummonCost( + override def updateFairySummonState( uuid: UUID, - fairySummonCost: FairySummonCost + fairySummonCost: FairySummonState ): F[Unit] = - persistence.updateFairySummonCost(uuid, fairySummonCost) + persistence.updateFairySummonState(uuid, fairySummonCost) - override def fairySummonCost(uuid: UUID): F[FairySummonCost] = - persistence.fairySummonCost(uuid) + override def fairySummonState(uuid: UUID): F[FairySummonState] = + persistence.fairySummonState(uuid) override protected val fairyPlaySoundRepository : KeyedDataRepository[UUID, Ref[F, FairyPlaySound]] = diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index 45b79d0216..09a84c0e07 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -15,13 +15,13 @@ trait FairyPersistence[F[_]] { def appleOpenState(uuid: UUID): F[AppleOpenState] /** - * 妖精を召喚するコストを変更します。 + * 妖精を召喚する状態を変更します。 */ - def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] + def updateFairySummonState(uuid: UUID, fairySummonCost: FairySummonState): F[Unit] /** - * 妖精を召喚するコストを取得します + * 妖精を召喚する状態を取得します */ - def fairySummonCost(uuid: UUID): F[FairySummonCost] + def fairySummonState(uuid: UUID): F[FairySummonState] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala deleted file mode 100644 index 10f98e1298..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain - -case class FairySummonCost(value: Int) { - require(1 <= value && value <= 4, "FairySummonCostは1~4の間で指定してください。") -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonState.scala new file mode 100644 index 0000000000..93e6c261d1 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonState.scala @@ -0,0 +1,5 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +case class FairySummonState(value: Int) { + require(1 <= value && value <= 4, "FairySummonStateは1~4の間で指定してください。") +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index fb4644518b..489b094e79 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -4,7 +4,7 @@ import cats.effect.Sync import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, FairyPersistence, - FairySummonCost + FairySummonState } import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} @@ -40,9 +40,9 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } /** - * 妖精を召喚するコストを変更します。 + * 妖精を召喚する状態を変更します。 */ - override def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] = + override def updateFairySummonState(uuid: UUID, fairySummonCost: FairySummonState): F[Unit] = Sync[F].delay { DB.localTx { implicit session => sql"UPDATE playerdata SET toggleVotingFairy = ${fairySummonCost.value} WHERE uuid = ${uuid.toString}" @@ -52,16 +52,16 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } /** - * `FairyLoreTable`からLoreを取得する + * 妖精を召喚する状態を取得します */ - override def fairySummonCost(uuid: UUID): F[FairySummonCost] = Sync[F].delay { + override def fairySummonState(uuid: UUID): F[FairySummonState] = Sync[F].delay { DB.readOnly { implicit session => val cost = sql"SELECT toggleVotingFairy FROM playerdata WHERE uuid = ${uuid.toString}" .map(_.int("toggleVotingFairy")) .single() .apply() .get - FairySummonCost(cost) + FairySummonState(cost) } } } From 24e3d52b62b04e7226abde77984dec265d27d1a0 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 01:22:20 +0900 Subject: [PATCH 025/482] =?UTF-8?q?[Add]SummonFairy=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 24 +++- .../seichiassist/subsystems/vote/System.scala | 3 + .../subsystems/vote/VoteAPI.scala | 5 + .../vote/domain/VotePersistence.scala | 5 + .../infrastructure/JdbcVotePersistence.scala | 14 +- .../vote/subsystems/fairy/FairyAPI.scala | 40 ++++-- .../vote/subsystems/fairy/System.scala | 27 +++- .../application/actions/SummonFairy.scala | 16 +++ .../fairy/bukkit/actions/SummonFairy.scala | 123 ++++++++++++++++++ .../fairy/domain/FairyPersistence.scala | 28 +++- .../fairy/domain/FairyRecoveryMana.scala | 5 + .../fairy/domain/FairySummonState.scala | 5 - .../fairy/domain/FairyUsingState.scala | 11 ++ .../fairy/domain/FairyValidTimeState.scala | 5 + .../infrastructure/JdbcFairyPersistence.scala | 81 ++++++++++-- 15 files changed, 353 insertions(+), 39 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyRecoveryMana.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonState.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyUsingState.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimeState.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 987deb590c..8cd74f9a8d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -16,7 +16,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, FairyPlaySound, - FairySummonState + FairyValidTimeState } import com.github.unchama.seichiassist.task.VotingFairyTask import com.github.unchama.targetedeffect.commandsender.MessageEffect @@ -120,16 +120,16 @@ object VoteMenu extends Menu { ) def fairySummonTimeToggleButton(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { - val summonState = fairyAPI.fairySummonState(uuid).unsafeRunSync() + val validTimeState = fairyAPI.fairyValidTimeState(uuid).unsafeRunSync() Button( new IconItemStackBuilder(Material.WATCH) .title(s"$AQUA$UNDERLINE${BOLD}マナ妖精 時間設定") .lore( List( - s"$RESET$GREEN$BOLD${VotingFairyTask.dispToggleVFTime(summonState.value)}", + s"$RESET$GREEN$BOLD${VotingFairyTask.dispToggleVFTime(validTimeState.value)}", "", s"$RESET${GRAY}コスト", - s"$RESET$RED$BOLD${summonState.value * 2}投票pt", + s"$RESET$RED$BOLD${validTimeState.value * 2}投票pt", "", s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え" ) @@ -139,7 +139,8 @@ object VoteMenu extends Menu { SequentialEffect( FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), UnfocusedEffect( - fairyAPI.updateFairySummonState(uuid, FairySummonState(summonState.value % 4 + 1)) + fairyAPI + .updateFairySummonState(uuid, FairyValidTimeState(validTimeState.value % 4 + 1)) ) ) } @@ -197,10 +198,21 @@ object VoteMenu extends Menu { } def fairySummonButton(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { + val fairySummonState = fairyAPI.fairyValidTimeState(uuid).unsafeRunSync().value Button( new IconItemStackBuilder(Material.GHAST_TEAR) .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}マナ妖精 召喚") - .lore(List(s"$RESET$GRAY${}")) + .lore( + List( + s"$RESET$GRAY${fairySummonState * 2}投票ptを消費して", + s"$RESET${GRAY}マナ妖精を呼びます", + s"$RESET${GRAY}時間: ${VotingFairyTask.dispToggleVFTime(fairySummonState)}", + s"$RESET${DARK_RED}Lv.10以上で開放" + ) + ) + .enchanted() + .build(), + LeftClickButtonEffect {} ) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index 83e3d57742..56ac33dd24 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -39,6 +39,9 @@ object System { override def chainVoteDayNumber(uuid: UUID): F[ChainVoteDayNumber] = votePersistence.chainVoteDays(uuid) + override def decreaseEffectPoint(uuid: UUID, effectPoint: EffectPoint): F[Unit] = + votePersistence.decreaseEffectPoints(uuid, effectPoint) + override def increaseEffectPointsByTen(uuid: UUID): F[Unit] = votePersistence.increaseEffectPointsByTen(uuid) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index 6dcc3d8b9f..e2097bd70d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -16,6 +16,11 @@ trait VoteWriteAPI[F[_]] { */ def updateChainVote(playerName: PlayerName): F[Unit] + /** + * effectPointを減少させる作用 + */ + def decreaseEffectPoint(uuid: UUID, effectPoint: EffectPoint): F[Unit] + /** * effectPointを10増加させる作用 */ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala index 6749e52650..a8eab457c8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala @@ -29,6 +29,11 @@ trait VotePersistence[F[_]] { */ def increaseEffectPointsByTen(uuid: UUID): F[Unit] + /** + * effectPointを減少させる作用 + */ + def decreaseEffectPoints(uuid: UUID, effectPoint: EffectPoint): F[Unit] + /** * effectPointを返す作用 */ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index 07cd0c87ea..3ac4dc32a2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -73,12 +73,24 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { */ override def increaseEffectPointsByTen(uuid: UUID): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET effectpoint = 10 WHERE uuid = ${uuid.toString}" + sql"UPDATE playerdata SET effectpoint = effectpoint + 10 WHERE uuid = ${uuid.toString}" .execute() .apply() } } + /** + * effectPointを減少させる作用 + */ + override def decreaseEffectPoints(uuid: UUID, effectPoint: EffectPoint): F[Unit] = + Sync[F].delay { + DB.localTx { implicit session => + sql"UPDATE playerdata SET effectpoint = effectpoint - ${effectPoint.value} WHERE uuid = ${uuid.toString}" + .execute() + .apply() + } + } + /** * effectPointを返す作用 */ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index e546a44363..5c54fd3e0e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -6,7 +6,9 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, FairyLore, FairyPlaySound, - FairySummonState + FairyRecoveryMana, + FairyUsingState, + FairyValidTimeState } import java.util.UUID @@ -20,19 +22,24 @@ trait FairyWriteAPI[F[_]] { def updateAppleOpenState(uuid: UUID, appleOpenState: AppleOpenState): F[Unit] /** - * 妖精を召喚する状態を変更します。 + * 妖精有効な時間の状態を変更します。 */ - def updateFairySummonState(uuid: UUID, fairySummonCost: FairySummonState): F[Unit] + def updateFairySummonState(uuid: UUID, fairyValidTimeState: FairyValidTimeState): F[Unit] /** - * fairyPlaySoundRepositoryから音を鳴らすかどうかを取得する + * fairyPlaySoundRepositoryの音を鳴らすかどうかの設定を切り替える */ - def fairyPlaySound(uuid: UUID): F[FairyPlaySound] + def fairyPlaySoundToggle(uuid: UUID): F[Unit] /** - * fairyPlaySoundRepositoryの音を鳴らすかどうかの設定を切り替える + * 妖精を使っているかどうかを切り替える */ - def fairyPlaySoundToggle(uuid: UUID): F[Unit] + def updateFairyUsingState(uuid: UUID, fairyUsingState: FairyUsingState): F[Unit] + + /** + * 妖精が回復するマナの量を変更する + */ + def updateFairyRecoveryManaAmount(uuid: UUID, fairyRecoveryMana: FairyRecoveryMana): F[Unit] } @@ -50,15 +57,30 @@ trait FairyReadAPI[F[_]] { def appleOpenState(uuid: UUID): F[AppleOpenState] /** - * 妖精を召喚する状態を取得します + * 妖精が有効な時間の状態を取得します */ - def fairySummonState(uuid: UUID): F[FairySummonState] + def fairyValidTimeState(uuid: UUID): F[FairyValidTimeState] /** * `FairyLoreTable`からLoreを取得する */ def getFairyLore(uuid: UUID): F[FairyLore] + /** + * fairyPlaySoundRepositoryから音を鳴らすかどうかを取得する + */ + def fairyPlaySound(uuid: UUID): F[FairyPlaySound] + + /** + * 妖精を使っているかを取得する + */ + def fairyUsingState(uuid: UUID): F[FairyUsingState] + + /** + * 妖精が回復するマナの量を取得する + */ + def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] + /** * 妖精の音を鳴らすかどうか保持するようのリポジトリ * ※永続化は必要ない diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 78fa28d0f2..f886f6e06c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -10,7 +10,9 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, FairyLore, FairyPlaySound, - FairySummonState + FairyRecoveryMana, + FairyUsingState, + FairyValidTimeState } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence @@ -40,11 +42,11 @@ object System { override def updateFairySummonState( uuid: UUID, - fairySummonCost: FairySummonState + validTimeState: FairyValidTimeState ): F[Unit] = - persistence.updateFairySummonState(uuid, fairySummonCost) + persistence.updateFairyValidTimeState(uuid, validTimeState) - override def fairySummonState(uuid: UUID): F[FairySummonState] = + override def fairyValidTimeState(uuid: UUID): F[FairyValidTimeState] = persistence.fairySummonState(uuid) override protected val fairyPlaySoundRepository @@ -62,6 +64,23 @@ object System { } yield fairyPlaySoundRepository(uuid).set( if (nowSetting == FairyPlaySound.play) FairyPlaySound.notPlay else FairyPlaySound.play ) + + override def fairyUsingState(uuid: UUID): F[FairyUsingState] = + persistence.fairyUsingState(uuid) + + override def updateFairyUsingState( + uuid: UUID, + fairyUsingState: FairyUsingState + ): F[Unit] = + persistence.updateFairyUsingState(uuid, fairyUsingState) + + override def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] = + persistence.fairyRecoveryMana(uuid) + + override def updateFairyRecoveryManaAmount( + uuid: UUID, + fairyRecoveryMana: FairyRecoveryMana + ): F[Unit] = persistence.updateFairyRecoveryMana(uuid, fairyRecoveryMana) } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala new file mode 100644 index 0000000000..5242cfdc4d --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala @@ -0,0 +1,16 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions + +trait SummonFairy[F[_]] { + + /** + * 妖精を召喚する作用 + */ + def summon: F[Unit] + +} + +object SummonFairy { + + def apply[F[_]](implicit ev: SummonFairy[F]): SummonFairy[F] = ev + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala new file mode 100644 index 0000000000..c32ec082fd --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala @@ -0,0 +1,123 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions + +import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps +import cats.effect.{ConcurrentEffect, LiftIO, SyncEffect} +import com.github.unchama.generic.ContextCoercion +import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI +import com.github.unchama.seichiassist.subsystems.mana.ManaApi +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI +import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + FairyRecoveryMana, + FairyUsingState, + FairyValidTimeState +} +import com.github.unchama.targetedeffect.commandsender.MessageEffect +import com.github.unchama.targetedeffect.player.FocusedSoundEffect +import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} +import org.bukkit.ChatColor._ +import org.bukkit.Sound +import org.bukkit.entity.Player + +import java.util.{Calendar, Date} +import scala.util.Random + +object SummonFairy { + + import cats.implicits._ + + def apply[F[_]: ConcurrentEffect: LiftIO, G[_]: SyncEffect: ContextCoercion[*[_], F]]( + player: Player + )( + implicit breakCountAPI: BreakCountAPI[F, G, Player], + fairyAPI: FairyAPI[F], + voteAPI: VoteAPI[F], + manaApi: ManaApi[F, G, Player] + ): SummonFairy[F] = new SummonFairy[F] { + override def summon: F[Unit] = { + val playerLevel = + ContextCoercion(breakCountAPI.seichiAmountDataRepository[G](player).read.map { + _.levelCorrespondingToExp.level + }).toIO.unsafeRunSync() + + val notEnoughLevelEffect = + SequentialEffect( + MessageEffect(s"${GOLD}プレイヤーレベルが足りません"), + FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) + ) + val alreadySummoned = + SequentialEffect( + MessageEffect(s"${GOLD}既に妖精を召喚しています"), + FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) + ) + val effectPoint = + SequentialEffect( + MessageEffect(s"${GOLD}投票ptが足りません"), + FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) + ) + + val uuid = player.getUniqueId + + val validTimeState = fairyAPI.fairyValidTimeState(uuid).toIO.unsafeRunSync() + + LiftIO[F].liftIO { + if (playerLevel < 10) notEnoughLevelEffect(player) // レベル不足 + else if (fairyAPI.fairyUsingState(uuid).toIO.unsafeRunSync() == FairyUsingState.Using) + alreadySummoned(player) // 既に召喚している + else if ( + voteAPI.effectPoints(uuid).toIO.unsafeRunSync().value < validTimeState.value * 2 + ) + effectPoint(player) // 投票ptがたりなかった + else { + val calender = Calendar.getInstance() + calender.setTime(new Date()) + val startTime = calender.getTime.clone // 召喚した時間 + validTimeState match { + case FairyValidTimeState(1) => + calender.add(Calendar.MINUTE, 30) + case FairyValidTimeState(2) => + calender.add(Calendar.HOUR_OF_DAY, 1) + case FairyValidTimeState(3) => + calender.add(Calendar.MINUTE, 30) + calender.add(Calendar.HOUR_OF_DAY, 1) + case FairyValidTimeState(4) => + calender.add(Calendar.HOUR_OF_DAY, 2) + } + val endTime = calender.getTime.clone() // 終了時間 + + val levelCappedManaAmount = + ContextCoercion(manaApi.readManaAmount(player)).toIO.unsafeRunSync().cap.value + + // 回復するマナの量 + val recoveryMana = FairyRecoveryMana( + (levelCappedManaAmount / 10 - levelCappedManaAmount / 30 + new Random() + .nextInt((levelCappedManaAmount / 20).toInt) / 2.9).toInt + 200 + ) + + import cats.implicits._ + + val eff = for { + _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(validTimeState.value * 2)) + _ <- fairyAPI.updateFairyUsingState(uuid, FairyUsingState.Using) + _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) + } yield () + + SequentialEffect( + UnfocusedEffect(eff.toIO.unsafeRunAsyncAndForget()), + MessageEffect( + List( + s"$RESET$YELLOW${BOLD}妖精を呼び出しました!", + s"$RESET$YELLOW${BOLD}この子は1分間に約${recoveryMana.recoveryMana}マナ", + s"$RESET$YELLOW${BOLD}回復させる力を持っているようです。" + ) + ) + ).apply(player) + } + + } + } + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index 09a84c0e07..64d493da4b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -15,13 +15,33 @@ trait FairyPersistence[F[_]] { def appleOpenState(uuid: UUID): F[AppleOpenState] /** - * 妖精を召喚する状態を変更します。 + * 妖精が有効な時間の状態 */ - def updateFairySummonState(uuid: UUID, fairySummonCost: FairySummonState): F[Unit] + def updateFairyValidTimeState(uuid: UUID, validTimeState: FairyValidTimeState): F[Unit] /** - * 妖精を召喚する状態を取得します + * 妖精が有効な時間の状態を取得します */ - def fairySummonState(uuid: UUID): F[FairySummonState] + def fairySummonState(uuid: UUID): F[FairyValidTimeState] + + /** + * 妖精が召喚されているかを更新します + */ + def updateFairyUsingState(uuid: UUID, fairyUsingState: FairyUsingState): F[Unit] + + /** + * 妖精が召喚されているかを取得します + */ + def fairyUsingState(uuid: UUID): F[FairyUsingState] + + /** + * 妖精が回復するマナの量を変更する + */ + def updateFairyRecoveryMana(uuid: UUID, fairyRecoveryMana: FairyRecoveryMana): F[Unit] + + /** + * 妖精が回復するマナの量を取得する + */ + def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyRecoveryMana.scala new file mode 100644 index 0000000000..1db62c5d1b --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyRecoveryMana.scala @@ -0,0 +1,5 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +case class FairyRecoveryMana(recoveryMana: Int) { + require(recoveryMana >= 0) +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonState.scala deleted file mode 100644 index 93e6c261d1..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonState.scala +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain - -case class FairySummonState(value: Int) { - require(1 <= value && value <= 4, "FairySummonStateは1~4の間で指定してください。") -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyUsingState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyUsingState.scala new file mode 100644 index 0000000000..b61d150598 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyUsingState.scala @@ -0,0 +1,11 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +sealed trait FairyUsingState + +object FairyUsingState { + + case object Using extends FairyUsingState + + case object NotUsing extends FairyUsingState + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimeState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimeState.scala new file mode 100644 index 0000000000..0dec989c12 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimeState.scala @@ -0,0 +1,5 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +case class FairyValidTimeState(value: Int) { + require(1 <= value && value <= 4, "FairySummonValidTimeStateは1~4の間で指定してください。") +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 489b094e79..dc0e7fa681 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -4,7 +4,9 @@ import cats.effect.Sync import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, FairyPersistence, - FairySummonState + FairyRecoveryMana, + FairyUsingState, + FairyValidTimeState } import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} @@ -40,28 +42,87 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } /** - * 妖精を召喚する状態を変更します。 + * 妖精が有効な時間の状態を更新します */ - override def updateFairySummonState(uuid: UUID, fairySummonCost: FairySummonState): F[Unit] = + override def updateFairyValidTimeState( + uuid: UUID, + fairyValidTimeState: FairyValidTimeState + ): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET toggleVotingFairy = ${fairySummonCost.value} WHERE uuid = ${uuid.toString}" + sql"UPDATE playerdata SET toggleVotingFairy = ${fairyValidTimeState.value} WHERE uuid = ${uuid.toString}" .execute() .apply() } } /** - * 妖精を召喚する状態を取得します + * 妖精が有効な時間の状態を取得します */ - override def fairySummonState(uuid: UUID): F[FairySummonState] = Sync[F].delay { + override def fairySummonState(uuid: UUID): F[FairyValidTimeState] = Sync[F].delay { DB.readOnly { implicit session => - val cost = sql"SELECT toggleVotingFairy FROM playerdata WHERE uuid = ${uuid.toString}" - .map(_.int("toggleVotingFairy")) + val validTimeState = + sql"SELECT toggleVotingFairy FROM playerdata WHERE uuid = ${uuid.toString}" + .map(_.int("toggleVotingFairy")) + .single() + .apply() + .get + FairyValidTimeState(validTimeState) + } + } + + /** + * 妖精が召喚されているかを更新します + */ + override def updateFairyUsingState(uuid: UUID, fairyUsingState: FairyUsingState): F[Unit] = + Sync[F].delay { + DB.localTx { implicit session => + sql"""UPDATE playerdata + | SET canVotingFairyUse = ${if (fairyUsingState == FairyUsingState.Using) true + else false} WHERE uuid = ${uuid.toString}""".stripMargin.execute().apply() + } + } + + /** + * 妖精が召喚されているかを取得します + */ + override def fairyUsingState(uuid: UUID): F[FairyUsingState] = Sync[F].delay { + val isFairyUsing = DB.readOnly { implicit session => + sql"SELECT canVotingFairyUse FROM playerdata WHERE uuid = ${uuid.toString}" + .map(_.boolean("canVotingFairyUse")) .single() .apply() - .get - FairySummonState(cost) + }.get + if (isFairyUsing) FairyUsingState.Using + else FairyUsingState.NotUsing + } + + /** + * 妖精が回復するマナの量を変更する + */ + override def updateFairyRecoveryMana( + uuid: UUID, + fairyRecoveryMana: FairyRecoveryMana + ): F[Unit] = Sync[F].delay { + DB.localTx { implicit session => + sql"UPDATE playerdata SET VotingFairyRecoveryValue = ${fairyRecoveryMana.recoveryMana} WHERE uuid = $uuid" + .execute() + .apply() + } + } + + /** + * 妖精が回復するマナの量を取得する + */ + override def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] = Sync[F].delay { + DB.readOnly { implicit session => + val recoveryMana = + sql"SELECT VotingFairyRecoveryValue FROM playerdata WHERE uuid = ${uuid.toString}" + .map(_.int("VotingFairyRecoveryValue")) + .single() + .apply() + .get + FairyRecoveryMana(recoveryMana) } } } From 0d3b37f5d95dcd3844b9a1eb7fb28a00af0c87e7 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 11:02:08 +0900 Subject: [PATCH 026/482] =?UTF-8?q?[FIx]SummonFairy=E3=81=AETime=E3=82=92L?= =?UTF-8?q?ocalDateTime=E3=81=A7=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/actions/SummonFairy.scala | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala index c32ec082fd..3522543316 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala @@ -21,6 +21,7 @@ import org.bukkit.ChatColor._ import org.bukkit.Sound import org.bukkit.entity.Player +import java.time.LocalDateTime import java.util.{Calendar, Date} import scala.util.Random @@ -71,21 +72,17 @@ object SummonFairy { ) effectPoint(player) // 投票ptがたりなかった else { - val calender = Calendar.getInstance() - calender.setTime(new Date()) - val startTime = calender.getTime.clone // 召喚した時間 - validTimeState match { + val startTime = LocalDateTime.now() // 召喚した時間 + val endTime = validTimeState match { case FairyValidTimeState(1) => - calender.add(Calendar.MINUTE, 30) + startTime.plusMonths(30) case FairyValidTimeState(2) => - calender.add(Calendar.HOUR_OF_DAY, 1) + startTime.plusHours(1) case FairyValidTimeState(3) => - calender.add(Calendar.MINUTE, 30) - calender.add(Calendar.HOUR_OF_DAY, 1) + startTime.plusHours(1).plusMinutes(30) case FairyValidTimeState(4) => - calender.add(Calendar.HOUR_OF_DAY, 2) + startTime.plusHours(2) } - val endTime = calender.getTime.clone() // 終了時間 val levelCappedManaAmount = ContextCoercion(manaApi.readManaAmount(player)).toIO.unsafeRunSync().cap.value From 09c131b162adf11b563fa0eca86d52f2b3017055 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 11:09:46 +0900 Subject: [PATCH 027/482] =?UTF-8?q?[Add]FairyVaildTime=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/domain/FairyValidTime.scala | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTime.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTime.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTime.scala new file mode 100644 index 0000000000..06d5b33da2 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTime.scala @@ -0,0 +1,5 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +import java.time.LocalDateTime + +case class FairyValidTime(validTIme: LocalDateTime) From 00dde8e8021e4ed5cd08768609907ca4227da706 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 11:14:35 +0900 Subject: [PATCH 028/482] =?UTF-8?q?[Add]validTime=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/domain/FairyValidTime.scala | 2 +- .../fairy/domain/FairyValidTimeState.scala | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTime.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTime.scala index 06d5b33da2..a5af97c1a2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTime.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTime.scala @@ -2,4 +2,4 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain import java.time.LocalDateTime -case class FairyValidTime(validTIme: LocalDateTime) +case class FairyValidTime(startTime: LocalDateTime, endTime: LocalDateTime) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimeState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimeState.scala index 0dec989c12..e1317e32f4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimeState.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimeState.scala @@ -1,5 +1,26 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +import java.time.LocalDateTime + case class FairyValidTimeState(value: Int) { require(1 <= value && value <= 4, "FairySummonValidTimeStateは1~4の間で指定してください。") + + /** + * @return 妖精が有効な時間 + */ + def validTime: FairyValidTime = { + val now = LocalDateTime.now() + val validTime = value match { + case 1 => + FairyValidTime(_, now.plusMonths(30)) + case 2 => + FairyValidTime(_, now.plusHours(1)) + case 3 => + FairyValidTime(_, now.plusHours(1).plusMinutes(30)) + case 4 => + FairyValidTime(_, now.plusHours(2)) + } + validTime(now) + } + } From cff2d58338b149106067f564971ba0853f39c689 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 11:15:46 +0900 Subject: [PATCH 029/482] [Rename]ValidTime -> ValidTimes --- .../fairy/bukkit/actions/SummonFairy.scala | 13 ++----------- .../fairy/domain/FairyValidTimeState.scala | 10 +++++----- .../{FairyValidTime.scala => FairyValidTimes.scala} | 2 +- 3 files changed, 8 insertions(+), 17 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{FairyValidTime.scala => FairyValidTimes.scala} (59%) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala index 3522543316..bc0c3493ce 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala @@ -72,17 +72,8 @@ object SummonFairy { ) effectPoint(player) // 投票ptがたりなかった else { - val startTime = LocalDateTime.now() // 召喚した時間 - val endTime = validTimeState match { - case FairyValidTimeState(1) => - startTime.plusMonths(30) - case FairyValidTimeState(2) => - startTime.plusHours(1) - case FairyValidTimeState(3) => - startTime.plusHours(1).plusMinutes(30) - case FairyValidTimeState(4) => - startTime.plusHours(2) - } + val validTime = validTimeState.validTime + val startTime = validTime.startTime val levelCappedManaAmount = ContextCoercion(manaApi.readManaAmount(player)).toIO.unsafeRunSync().cap.value diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimeState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimeState.scala index e1317e32f4..ddb32dec79 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimeState.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimeState.scala @@ -8,17 +8,17 @@ case class FairyValidTimeState(value: Int) { /** * @return 妖精が有効な時間 */ - def validTime: FairyValidTime = { + def validTime: FairyValidTimes = { val now = LocalDateTime.now() val validTime = value match { case 1 => - FairyValidTime(_, now.plusMonths(30)) + FairyValidTimes(_, now.plusMonths(30)) case 2 => - FairyValidTime(_, now.plusHours(1)) + FairyValidTimes(_, now.plusHours(1)) case 3 => - FairyValidTime(_, now.plusHours(1).plusMinutes(30)) + FairyValidTimes(_, now.plusHours(1).plusMinutes(30)) case 4 => - FairyValidTime(_, now.plusHours(2)) + FairyValidTimes(_, now.plusHours(2)) } validTime(now) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTime.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimes.scala similarity index 59% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTime.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimes.scala index a5af97c1a2..0cb33e96ba 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTime.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimes.scala @@ -2,4 +2,4 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain import java.time.LocalDateTime -case class FairyValidTime(startTime: LocalDateTime, endTime: LocalDateTime) +case class FairyValidTimes(startTime: LocalDateTime, endTime: LocalDateTime) From 6a6e78aa05c44f4fe4bcb35cfa2ff9fad1f87f7a Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 11:35:44 +0900 Subject: [PATCH 030/482] =?UTF-8?q?[Add]fairyValidTimes=E3=80=81updateFair?= =?UTF-8?q?yValidTimes=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/FairyAPI.scala | 21 ++++++++++++++++++- .../vote/subsystems/fairy/System.scala | 15 ++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 5c54fd3e0e..5ebb17e840 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -8,7 +8,8 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ FairyPlaySound, FairyRecoveryMana, FairyUsingState, - FairyValidTimeState + FairyValidTimeState, + FairyValidTimes } import java.util.UUID @@ -41,6 +42,11 @@ trait FairyWriteAPI[F[_]] { */ def updateFairyRecoveryManaAmount(uuid: UUID, fairyRecoveryMana: FairyRecoveryMana): F[Unit] + /** + * 妖精が有効な時間を変更する + */ + def updateFairyValidTimes(uuid: UUID, fairyValidTimes: Option[FairyValidTimes]): F[Unit] + } object FairyWriteAPI { @@ -90,6 +96,19 @@ trait FairyReadAPI[F[_]] { Ref[F, FairyPlaySound] ] + /** + * 妖精の有効な時間を保存するリポジトリ + * ※永続化は必要ない + */ + protected[this] val fairyValidTimeRepository: KeyedDataRepository[UUID, Ref[F, Option[ + FairyValidTimes + ]]] + + /** + * 妖精が有効な時間を返す + */ + def fairyValidTimes(uuid: UUID): F[Option[FairyValidTimes]] + } object FairyReadAPI { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index f886f6e06c..9293cf18b4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -12,7 +12,8 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ FairyPlaySound, FairyRecoveryMana, FairyUsingState, - FairyValidTimeState + FairyValidTimeState, + FairyValidTimes } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence @@ -65,6 +66,18 @@ object System { if (nowSetting == FairyPlaySound.play) FairyPlaySound.notPlay else FairyPlaySound.play ) + override protected[this] val fairyValidTimeRepository + : KeyedDataRepository[UUID, Ref[F, Option[FairyValidTimes]]] = + KeyedDataRepository.unlift[UUID, Ref[F, Option[FairyValidTimes]]](_ => None) + + override def fairyValidTimes(uuid: UUID): F[Option[FairyValidTimes]] = + fairyValidTimeRepository(uuid).get + + override def updateFairyValidTimes( + uuid: UUID, + fairyValidTimes: Option[FairyValidTimes] + ): F[Unit] = fairyValidTimeRepository(uuid).set(fairyValidTimes) + override def fairyUsingState(uuid: UUID): F[FairyUsingState] = persistence.fairyUsingState(uuid) From dc323df09c4fb09c5bd88147d8548a349487f079 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 12:16:38 +0900 Subject: [PATCH 031/482] =?UTF-8?q?[Chore]SummonFairy=E3=81=AE=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92=E7=B4=B0=E5=88=86=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 10 ++++++++ .../vote/subsystems/fairy/FairyAPI.scala | 10 ++++++++ .../vote/subsystems/fairy/System.scala | 10 ++++++++ .../fairy/bukkit/actions/SummonFairy.scala | 23 ++++++------------- .../domain/FairyRecoveryManaAmount.scala | 15 ++++++++++++ .../infrastructure/JdbcFairyPersistence.scala | 14 +++++++++++ 6 files changed, 66 insertions(+), 16 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyRecoveryManaAmount.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 8cd74f9a8d..fe197c3817 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -10,6 +10,16 @@ import com.github.unchama.seichiassist.SeichiAssist import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMainThread import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI +import com.github.unchama.seichiassist.subsystems.fairy.domain.{ + AppleOpenState, + FairyPlaySound, + FairyValidTimeState +} +import com.github.unchama.seichiassist.subsystems.mana.subsystems.fairy.domain.{ + AppleOpenState, + FairyPlaySound, + FairyValidTimeState +} import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 5ebb17e840..7d10e182cb 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -2,6 +2,16 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.concurrent.Ref import com.github.unchama.datarepository.KeyedDataRepository +import com.github.unchama.seichiassist.subsystems.fairy.domain.{ + AppleOpenState, + FairyLore, + FairyPlaySound, + FairyRecoveryMana, + FairyUsingState, + FairyValidTimeState, + FairyValidTimes +} +import com.github.unchama.seichiassist.subsystems.mana.subsystems.fairy.domain._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, FairyLore, diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 9293cf18b4..e3f5ee39f7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -5,6 +5,16 @@ import cats.effect.concurrent.Ref import com.github.unchama.datarepository.KeyedDataRepository import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem +import com.github.unchama.seichiassist.subsystems.fairy.domain.{ + AppleOpenState, + FairyLore, + FairyPlaySound, + FairyRecoveryMana, + FairyUsingState, + FairyValidTimeState, + FairyValidTimes +} +import com.github.unchama.seichiassist.subsystems.mana.subsystems.fairy.domain._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit.FairyLoreTable import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala index bc0c3493ce..035497d006 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala @@ -9,10 +9,10 @@ import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyUsingState.Using import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - FairyRecoveryMana, - FairyUsingState, - FairyValidTimeState + FairyRecoveryManaAmount, + FairyUsingState } import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect @@ -21,10 +21,6 @@ import org.bukkit.ChatColor._ import org.bukkit.Sound import org.bukkit.entity.Player -import java.time.LocalDateTime -import java.util.{Calendar, Date} -import scala.util.Random - object SummonFairy { import cats.implicits._ @@ -65,31 +61,26 @@ object SummonFairy { LiftIO[F].liftIO { if (playerLevel < 10) notEnoughLevelEffect(player) // レベル不足 - else if (fairyAPI.fairyUsingState(uuid).toIO.unsafeRunSync() == FairyUsingState.Using) + else if (fairyAPI.fairyUsingState(uuid).toIO.unsafeRunSync() == Using) alreadySummoned(player) // 既に召喚している else if ( voteAPI.effectPoints(uuid).toIO.unsafeRunSync().value < validTimeState.value * 2 ) effectPoint(player) // 投票ptがたりなかった else { - val validTime = validTimeState.validTime - val startTime = validTime.startTime - val levelCappedManaAmount = ContextCoercion(manaApi.readManaAmount(player)).toIO.unsafeRunSync().cap.value // 回復するマナの量 - val recoveryMana = FairyRecoveryMana( - (levelCappedManaAmount / 10 - levelCappedManaAmount / 30 + new Random() - .nextInt((levelCappedManaAmount / 20).toInt) / 2.9).toInt + 200 - ) + val recoveryMana = FairyRecoveryManaAmount.manaAmountAt(levelCappedManaAmount) import cats.implicits._ val eff = for { - _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(validTimeState.value * 2)) _ <- fairyAPI.updateFairyUsingState(uuid, FairyUsingState.Using) + _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(validTimeState.value * 2)) _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) + _ <- fairyAPI.updateFairyValidTimes(uuid, Some(validTimeState.validTime)) } yield () SequentialEffect( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyRecoveryManaAmount.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyRecoveryManaAmount.scala new file mode 100644 index 0000000000..cbe5e93f44 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyRecoveryManaAmount.scala @@ -0,0 +1,15 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +import scala.util.Random + +object FairyRecoveryManaAmount { + + def manaAmountAt(levelCappedManaAmount: Double): FairyRecoveryMana = { + require(levelCappedManaAmount >= 0.0, "levelCappedManaAmountは非負の値で指定してください。") + FairyRecoveryMana( + (levelCappedManaAmount / 10 - levelCappedManaAmount / 30 + new Random() + .nextInt((levelCappedManaAmount / 20).toInt) / 2.9).toInt + 200 + ) + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index dc0e7fa681..eac34633be 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -1,6 +1,20 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure import cats.effect.Sync +import com.github.unchama.seichiassist.subsystems.fairy.domain.{ + AppleOpenState, + FairyPersistence, + FairyRecoveryMana, + FairyUsingState, + FairyValidTimeState +} +import com.github.unchama.seichiassist.subsystems.mana.subsystems.fairy.domain.{ + AppleOpenState, + FairyPersistence, + FairyRecoveryMana, + FairyUsingState, + FairyValidTimeState +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, FairyPersistence, From 5d77dc7a4a452d1bb4e47d14b3e5f1000caf1fa4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 12:18:39 +0900 Subject: [PATCH 032/482] [Rename]effectPoint -> notEnoughEffectPoint --- .../vote/subsystems/fairy/bukkit/actions/SummonFairy.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala index 035497d006..7f2bfeba78 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala @@ -49,7 +49,7 @@ object SummonFairy { MessageEffect(s"${GOLD}既に妖精を召喚しています"), FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) ) - val effectPoint = + val notEnoughEffectPoint = SequentialEffect( MessageEffect(s"${GOLD}投票ptが足りません"), FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) @@ -66,7 +66,7 @@ object SummonFairy { else if ( voteAPI.effectPoints(uuid).toIO.unsafeRunSync().value < validTimeState.value * 2 ) - effectPoint(player) // 投票ptがたりなかった + notEnoughEffectPoint(player) // 投票ptがたりなかった else { val levelCappedManaAmount = ContextCoercion(manaApi.readManaAmount(player)).toIO.unsafeRunSync().cap.value From a86c658417f2ae3559356aa48ab56cdf16e64a62 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 12:21:18 +0900 Subject: [PATCH 033/482] [Rename]SummonFairy -> BukktiSummonFairy --- .../actions/{SummonFairy.scala => BukkitSummonFairy.scala} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/{SummonFairy.scala => BukkitSummonFairy.scala} (99%) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala similarity index 99% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 7f2bfeba78..b32142efb4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/SummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -21,7 +21,7 @@ import org.bukkit.ChatColor._ import org.bukkit.Sound import org.bukkit.entity.Player -object SummonFairy { +object BukkitSummonFairy { import cats.implicits._ From b39f94fc05717d8f8996d6a2a3f38a599381718a Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 12:24:32 +0900 Subject: [PATCH 034/482] =?UTF-8?q?[Fix]BukkitSummonFiary=E3=81=A7ealry-re?= =?UTF-8?q?turn=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/actions/BukkitSummonFairy.scala | 67 +++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index b32142efb4..1f72e4e66e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -59,43 +59,42 @@ object BukkitSummonFairy { val validTimeState = fairyAPI.fairyValidTimeState(uuid).toIO.unsafeRunSync() + if (playerLevel < 10) return LiftIO[F].liftIO(notEnoughLevelEffect(player)) // レベル不足 + + if (fairyAPI.fairyUsingState(uuid).toIO.unsafeRunSync() == Using) + return LiftIO[F].liftIO(alreadySummoned(player)) // 既に召喚している + + if (voteAPI.effectPoints(uuid).toIO.unsafeRunSync().value < validTimeState.value * 2) + return LiftIO[F].liftIO(notEnoughEffectPoint(player)) // 投票ptがたりなかった + + val levelCappedManaAmount = + ContextCoercion(manaApi.readManaAmount(player)).toIO.unsafeRunSync().cap.value + + // 回復するマナの量 + val recoveryMana = FairyRecoveryManaAmount.manaAmountAt(levelCappedManaAmount) + + import cats.implicits._ + + val eff = for { + _ <- fairyAPI.updateFairyUsingState(uuid, FairyUsingState.Using) + _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(validTimeState.value * 2)) + _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) + _ <- fairyAPI.updateFairyValidTimes(uuid, Some(validTimeState.validTime)) + } yield () + LiftIO[F].liftIO { - if (playerLevel < 10) notEnoughLevelEffect(player) // レベル不足 - else if (fairyAPI.fairyUsingState(uuid).toIO.unsafeRunSync() == Using) - alreadySummoned(player) // 既に召喚している - else if ( - voteAPI.effectPoints(uuid).toIO.unsafeRunSync().value < validTimeState.value * 2 - ) - notEnoughEffectPoint(player) // 投票ptがたりなかった - else { - val levelCappedManaAmount = - ContextCoercion(manaApi.readManaAmount(player)).toIO.unsafeRunSync().cap.value - - // 回復するマナの量 - val recoveryMana = FairyRecoveryManaAmount.manaAmountAt(levelCappedManaAmount) - - import cats.implicits._ - - val eff = for { - _ <- fairyAPI.updateFairyUsingState(uuid, FairyUsingState.Using) - _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(validTimeState.value * 2)) - _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) - _ <- fairyAPI.updateFairyValidTimes(uuid, Some(validTimeState.validTime)) - } yield () - - SequentialEffect( - UnfocusedEffect(eff.toIO.unsafeRunAsyncAndForget()), - MessageEffect( - List( - s"$RESET$YELLOW${BOLD}妖精を呼び出しました!", - s"$RESET$YELLOW${BOLD}この子は1分間に約${recoveryMana.recoveryMana}マナ", - s"$RESET$YELLOW${BOLD}回復させる力を持っているようです。" - ) + SequentialEffect( + UnfocusedEffect(eff.toIO.unsafeRunAsyncAndForget()), + MessageEffect( + List( + s"$RESET$YELLOW${BOLD}妖精を呼び出しました!", + s"$RESET$YELLOW${BOLD}この子は1分間に約${recoveryMana.recoveryMana}マナ", + s"$RESET$YELLOW${BOLD}回復させる力を持っているようです。" ) - ).apply(player) - } - + ) + ).apply(player) } + } } From 2fd6ef87549c1eba121e0e2bd776daf6bb90d76e Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 12:29:10 +0900 Subject: [PATCH 035/482] =?UTF-8?q?[Add]FairySpeakTask=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/application/actions/FairySpeakTask.scala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeakTask.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeakTask.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeakTask.scala new file mode 100644 index 0000000000..c652310242 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeakTask.scala @@ -0,0 +1,14 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions + +trait FairySpeakTask[F[_], Player] { + + def speak(player: Player): F[Unit] + +} + +object FairySpeakTask { + + def apply[F[_], Player](implicit ev: FairySpeakTask[F, Player]): FairySpeakTask[F, Player] = + ev + +} From 94efa99c6e71c6515b8ad8f7b34f73ebb5eb151e Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 12:39:13 +0900 Subject: [PATCH 036/482] =?UTF-8?q?[Add]FairyMessages=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/actions/BukkitFairySpeakTask.scala | 12 ++++++++++++ .../fairy/bukkit/actions/BukkitSummonFairy.scala | 2 -- .../vote/subsystems/fairy/domain/FairyMessages.scala | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeakTask.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessages.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeakTask.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeakTask.scala new file mode 100644 index 0000000000..72641baf05 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeakTask.scala @@ -0,0 +1,12 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions + +import cats.effect.{Concurrent, ConcurrentEffect} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairySpeakTask +import org.bukkit.entity.Player + +object BukkitFairySpeakTask { + + def apply[F[_]: ConcurrentEffect](player: Player): FairySpeakTask[F, Player] = + (player: Player) => {} + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 1f72e4e66e..3c50f46788 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -73,8 +73,6 @@ object BukkitSummonFairy { // 回復するマナの量 val recoveryMana = FairyRecoveryManaAmount.manaAmountAt(levelCappedManaAmount) - import cats.implicits._ - val eff = for { _ <- fairyAPI.updateFairyUsingState(uuid, FairyUsingState.Using) _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(validTimeState.value * 2)) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessages.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessages.scala new file mode 100644 index 0000000000..a4956b004e --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessages.scala @@ -0,0 +1,5 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +import cats.data.NonEmptyList + +case class FairyMessages(messages: NonEmptyList[String]) From 5d8b4c60792ff385132e8bd1552c5b6ba1e1f6aa Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 12:55:08 +0900 Subject: [PATCH 037/482] =?UTF-8?q?[Add]FairyMessageTable=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/domain/FairyMessageTable.scala | 32 +++++++++++++++++++ .../fairy/domain/FairyMessages.scala | 6 ++-- .../fairy/domain/NameCalledByFairy.scala | 3 ++ 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessageTable.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/NameCalledByFairy.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessageTable.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessageTable.scala new file mode 100644 index 0000000000..5a63d4a84b --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessageTable.scala @@ -0,0 +1,32 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +object FairyMessageTable { + + val morningMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => + FairyMessages( + s"おはよ!${name.value}", + s"ヤッホー${name.value}", + s"ふわぁ。。。${name.value}朝は早いね。", + "うーん、今日も一日頑張ろ!", + s"今日は整地日和だね!${name.value}" + ) + + val dayMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => + FairyMessages( + s"やあ!${name.value}", + s"ヤッホー${name.value}!", + s"あっ、${name.value}じゃん。丁度お腹空いてたんだ!", + s"この匂い…${name.value}ってがちゃりんごいっぱい持ってる…?", + "今日のおやつはがちゃりんごいっぱいだ!" + ) + + val nightMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => + FairyMessages( + s"やあ!${name.value}", + s"ヤッホー${name.value}!", + s"ふわぁ。。。${name.value}は夜も元気だね。", + s"もう寝ようと思ってたのにー。${name.value}はしょうがないなぁ", + "こんな時間に呼ぶなんて…りんごははずんでもらうよ?" + ) + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessages.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessages.scala index a4956b004e..c03ae37299 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessages.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessages.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain -import cats.data.NonEmptyList - -case class FairyMessages(messages: NonEmptyList[String]) +case class FairyMessages(messages: String*) { + require(messages.nonEmpty) +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/NameCalledByFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/NameCalledByFairy.scala new file mode 100644 index 0000000000..452ee77bb5 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/NameCalledByFairy.scala @@ -0,0 +1,3 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +case class NameCalledByFairy(value: String) From def9c3d0217b8acd7a1352e55b97fd84912910ee Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 15:04:59 +0900 Subject: [PATCH 038/482] =?UTF-8?q?[Add]BukkitFairySpeak=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/actions/FairySpeak.scala | 24 ++++++++ .../application/actions/FairySpeakTask.scala | 14 ----- .../bukkit/actions/BukkitFairySpeak.scala | 56 +++++++++++++++++++ .../bukkit/actions/BukkitFairySpeakTask.scala | 12 ---- .../fairy/domain/FairyMessage.scala | 5 ++ .../fairy/domain/FairyMessageTable.scala | 30 +++++----- .../fairy/domain/FairyMessages.scala | 2 +- 7 files changed, 101 insertions(+), 42 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeakTask.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeakTask.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessage.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala new file mode 100644 index 0000000000..54ed16e799 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala @@ -0,0 +1,24 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions + +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + FairyMessage, + FairyValidTimes +} + +trait FairySpeak[F[_], Player] { + + def speak(player: Player, fairyMessage: FairyMessage)(implicit fairyAPI: FairyAPI[F]): F[Unit] + + def speakRandomly(player: Player, fairyValidTimes: FairyValidTimes)( + implicit fairyAPI: FairyAPI[F] + ): F[Unit] + +} + +object FairySpeak { + + def apply[F[_], Player](implicit ev: FairySpeak[F, Player]): FairySpeak[F, Player] = + ev + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeakTask.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeakTask.scala deleted file mode 100644 index c652310242..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeakTask.scala +++ /dev/null @@ -1,14 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions - -trait FairySpeakTask[F[_], Player] { - - def speak(player: Player): F[Unit] - -} - -object FairySpeakTask { - - def apply[F[_], Player](implicit ev: FairySpeakTask[F, Player]): FairySpeakTask[F, Player] = - ev - -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala new file mode 100644 index 0000000000..849bdc4b01 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala @@ -0,0 +1,56 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions + +import cats.effect.Sync +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairySpeak +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ +import com.github.unchama.targetedeffect.SequentialEffect +import com.github.unchama.targetedeffect.commandsender.MessageEffect +import com.github.unchama.targetedeffect.player.FocusedSoundEffect +import org.bukkit.Sound +import org.bukkit.entity.Player + +import scala.util.Random + +object BukkitFairySpeak { + + import cats.implicits._ + + def apply[F[_]: Sync]: FairySpeak[F, Player] = new FairySpeak[F, Player] { + override def speak(player: Player, fairyMessage: FairyMessage)( + implicit fairyAPI: FairyAPI[F] + ): F[Unit] = for { + playSound <- fairyAPI.fairyPlaySound(player.getUniqueId) + } yield { + if (playSound == FairyPlaySound.play) + SequentialEffect( + FocusedSoundEffect(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f), + MessageEffect(fairyMessage.message) + ).apply(player) + else SequentialEffect(MessageEffect(fairyMessage.message)).apply(player) + } + + override def speakRandomly(player: Player, fairyValidTimes: FairyValidTimes)( + implicit fairyAPI: FairyAPI[F] + ): F[Unit] = { + val startTimeHour = fairyValidTimes.startTime.getHour + val nameCalledByFairy = NameCalledByFairy(player.getName) + for { + fairyMessage <- + if (4 <= startTimeHour && startTimeHour < 10) + getMessageRandomly(FairyMessageTable.morningMessages(nameCalledByFairy)) + else if (10 <= startTimeHour && startTimeHour < 18) + getMessageRandomly(FairyMessageTable.dayMessages(nameCalledByFairy)) + else + getMessageRandomly(FairyMessageTable.nightMessages(nameCalledByFairy)) + } yield speak(fairyMessage) + } + } + + private def getMessageRandomly[F[_]: Sync](fairyMessages: FairyMessages): F[FairyMessage] = + Sync[F].delay { + val messages = fairyMessages.messages + messages(Random.nextInt(messages.size)) + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeakTask.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeakTask.scala deleted file mode 100644 index 72641baf05..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeakTask.scala +++ /dev/null @@ -1,12 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions - -import cats.effect.{Concurrent, ConcurrentEffect} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairySpeakTask -import org.bukkit.entity.Player - -object BukkitFairySpeakTask { - - def apply[F[_]: ConcurrentEffect](player: Player): FairySpeakTask[F, Player] = - (player: Player) => {} - -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessage.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessage.scala new file mode 100644 index 0000000000..dda9036a12 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessage.scala @@ -0,0 +1,5 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +case class FairyMessage(message: String) { + require(message.nonEmpty) +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessageTable.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessageTable.scala index 5a63d4a84b..855738d0c9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessageTable.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessageTable.scala @@ -4,29 +4,29 @@ object FairyMessageTable { val morningMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( - s"おはよ!${name.value}", - s"ヤッホー${name.value}", - s"ふわぁ。。。${name.value}朝は早いね。", - "うーん、今日も一日頑張ろ!", - s"今日は整地日和だね!${name.value}" + FairyMessage(s"おはよ!${name.value}"), + FairyMessage(s"ヤッホー${name.value}"), + FairyMessage(s"ふわぁ。。。${name.value}朝は早いね。"), + FairyMessage("うーん、今日も一日頑張ろ!"), + FairyMessage(s"今日は整地日和だね!${name.value}") ) val dayMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( - s"やあ!${name.value}", - s"ヤッホー${name.value}!", - s"あっ、${name.value}じゃん。丁度お腹空いてたんだ!", - s"この匂い…${name.value}ってがちゃりんごいっぱい持ってる…?", - "今日のおやつはがちゃりんごいっぱいだ!" + FairyMessage(s"やあ!${name.value}"), + FairyMessage(s"ヤッホー${name.value}!"), + FairyMessage(s"あっ、${name.value}じゃん。丁度お腹空いてたんだ!"), + FairyMessage(s"この匂い…${name.value}ってがちゃりんごいっぱい持ってる…?"), + FairyMessage("今日のおやつはがちゃりんごいっぱいだ!") ) val nightMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( - s"やあ!${name.value}", - s"ヤッホー${name.value}!", - s"ふわぁ。。。${name.value}は夜も元気だね。", - s"もう寝ようと思ってたのにー。${name.value}はしょうがないなぁ", - "こんな時間に呼ぶなんて…りんごははずんでもらうよ?" + FairyMessage(s"やあ!${name.value}"), + FairyMessage(s"ヤッホー${name.value}!"), + FairyMessage(s"ふわぁ。。。${name.value}は夜も元気だね。"), + FairyMessage(s"もう寝ようと思ってたのにー。${name.value}はしょうがないなぁ"), + FairyMessage("こんな時間に呼ぶなんて…りんごははずんでもらうよ?") ) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessages.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessages.scala index c03ae37299..abf80c5058 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessages.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessages.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain -case class FairyMessages(messages: String*) { +case class FairyMessages(messages: FairyMessage*) { require(messages.nonEmpty) } From a7542ca1577a1e36ff685459f2bf469782d12aec Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 15:40:57 +0900 Subject: [PATCH 039/482] =?UTF-8?q?[Add]FairySpeechRoutine=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/actions/FairySpeak.scala | 9 ++--- .../bukkit/actions/BukkitFairySpeak.scala | 9 +++-- .../bukkit/routines/FairySpeechRoutine.scala | 35 +++++++++++++++++++ 3 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala index 54ed16e799..2429f06582 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala @@ -1,18 +1,13 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - FairyMessage, - FairyValidTimes -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyMessage trait FairySpeak[F[_], Player] { def speak(player: Player, fairyMessage: FairyMessage)(implicit fairyAPI: FairyAPI[F]): F[Unit] - def speakRandomly(player: Player, fairyValidTimes: FairyValidTimes)( - implicit fairyAPI: FairyAPI[F] - ): F[Unit] + def speakRandomly(player: Player)(implicit fairyAPI: FairyAPI[F]): F[Unit] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala index 849bdc4b01..6d9cfb8ff6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala @@ -30,12 +30,11 @@ object BukkitFairySpeak { else SequentialEffect(MessageEffect(fairyMessage.message)).apply(player) } - override def speakRandomly(player: Player, fairyValidTimes: FairyValidTimes)( - implicit fairyAPI: FairyAPI[F] - ): F[Unit] = { - val startTimeHour = fairyValidTimes.startTime.getHour + override def speakRandomly(player: Player)(implicit fairyAPI: FairyAPI[F]): F[Unit] = { val nameCalledByFairy = NameCalledByFairy(player.getName) for { + fairyValidTimesOpt <- fairyAPI.fairyValidTimes(player.getUniqueId) + startTimeHour = fairyValidTimesOpt.getOrElse(return Sync[F].unit).startTime.getHour fairyMessage <- if (4 <= startTimeHour && startTimeHour < 10) getMessageRandomly(FairyMessageTable.morningMessages(nameCalledByFairy)) @@ -43,7 +42,7 @@ object BukkitFairySpeak { getMessageRandomly(FairyMessageTable.dayMessages(nameCalledByFairy)) else getMessageRandomly(FairyMessageTable.nightMessages(nameCalledByFairy)) - } yield speak(fairyMessage) + } yield speak(player, fairyMessage) } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala new file mode 100644 index 0000000000..6565a43584 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala @@ -0,0 +1,35 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines + +import cats.effect.{IO, SyncIO, Timer} +import com.github.unchama.concurrent.{RepeatingRoutine, RepeatingTaskContext} +import com.github.unchama.minecraft.actions.OnMinecraftServerThread +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitFairySpeak +import org.bukkit.entity.Player + +import scala.concurrent.duration.FiniteDuration + +object FairySpeechRoutine { + + private val repeatInterval: IO[FiniteDuration] = IO { + import scala.concurrent.duration._ + + 1.minute + } + + def start(player: Player)( + implicit fairyAPI: FairyAPI[SyncIO], + context: RepeatingTaskContext, + onMainThread: OnMinecraftServerThread[IO] + ): IO[Unit] = { + implicit val timer: Timer[IO] = IO.timer(context) + + RepeatingRoutine.permanentRoutine( + repeatInterval, + onMainThread.runAction { + BukkitFairySpeak[SyncIO].speakRandomly(player) + } + ) + } + +} From ae1bed46009b9a797c2b39980ad39b5ec157f246 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 16:16:35 +0900 Subject: [PATCH 040/482] =?UTF-8?q?[Fix]FairySpeechRoutine=E5=91=A8?= =?UTF-8?q?=E3=82=8A=E3=82=92=E3=81=84=E3=81=84=E6=84=9F=E3=81=98=E3=81=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/actions/BukkitFairySpeak.scala | 21 ++++++++++----- .../bukkit/actions/BukkitSummonFairy.scala | 27 +++++++++++++++---- .../bukkit/routines/FairySpeechRoutine.scala | 25 +++++++++-------- 3 files changed, 48 insertions(+), 25 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala index 6d9cfb8ff6..abeb4274fa 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala @@ -1,6 +1,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions -import cats.effect.Sync +import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps +import cats.effect.{ConcurrentEffect, Sync} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairySpeak import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ @@ -16,7 +17,7 @@ object BukkitFairySpeak { import cats.implicits._ - def apply[F[_]: Sync]: FairySpeak[F, Player] = new FairySpeak[F, Player] { + def apply[F[_]: ConcurrentEffect]: FairySpeak[F, Player] = new FairySpeak[F, Player] { override def speak(player: Player, fairyMessage: FairyMessage)( implicit fairyAPI: FairyAPI[F] ): F[Unit] = for { @@ -32,16 +33,22 @@ object BukkitFairySpeak { override def speakRandomly(player: Player)(implicit fairyAPI: FairyAPI[F]): F[Unit] = { val nameCalledByFairy = NameCalledByFairy(player.getName) + val uuid = player.getUniqueId + + if (fairyAPI.fairyUsingState(uuid).toIO.unsafeRunSync() == FairyUsingState.NotUsing) + return Sync[F].unit + for { - fairyValidTimesOpt <- fairyAPI.fairyValidTimes(player.getUniqueId) + fairyValidTimesOpt <- fairyAPI.fairyValidTimes(uuid) startTimeHour = fairyValidTimesOpt.getOrElse(return Sync[F].unit).startTime.getHour - fairyMessage <- + fairyMessages = if (4 <= startTimeHour && startTimeHour < 10) - getMessageRandomly(FairyMessageTable.morningMessages(nameCalledByFairy)) + FairyMessageTable.morningMessages(nameCalledByFairy) else if (10 <= startTimeHour && startTimeHour < 18) - getMessageRandomly(FairyMessageTable.dayMessages(nameCalledByFairy)) + FairyMessageTable.dayMessages(nameCalledByFairy) else - getMessageRandomly(FairyMessageTable.nightMessages(nameCalledByFairy)) + FairyMessageTable.nightMessages(nameCalledByFairy) + fairyMessage <- getMessageRandomly(fairyMessages) } yield speak(player, fairyMessage) } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 3c50f46788..2beec502fd 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -1,14 +1,17 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps -import cats.effect.{ConcurrentEffect, LiftIO, SyncEffect} +import cats.effect.{ConcurrentEffect, LiftIO, SyncEffect, Timer} +import com.github.unchama.concurrent.RepeatingTaskContext import com.github.unchama.generic.ContextCoercion +import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.FairySpeechRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyUsingState.Using import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ FairyRecoveryManaAmount, @@ -25,9 +28,11 @@ object BukkitSummonFairy { import cats.implicits._ - def apply[F[_]: ConcurrentEffect: LiftIO, G[_]: SyncEffect: ContextCoercion[*[_], F]]( - player: Player - )( + def apply[F[ + _ + ]: ConcurrentEffect: LiftIO: Timer: RepeatingTaskContext: OnMinecraftServerThread, G[ + _ + ]: SyncEffect: ContextCoercion[*[_], F]](player: Player)( implicit breakCountAPI: BreakCountAPI[F, G, Player], fairyAPI: FairyAPI[F], voteAPI: VoteAPI[F], @@ -77,8 +82,20 @@ object BukkitSummonFairy { _ <- fairyAPI.updateFairyUsingState(uuid, FairyUsingState.Using) _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(validTimeState.value * 2)) _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) + validTimes <- fairyAPI.fairyValidTimes(uuid) _ <- fairyAPI.updateFairyValidTimes(uuid, Some(validTimeState.validTime)) - } yield () + } yield { + /* + FairySpeechRoutineが一度も起動されていなければ起動する + そうじゃなかったからfor実行 + */ + validTimes match { + case Some(_) => () + case None => + FairySpeechRoutine.start[F, G](player).start + () + } + } LiftIO[F].liftIO { SequentialEffect( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala index 6565a43584..f0e36dc72d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines -import cats.effect.{IO, SyncIO, Timer} +import cats.effect.{ConcurrentEffect, Sync, SyncEffect, Timer} import com.github.unchama.concurrent.{RepeatingRoutine, RepeatingTaskContext} import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI @@ -11,23 +11,22 @@ import scala.concurrent.duration.FiniteDuration object FairySpeechRoutine { - private val repeatInterval: IO[FiniteDuration] = IO { - import scala.concurrent.duration._ + def start[F[_]: ConcurrentEffect: Timer, G[_]: SyncEffect](player: Player)( + implicit fairyAPI: FairyAPI[F], + context: RepeatingTaskContext, + onMainThread: OnMinecraftServerThread[F] + ): F[Nothing] = { - 1.minute - } + val repeatInterval: F[FiniteDuration] = Sync[F].pure { + import scala.concurrent.duration._ - def start(player: Player)( - implicit fairyAPI: FairyAPI[SyncIO], - context: RepeatingTaskContext, - onMainThread: OnMinecraftServerThread[IO] - ): IO[Unit] = { - implicit val timer: Timer[IO] = IO.timer(context) + 1.minute + } - RepeatingRoutine.permanentRoutine( + RepeatingRoutine.permanentRoutine[F, G]( repeatInterval, onMainThread.runAction { - BukkitFairySpeak[SyncIO].speakRandomly(player) + BukkitFairySpeak[F].speakRandomly(player) } ) } From be51b9882536a44d217749379ddfeeaf49b15d15 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 18:17:50 +0900 Subject: [PATCH 041/482] =?UTF-8?q?[Add]computeMenuLayout=E3=81=ABlayout?= =?UTF-8?q?=E3=82=92=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 107 ++++++++++++++---- 1 file changed, 83 insertions(+), 24 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index fe197c3817..c49b4bae80 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -2,29 +2,26 @@ package com.github.unchama.seichiassist.menus import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.itemstackbuilder.IconItemStackBuilder +import com.github.unchama.menuinventory.router.CanOpen import com.github.unchama.menuinventory.slot.button.Button import com.github.unchama.menuinventory.slot.button.action.LeftClickButtonEffect import com.github.unchama.menuinventory.syntax.IntInventorySizeOps -import com.github.unchama.menuinventory.{Menu, MenuFrame, MenuSlotLayout} -import com.github.unchama.seichiassist.SeichiAssist +import com.github.unchama.menuinventory.{ChestSlotRef, Menu, MenuFrame, MenuSlotLayout} import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts -import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMainThread +import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.{onMainThread, timer} +import com.github.unchama.seichiassist.menus.stickmenu.FirstPage import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI -import com.github.unchama.seichiassist.subsystems.fairy.domain.{ - AppleOpenState, - FairyPlaySound, - FairyValidTimeState -} -import com.github.unchama.seichiassist.subsystems.mana.subsystems.fairy.domain.{ - AppleOpenState, - FairyPlaySound, - FairyValidTimeState -} +import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.{ + BukkitFairySpeak, + BukkitSummonFairy +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, + FairyMessage, FairyPlaySound, FairyValidTimeState } @@ -43,8 +40,10 @@ object VoteMenu extends Menu { class Environment( implicit val voteAPI: VoteAPI[IO], - fairyAPI: FairyAPI[IO], - breakCountAPI: BreakCountAPI[IO, SyncIO, Player] + val fairyAPI: FairyAPI[IO], + val breakCountAPI: BreakCountAPI[IO, SyncIO, Player], + val manaApi: ManaApi[IO, SyncIO, Player], + val ioCanOpenFirstPage: IO CanOpen FirstPage.type ) /** @@ -56,12 +55,34 @@ object VoteMenu extends Menu { * @return * `player`からメニューの[[MenuSlotLayout]]を計算する[[IO]] */ - override def computeMenuLayout(player: Player)( - implicit environment: Environment - ): IO[MenuSlotLayout] = {} + override def computeMenuLayout( + player: Player + )(implicit environment: Environment): IO[MenuSlotLayout] = { + import ConstantButtons._ + import environment._ + import eu.timepit.refined.auto._ + + val uuid = player.getUniqueId + + val buttons = + Map( + ChestSlotRef(0, 0) -> receiveVoteBenefitsButton(uuid), + ChestSlotRef(0, 2) -> fairySummonTimeToggleButton(uuid), + ChestSlotRef(0, 4) -> fairySummonButton(player), + ChestSlotRef(1, 0) -> showVoteURLButton, + ChestSlotRef(1, 2) -> fairyContractSettingToggle(uuid), + ChestSlotRef(2, 2) -> fairyPlaySoundToggleButton(uuid), + ChestSlotRef(3, 0) -> CommonButtons.openStickMenu + ) + + IO(MenuSlotLayout(buttons)) + } private object ConstantButtons { + implicit val ioCE: ConcurrentEffect[IO] = + IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) + def receiveVoteBenefitsButton(uuid: UUID)( implicit voteAPI: VoteAPI[IO], breakCountAPI: BreakCountAPI[IO, SyncIO, Player] @@ -86,8 +107,6 @@ object VoteMenu extends Menu { .enchanted() .build(), LeftClickButtonEffect { - implicit val ioCE: ConcurrentEffect[IO] = - IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) SequentialEffect( TargetedEffect.delay { player => BukkitReceiveVoteBenefits[IO, SyncIO].receive(player).unsafeRunAsyncAndForget() @@ -183,7 +202,7 @@ object VoteMenu extends Menu { def fairyPlaySoundToggleButton(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { val description = - List(s"$RESET${DARK_GRAY}※この機能はデフォルトでONです。", s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え") + List(s"$RESET$DARK_GRAY※この機能はデフォルトでONです。", s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え") val playSoundOnLore = List(s"$RESET${GREEN}現在音が鳴る設定になっています。") ++ description val playSoundOffLore = List(s"$RESET${GREEN}現在音が鳴らない設定になっています。") ++ description @@ -207,8 +226,14 @@ object VoteMenu extends Menu { ) } - def fairySummonButton(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { - val fairySummonState = fairyAPI.fairyValidTimeState(uuid).unsafeRunSync().value + def fairySummonButton(player: Player)( + implicit fairyAPI: FairyAPI[IO], + voteAPI: VoteAPI[IO], + breakCountAPI: BreakCountAPI[IO, SyncIO, Player], + manaApi: ManaApi[IO, SyncIO, Player] + ): Button = { + val fairySummonState = + fairyAPI.fairyValidTimeState(player.getUniqueId).unsafeRunSync().value Button( new IconItemStackBuilder(Material.GHAST_TEAR) .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}マナ妖精 召喚") @@ -222,7 +247,41 @@ object VoteMenu extends Menu { ) .enchanted() .build(), - LeftClickButtonEffect {} + LeftClickButtonEffect { + SequentialEffect( + UnfocusedEffect { + import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.sleepAndRoutineContext + BukkitSummonFairy[IO, SyncIO](player).summon.unsafeRunAsyncAndForget() + }, + closeInventoryEffect + ) + } + ) + } + + def checkTimeButton(player: Player)(implicit fairyAPI: FairyAPI[IO]): Button = { + Button( + new IconItemStackBuilder(Material.COMPASS) + .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}マナ妖精に時間を聞く") + .lore(List(s"$RESET${GRAY}妖精さんはいそがしい。", s"${GRAY}帰っちゃう時間を教えてくれる")) + .enchanted() + .build(), + LeftClickButtonEffect { + SequentialEffect( + UnfocusedEffect { + val endTime = + fairyAPI.fairyValidTimes(player.getUniqueId).unsafeRunSync().get.endTime + + BukkitFairySpeak[IO] + .speak( + player, + FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。") + ) + .unsafeRunAsyncAndForget() + }, + closeInventoryEffect + ) + } ) } From 47aeaabd2843a0b10f39679f4c41cd19cd14071d Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 19:42:32 +0900 Subject: [PATCH 042/482] [Fix]compile error --- .../manipulators/PlayerDataManipulator.scala | 4 +- .../unchama/seichiassist/menus/VoteMenu.scala | 31 ++++++----- .../seichiassist/subsystems/vote/System.scala | 2 +- .../actions/ReceiveVoteBenefits.scala | 2 +- .../actions/BukkitReceiveVoteBenefits.scala | 8 +-- .../vote/domain/ChainVoteDayNumber.scala | 2 +- .../subsystems/vote/domain/EffectPoint.scala | 2 +- .../subsystems/vote/domain/PlayerName.scala | 2 +- .../subsystems/vote/domain/VoteBenefit.scala | 2 +- .../subsystems/vote/domain/VoteCounter.scala | 2 +- .../vote/subsystems/fairy/FairyAPI.scala | 10 ---- .../vote/subsystems/fairy/System.scala | 10 ---- .../bukkit/actions/BukkitSummonFairy.scala | 51 +++++++++---------- .../bukkit/routines/FairySpeechRoutine.scala | 19 ++++--- .../infrastructure/JdbcFairyPersistence.scala | 14 ----- 15 files changed, 64 insertions(+), 97 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/database/manipulators/PlayerDataManipulator.scala b/src/main/scala/com/github/unchama/seichiassist/database/manipulators/PlayerDataManipulator.scala index 0547a99a03..f65fe2b769 100644 --- a/src/main/scala/com/github/unchama/seichiassist/database/manipulators/PlayerDataManipulator.scala +++ b/src/main/scala/com/github/unchama/seichiassist/database/manipulators/PlayerDataManipulator.scala @@ -17,11 +17,9 @@ import org.bukkit.ChatColor._ import org.bukkit.command.CommandSender import org.bukkit.entity.Player import org.bukkit.inventory.Inventory -import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} import java.sql.SQLException -import java.text.SimpleDateFormat -import java.util.{Calendar, UUID} +import java.util.UUID import scala.collection.mutable class PlayerDataManipulator(private val gateway: DatabaseGateway) { diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index c49b4bae80..5886a3aee4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.menus -import cats.effect.{ConcurrentEffect, IO, SyncIO} +import cats.effect.{ConcurrentEffect, ContextShift, IO, SyncIO} import com.github.unchama.itemstackbuilder.IconItemStackBuilder import com.github.unchama.menuinventory.router.CanOpen import com.github.unchama.menuinventory.slot.button.Button @@ -8,7 +8,7 @@ import com.github.unchama.menuinventory.slot.button.action.LeftClickButtonEffect import com.github.unchama.menuinventory.syntax.IntInventorySizeOps import com.github.unchama.menuinventory.{ChestSlotRef, Menu, MenuFrame, MenuSlotLayout} import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts -import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.{onMainThread, timer} +import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMainThread import com.github.unchama.seichiassist.menus.stickmenu.FirstPage import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi @@ -39,8 +39,10 @@ import java.util.UUID object VoteMenu extends Menu { class Environment( - implicit val voteAPI: VoteAPI[IO], - val fairyAPI: FairyAPI[IO], + implicit val voteAPI: VoteAPI[SyncIO], + val fairyAPI: FairyAPI[SyncIO], + val concurrentEffect: ConcurrentEffect[SyncIO], + val contextShift: ContextShift[IO], val breakCountAPI: BreakCountAPI[IO, SyncIO, Player], val manaApi: ManaApi[IO, SyncIO, Player], val ioCanOpenFirstPage: IO CanOpen FirstPage.type @@ -84,7 +86,7 @@ object VoteMenu extends Menu { IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) def receiveVoteBenefitsButton(uuid: UUID)( - implicit voteAPI: VoteAPI[IO], + implicit voteAPI: VoteAPI[SyncIO], breakCountAPI: BreakCountAPI[IO, SyncIO, Player] ): Button = { for { @@ -109,7 +111,7 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( TargetedEffect.delay { player => - BukkitReceiveVoteBenefits[IO, SyncIO].receive(player).unsafeRunAsyncAndForget() + BukkitReceiveVoteBenefits[IO, SyncIO].receive(player).unsafeRunSync() }, MessageEffect( s"${GOLD}投票特典$WHITE(${voteCounter.value - benefits.value}票分)を受け取りました" @@ -148,7 +150,7 @@ object VoteMenu extends Menu { } ) - def fairySummonTimeToggleButton(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { + def fairySummonTimeToggleButton(uuid: UUID)(implicit fairyAPI: FairyAPI[SyncIO]): Button = { val validTimeState = fairyAPI.fairyValidTimeState(uuid).unsafeRunSync() Button( new IconItemStackBuilder(Material.WATCH) @@ -176,7 +178,7 @@ object VoteMenu extends Menu { ) } - def fairyContractSettingToggle(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = + def fairyContractSettingToggle(uuid: UUID)(implicit fairyAPI: FairyAPI[SyncIO]): Button = Button( new IconItemStackBuilder(Material.PAPER) .title(s"$GOLD$UNDERLINE${BOLD}妖精とのお約束") @@ -200,7 +202,7 @@ object VoteMenu extends Menu { } ) - def fairyPlaySoundToggleButton(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { + def fairyPlaySoundToggleButton(uuid: UUID)(implicit fairyAPI: FairyAPI[SyncIO]): Button = { val description = List(s"$RESET$DARK_GRAY※この機能はデフォルトでONです。", s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え") val playSoundOnLore = List(s"$RESET${GREEN}現在音が鳴る設定になっています。") ++ description @@ -219,7 +221,7 @@ object VoteMenu extends Menu { SequentialEffect( FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), UnfocusedEffect { - fairyAPI.fairyPlaySoundToggle(uuid).unsafeRunAsyncAndForget() + fairyAPI.fairyPlaySoundToggle(uuid).unsafeRunSync() } ) } @@ -227,8 +229,10 @@ object VoteMenu extends Menu { } def fairySummonButton(player: Player)( - implicit fairyAPI: FairyAPI[IO], - voteAPI: VoteAPI[IO], + implicit fairyAPI: FairyAPI[SyncIO], + voteAPI: VoteAPI[SyncIO], + concurrentEffect: ConcurrentEffect[SyncIO], + contextShift: ContextShift[IO], breakCountAPI: BreakCountAPI[IO, SyncIO, Player], manaApi: ManaApi[IO, SyncIO, Player] ): Button = { @@ -250,8 +254,7 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( UnfocusedEffect { - import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.sleepAndRoutineContext - BukkitSummonFairy[IO, SyncIO](player).summon.unsafeRunAsyncAndForget() + BukkitSummonFairy(player).summon.unsafeRunAsyncAndForget() }, closeInventoryEffect ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index 56ac33dd24..e68cce3358 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -59,7 +59,7 @@ object System { override def notReceivedVoteBenefits(uuid: UUID): F[VoteBenefit] = for { voteCounter <- voteCounter(uuid) receivedVote <- receivedVoteBenefits(uuid) - } yield voteCounter.value - receivedVote.value + } yield VoteBenefit(voteCounter.value - receivedVote.value) } override val commands: Map[String, TabExecutor] = Map( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala index daeadd24fb..dafd5a2cb3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala @@ -7,7 +7,7 @@ trait ReceiveVoteBenefits[F[_], G[_], Player] { def receive( player: Player - )(implicit voteAPI: VoteAPI[F], breakCountAPI: BreakCountAPI[F, G, Player]): F[Unit] + )(implicit voteAPI: VoteAPI[G], breakCountAPI: BreakCountAPI[F, G, Player]): G[Unit] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 3450e70015..05f9d4a4dc 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -25,21 +25,21 @@ object BukkitReceiveVoteBenefits { new ReceiveVoteBenefits[F, G, Player] { override def receive( player: Player - )(implicit voteAPI: VoteAPI[F], breakCountAPI: BreakCountAPI[F, G, Player]): F[Unit] = { + )(implicit voteAPI: VoteAPI[G], breakCountAPI: BreakCountAPI[F, G, Player]): G[Unit] = { val uuid = player.getUniqueId for { notReceivedBenefits <- voteAPI.notReceivedVoteBenefits(uuid) // 受け取っていない投票特典数 _ <- voteAPI.increaseVoteBenefits(uuid, notReceivedBenefits) // 受け取ってない分を受け取ったことにする } yield { - if (notReceivedBenefits.value == 0) return Sync[F].pure() + if (notReceivedBenefits.value == 0) return Sync[G].pure(()) val playerLevel = - ContextCoercion(breakCountAPI.seichiAmountDataRepository[G](player).read.map { + ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read.map { _.levelCorrespondingToExp.level }).toIO.unsafeRunSync() val items = (0 until notReceivedBenefits.value).map { _ => - voteAPI.increaseEffectPointsByTen(uuid).toIO.unsafeRunAsyncAndForget() + ContextCoercion(voteAPI.increaseEffectPointsByTen(uuid)).toIO.unsafeRunSync() Seq.fill(10)(GachaSkullData.gachaForVoting) ++ Seq( if (playerLevel < 50) ItemData.getSuperPickaxe(1) else ItemData.getVotingGift(1) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVoteDayNumber.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVoteDayNumber.scala index c18ce82a21..7d4bf5ad23 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVoteDayNumber.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/ChainVoteDayNumber.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.domain -case class ChainVoteDayNumber(value: Int) extends AnyVal { +case class ChainVoteDayNumber(value: Int) { require(value >= 0, "投票日数は非負である必要があります。") } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/EffectPoint.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/EffectPoint.scala index b5e54305ba..e5d3cfa33d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/EffectPoint.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/EffectPoint.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.domain -case class EffectPoint(value: Int) extends AnyVal { +case class EffectPoint(value: Int) { require(value >= 0) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/PlayerName.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/PlayerName.scala index 95477b8548..70bb1617e3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/PlayerName.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/PlayerName.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.domain -case class PlayerName(name: String) extends AnyVal { +case class PlayerName(name: String) { require(name.forall(_.isLower)) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteBenefit.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteBenefit.scala index dae9912b95..9510fa85e1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteBenefit.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteBenefit.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.domain -case class VoteBenefit(value: Int) extends AnyVal { +case class VoteBenefit(value: Int) { require(value >= 0) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCounter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCounter.scala index 8fe1936814..9013d68121 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCounter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCounter.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.domain -case class VoteCounter(value: Int) extends AnyVal { +case class VoteCounter(value: Int) { require(value >= 0, "votePointは非負である必要があります。") } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 7d10e182cb..5ebb17e840 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -2,16 +2,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.concurrent.Ref import com.github.unchama.datarepository.KeyedDataRepository -import com.github.unchama.seichiassist.subsystems.fairy.domain.{ - AppleOpenState, - FairyLore, - FairyPlaySound, - FairyRecoveryMana, - FairyUsingState, - FairyValidTimeState, - FairyValidTimes -} -import com.github.unchama.seichiassist.subsystems.mana.subsystems.fairy.domain._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, FairyLore, diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index e3f5ee39f7..9293cf18b4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -5,16 +5,6 @@ import cats.effect.concurrent.Ref import com.github.unchama.datarepository.KeyedDataRepository import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem -import com.github.unchama.seichiassist.subsystems.fairy.domain.{ - AppleOpenState, - FairyLore, - FairyPlaySound, - FairyRecoveryMana, - FairyUsingState, - FairyValidTimeState, - FairyValidTimes -} -import com.github.unchama.seichiassist.subsystems.mana.subsystems.fairy.domain._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit.FairyLoreTable import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 2beec502fd..22a27e279a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -1,10 +1,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions -import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps -import cats.effect.{ConcurrentEffect, LiftIO, SyncEffect, Timer} -import com.github.unchama.concurrent.RepeatingTaskContext -import com.github.unchama.generic.ContextCoercion -import com.github.unchama.minecraft.actions.OnMinecraftServerThread +import cats.effect.{ConcurrentEffect, ContextShift, IO, LiftIO, SyncIO} +import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMainThread import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI @@ -26,23 +23,22 @@ import org.bukkit.entity.Player object BukkitSummonFairy { - import cats.implicits._ - - def apply[F[ - _ - ]: ConcurrentEffect: LiftIO: Timer: RepeatingTaskContext: OnMinecraftServerThread, G[ - _ - ]: SyncEffect: ContextCoercion[*[_], F]](player: Player)( - implicit breakCountAPI: BreakCountAPI[F, G, Player], - fairyAPI: FairyAPI[F], - voteAPI: VoteAPI[F], - manaApi: ManaApi[F, G, Player] - ): SummonFairy[F] = new SummonFairy[F] { - override def summon: F[Unit] = { + def apply(player: Player)( + implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], + fairyAPI: FairyAPI[SyncIO], + concurrentEffect: ConcurrentEffect[SyncIO], + contextShift: ContextShift[IO], + voteAPI: VoteAPI[SyncIO], + manaApi: ManaApi[IO, SyncIO, Player] + ): SummonFairy[IO] = new SummonFairy[IO] { + override def summon: IO[Unit] = { val playerLevel = - ContextCoercion(breakCountAPI.seichiAmountDataRepository[G](player).read.map { - _.levelCorrespondingToExp.level - }).toIO.unsafeRunSync() + breakCountAPI + .seichiAmountDataRepository(player) + .read + .unsafeRunSync() + .levelCorrespondingToExp + .level val notEnoughLevelEffect = SequentialEffect( @@ -64,16 +60,16 @@ object BukkitSummonFairy { val validTimeState = fairyAPI.fairyValidTimeState(uuid).toIO.unsafeRunSync() - if (playerLevel < 10) return LiftIO[F].liftIO(notEnoughLevelEffect(player)) // レベル不足 + if (playerLevel < 10) return notEnoughLevelEffect(player) // レベル不足 if (fairyAPI.fairyUsingState(uuid).toIO.unsafeRunSync() == Using) - return LiftIO[F].liftIO(alreadySummoned(player)) // 既に召喚している + return alreadySummoned(player) // 既に召喚している if (voteAPI.effectPoints(uuid).toIO.unsafeRunSync().value < validTimeState.value * 2) - return LiftIO[F].liftIO(notEnoughEffectPoint(player)) // 投票ptがたりなかった + return notEnoughEffectPoint(player) // 投票ptがたりなかった val levelCappedManaAmount = - ContextCoercion(manaApi.readManaAmount(player)).toIO.unsafeRunSync().cap.value + manaApi.readManaAmount(player).unsafeRunSync().cap.value // 回復するマナの量 val recoveryMana = FairyRecoveryManaAmount.manaAmountAt(levelCappedManaAmount) @@ -92,12 +88,13 @@ object BukkitSummonFairy { validTimes match { case Some(_) => () case None => - FairySpeechRoutine.start[F, G](player).start + import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.sleepAndRoutineContext + FairySpeechRoutine.start(player).start () } } - LiftIO[F].liftIO { + LiftIO[IO].liftIO { SequentialEffect( UnfocusedEffect(eff.toIO.unsafeRunAsyncAndForget()), MessageEffect( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala index f0e36dc72d..379180e2d7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines -import cats.effect.{ConcurrentEffect, Sync, SyncEffect, Timer} +import cats.effect.{ConcurrentEffect, IO, SyncIO, Timer} import com.github.unchama.concurrent.{RepeatingRoutine, RepeatingTaskContext} import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI @@ -11,22 +11,25 @@ import scala.concurrent.duration.FiniteDuration object FairySpeechRoutine { - def start[F[_]: ConcurrentEffect: Timer, G[_]: SyncEffect](player: Player)( - implicit fairyAPI: FairyAPI[F], + def start(player: Player)( + implicit fairyAPI: FairyAPI[SyncIO], + concurrentEffect: ConcurrentEffect[SyncIO], context: RepeatingTaskContext, - onMainThread: OnMinecraftServerThread[F] - ): F[Nothing] = { + onMainThread: OnMinecraftServerThread[IO] + ): IO[Nothing] = { - val repeatInterval: F[FiniteDuration] = Sync[F].pure { + val repeatInterval: IO[FiniteDuration] = IO { import scala.concurrent.duration._ 1.minute } - RepeatingRoutine.permanentRoutine[F, G]( + implicit val timer: Timer[IO] = IO.timer(context) + + RepeatingRoutine.permanentRoutine( repeatInterval, onMainThread.runAction { - BukkitFairySpeak[F].speakRandomly(player) + BukkitFairySpeak[SyncIO].speakRandomly(player) } ) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index eac34633be..dc0e7fa681 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -1,20 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure import cats.effect.Sync -import com.github.unchama.seichiassist.subsystems.fairy.domain.{ - AppleOpenState, - FairyPersistence, - FairyRecoveryMana, - FairyUsingState, - FairyValidTimeState -} -import com.github.unchama.seichiassist.subsystems.mana.subsystems.fairy.domain.{ - AppleOpenState, - FairyPersistence, - FairyRecoveryMana, - FairyUsingState, - FairyValidTimeState -} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, FairyPersistence, From 676b558268a18d8af61487c4ad47a118ea872fe0 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 19:58:18 +0900 Subject: [PATCH 043/482] =?UTF-8?q?[Replace]VoteMenu=E3=81=AB=E7=BD=AE?= =?UTF-8?q?=E3=81=8D=E6=8F=9B=E3=81=88=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/stickmenu/FirstPage.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/stickmenu/FirstPage.scala b/src/main/scala/com/github/unchama/seichiassist/menus/stickmenu/FirstPage.scala index 49e846009a..1e230985c3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/stickmenu/FirstPage.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/stickmenu/FirstPage.scala @@ -22,7 +22,8 @@ import com.github.unchama.seichiassist.menus.{ CommonButtons, HomeMenu, RegionMenu, - ServerSwitchMenu + ServerSwitchMenu, + VoteMenu } import com.github.unchama.seichiassist.subsystems.anywhereender.AnywhereEnderChestAPI import com.github.unchama.seichiassist.subsystems.anywhereender.domain.AccessDenialReason @@ -87,6 +88,7 @@ object FirstPage extends Menu { val ioCanOpenHomeMenu: IO CanOpen HomeMenu.type, val ioCanOpenPassiveSkillMenu: IO CanOpen PassiveSkillMenu.type, val ioCanOpenRankingRootMenu: IO CanOpen RankingRootMenu.type, + val ioCanOpenVoteMenu: IO CanOpen VoteMenu.type, val enderChestAccessApi: AnywhereEnderChestAPI[IO] ) @@ -734,7 +736,7 @@ object FirstPage extends Menu { ) } - val votePointMenuButton: Button = { + def votePointMenuButton(implicit ioCanOpenVoteMenu: IO CanOpen VoteMenu.type): Button = { val iconItemStack = new IconItemStackBuilder(Material.DIAMOND) .enchanted() @@ -746,8 +748,7 @@ object FirstPage extends Menu { iconItemStack, LeftClickButtonEffect( CommonSoundEffects.menuTransitionFenceSound, - // TODO メニューに置き換える - ComputedEffect(p => openInventoryEffect(MenuInventoryData.getVotingMenuData(p))) + ioCanOpenVoteMenu.open(VoteMenu) ) ) } From 7a9656fcfe8c0f2f09140ea4b3b4d36a0da25e57 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 21:48:21 +0900 Subject: [PATCH 044/482] [Fix]compile error --- .../unchama/seichiassist/SeichiAssist.scala | 10 +++++++++ .../seichiassist/menus/TopLevelRouter.scala | 10 ++++++++- .../unchama/seichiassist/menus/VoteMenu.scala | 22 ++++++++----------- .../menus/stickmenu/FirstPage.scala | 2 +- .../actions/ReceiveVoteBenefits.scala | 2 +- .../actions/BukkitReceiveVoteBenefits.scala | 4 ++-- .../bukkit/actions/BukkitSummonFairy.scala | 21 +++++++++--------- .../bukkit/routines/FairySpeechRoutine.scala | 18 +++++++++------ 8 files changed, 54 insertions(+), 35 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 1e87f7e588..b1a055e368 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -78,6 +78,8 @@ import com.github.unchama.seichiassist.subsystems.present.infrastructure.GlobalP import com.github.unchama.seichiassist.subsystems.seasonalevents.api.SeasonalEventsAPI import com.github.unchama.seichiassist.subsystems.sharedinventory.SharedInventoryAPI import com.github.unchama.seichiassist.subsystems.subhome.SubHomeReadAPI +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.task.PlayerDataSaveTask import com.github.unchama.seichiassist.task.global._ import com.github.unchama.util.{ActionStatus, ClassUtils} @@ -386,6 +388,12 @@ class SeichiAssist extends JavaPlugin() { private lazy val sharedInventorySystem: subsystems.sharedinventory.System[IO] = subsystems.sharedinventory.System.wired[IO] + private lazy val voteSystem: subsystems.vote.System[IO] = + subsystems.vote.System.wired[IO] + + private lazy val fairySystem: subsystems.vote.subsystems.fairy.System[IO] = + subsystems.vote.subsystems.fairy.System.wired[IO] + private lazy val wiredSubsystems: List[Subsystem[IO]] = List( mebiusSystem, expBottleStackSystem, @@ -564,6 +572,8 @@ class SeichiAssist extends JavaPlugin() { anywhereEnderSystem.accessApi implicit val sharedInventoryAPI: SharedInventoryAPI[IO, Player] = sharedInventorySystem.api + implicit val voteAPI: VoteAPI[IO] = voteSystem.api + implicit val fairyAPI: FairyAPI[IO] = fairySystem.api val menuRouter = TopLevelRouter.apply import menuRouter.{canOpenStickMenu, ioCanOpenCategorizedMineStackMenu} diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala index 12c1a62f07..0eb513e230 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala @@ -40,6 +40,8 @@ import com.github.unchama.seichiassist.subsystems.ranking.api.AssortedRankingApi import com.github.unchama.seichiassist.subsystems.ranking.domain.values.{LoginTime, VoteCount} import com.github.unchama.seichiassist.subsystems.sharedinventory.SharedInventoryAPI import com.github.unchama.seichiassist.subsystems.subhome.SubHomeReadAPI +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import io.chrisdavenport.cats.effect.time.JavaTime import org.bukkit.entity.Player @@ -70,7 +72,9 @@ object TopLevelRouter { globalNotification: DiscordNotificationAPI[IO], subHomeReadApi: SubHomeReadAPI[IO], enderChestAccessApi: AnywhereEnderChestAPI[IO], - sharedInventoryAPI: SharedInventoryAPI[IO, Player] + sharedInventoryAPI: SharedInventoryAPI[IO, Player], + voteAPI: VoteAPI[IO], + fairyAPI: FairyAPI[IO] ): TopLevelRouter[IO] = new TopLevelRouter[IO] { import assortedRankingApi._ @@ -117,8 +121,12 @@ object TopLevelRouter { implicit lazy val rankingRootMenuEnv: RankingRootMenu.Environment = new RankingRootMenu.Environment + implicit lazy val voteMenuEnv: VoteMenu.Environment = new VoteMenu.Environment + implicit lazy val stickMenuEnv: FirstPage.Environment = new FirstPage.Environment + implicit lazy val ioCanOpenVoteMenu: IO CanOpen VoteMenu.type = _.open + implicit lazy val ioCanOpenSelectItemColorMenu: IO CanOpen MineStackSelectItemColorMenu = _.open implicit lazy val ioCanOpenAchievementGroupMenu: IO CanOpen AchievementGroupMenu = _.open diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 5886a3aee4..a0b419735d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.menus -import cats.effect.{ConcurrentEffect, ContextShift, IO, SyncIO} +import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.itemstackbuilder.IconItemStackBuilder import com.github.unchama.menuinventory.router.CanOpen import com.github.unchama.menuinventory.slot.button.Button @@ -39,10 +39,8 @@ import java.util.UUID object VoteMenu extends Menu { class Environment( - implicit val voteAPI: VoteAPI[SyncIO], - val fairyAPI: FairyAPI[SyncIO], - val concurrentEffect: ConcurrentEffect[SyncIO], - val contextShift: ContextShift[IO], + implicit val voteAPI: VoteAPI[IO], + val fairyAPI: FairyAPI[IO], val breakCountAPI: BreakCountAPI[IO, SyncIO, Player], val manaApi: ManaApi[IO, SyncIO, Player], val ioCanOpenFirstPage: IO CanOpen FirstPage.type @@ -86,7 +84,7 @@ object VoteMenu extends Menu { IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) def receiveVoteBenefitsButton(uuid: UUID)( - implicit voteAPI: VoteAPI[SyncIO], + implicit voteAPI: VoteAPI[IO], breakCountAPI: BreakCountAPI[IO, SyncIO, Player] ): Button = { for { @@ -150,7 +148,7 @@ object VoteMenu extends Menu { } ) - def fairySummonTimeToggleButton(uuid: UUID)(implicit fairyAPI: FairyAPI[SyncIO]): Button = { + def fairySummonTimeToggleButton(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { val validTimeState = fairyAPI.fairyValidTimeState(uuid).unsafeRunSync() Button( new IconItemStackBuilder(Material.WATCH) @@ -178,7 +176,7 @@ object VoteMenu extends Menu { ) } - def fairyContractSettingToggle(uuid: UUID)(implicit fairyAPI: FairyAPI[SyncIO]): Button = + def fairyContractSettingToggle(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = Button( new IconItemStackBuilder(Material.PAPER) .title(s"$GOLD$UNDERLINE${BOLD}妖精とのお約束") @@ -202,7 +200,7 @@ object VoteMenu extends Menu { } ) - def fairyPlaySoundToggleButton(uuid: UUID)(implicit fairyAPI: FairyAPI[SyncIO]): Button = { + def fairyPlaySoundToggleButton(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { val description = List(s"$RESET$DARK_GRAY※この機能はデフォルトでONです。", s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え") val playSoundOnLore = List(s"$RESET${GREEN}現在音が鳴る設定になっています。") ++ description @@ -229,10 +227,8 @@ object VoteMenu extends Menu { } def fairySummonButton(player: Player)( - implicit fairyAPI: FairyAPI[SyncIO], - voteAPI: VoteAPI[SyncIO], - concurrentEffect: ConcurrentEffect[SyncIO], - contextShift: ContextShift[IO], + implicit fairyAPI: FairyAPI[IO], + voteAPI: VoteAPI[IO], breakCountAPI: BreakCountAPI[IO, SyncIO, Player], manaApi: ManaApi[IO, SyncIO, Player] ): Button = { diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/stickmenu/FirstPage.scala b/src/main/scala/com/github/unchama/seichiassist/menus/stickmenu/FirstPage.scala index 1e230985c3..822af6b4f4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/stickmenu/FirstPage.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/stickmenu/FirstPage.scala @@ -12,7 +12,7 @@ import com.github.unchama.menuinventory.slot.button.action.{ } import com.github.unchama.menuinventory.slot.button.{Button, RecomputedButton, action} import com.github.unchama.seichiassist.data.descrptions.PlayerStatsLoreGenerator -import com.github.unchama.seichiassist.data.{GachaSkullData, MenuInventoryData} +import com.github.unchama.seichiassist.data.GachaSkullData import com.github.unchama.seichiassist.effects.player.CommonSoundEffects import com.github.unchama.seichiassist.menus.achievement.AchievementMenu import com.github.unchama.seichiassist.menus.minestack.MineStackMainMenu diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala index dafd5a2cb3..daeadd24fb 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala @@ -7,7 +7,7 @@ trait ReceiveVoteBenefits[F[_], G[_], Player] { def receive( player: Player - )(implicit voteAPI: VoteAPI[G], breakCountAPI: BreakCountAPI[F, G, Player]): G[Unit] + )(implicit voteAPI: VoteAPI[F], breakCountAPI: BreakCountAPI[F, G, Player]): F[Unit] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 05f9d4a4dc..91759864f3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -25,13 +25,13 @@ object BukkitReceiveVoteBenefits { new ReceiveVoteBenefits[F, G, Player] { override def receive( player: Player - )(implicit voteAPI: VoteAPI[G], breakCountAPI: BreakCountAPI[F, G, Player]): G[Unit] = { + )(implicit voteAPI: VoteAPI[F], breakCountAPI: BreakCountAPI[F, G, Player]): F[Unit] = { val uuid = player.getUniqueId for { notReceivedBenefits <- voteAPI.notReceivedVoteBenefits(uuid) // 受け取っていない投票特典数 _ <- voteAPI.increaseVoteBenefits(uuid, notReceivedBenefits) // 受け取ってない分を受け取ったことにする } yield { - if (notReceivedBenefits.value == 0) return Sync[G].pure(()) + if (notReceivedBenefits.value == 0) return Sync[F].pure(()) val playerLevel = ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read.map { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 22a27e279a..66b5495fa8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -1,7 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions -import cats.effect.{ConcurrentEffect, ContextShift, IO, LiftIO, SyncIO} -import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMainThread +import cats.effect.{ContextShift, IO, LiftIO, SyncIO} import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI @@ -21,14 +20,14 @@ import org.bukkit.ChatColor._ import org.bukkit.Sound import org.bukkit.entity.Player +import scala.concurrent.ExecutionContext + object BukkitSummonFairy { def apply(player: Player)( implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], - fairyAPI: FairyAPI[SyncIO], - concurrentEffect: ConcurrentEffect[SyncIO], - contextShift: ContextShift[IO], - voteAPI: VoteAPI[SyncIO], + fairyAPI: FairyAPI[IO], + voteAPI: VoteAPI[IO], manaApi: ManaApi[IO, SyncIO, Player] ): SummonFairy[IO] = new SummonFairy[IO] { override def summon: IO[Unit] = { @@ -58,14 +57,14 @@ object BukkitSummonFairy { val uuid = player.getUniqueId - val validTimeState = fairyAPI.fairyValidTimeState(uuid).toIO.unsafeRunSync() + val validTimeState = fairyAPI.fairyValidTimeState(uuid).unsafeRunSync() if (playerLevel < 10) return notEnoughLevelEffect(player) // レベル不足 - if (fairyAPI.fairyUsingState(uuid).toIO.unsafeRunSync() == Using) + if (fairyAPI.fairyUsingState(uuid).unsafeRunSync() == Using) return alreadySummoned(player) // 既に召喚している - if (voteAPI.effectPoints(uuid).toIO.unsafeRunSync().value < validTimeState.value * 2) + if (voteAPI.effectPoints(uuid).unsafeRunSync().value < validTimeState.value * 2) return notEnoughEffectPoint(player) // 投票ptがたりなかった val levelCappedManaAmount = @@ -89,6 +88,8 @@ object BukkitSummonFairy { case Some(_) => () case None => import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.sleepAndRoutineContext + implicit val contextShift: ContextShift[IO] = + IO.contextShift(ExecutionContext.global) FairySpeechRoutine.start(player).start () } @@ -96,7 +97,7 @@ object BukkitSummonFairy { LiftIO[IO].liftIO { SequentialEffect( - UnfocusedEffect(eff.toIO.unsafeRunAsyncAndForget()), + UnfocusedEffect(eff.unsafeRunAsyncAndForget()), MessageEffect( List( s"$RESET$YELLOW${BOLD}妖精を呼び出しました!", diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala index 379180e2d7..14882c8645 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala @@ -3,6 +3,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit. import cats.effect.{ConcurrentEffect, IO, SyncIO, Timer} import com.github.unchama.concurrent.{RepeatingRoutine, RepeatingTaskContext} import com.github.unchama.minecraft.actions.OnMinecraftServerThread +import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitFairySpeak import org.bukkit.entity.Player @@ -11,12 +12,9 @@ import scala.concurrent.duration.FiniteDuration object FairySpeechRoutine { - def start(player: Player)( - implicit fairyAPI: FairyAPI[SyncIO], - concurrentEffect: ConcurrentEffect[SyncIO], - context: RepeatingTaskContext, - onMainThread: OnMinecraftServerThread[IO] - ): IO[Nothing] = { + def start( + player: Player + )(implicit fairyAPI: FairyAPI[IO], context: RepeatingTaskContext): IO[Nothing] = { val repeatInterval: IO[FiniteDuration] = IO { import scala.concurrent.duration._ @@ -25,11 +23,17 @@ object FairySpeechRoutine { } implicit val timer: Timer[IO] = IO.timer(context) + implicit val ioCE: ConcurrentEffect[IO] = + IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) + implicit val onMainThread: OnMinecraftServerThread[IO] = + PluginExecutionContexts.onMainThread RepeatingRoutine.permanentRoutine( repeatInterval, onMainThread.runAction { - BukkitFairySpeak[SyncIO].speakRandomly(player) + SyncIO { + BukkitFairySpeak[IO].speakRandomly(player).unsafeRunSync() + } } ) } From 33c75326d55ee3624af67c3fb91633c3d92e8213 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 21:53:53 +0900 Subject: [PATCH 045/482] =?UTF-8?q?[Fix]effectPoint=E3=82=92=E5=8F=96?= =?UTF-8?q?=E5=BE=97=E3=81=99=E3=82=8B=E3=81=9F=E3=82=81=E3=81=AEuuid=3D?= =?UTF-8?q?=E3=81=8Cname=E6=8B=85=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/infrastructure/JdbcVotePersistence.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index 3ac4dc32a2..b9f252a1b5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -96,7 +96,7 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { */ override def effectPoints(uuid: UUID): F[EffectPoint] = Sync[F].delay { DB.readOnly { implicit session => - val effectPoints = sql"SELECT effectpoint FROM playerdata WHERE name = ${uuid.toString}" + val effectPoints = sql"SELECT effectpoint FROM playerdata WHERE uuid = ${uuid.toString}" .map(_.int("effectpoint")) .single() .apply() From d8c801676ed2e5f77000377b08d424ecc68b914b Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 22:15:09 +0900 Subject: [PATCH 046/482] =?UTF-8?q?[Fix]fairyPlaySoundRepository=E3=81=A7?= =?UTF-8?q?=E5=88=9D=E6=9C=9F=E5=80=A4=E3=82=92=E6=8C=81=E3=81=9F=E3=81=9B?= =?UTF-8?q?=E3=81=9A=E3=81=AB=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B=E3=81=A8?= =?UTF-8?q?=E3=81=8D=E3=81=AB=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E5=A0=B4?= =?UTF-8?q?=E5=90=88=E3=81=AF=E5=88=9D=E6=9C=9F=E5=80=A4=E3=82=92=E8=BF=94?= =?UTF-8?q?=E3=81=99=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 2 +- .../subsystems/vote/subsystems/fairy/System.scala | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index a0b419735d..d61f1148ca 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -219,7 +219,7 @@ object VoteMenu extends Menu { SequentialEffect( FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), UnfocusedEffect { - fairyAPI.fairyPlaySoundToggle(uuid).unsafeRunSync() + fairyAPI.fairyPlaySoundToggle(uuid).unsafeRunAsyncAndForget() } ) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 9293cf18b4..caa6b0b433 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy -import cats.effect.ConcurrentEffect +import cats.effect.{ConcurrentEffect, Sync} import cats.effect.concurrent.Ref import com.github.unchama.datarepository.KeyedDataRepository import com.github.unchama.minecraft.actions.OnMinecraftServerThread @@ -52,13 +52,13 @@ object System { override protected val fairyPlaySoundRepository : KeyedDataRepository[UUID, Ref[F, FairyPlaySound]] = - KeyedDataRepository.unlift[UUID, Ref[F, FairyPlaySound]](_ => - Some(Ref.unsafe(FairyPlaySound.play)) - ) + KeyedDataRepository.unlift[UUID, Ref[F, FairyPlaySound]] - override def fairyPlaySound(uuid: UUID): F[FairyPlaySound] = fairyPlaySoundRepository( - uuid - ).get + override def fairyPlaySound(uuid: UUID): F[FairyPlaySound] = + if (fairyPlaySoundRepository.isDefinedAt(uuid)) + fairyPlaySoundRepository(uuid).get + else + Sync[F].pure(FairyPlaySound.play) override def fairyPlaySoundToggle(uuid: UUID): F[Unit] = for { nowSetting <- fairyPlaySound(uuid) From d66b0f51828c77d99f8c8f508c119b7cd0300104 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 23:05:05 +0900 Subject: [PATCH 047/482] =?UTF-8?q?[Fix]UUID=E3=81=8Cstring=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=8F=9B=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA?= =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=9F=E3=81=AE=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listener/PlayerInventoryListener.scala | 2 +- .../unchama/seichiassist/menus/VoteMenu.scala | 2 +- .../vote/subsystems/fairy/FairyAPI.scala | 10 +--------- .../vote/subsystems/fairy/System.scala | 19 ++++++------------- .../infrastructure/JdbcFairyPersistence.scala | 2 +- 5 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala b/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala index 13d03a50f7..217b112af4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala +++ b/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala @@ -386,7 +386,7 @@ class PlayerInventoryListener( } // 投票ptメニュー - @EventHandler +// @EventHandler def onVotingMenuEvent(event: InventoryClickEvent): Unit = { // 外枠のクリック処理なら終了 if (event.getClickedInventory == null) { diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index d61f1148ca..44af03cdf1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -250,7 +250,7 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( UnfocusedEffect { - BukkitSummonFairy(player).summon.unsafeRunAsyncAndForget() + BukkitSummonFairy(player).summon.unsafeRunSync() }, closeInventoryEffect ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 5ebb17e840..e7eb4b13ba 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -2,15 +2,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.concurrent.Ref import com.github.unchama.datarepository.KeyedDataRepository -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - AppleOpenState, - FairyLore, - FairyPlaySound, - FairyRecoveryMana, - FairyUsingState, - FairyValidTimeState, - FairyValidTimes -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ import java.util.UUID diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index caa6b0b433..1e11a87a71 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -6,15 +6,7 @@ import com.github.unchama.datarepository.KeyedDataRepository import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit.FairyLoreTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - AppleOpenState, - FairyLore, - FairyPlaySound, - FairyRecoveryMana, - FairyUsingState, - FairyValidTimeState, - FairyValidTimes -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import java.util.UUID @@ -39,7 +31,7 @@ object System { override def getFairyLore(uuid: UUID): F[FairyLore] = for { state <- appleOpenState(uuid) - } yield FairyLoreTable.loreTable(state.amount) + } yield FairyLoreTable.loreTable(state.amount - 1) override def updateFairySummonState( uuid: UUID, @@ -52,13 +44,14 @@ object System { override protected val fairyPlaySoundRepository : KeyedDataRepository[UUID, Ref[F, FairyPlaySound]] = - KeyedDataRepository.unlift[UUID, Ref[F, FairyPlaySound]] + KeyedDataRepository.unlift[UUID, Ref[F, FairyPlaySound]] { _ => + Some(Ref.unsafe(FairyPlaySound.play)) + } override def fairyPlaySound(uuid: UUID): F[FairyPlaySound] = if (fairyPlaySoundRepository.isDefinedAt(uuid)) fairyPlaySoundRepository(uuid).get - else - Sync[F].pure(FairyPlaySound.play) + else Sync[F].pure(FairyPlaySound.play) override def fairyPlaySoundToggle(uuid: UUID): F[Unit] = for { nowSetting <- fairyPlaySound(uuid) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index dc0e7fa681..f6629dcf58 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -105,7 +105,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { fairyRecoveryMana: FairyRecoveryMana ): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET VotingFairyRecoveryValue = ${fairyRecoveryMana.recoveryMana} WHERE uuid = $uuid" + sql"UPDATE playerdata SET VotingFairyRecoveryValue = ${fairyRecoveryMana.recoveryMana} WHERE uuid = ${uuid.toString}" .execute() .apply() } From d06ed4d0d385ff463a3e35dee093eb40090e555a Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 25 Jul 2022 23:36:34 +0900 Subject: [PATCH 048/482] =?UTF-8?q?[Fix]fairyValidTimeRepository=E3=81=ABR?= =?UTF-8?q?ef=E3=82=92=E5=85=A5=E3=82=8C=E5=BF=98=E3=82=8C=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=9F=E3=81=AE=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/System.scala | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 1e11a87a71..b66f16c69c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -61,15 +61,21 @@ object System { override protected[this] val fairyValidTimeRepository : KeyedDataRepository[UUID, Ref[F, Option[FairyValidTimes]]] = - KeyedDataRepository.unlift[UUID, Ref[F, Option[FairyValidTimes]]](_ => None) + KeyedDataRepository.unlift[UUID, Ref[F, Option[FairyValidTimes]]](_ => + Some(Ref.unsafe(None)) + ) override def fairyValidTimes(uuid: UUID): F[Option[FairyValidTimes]] = - fairyValidTimeRepository(uuid).get + if (fairyValidTimeRepository.isDefinedAt(uuid)) + fairyValidTimeRepository(uuid).get + else + Sync[F].pure(None) override def updateFairyValidTimes( uuid: UUID, fairyValidTimes: Option[FairyValidTimes] - ): F[Unit] = fairyValidTimeRepository(uuid).set(fairyValidTimes) + ): F[Unit] = + fairyValidTimeRepository(uuid).set(fairyValidTimes) override def fairyUsingState(uuid: UUID): F[FairyUsingState] = persistence.fairyUsingState(uuid) From 987efde9444430eca7c7be90285c66716408f071 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 26 Jul 2022 11:59:58 +0900 Subject: [PATCH 049/482] =?UTF-8?q?[Add]FairyValidTimeRepository=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/SeichiAssist.scala | 6 +- .../seichiassist/menus/TopLevelRouter.scala | 2 +- .../unchama/seichiassist/menus/VoteMenu.scala | 34 ++-- .../vote/subsystems/fairy/FairyAPI.scala | 24 +-- .../vote/subsystems/fairy/System.scala | 187 +++++++++++------- .../application/actions/FairySpeak.scala | 6 +- .../FairyValidTimeRepositoryDefinition.scala | 27 +++ .../bukkit/actions/BukkitFairySpeak.scala | 27 ++- .../bukkit/actions/BukkitSummonFairy.scala | 14 +- .../bukkit/routines/FairySpeechRoutine.scala | 2 +- .../fairy/domain/FairyPersistence.scala | 12 +- .../fairy/domain/FairyPlaySound.scala | 4 +- ...dTimeState.scala => FairySummonCost.scala} | 5 +- .../fairy/domain/FairyValidTimesState.scala | 21 ++ .../infrastructure/JdbcFairyPersistence.scala | 19 +- 15 files changed, 245 insertions(+), 145 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyValidTimeRepositoryDefinition.scala rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{FairyValidTimeState.scala => FairySummonCost.scala} (72%) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimesState.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index b1a055e368..5f512f6de2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -391,8 +391,8 @@ class SeichiAssist extends JavaPlugin() { private lazy val voteSystem: subsystems.vote.System[IO] = subsystems.vote.System.wired[IO] - private lazy val fairySystem: subsystems.vote.subsystems.fairy.System[IO] = - subsystems.vote.subsystems.fairy.System.wired[IO] + private lazy val fairySystem: subsystems.vote.subsystems.fairy.System[IO, Player] = + subsystems.vote.subsystems.fairy.System.wired[IO, SyncIO].unsafeRunSync() private lazy val wiredSubsystems: List[Subsystem[IO]] = List( mebiusSystem, @@ -573,7 +573,7 @@ class SeichiAssist extends JavaPlugin() { implicit val sharedInventoryAPI: SharedInventoryAPI[IO, Player] = sharedInventorySystem.api implicit val voteAPI: VoteAPI[IO] = voteSystem.api - implicit val fairyAPI: FairyAPI[IO] = fairySystem.api + implicit val fairyAPI: FairyAPI[IO, Player] = fairySystem.api val menuRouter = TopLevelRouter.apply import menuRouter.{canOpenStickMenu, ioCanOpenCategorizedMineStackMenu} diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala index 0eb513e230..cf36ecaef5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala @@ -74,7 +74,7 @@ object TopLevelRouter { enderChestAccessApi: AnywhereEnderChestAPI[IO], sharedInventoryAPI: SharedInventoryAPI[IO, Player], voteAPI: VoteAPI[IO], - fairyAPI: FairyAPI[IO] + fairyAPI: FairyAPI[IO, Player] ): TopLevelRouter[IO] = new TopLevelRouter[IO] { import assortedRankingApi._ diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 44af03cdf1..ce19226615 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -23,7 +23,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, FairyMessage, FairyPlaySound, - FairyValidTimeState + FairySummonCost } import com.github.unchama.seichiassist.task.VotingFairyTask import com.github.unchama.targetedeffect.commandsender.MessageEffect @@ -40,7 +40,7 @@ object VoteMenu extends Menu { class Environment( implicit val voteAPI: VoteAPI[IO], - val fairyAPI: FairyAPI[IO], + val fairyAPI: FairyAPI[IO, Player], val breakCountAPI: BreakCountAPI[IO, SyncIO, Player], val manaApi: ManaApi[IO, SyncIO, Player], val ioCanOpenFirstPage: IO CanOpen FirstPage.type @@ -148,17 +148,19 @@ object VoteMenu extends Menu { } ) - def fairySummonTimeToggleButton(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { - val validTimeState = fairyAPI.fairyValidTimeState(uuid).unsafeRunSync() + def fairySummonTimeToggleButton( + uuid: UUID + )(implicit fairyAPI: FairyAPI[IO, Player]): Button = { + val fairySummonCost = fairyAPI.fairySummonCost(uuid).unsafeRunSync() Button( new IconItemStackBuilder(Material.WATCH) .title(s"$AQUA$UNDERLINE${BOLD}マナ妖精 時間設定") .lore( List( - s"$RESET$GREEN$BOLD${VotingFairyTask.dispToggleVFTime(validTimeState.value)}", + s"$RESET$GREEN$BOLD${VotingFairyTask.dispToggleVFTime(fairySummonCost.value)}", "", s"$RESET${GRAY}コスト", - s"$RESET$RED$BOLD${validTimeState.value * 2}投票pt", + s"$RESET$RED$BOLD${fairySummonCost.value * 2}投票pt", "", s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え" ) @@ -169,14 +171,16 @@ object VoteMenu extends Menu { FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), UnfocusedEffect( fairyAPI - .updateFairySummonState(uuid, FairyValidTimeState(validTimeState.value % 4 + 1)) + .updateFairySummonCost(uuid, FairySummonCost(fairySummonCost.value % 4 + 1)) ) ) } ) } - def fairyContractSettingToggle(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = + def fairyContractSettingToggle( + uuid: UUID + )(implicit fairyAPI: FairyAPI[IO, Player]): Button = Button( new IconItemStackBuilder(Material.PAPER) .title(s"$GOLD$UNDERLINE${BOLD}妖精とのお約束") @@ -200,7 +204,9 @@ object VoteMenu extends Menu { } ) - def fairyPlaySoundToggleButton(uuid: UUID)(implicit fairyAPI: FairyAPI[IO]): Button = { + def fairyPlaySoundToggleButton( + uuid: UUID + )(implicit fairyAPI: FairyAPI[IO, Player]): Button = { val description = List(s"$RESET$DARK_GRAY※この機能はデフォルトでONです。", s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え") val playSoundOnLore = List(s"$RESET${GREEN}現在音が鳴る設定になっています。") ++ description @@ -210,7 +216,7 @@ object VoteMenu extends Menu { new IconItemStackBuilder(Material.JUKEBOX) .title(s"$GOLD$UNDERLINE${BOLD}マナ妖精の音トグル") .lore( - if (fairyAPI.fairyPlaySound(uuid).unsafeRunSync() == FairyPlaySound.play) + if (fairyAPI.fairyPlaySound(uuid).unsafeRunSync() == FairyPlaySound.on) playSoundOnLore else playSoundOffLore ) @@ -227,13 +233,13 @@ object VoteMenu extends Menu { } def fairySummonButton(player: Player)( - implicit fairyAPI: FairyAPI[IO], + implicit fairyAPI: FairyAPI[IO, Player], voteAPI: VoteAPI[IO], breakCountAPI: BreakCountAPI[IO, SyncIO, Player], manaApi: ManaApi[IO, SyncIO, Player] ): Button = { val fairySummonState = - fairyAPI.fairyValidTimeState(player.getUniqueId).unsafeRunSync().value + fairyAPI.fairySummonCost(player.getUniqueId).unsafeRunSync().value Button( new IconItemStackBuilder(Material.GHAST_TEAR) .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}マナ妖精 召喚") @@ -258,7 +264,7 @@ object VoteMenu extends Menu { ) } - def checkTimeButton(player: Player)(implicit fairyAPI: FairyAPI[IO]): Button = { + def checkTimeButton(player: Player)(implicit fairyAPI: FairyAPI[IO, Player]): Button = { Button( new IconItemStackBuilder(Material.COMPASS) .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}マナ妖精に時間を聞く") @@ -269,7 +275,7 @@ object VoteMenu extends Menu { SequentialEffect( UnfocusedEffect { val endTime = - fairyAPI.fairyValidTimes(player.getUniqueId).unsafeRunSync().get.endTime + fairyAPI.fairyValidTimes(player).unsafeRunSync().get.endTime BukkitFairySpeak[IO] .speak( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index e7eb4b13ba..b9a14da1d2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -6,7 +6,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ import java.util.UUID -trait FairyWriteAPI[F[_]] { +trait FairyWriteAPI[F[_], Player] { /** * 妖精にあげるりんごの開放状態を変更する @@ -15,9 +15,9 @@ trait FairyWriteAPI[F[_]] { def updateAppleOpenState(uuid: UUID, appleOpenState: AppleOpenState): F[Unit] /** - * 妖精有効な時間の状態を変更します。 + * 妖精を召喚するためのコストを変更します。 */ - def updateFairySummonState(uuid: UUID, fairyValidTimeState: FairyValidTimeState): F[Unit] + def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] /** * fairyPlaySoundRepositoryの音を鳴らすかどうかの設定を切り替える @@ -37,17 +37,17 @@ trait FairyWriteAPI[F[_]] { /** * 妖精が有効な時間を変更する */ - def updateFairyValidTimes(uuid: UUID, fairyValidTimes: Option[FairyValidTimes]): F[Unit] + def updateFairyValidTimes(player: Player, fairyValidTimes: Option[FairyValidTimes]): F[Unit] } object FairyWriteAPI { - def apply[F[_]](implicit ev: FairyWriteAPI[F]): FairyWriteAPI[F] = ev + def apply[F[_], Player](implicit ev: FairyWriteAPI[F, Player]): FairyWriteAPI[F, Player] = ev } -trait FairyReadAPI[F[_]] { +trait FairyReadAPI[F[_], Player] { /** * 妖精にあげるりんごの開放状態を取得する @@ -55,9 +55,9 @@ trait FairyReadAPI[F[_]] { def appleOpenState(uuid: UUID): F[AppleOpenState] /** - * 妖精が有効な時間の状態を取得します + * 妖精を召喚するためのコストを取得する */ - def fairyValidTimeState(uuid: UUID): F[FairyValidTimeState] + def fairySummonCost(uuid: UUID): F[FairySummonCost] /** * `FairyLoreTable`からLoreを取得する @@ -92,21 +92,21 @@ trait FairyReadAPI[F[_]] { * 妖精の有効な時間を保存するリポジトリ * ※永続化は必要ない */ - protected[this] val fairyValidTimeRepository: KeyedDataRepository[UUID, Ref[F, Option[ + protected[this] val fairyValidTimeRepository: KeyedDataRepository[Player, Ref[F, Option[ FairyValidTimes ]]] /** * 妖精が有効な時間を返す */ - def fairyValidTimes(uuid: UUID): F[Option[FairyValidTimes]] + def fairyValidTimes(player: Player): F[Option[FairyValidTimes]] } object FairyReadAPI { - def apply[F[_]](implicit ev: FairyReadAPI[F]): FairyReadAPI[F] = ev + def apply[F[_], Player](implicit ev: FairyReadAPI[F, Player]): FairyReadAPI[F, Player] = ev } -trait FairyAPI[F[_]] extends FairyReadAPI[F] with FairyWriteAPI[F] +trait FairyAPI[F[_], Player] extends FairyReadAPI[F, Player] with FairyWriteAPI[F, Player] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index b66f16c69c..6e1f582d80 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -1,98 +1,133 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy -import cats.effect.{ConcurrentEffect, Sync} import cats.effect.concurrent.Ref +import cats.effect.{ConcurrentEffect, Sync, SyncEffect} import com.github.unchama.datarepository.KeyedDataRepository +import com.github.unchama.datarepository.bukkit.player.{ + BukkitRepositoryControls, + PlayerDataRepository +} +import com.github.unchama.datarepository.template.RepositoryDefinition +import com.github.unchama.generic.ContextCoercion import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit.FairyLoreTable +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.FairyValidTimeRepositoryDefinition import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit.FairyLoreTable import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence +import org.bukkit.entity.Player import java.util.UUID -trait System[F[_]] extends Subsystem[F] { - val api: FairyAPI[F] +trait System[F[_], Player] extends Subsystem[F] { + val api: FairyAPI[F, Player] } object System { - def wired[F[_]: ConcurrentEffect: OnMinecraftServerThread]: System[F] = { + import cats.implicits._ + + def wired[F[_]: ConcurrentEffect: OnMinecraftServerThread, G[_]: SyncEffect: ContextCoercion[ + *[_], + F + ]]: F[System[F, Player]] = { val persistence = new JdbcFairyPersistence[F] - new System[F] { - override val api: FairyAPI[F] = new FairyAPI[F] { - override def appleOpenState(uuid: UUID): F[AppleOpenState] = - persistence.appleOpenState(uuid) - - override def updateAppleOpenState(uuid: UUID, appleOpenState: AppleOpenState): F[Unit] = - persistence.changeAppleOpenState(uuid, appleOpenState) - - import cats.implicits._ - - override def getFairyLore(uuid: UUID): F[FairyLore] = for { - state <- appleOpenState(uuid) - } yield FairyLoreTable.loreTable(state.amount - 1) - - override def updateFairySummonState( - uuid: UUID, - validTimeState: FairyValidTimeState - ): F[Unit] = - persistence.updateFairyValidTimeState(uuid, validTimeState) - - override def fairyValidTimeState(uuid: UUID): F[FairyValidTimeState] = - persistence.fairySummonState(uuid) - - override protected val fairyPlaySoundRepository - : KeyedDataRepository[UUID, Ref[F, FairyPlaySound]] = - KeyedDataRepository.unlift[UUID, Ref[F, FairyPlaySound]] { _ => - Some(Ref.unsafe(FairyPlaySound.play)) - } - - override def fairyPlaySound(uuid: UUID): F[FairyPlaySound] = - if (fairyPlaySoundRepository.isDefinedAt(uuid)) - fairyPlaySoundRepository(uuid).get - else Sync[F].pure(FairyPlaySound.play) - - override def fairyPlaySoundToggle(uuid: UUID): F[Unit] = for { - nowSetting <- fairyPlaySound(uuid) - } yield fairyPlaySoundRepository(uuid).set( - if (nowSetting == FairyPlaySound.play) FairyPlaySound.notPlay else FairyPlaySound.play + implicit val fairyValidTimesState: FairyValidTimesState[G] = new FairyValidTimesState[G] + + for { + fairyValidTimeRepositoryControls <- ContextCoercion( + BukkitRepositoryControls.createHandles( + RepositoryDefinition + .Phased + .TwoPhased( + FairyValidTimeRepositoryDefinition.initialization[G, Player], + FairyValidTimeRepositoryDefinition.finalization[G, Player] + ) ) - - override protected[this] val fairyValidTimeRepository - : KeyedDataRepository[UUID, Ref[F, Option[FairyValidTimes]]] = - KeyedDataRepository.unlift[UUID, Ref[F, Option[FairyValidTimes]]](_ => - Some(Ref.unsafe(None)) + ) + } yield { + new System[F, Player] { + override val api: FairyAPI[F, Player] = new FairyAPI[F, Player] { + + val repository: PlayerDataRepository[Ref[F, Option[FairyValidTimes]]] = + fairyValidTimeRepositoryControls + .repository + .map(_.mapK[F](ContextCoercion.asFunctionK)) + + override def appleOpenState(uuid: UUID): F[AppleOpenState] = + persistence.appleOpenState(uuid) + + override def updateAppleOpenState( + uuid: UUID, + appleOpenState: AppleOpenState + ): F[Unit] = + persistence.changeAppleOpenState(uuid, appleOpenState) + + import cats.implicits._ + + override def getFairyLore(uuid: UUID): F[FairyLore] = for { + state <- appleOpenState(uuid) + } yield FairyLoreTable.loreTable(state.amount - 1) + + override def updateFairySummonCost( + uuid: UUID, + fairySummonCost: FairySummonCost + ): F[Unit] = + persistence.updateFairySummonCost(uuid, fairySummonCost) + + override def fairySummonCost(uuid: UUID): F[FairySummonCost] = + persistence.fairySummonCost(uuid) + + override protected val fairyPlaySoundRepository + : KeyedDataRepository[UUID, Ref[F, FairyPlaySound]] = + KeyedDataRepository.unlift[UUID, Ref[F, FairyPlaySound]] { _ => + Some(Ref.unsafe(FairyPlaySound.on)) + } + + override def fairyPlaySound(uuid: UUID): F[FairyPlaySound] = + if (fairyPlaySoundRepository.isDefinedAt(uuid)) + fairyPlaySoundRepository(uuid).get + else Sync[F].pure(FairyPlaySound.on) + + override def fairyPlaySoundToggle(uuid: UUID): F[Unit] = for { + nowSetting <- fairyPlaySound(uuid) + } yield fairyPlaySoundRepository(uuid).set( + if (nowSetting == FairyPlaySound.on) FairyPlaySound.off + else FairyPlaySound.on ) - override def fairyValidTimes(uuid: UUID): F[Option[FairyValidTimes]] = - if (fairyValidTimeRepository.isDefinedAt(uuid)) - fairyValidTimeRepository(uuid).get - else - Sync[F].pure(None) - - override def updateFairyValidTimes( - uuid: UUID, - fairyValidTimes: Option[FairyValidTimes] - ): F[Unit] = - fairyValidTimeRepository(uuid).set(fairyValidTimes) - - override def fairyUsingState(uuid: UUID): F[FairyUsingState] = - persistence.fairyUsingState(uuid) - - override def updateFairyUsingState( - uuid: UUID, - fairyUsingState: FairyUsingState - ): F[Unit] = - persistence.updateFairyUsingState(uuid, fairyUsingState) - - override def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] = - persistence.fairyRecoveryMana(uuid) - - override def updateFairyRecoveryManaAmount( - uuid: UUID, - fairyRecoveryMana: FairyRecoveryMana - ): F[Unit] = persistence.updateFairyRecoveryMana(uuid, fairyRecoveryMana) + override protected[this] val fairyValidTimeRepository + : KeyedDataRepository[Player, Ref[F, Option[FairyValidTimes]]] = + repository + + override def fairyValidTimes(player: Player): F[Option[FairyValidTimes]] = + fairyValidTimeRepository(player).get + + override def updateFairyValidTimes( + player: Player, + fairyValidTimes: Option[FairyValidTimes] + ): F[Unit] = + fairyValidTimeRepository(player).set(fairyValidTimes) + + override def fairyUsingState(uuid: UUID): F[FairyUsingState] = + persistence.fairyUsingState(uuid) + + override def updateFairyUsingState( + uuid: UUID, + fairyUsingState: FairyUsingState + ): F[Unit] = + persistence.updateFairyUsingState(uuid, fairyUsingState) + + override def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] = + persistence.fairyRecoveryMana(uuid) + + override def updateFairyRecoveryManaAmount( + uuid: UUID, + fairyRecoveryMana: FairyRecoveryMana + ): F[Unit] = persistence.updateFairyRecoveryMana(uuid, fairyRecoveryMana) + } + override val managedRepositoryControls: Seq[BukkitRepositoryControls[F, _]] = + Seq(fairyValidTimeRepositoryControls.coerceFinalizationContextTo[F]) } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala index 2429f06582..643a514fe2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala @@ -5,9 +5,11 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.F trait FairySpeak[F[_], Player] { - def speak(player: Player, fairyMessage: FairyMessage)(implicit fairyAPI: FairyAPI[F]): F[Unit] + def speak(player: Player, fairyMessage: FairyMessage)( + implicit fairyAPI: FairyAPI[F, Player] + ): F[Unit] - def speakRandomly(player: Player)(implicit fairyAPI: FairyAPI[F]): F[Unit] + def speakRandomly(player: Player)(implicit fairyAPI: FairyAPI[F, Player]): F[Unit] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyValidTimeRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyValidTimeRepositoryDefinition.scala new file mode 100644 index 0000000000..d0d129d17e --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyValidTimeRepositoryDefinition.scala @@ -0,0 +1,27 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository + +import cats.effect.Sync +import cats.effect.concurrent.Ref +import cats.{Applicative, Monad} +import com.github.unchama.datarepository.template.finalization.RepositoryFinalization +import com.github.unchama.datarepository.template.initialization.TwoPhasedRepositoryInitialization +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + FairyValidTimes, + FairyValidTimesState +} + +object FairyValidTimeRepositoryDefinition { + + def initialization[F[_]: Sync: Monad, Player]( + implicit fairyValidTimesState: FairyValidTimesState[F] + ): TwoPhasedRepositoryInitialization[F, Player, Ref[F, Option[FairyValidTimes]]] = + TwoPhasedRepositoryInitialization + .withoutPrefetching[F, Player, Ref[F, Option[FairyValidTimes]]] { _ => + Sync[F].pure(fairyValidTimesState.fairyValidTimes) + } + + def finalization[F[_]: Applicative, Player] + : RepositoryFinalization[F, Player, Ref[F, Option[FairyValidTimes]]] = + RepositoryFinalization.trivial + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala index abeb4274fa..c22a42987c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala @@ -1,5 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions +import cats.Monad import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import cats.effect.{ConcurrentEffect, Sync} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI @@ -19,11 +20,11 @@ object BukkitFairySpeak { def apply[F[_]: ConcurrentEffect]: FairySpeak[F, Player] = new FairySpeak[F, Player] { override def speak(player: Player, fairyMessage: FairyMessage)( - implicit fairyAPI: FairyAPI[F] + implicit fairyAPI: FairyAPI[F, Player] ): F[Unit] = for { playSound <- fairyAPI.fairyPlaySound(player.getUniqueId) } yield { - if (playSound == FairyPlaySound.play) + if (playSound == FairyPlaySound.on) SequentialEffect( FocusedSoundEffect(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f), MessageEffect(fairyMessage.message) @@ -31,16 +32,26 @@ object BukkitFairySpeak { else SequentialEffect(MessageEffect(fairyMessage.message)).apply(player) } - override def speakRandomly(player: Player)(implicit fairyAPI: FairyAPI[F]): F[Unit] = { + override def speakRandomly( + player: Player + )(implicit fairyAPI: FairyAPI[F, Player]): F[Unit] = { val nameCalledByFairy = NameCalledByFairy(player.getName) val uuid = player.getUniqueId - if (fairyAPI.fairyUsingState(uuid).toIO.unsafeRunSync() == FairyUsingState.NotUsing) - return Sync[F].unit + println("random1") + + implicit val F: Monad[F] = implicitly + + F.ifM(fairyAPI.fairyUsingState(uuid).map(_ == FairyUsingState.NotUsing))( + return Sync[F].unit, + Sync[F].unit + ) + + println("random2") for { - fairyValidTimesOpt <- fairyAPI.fairyValidTimes(uuid) - startTimeHour = fairyValidTimesOpt.getOrElse(return Sync[F].unit).startTime.getHour + fairyValidTimesOpt <- fairyAPI.fairyValidTimes(player) + startTimeHour = fairyValidTimesOpt.get.startTime.getHour fairyMessages = if (4 <= startTimeHour && startTimeHour < 10) FairyMessageTable.morningMessages(nameCalledByFairy) @@ -49,7 +60,7 @@ object BukkitFairySpeak { else FairyMessageTable.nightMessages(nameCalledByFairy) fairyMessage <- getMessageRandomly(fairyMessages) - } yield speak(player, fairyMessage) + } yield speak(player, fairyMessage).toIO.unsafeRunSync() } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 66b5495fa8..813cb728c6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -26,7 +26,7 @@ object BukkitSummonFairy { def apply(player: Player)( implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], - fairyAPI: FairyAPI[IO], + fairyAPI: FairyAPI[IO, Player], voteAPI: VoteAPI[IO], manaApi: ManaApi[IO, SyncIO, Player] ): SummonFairy[IO] = new SummonFairy[IO] { @@ -57,14 +57,14 @@ object BukkitSummonFairy { val uuid = player.getUniqueId - val validTimeState = fairyAPI.fairyValidTimeState(uuid).unsafeRunSync() + val fairySummonCost = fairyAPI.fairySummonCost(uuid).unsafeRunSync() if (playerLevel < 10) return notEnoughLevelEffect(player) // レベル不足 if (fairyAPI.fairyUsingState(uuid).unsafeRunSync() == Using) return alreadySummoned(player) // 既に召喚している - if (voteAPI.effectPoints(uuid).unsafeRunSync().value < validTimeState.value * 2) + if (voteAPI.effectPoints(uuid).unsafeRunSync().value < fairySummonCost.value * 2) return notEnoughEffectPoint(player) // 投票ptがたりなかった val levelCappedManaAmount = @@ -75,10 +75,10 @@ object BukkitSummonFairy { val eff = for { _ <- fairyAPI.updateFairyUsingState(uuid, FairyUsingState.Using) - _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(validTimeState.value * 2)) + _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(fairySummonCost.value * 2)) _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) - validTimes <- fairyAPI.fairyValidTimes(uuid) - _ <- fairyAPI.updateFairyValidTimes(uuid, Some(validTimeState.validTime)) + validTimes <- fairyAPI.fairyValidTimes(player) + _ <- fairyAPI.updateFairyValidTimes(player, Some(fairySummonCost.validTime)) } yield { /* FairySpeechRoutineが一度も起動されていなければ起動する @@ -90,7 +90,7 @@ object BukkitSummonFairy { import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.sleepAndRoutineContext implicit val contextShift: ContextShift[IO] = IO.contextShift(ExecutionContext.global) - FairySpeechRoutine.start(player).start + FairySpeechRoutine.start(player).start.unsafeRunSync() () } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala index 14882c8645..8b8c554f35 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala @@ -14,7 +14,7 @@ object FairySpeechRoutine { def start( player: Player - )(implicit fairyAPI: FairyAPI[IO], context: RepeatingTaskContext): IO[Nothing] = { + )(implicit fairyAPI: FairyAPI[IO, Player], context: RepeatingTaskContext): IO[Nothing] = { val repeatInterval: IO[FiniteDuration] = IO { import scala.concurrent.duration._ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index 64d493da4b..de68ff90eb 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -15,22 +15,22 @@ trait FairyPersistence[F[_]] { def appleOpenState(uuid: UUID): F[AppleOpenState] /** - * 妖精が有効な時間の状態 + * 妖精が召喚するためのコストを変更する */ - def updateFairyValidTimeState(uuid: UUID, validTimeState: FairyValidTimeState): F[Unit] + def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] /** - * 妖精が有効な時間の状態を取得します + * 妖精を召喚するためのコストを取得する */ - def fairySummonState(uuid: UUID): F[FairyValidTimeState] + def fairySummonCost(uuid: UUID): F[FairySummonCost] /** - * 妖精が召喚されているかを更新します + * 妖精が召喚されているかを更新する */ def updateFairyUsingState(uuid: UUID, fairyUsingState: FairyUsingState): F[Unit] /** - * 妖精が召喚されているかを取得します + * 妖精が召喚されているかを取得する */ def fairyUsingState(uuid: UUID): F[FairyUsingState] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPlaySound.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPlaySound.scala index c0971c16c9..d76258e3cf 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPlaySound.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPlaySound.scala @@ -4,8 +4,8 @@ sealed trait FairyPlaySound object FairyPlaySound { - case object play extends FairyPlaySound + case object on extends FairyPlaySound - case object notPlay extends FairyPlaySound + case object off extends FairyPlaySound } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimeState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala similarity index 72% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimeState.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala index ddb32dec79..03b33a8929 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimeState.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala @@ -2,11 +2,12 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain import java.time.LocalDateTime -case class FairyValidTimeState(value: Int) { - require(1 <= value && value <= 4, "FairySummonValidTimeStateは1~4の間で指定してください。") +case class FairySummonCost(value: Int) { + require(1 <= value && value <= 4, "FairySummonCostは1~4の間で指定してください。") /** * @return 妖精が有効な時間 + * NOTE: 妖精が有効な時間はコストによって定められる。 */ def validTime: FairyValidTimes = { val now = LocalDateTime.now() diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimesState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimesState.scala new file mode 100644 index 0000000000..fd494871e9 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimesState.scala @@ -0,0 +1,21 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +import cats.effect.Sync +import cats.effect.concurrent.Ref + +/** + * 妖精が有効な時間を管理するクラス + */ +final class FairyValidTimesState[F[_]: Sync] { + + private val validTimesState: Ref[F, Option[FairyValidTimes]] = + Ref.unsafe[F, Option[FairyValidTimes]](None) + + def updateState(validTimes: FairyValidTimes): F[Unit] = + validTimesState.set(Some(validTimes)) + + def setNoneState(): F[Unit] = validTimesState.set(None) + + def fairyValidTimes: Ref[F, Option[FairyValidTimes]] = validTimesState + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index f6629dcf58..83ef493f09 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -6,7 +6,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ FairyPersistence, FairyRecoveryMana, FairyUsingState, - FairyValidTimeState + FairySummonCost } import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} @@ -42,32 +42,29 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } /** - * 妖精が有効な時間の状態を更新します + * 妖精が有効な時間の状態を更新する */ - override def updateFairyValidTimeState( - uuid: UUID, - fairyValidTimeState: FairyValidTimeState - ): F[Unit] = + override def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET toggleVotingFairy = ${fairyValidTimeState.value} WHERE uuid = ${uuid.toString}" + sql"UPDATE playerdata SET toggleVotingFairy = ${fairySummonCost.value} WHERE uuid = ${uuid.toString}" .execute() .apply() } } /** - * 妖精が有効な時間の状態を取得します + * 妖精を召喚するためのコストを取得する */ - override def fairySummonState(uuid: UUID): F[FairyValidTimeState] = Sync[F].delay { + override def fairySummonCost(uuid: UUID): F[FairySummonCost] = Sync[F].delay { DB.readOnly { implicit session => - val validTimeState = + val fairySummonCost = sql"SELECT toggleVotingFairy FROM playerdata WHERE uuid = ${uuid.toString}" .map(_.int("toggleVotingFairy")) .single() .apply() .get - FairyValidTimeState(validTimeState) + FairySummonCost(fairySummonCost) } } From 473e90390779753d3df92200bb025760888b661d Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 26 Jul 2022 19:45:15 +0900 Subject: [PATCH 050/482] =?UTF-8?q?[Add]FairyValidTimeRepository=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9=E3=81=97=E7=9B=B4=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/FairyAPI.scala | 4 +- .../vote/subsystems/fairy/System.scala | 26 ++++++------- .../FairyValidTimeRepositoryDefinition.scala | 25 +++++-------- .../bukkit/actions/BukkitFairySpeak.scala | 4 +- .../bukkit/actions/BukkitSummonFairy.scala | 16 +++----- .../fairy/domain/FairyValidTimes.scala | 2 +- .../domain/FairyValidTimesPersistence.scala | 7 ++++ .../JdbcFairyValidTimesPersistence.scala | 37 +++++++++++++++++++ 8 files changed, 77 insertions(+), 44 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimesPersistence.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyValidTimesPersistence.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index b9a14da1d2..10a9fe70d3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -92,9 +92,7 @@ trait FairyReadAPI[F[_], Player] { * 妖精の有効な時間を保存するリポジトリ * ※永続化は必要ない */ - protected[this] val fairyValidTimeRepository: KeyedDataRepository[Player, Ref[F, Option[ - FairyValidTimes - ]]] + val fairyValidTimeRepository: KeyedDataRepository[Player, Ref[F, Option[FairyValidTimes]]] /** * 妖精が有効な時間を返す diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 6e1f582d80..0724750e4a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -7,14 +7,16 @@ import com.github.unchama.datarepository.bukkit.player.{ BukkitRepositoryControls, PlayerDataRepository } -import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.generic.ContextCoercion import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.FairyValidTimeRepositoryDefinition import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit.FairyLoreTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.{ + JdbcFairyPersistence, + JdbcFairyValidTimesPersistence +} import org.bukkit.entity.Player import java.util.UUID @@ -31,18 +33,15 @@ object System { *[_], F ]]: F[System[F, Player]] = { + import com.github.unchama.minecraft.bukkit.algebra.BukkitPlayerHasUuid.instance val persistence = new JdbcFairyPersistence[F] - implicit val fairyValidTimesState: FairyValidTimesState[G] = new FairyValidTimesState[G] + implicit val fairyValidTimesState: FairyValidTimesState[F] = new FairyValidTimesState[F] + val fairyValidTimesPersistence = new JdbcFairyValidTimesPersistence[G] for { fairyValidTimeRepositoryControls <- ContextCoercion( BukkitRepositoryControls.createHandles( - RepositoryDefinition - .Phased - .TwoPhased( - FairyValidTimeRepositoryDefinition.initialization[G, Player], - FairyValidTimeRepositoryDefinition.finalization[G, Player] - ) + FairyValidTimeRepositoryDefinition.withContext[G, Player](fairyValidTimesPersistence) ) ) } yield { @@ -96,18 +95,17 @@ object System { else FairyPlaySound.on ) - override protected[this] val fairyValidTimeRepository + override val fairyValidTimeRepository : KeyedDataRepository[Player, Ref[F, Option[FairyValidTimes]]] = - repository + KeyedDataRepository.unlift { player => repository.lift(player) } - override def fairyValidTimes(player: Player): F[Option[FairyValidTimes]] = - fairyValidTimeRepository(player).get + override def fairyValidTimes(player: Player): F[Option[FairyValidTimes]] = ??? override def updateFairyValidTimes( player: Player, fairyValidTimes: Option[FairyValidTimes] ): F[Unit] = - fairyValidTimeRepository(player).set(fairyValidTimes) + repository.lift(player).traverse { value => value.set(fairyValidTimes) }.as(()) override def fairyUsingState(uuid: UUID): F[FairyUsingState] = persistence.fairyUsingState(uuid) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyValidTimeRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyValidTimeRepositoryDefinition.scala index d0d129d17e..baed6a3ffb 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyValidTimeRepositoryDefinition.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyValidTimeRepositoryDefinition.scala @@ -2,26 +2,21 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applica import cats.effect.Sync import cats.effect.concurrent.Ref -import cats.{Applicative, Monad} -import com.github.unchama.datarepository.template.finalization.RepositoryFinalization -import com.github.unchama.datarepository.template.initialization.TwoPhasedRepositoryInitialization +import com.github.unchama.datarepository.definitions.RefDictBackedRepositoryDefinition +import com.github.unchama.datarepository.template.RepositoryDefinition +import com.github.unchama.minecraft.algebra.HasUuid import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ FairyValidTimes, - FairyValidTimesState + FairyValidTimesPersistence } object FairyValidTimeRepositoryDefinition { - def initialization[F[_]: Sync: Monad, Player]( - implicit fairyValidTimesState: FairyValidTimesState[F] - ): TwoPhasedRepositoryInitialization[F, Player, Ref[F, Option[FairyValidTimes]]] = - TwoPhasedRepositoryInitialization - .withoutPrefetching[F, Player, Ref[F, Option[FairyValidTimes]]] { _ => - Sync[F].pure(fairyValidTimesState.fairyValidTimes) - } - - def finalization[F[_]: Applicative, Player] - : RepositoryFinalization[F, Player, Ref[F, Option[FairyValidTimes]]] = - RepositoryFinalization.trivial + def withContext[F[_]: Sync, Player: HasUuid]( + persistence: FairyValidTimesPersistence[F] + ): RepositoryDefinition[F, Player, Ref[F, FairyValidTimes]] = + RefDictBackedRepositoryDefinition + .usingUuidRefDict[F, Player, FairyValidTimes](persistence)(FairyValidTimes(None)) + .toRefRepository } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala index c22a42987c..346f702ada 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala @@ -49,8 +49,10 @@ object BukkitFairySpeak { println("random2") + println("isDefinedAt:" + fairyAPI.fairyValidTimeRepository.isDefinedAt(player)) + for { - fairyValidTimesOpt <- fairyAPI.fairyValidTimes(player) + fairyValidTimesOpt <- fairyAPI.fairyValidTimeRepository(player).get startTimeHour = fairyValidTimesOpt.get.startTime.getHour fairyMessages = if (4 <= startTimeHour && startTimeHour < 10) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 813cb728c6..2b588c0c7a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -77,21 +77,17 @@ object BukkitSummonFairy { _ <- fairyAPI.updateFairyUsingState(uuid, FairyUsingState.Using) _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(fairySummonCost.value * 2)) _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) - validTimes <- fairyAPI.fairyValidTimes(player) + isFairyValidTimeDefined = fairyAPI.fairyValidTimeRepository.isDefinedAt(player) _ <- fairyAPI.updateFairyValidTimes(player, Some(fairySummonCost.validTime)) } yield { /* FairySpeechRoutineが一度も起動されていなければ起動する - そうじゃなかったからfor実行 */ - validTimes match { - case Some(_) => () - case None => - import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.sleepAndRoutineContext - implicit val contextShift: ContextShift[IO] = - IO.contextShift(ExecutionContext.global) - FairySpeechRoutine.start(player).start.unsafeRunSync() - () + if (!isFairyValidTimeDefined) { + import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.sleepAndRoutineContext + implicit val contextShift: ContextShift[IO] = + IO.contextShift(ExecutionContext.global) + FairySpeechRoutine.start(player).start.unsafeRunSync() } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimes.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimes.scala index 0cb33e96ba..48e8761b06 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimes.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimes.scala @@ -2,4 +2,4 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain import java.time.LocalDateTime -case class FairyValidTimes(startTime: LocalDateTime, endTime: LocalDateTime) +case class FairyValidTimes(endTimeOpt: Option[LocalDateTime]) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimesPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimesPersistence.scala new file mode 100644 index 0000000000..329c641b00 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimesPersistence.scala @@ -0,0 +1,7 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +import com.github.unchama.generic.RefDict + +import java.util.UUID + +trait FairyValidTimesPersistence[F[_]] extends RefDict[F, UUID, FairyValidTimes] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyValidTimesPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyValidTimesPersistence.scala new file mode 100644 index 0000000000..659f6ae14c --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyValidTimesPersistence.scala @@ -0,0 +1,37 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure + +import cats.effect.Sync +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + FairyValidTimes, + FairyValidTimesPersistence +} +import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} + +import java.time.{LocalDateTime, ZoneId, ZonedDateTime} +import java.util.{Date, UUID} + +class JdbcFairyValidTimesPersistence[F[_]: Sync] extends FairyValidTimesPersistence[F] { + override def read(uuid: UUID): F[Option[FairyValidTimes]] = Sync[F].delay { + DB.readOnly { implicit session => + val dateOpt = sql"SELECT newVotingFairyTime FROM playerdata WHERE uuid = ${uuid.toString}" + .map(_.date("newVotingFairyTime")) + .single() + .apply() + dateOpt.map { date => + FairyValidTimes(Some(LocalDateTime.ofInstant(date.toInstant, ZoneId.systemDefault()))) + } + } + } + + /** + * [[FairyValidTimes]]を[[java.util.Date]]に変換してDBに保存する + */ + override def write(uuid: UUID, fairyValidTimes: FairyValidTimes): F[Unit] = + Sync[F].delay { + DB.localTx { implicit session => + sql"UPDATE playerdata SET newVotingFairyTime = ${Date.from( + ZonedDateTime.of(fairyValidTimes.endTimeOpt.get, ZoneId.systemDefault()).toInstant + )} WHERE uuid = ${uuid.toString}".execute().apply() + } + } +} From e0e660edade2f35d1d3d197c79865a3aea3f131a Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 26 Jul 2022 19:50:27 +0900 Subject: [PATCH 051/482] =?UTF-8?q?[Add]=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=83=99=E3=83=BC=E3=82=B9=E3=83=9E=E3=82=A4=E3=82=B0=E3=83=AC?= =?UTF-8?q?=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V2.0.0__Change_new_fairy_time_type.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/main/resources/db/migration/V2.0.0__Change_new_fairy_time_type.sql diff --git a/src/main/resources/db/migration/V2.0.0__Change_new_fairy_time_type.sql b/src/main/resources/db/migration/V2.0.0__Change_new_fairy_time_type.sql new file mode 100644 index 0000000000..23c451660d --- /dev/null +++ b/src/main/resources/db/migration/V2.0.0__Change_new_fairy_time_type.sql @@ -0,0 +1,5 @@ +use seichiassist; + +-- 型を変えるので一度内容をリセットする +UPDATE playerdata SET newVotingFairyTime = NULL; +ALTER TABLE playerdata ALTER COLUMN newVotingFairyTime DATETIME; From 826dd75106340608a5122c60acb1748f8b3dc40c Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 26 Jul 2022 20:11:39 +0900 Subject: [PATCH 052/482] [Fix]compile error --- .../unchama/seichiassist/menus/VoteMenu.scala | 2 +- .../vote/subsystems/fairy/FairyAPI.scala | 5 +- .../vote/subsystems/fairy/System.scala | 13 ++--- .../application/actions/FairySpeak.scala | 4 ++ .../bukkit/actions/BukkitFairySpeak.scala | 54 ++++++++++++++----- .../bukkit/actions/BukkitSummonFairy.scala | 12 +++-- .../fairy/domain/FairySummonCost.scala | 10 ++-- 7 files changed, 67 insertions(+), 33 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index ce19226615..b9db74a97f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -275,7 +275,7 @@ object VoteMenu extends Menu { SequentialEffect( UnfocusedEffect { val endTime = - fairyAPI.fairyValidTimes(player).unsafeRunSync().get.endTime + fairyAPI.fairyValidTimes(player).unsafeRunSync().get.endTimeOpt.get BukkitFairySpeak[IO] .speak( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 10a9fe70d3..f433fb1ef2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -37,7 +37,7 @@ trait FairyWriteAPI[F[_], Player] { /** * 妖精が有効な時間を変更する */ - def updateFairyValidTimes(player: Player, fairyValidTimes: Option[FairyValidTimes]): F[Unit] + def updateFairyValidTimes(player: Player, fairyValidTimes: FairyValidTimes): F[Unit] } @@ -90,9 +90,8 @@ trait FairyReadAPI[F[_], Player] { /** * 妖精の有効な時間を保存するリポジトリ - * ※永続化は必要ない */ - val fairyValidTimeRepository: KeyedDataRepository[Player, Ref[F, Option[FairyValidTimes]]] + val fairyValidTimeRepository: KeyedDataRepository[Player, Ref[F, FairyValidTimes]] /** * 妖精が有効な時間を返す diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 0724750e4a..120fc79b42 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -48,10 +48,8 @@ object System { new System[F, Player] { override val api: FairyAPI[F, Player] = new FairyAPI[F, Player] { - val repository: PlayerDataRepository[Ref[F, Option[FairyValidTimes]]] = - fairyValidTimeRepositoryControls - .repository - .map(_.mapK[F](ContextCoercion.asFunctionK)) + val repository: PlayerDataRepository[Ref[F, FairyValidTimes]] = + fairyValidTimeRepositoryControls.repository.map(_.mapK(ContextCoercion.asFunctionK)) override def appleOpenState(uuid: UUID): F[AppleOpenState] = persistence.appleOpenState(uuid) @@ -96,16 +94,15 @@ object System { ) override val fairyValidTimeRepository - : KeyedDataRepository[Player, Ref[F, Option[FairyValidTimes]]] = - KeyedDataRepository.unlift { player => repository.lift(player) } + : KeyedDataRepository[Player, Ref[F, FairyValidTimes]] = repository override def fairyValidTimes(player: Player): F[Option[FairyValidTimes]] = ??? override def updateFairyValidTimes( player: Player, - fairyValidTimes: Option[FairyValidTimes] + fairyValidTimes: FairyValidTimes ): F[Unit] = - repository.lift(player).traverse { value => value.set(fairyValidTimes) }.as(()) + repository(player).set(fairyValidTimes) override def fairyUsingState(uuid: UUID): F[FairyUsingState] = persistence.fairyUsingState(uuid) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala index 643a514fe2..740c0ec621 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala @@ -11,6 +11,10 @@ trait FairySpeak[F[_], Player] { def speakRandomly(player: Player)(implicit fairyAPI: FairyAPI[F, Player]): F[Unit] + def speakStartMessage(player: Player, startTimeHour: Int)( + implicit fairyAPI: FairyAPI[F, Player] + ): F[Unit] + } object FairySpeak { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala index 346f702ada..ce7e3fb61c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala @@ -35,6 +35,39 @@ object BukkitFairySpeak { override def speakRandomly( player: Player )(implicit fairyAPI: FairyAPI[F, Player]): F[Unit] = { + Sync[F].unit +// val nameCalledByFairy = NameCalledByFairy(player.getName) +// val uuid = player.getUniqueId +// +// println("random1") +// +// implicit val F: Monad[F] = implicitly +// +// F.ifM(fairyAPI.fairyUsingState(uuid).map(_ == FairyUsingState.NotUsing))( +// return Sync[F].unit, +// Sync[F].unit +// ) +// +// println("random2") +// +// println("isDefinedAt:" + fairyAPI.fairyValidTimeRepository.isDefinedAt(player)) +// +// for { +// fairyValidTimesOpt <- fairyAPI.fairyValidTimeRepository(player).get +// fairyMessages = +// if (4 <= startTimeHour && startTimeHour < 10) +// FairyMessageTable.morningMessages(nameCalledByFairy) +// else if (10 <= startTimeHour && startTimeHour < 18) +// FairyMessageTable.dayMessages(nameCalledByFairy) +// else +// FairyMessageTable.nightMessages(nameCalledByFairy) +// fairyMessage <- getMessageRandomly(fairyMessages) +// } yield speak(player, fairyMessage).toIO.unsafeRunSync() + } + + override def speakStartMessage(player: Player, startTimeHour: Int)( + implicit fairyAPI: FairyAPI[F, Player] + ): F[Unit] = { val nameCalledByFairy = NameCalledByFairy(player.getName) val uuid = player.getUniqueId @@ -51,18 +84,15 @@ object BukkitFairySpeak { println("isDefinedAt:" + fairyAPI.fairyValidTimeRepository.isDefinedAt(player)) - for { - fairyValidTimesOpt <- fairyAPI.fairyValidTimeRepository(player).get - startTimeHour = fairyValidTimesOpt.get.startTime.getHour - fairyMessages = - if (4 <= startTimeHour && startTimeHour < 10) - FairyMessageTable.morningMessages(nameCalledByFairy) - else if (10 <= startTimeHour && startTimeHour < 18) - FairyMessageTable.dayMessages(nameCalledByFairy) - else - FairyMessageTable.nightMessages(nameCalledByFairy) - fairyMessage <- getMessageRandomly(fairyMessages) - } yield speak(player, fairyMessage).toIO.unsafeRunSync() + val fairyMessages = + if (4 <= startTimeHour && startTimeHour < 10) + FairyMessageTable.morningMessages(nameCalledByFairy) + else if (10 <= startTimeHour && startTimeHour < 18) + FairyMessageTable.dayMessages(nameCalledByFairy) + else + FairyMessageTable.nightMessages(nameCalledByFairy) + + getMessageRandomly(fairyMessages).map(speak(player, _).toIO.unsafeRunSync()) } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 2b588c0c7a..6ed419bee0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions -import cats.effect.{ContextShift, IO, LiftIO, SyncIO} +import cats.effect.{ConcurrentEffect, ContextShift, IO, LiftIO, SyncIO} import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI @@ -28,7 +28,8 @@ object BukkitSummonFairy { implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], fairyAPI: FairyAPI[IO, Player], voteAPI: VoteAPI[IO], - manaApi: ManaApi[IO, SyncIO, Player] + manaApi: ManaApi[IO, SyncIO, Player], + concurrentEffect: ConcurrentEffect[IO] ): SummonFairy[IO] = new SummonFairy[IO] { override def summon: IO[Unit] = { val playerLevel = @@ -78,7 +79,7 @@ object BukkitSummonFairy { _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(fairySummonCost.value * 2)) _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) isFairyValidTimeDefined = fairyAPI.fairyValidTimeRepository.isDefinedAt(player) - _ <- fairyAPI.updateFairyValidTimes(player, Some(fairySummonCost.validTime)) + _ <- fairyAPI.updateFairyValidTimes(player, fairySummonCost.validTime) } yield { /* FairySpeechRoutineが一度も起動されていなければ起動する @@ -93,7 +94,10 @@ object BukkitSummonFairy { LiftIO[IO].liftIO { SequentialEffect( - UnfocusedEffect(eff.unsafeRunAsyncAndForget()), + UnfocusedEffect { + BukkitFairySpeak[IO].speakRandomly(player).unsafeRunSync() + eff.unsafeRunAsyncAndForget() + }, MessageEffect( List( s"$RESET$YELLOW${BOLD}妖精を呼び出しました!", diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala index 03b33a8929..63c5d679e6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala @@ -13,15 +13,15 @@ case class FairySummonCost(value: Int) { val now = LocalDateTime.now() val validTime = value match { case 1 => - FairyValidTimes(_, now.plusMonths(30)) + FairyValidTimes(Some(now.plusMonths(30))) case 2 => - FairyValidTimes(_, now.plusHours(1)) + FairyValidTimes(Some(now.plusHours(1))) case 3 => - FairyValidTimes(_, now.plusHours(1).plusMinutes(30)) + FairyValidTimes(Some(now.plusHours(1).plusMinutes(30))) case 4 => - FairyValidTimes(_, now.plusHours(2)) + FairyValidTimes(Some(now.plusHours(2))) } - validTime(now) + validTime } } From 60c665bcb70f898f46aa9b6da3e871b032d80fc0 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 26 Jul 2022 21:42:06 +0900 Subject: [PATCH 053/482] =?UTF-8?q?[Fix]migration=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E3=81=AE=E5=9E=8B=E5=A4=89=E6=8F=9B=E6=96=87?= =?UTF-8?q?=E3=81=AE=E3=83=9F=E3=82=B9=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V2.0.0__Change_new_fairy_time_type.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/db/migration/V2.0.0__Change_new_fairy_time_type.sql b/src/main/resources/db/migration/V2.0.0__Change_new_fairy_time_type.sql index 23c451660d..6644ab7048 100644 --- a/src/main/resources/db/migration/V2.0.0__Change_new_fairy_time_type.sql +++ b/src/main/resources/db/migration/V2.0.0__Change_new_fairy_time_type.sql @@ -2,4 +2,4 @@ use seichiassist; -- 型を変えるので一度内容をリセットする UPDATE playerdata SET newVotingFairyTime = NULL; -ALTER TABLE playerdata ALTER COLUMN newVotingFairyTime DATETIME; +ALTER TABLE playerdata MODIFY newVotingFairyTime DATETIME; From 733283908b468d7c0d5d4b1d22396074aaec31a4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 26 Jul 2022 22:56:40 +0900 Subject: [PATCH 054/482] =?UTF-8?q?[Fix]=E5=A6=96=E7=B2=BE=E3=81=AE?= =?UTF-8?q?=E7=B5=82=E4=BA=86=E6=99=82=E9=96=93=E3=82=92DB=E3=81=AB?= =?UTF-8?q?=E4=BE=9D=E5=AD=98=E3=81=95=E3=81=9B=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/SeichiAssist.scala | 2 +- .../vote/subsystems/fairy/FairyAPI.scala | 5 - .../vote/subsystems/fairy/System.scala | 167 +++++++----------- .../application/actions/FairySpeak.scala | 4 +- .../FairyValidTimeRepositoryDefinition.scala | 22 --- .../bukkit/actions/BukkitFairySpeak.scala | 45 +---- .../bukkit/actions/BukkitSummonFairy.scala | 6 +- .../fairy/domain/FairyPersistence.scala | 10 ++ .../domain/FairyValidTimesPersistence.scala | 7 - .../fairy/domain/FairyValidTimesState.scala | 21 --- .../infrastructure/JdbcFairyPersistence.scala | 34 +++- .../JdbcFairyValidTimesPersistence.scala | 37 ---- 12 files changed, 121 insertions(+), 239 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyValidTimeRepositoryDefinition.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimesPersistence.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimesState.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyValidTimesPersistence.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 5f512f6de2..4842613563 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -392,7 +392,7 @@ class SeichiAssist extends JavaPlugin() { subsystems.vote.System.wired[IO] private lazy val fairySystem: subsystems.vote.subsystems.fairy.System[IO, Player] = - subsystems.vote.subsystems.fairy.System.wired[IO, SyncIO].unsafeRunSync() + subsystems.vote.subsystems.fairy.System.wired[IO, SyncIO] private lazy val wiredSubsystems: List[Subsystem[IO]] = List( mebiusSystem, diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index f433fb1ef2..452e2abd99 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -88,11 +88,6 @@ trait FairyReadAPI[F[_], Player] { Ref[F, FairyPlaySound] ] - /** - * 妖精の有効な時間を保存するリポジトリ - */ - val fairyValidTimeRepository: KeyedDataRepository[Player, Ref[F, FairyValidTimes]] - /** * 妖精が有効な時間を返す */ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 120fc79b42..b63cd00dd6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -3,20 +3,12 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.concurrent.Ref import cats.effect.{ConcurrentEffect, Sync, SyncEffect} import com.github.unchama.datarepository.KeyedDataRepository -import com.github.unchama.datarepository.bukkit.player.{ - BukkitRepositoryControls, - PlayerDataRepository -} import com.github.unchama.generic.ContextCoercion import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.FairyValidTimeRepositoryDefinition import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit.FairyLoreTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.{ - JdbcFairyPersistence, - JdbcFairyValidTimesPersistence -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import org.bukkit.entity.Player import java.util.UUID @@ -27,102 +19,77 @@ trait System[F[_], Player] extends Subsystem[F] { object System { - import cats.implicits._ - def wired[F[_]: ConcurrentEffect: OnMinecraftServerThread, G[_]: SyncEffect: ContextCoercion[ *[_], F - ]]: F[System[F, Player]] = { - import com.github.unchama.minecraft.bukkit.algebra.BukkitPlayerHasUuid.instance + ]]: System[F, Player] = { val persistence = new JdbcFairyPersistence[F] - implicit val fairyValidTimesState: FairyValidTimesState[F] = new FairyValidTimesState[F] - val fairyValidTimesPersistence = new JdbcFairyValidTimesPersistence[G] - - for { - fairyValidTimeRepositoryControls <- ContextCoercion( - BukkitRepositoryControls.createHandles( - FairyValidTimeRepositoryDefinition.withContext[G, Player](fairyValidTimesPersistence) + new System[F, Player] { + override val api: FairyAPI[F, Player] = new FairyAPI[F, Player] { + override def appleOpenState(uuid: UUID): F[AppleOpenState] = + persistence.appleOpenState(uuid) + + override def updateAppleOpenState(uuid: UUID, appleOpenState: AppleOpenState): F[Unit] = + persistence.changeAppleOpenState(uuid, appleOpenState) + + import cats.implicits._ + + override def getFairyLore(uuid: UUID): F[FairyLore] = for { + state <- appleOpenState(uuid) + } yield FairyLoreTable.loreTable(state.amount - 1) + + override def updateFairySummonCost( + uuid: UUID, + fairySummonCost: FairySummonCost + ): F[Unit] = + persistence.updateFairySummonCost(uuid, fairySummonCost) + + override def fairySummonCost(uuid: UUID): F[FairySummonCost] = + persistence.fairySummonCost(uuid) + + override protected val fairyPlaySoundRepository + : KeyedDataRepository[UUID, Ref[F, FairyPlaySound]] = + KeyedDataRepository.unlift[UUID, Ref[F, FairyPlaySound]] { _ => + Some(Ref.unsafe(FairyPlaySound.on)) + } + + override def fairyPlaySound(uuid: UUID): F[FairyPlaySound] = + if (fairyPlaySoundRepository.isDefinedAt(uuid)) + fairyPlaySoundRepository(uuid).get + else Sync[F].pure(FairyPlaySound.on) + + override def fairyPlaySoundToggle(uuid: UUID): F[Unit] = for { + nowSetting <- fairyPlaySound(uuid) + } yield fairyPlaySoundRepository(uuid).set( + if (nowSetting == FairyPlaySound.on) FairyPlaySound.off + else FairyPlaySound.on ) - ) - } yield { - new System[F, Player] { - override val api: FairyAPI[F, Player] = new FairyAPI[F, Player] { - - val repository: PlayerDataRepository[Ref[F, FairyValidTimes]] = - fairyValidTimeRepositoryControls.repository.map(_.mapK(ContextCoercion.asFunctionK)) - - override def appleOpenState(uuid: UUID): F[AppleOpenState] = - persistence.appleOpenState(uuid) - - override def updateAppleOpenState( - uuid: UUID, - appleOpenState: AppleOpenState - ): F[Unit] = - persistence.changeAppleOpenState(uuid, appleOpenState) - - import cats.implicits._ - - override def getFairyLore(uuid: UUID): F[FairyLore] = for { - state <- appleOpenState(uuid) - } yield FairyLoreTable.loreTable(state.amount - 1) - - override def updateFairySummonCost( - uuid: UUID, - fairySummonCost: FairySummonCost - ): F[Unit] = - persistence.updateFairySummonCost(uuid, fairySummonCost) - - override def fairySummonCost(uuid: UUID): F[FairySummonCost] = - persistence.fairySummonCost(uuid) - - override protected val fairyPlaySoundRepository - : KeyedDataRepository[UUID, Ref[F, FairyPlaySound]] = - KeyedDataRepository.unlift[UUID, Ref[F, FairyPlaySound]] { _ => - Some(Ref.unsafe(FairyPlaySound.on)) - } - - override def fairyPlaySound(uuid: UUID): F[FairyPlaySound] = - if (fairyPlaySoundRepository.isDefinedAt(uuid)) - fairyPlaySoundRepository(uuid).get - else Sync[F].pure(FairyPlaySound.on) - - override def fairyPlaySoundToggle(uuid: UUID): F[Unit] = for { - nowSetting <- fairyPlaySound(uuid) - } yield fairyPlaySoundRepository(uuid).set( - if (nowSetting == FairyPlaySound.on) FairyPlaySound.off - else FairyPlaySound.on - ) - - override val fairyValidTimeRepository - : KeyedDataRepository[Player, Ref[F, FairyValidTimes]] = repository - - override def fairyValidTimes(player: Player): F[Option[FairyValidTimes]] = ??? - - override def updateFairyValidTimes( - player: Player, - fairyValidTimes: FairyValidTimes - ): F[Unit] = - repository(player).set(fairyValidTimes) - - override def fairyUsingState(uuid: UUID): F[FairyUsingState] = - persistence.fairyUsingState(uuid) - - override def updateFairyUsingState( - uuid: UUID, - fairyUsingState: FairyUsingState - ): F[Unit] = - persistence.updateFairyUsingState(uuid, fairyUsingState) - - override def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] = - persistence.fairyRecoveryMana(uuid) - - override def updateFairyRecoveryManaAmount( - uuid: UUID, - fairyRecoveryMana: FairyRecoveryMana - ): F[Unit] = persistence.updateFairyRecoveryMana(uuid, fairyRecoveryMana) - } - override val managedRepositoryControls: Seq[BukkitRepositoryControls[F, _]] = - Seq(fairyValidTimeRepositoryControls.coerceFinalizationContextTo[F]) + + override def fairyValidTimes(player: Player): F[Option[FairyValidTimes]] = + persistence.fairyEndTime(player.getUniqueId) + + override def updateFairyValidTimes( + player: Player, + fairyValidTimes: FairyValidTimes + ): F[Unit] = + persistence.updateFairyEndTime(player.getUniqueId, fairyValidTimes) + + override def fairyUsingState(uuid: UUID): F[FairyUsingState] = + persistence.fairyUsingState(uuid) + + override def updateFairyUsingState( + uuid: UUID, + fairyUsingState: FairyUsingState + ): F[Unit] = + persistence.updateFairyUsingState(uuid, fairyUsingState) + + override def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] = + persistence.fairyRecoveryMana(uuid) + + override def updateFairyRecoveryManaAmount( + uuid: UUID, + fairyRecoveryMana: FairyRecoveryMana + ): F[Unit] = persistence.updateFairyRecoveryMana(uuid, fairyRecoveryMana) } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala index 740c0ec621..1c9359ea78 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala @@ -11,9 +11,7 @@ trait FairySpeak[F[_], Player] { def speakRandomly(player: Player)(implicit fairyAPI: FairyAPI[F, Player]): F[Unit] - def speakStartMessage(player: Player, startTimeHour: Int)( - implicit fairyAPI: FairyAPI[F, Player] - ): F[Unit] + def speakStartMessage(player: Player)(implicit fairyAPI: FairyAPI[F, Player]): F[Unit] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyValidTimeRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyValidTimeRepositoryDefinition.scala deleted file mode 100644 index baed6a3ffb..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyValidTimeRepositoryDefinition.scala +++ /dev/null @@ -1,22 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository - -import cats.effect.Sync -import cats.effect.concurrent.Ref -import com.github.unchama.datarepository.definitions.RefDictBackedRepositoryDefinition -import com.github.unchama.datarepository.template.RepositoryDefinition -import com.github.unchama.minecraft.algebra.HasUuid -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - FairyValidTimes, - FairyValidTimesPersistence -} - -object FairyValidTimeRepositoryDefinition { - - def withContext[F[_]: Sync, Player: HasUuid]( - persistence: FairyValidTimesPersistence[F] - ): RepositoryDefinition[F, Player, Ref[F, FairyValidTimes]] = - RefDictBackedRepositoryDefinition - .usingUuidRefDict[F, Player, FairyValidTimes](persistence)(FairyValidTimes(None)) - .toRefRepository - -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala index ce7e3fb61c..f9448328fc 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala @@ -12,6 +12,7 @@ import com.github.unchama.targetedeffect.player.FocusedSoundEffect import org.bukkit.Sound import org.bukkit.entity.Player +import java.time.LocalTime import scala.util.Random object BukkitFairySpeak { @@ -36,58 +37,26 @@ object BukkitFairySpeak { player: Player )(implicit fairyAPI: FairyAPI[F, Player]): F[Unit] = { Sync[F].unit -// val nameCalledByFairy = NameCalledByFairy(player.getName) -// val uuid = player.getUniqueId -// -// println("random1") -// -// implicit val F: Monad[F] = implicitly -// -// F.ifM(fairyAPI.fairyUsingState(uuid).map(_ == FairyUsingState.NotUsing))( -// return Sync[F].unit, -// Sync[F].unit -// ) -// -// println("random2") -// -// println("isDefinedAt:" + fairyAPI.fairyValidTimeRepository.isDefinedAt(player)) -// -// for { -// fairyValidTimesOpt <- fairyAPI.fairyValidTimeRepository(player).get -// fairyMessages = -// if (4 <= startTimeHour && startTimeHour < 10) -// FairyMessageTable.morningMessages(nameCalledByFairy) -// else if (10 <= startTimeHour && startTimeHour < 18) -// FairyMessageTable.dayMessages(nameCalledByFairy) -// else -// FairyMessageTable.nightMessages(nameCalledByFairy) -// fairyMessage <- getMessageRandomly(fairyMessages) -// } yield speak(player, fairyMessage).toIO.unsafeRunSync() } - override def speakStartMessage(player: Player, startTimeHour: Int)( - implicit fairyAPI: FairyAPI[F, Player] - ): F[Unit] = { + override def speakStartMessage( + player: Player + )(implicit fairyAPI: FairyAPI[F, Player]): F[Unit] = { val nameCalledByFairy = NameCalledByFairy(player.getName) val uuid = player.getUniqueId - println("random1") - implicit val F: Monad[F] = implicitly F.ifM(fairyAPI.fairyUsingState(uuid).map(_ == FairyUsingState.NotUsing))( return Sync[F].unit, Sync[F].unit ) - - println("random2") - - println("isDefinedAt:" + fairyAPI.fairyValidTimeRepository.isDefinedAt(player)) + val startHour = LocalTime.now().getHour val fairyMessages = - if (4 <= startTimeHour && startTimeHour < 10) + if (4 <= startHour && startHour < 10) FairyMessageTable.morningMessages(nameCalledByFairy) - else if (10 <= startTimeHour && startTimeHour < 18) + else if (10 <= startHour && startHour < 18) FairyMessageTable.dayMessages(nameCalledByFairy) else FairyMessageTable.nightMessages(nameCalledByFairy) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 6ed419bee0..f3ef0d23d8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -78,13 +78,13 @@ object BukkitSummonFairy { _ <- fairyAPI.updateFairyUsingState(uuid, FairyUsingState.Using) _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(fairySummonCost.value * 2)) _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) - isFairyValidTimeDefined = fairyAPI.fairyValidTimeRepository.isDefinedAt(player) + isFairyValidTimeDefined <- fairyAPI.fairyValidTimes(player) _ <- fairyAPI.updateFairyValidTimes(player, fairySummonCost.validTime) } yield { /* FairySpeechRoutineが一度も起動されていなければ起動する */ - if (!isFairyValidTimeDefined) { + if (isFairyValidTimeDefined.isEmpty) { import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.sleepAndRoutineContext implicit val contextShift: ContextShift[IO] = IO.contextShift(ExecutionContext.global) @@ -95,7 +95,7 @@ object BukkitSummonFairy { LiftIO[IO].liftIO { SequentialEffect( UnfocusedEffect { - BukkitFairySpeak[IO].speakRandomly(player).unsafeRunSync() + BukkitFairySpeak[IO].speakStartMessage(player).unsafeRunSync() eff.unsafeRunAsyncAndForget() }, MessageEffect( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index de68ff90eb..2ea67b7358 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -44,4 +44,14 @@ trait FairyPersistence[F[_]] { */ def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] + /** + * 妖精の効果が終了する時刻を変更する + */ + def updateFairyEndTime(uuid: UUID, fairyValidTimes: FairyValidTimes): F[Unit] + + /** + * 妖精の効果が終了する時刻を取得する + */ + def fairyEndTime(uuid: UUID): F[Option[FairyValidTimes]] + } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimesPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimesPersistence.scala deleted file mode 100644 index 329c641b00..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimesPersistence.scala +++ /dev/null @@ -1,7 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain - -import com.github.unchama.generic.RefDict - -import java.util.UUID - -trait FairyValidTimesPersistence[F[_]] extends RefDict[F, UUID, FairyValidTimes] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimesState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimesState.scala deleted file mode 100644 index fd494871e9..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimesState.scala +++ /dev/null @@ -1,21 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain - -import cats.effect.Sync -import cats.effect.concurrent.Ref - -/** - * 妖精が有効な時間を管理するクラス - */ -final class FairyValidTimesState[F[_]: Sync] { - - private val validTimesState: Ref[F, Option[FairyValidTimes]] = - Ref.unsafe[F, Option[FairyValidTimes]](None) - - def updateState(validTimes: FairyValidTimes): F[Unit] = - validTimesState.set(Some(validTimes)) - - def setNoneState(): F[Unit] = validTimesState.set(None) - - def fairyValidTimes: Ref[F, Option[FairyValidTimes]] = validTimesState - -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 83ef493f09..e6d77f7c31 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -5,12 +5,14 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ AppleOpenState, FairyPersistence, FairyRecoveryMana, + FairySummonCost, FairyUsingState, - FairySummonCost + FairyValidTimes } import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} -import java.util.UUID +import java.time.{LocalDateTime, ZoneId, ZonedDateTime} +import java.util.{Date, UUID} class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { @@ -122,4 +124,32 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { FairyRecoveryMana(recoveryMana) } } + + /** + * 妖精の効果が終了する時刻を変更する + */ + override def updateFairyEndTime(uuid: UUID, fairyValidTimes: FairyValidTimes): F[Unit] = + Sync[F].delay { + DB.localTx { implicit session => + sql"UPDATE playerdata SET newVotingFairyTime = ${Date.from( + ZonedDateTime.of(fairyValidTimes.endTimeOpt.get, ZoneId.systemDefault()).toInstant + )} WHERE uuid = ${uuid.toString}".execute().apply() + } + } + + /** + * 妖精の効果が終了する時刻を取得する + */ + override def fairyEndTime(uuid: UUID): F[Option[FairyValidTimes]] = Sync[F].delay { + DB.readOnly { implicit session => + val dateOpt = sql"SELECT newVotingFairyTime FROM playerdata WHERE uuid = ${uuid.toString}" + .map(_.date("newVotingFairyTime")) + .single() + .apply() + dateOpt.map { date => + FairyValidTimes(Some(LocalDateTime.ofInstant(date.toInstant, ZoneId.systemDefault()))) + } + } + } + } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyValidTimesPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyValidTimesPersistence.scala deleted file mode 100644 index 659f6ae14c..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyValidTimesPersistence.scala +++ /dev/null @@ -1,37 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure - -import cats.effect.Sync -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - FairyValidTimes, - FairyValidTimesPersistence -} -import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} - -import java.time.{LocalDateTime, ZoneId, ZonedDateTime} -import java.util.{Date, UUID} - -class JdbcFairyValidTimesPersistence[F[_]: Sync] extends FairyValidTimesPersistence[F] { - override def read(uuid: UUID): F[Option[FairyValidTimes]] = Sync[F].delay { - DB.readOnly { implicit session => - val dateOpt = sql"SELECT newVotingFairyTime FROM playerdata WHERE uuid = ${uuid.toString}" - .map(_.date("newVotingFairyTime")) - .single() - .apply() - dateOpt.map { date => - FairyValidTimes(Some(LocalDateTime.ofInstant(date.toInstant, ZoneId.systemDefault()))) - } - } - } - - /** - * [[FairyValidTimes]]を[[java.util.Date]]に変換してDBに保存する - */ - override def write(uuid: UUID, fairyValidTimes: FairyValidTimes): F[Unit] = - Sync[F].delay { - DB.localTx { implicit session => - sql"UPDATE playerdata SET newVotingFairyTime = ${Date.from( - ZonedDateTime.of(fairyValidTimes.endTimeOpt.get, ZoneId.systemDefault()).toInstant - )} WHERE uuid = ${uuid.toString}".execute().apply() - } - } -} From 19cfb87572e9e2d0b16b60cc0b0d32beb3e2f60f Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 26 Jul 2022 22:58:59 +0900 Subject: [PATCH 055/482] =?UTF-8?q?[Fix]JdbcFairyPersistence=E3=81=8B?= =?UTF-8?q?=E3=82=89=E5=A6=96=E7=B2=BE=E3=81=AE=E7=B5=82=E4=BA=86=E6=99=82?= =?UTF-8?q?=E9=96=93=E3=82=92=E8=A8=98=E9=8C=B2=E3=81=99=E3=82=8B=E9=9A=9B?= =?UTF-8?q?=E3=81=ABLocalDateTime=E3=82=92=E7=9B=B4=E6=8E=A5=E5=88=A9?= =?UTF-8?q?=E7=94=A8=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/infrastructure/JdbcFairyPersistence.scala | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index e6d77f7c31..2c498f0b93 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -131,9 +131,9 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def updateFairyEndTime(uuid: UUID, fairyValidTimes: FairyValidTimes): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET newVotingFairyTime = ${Date.from( - ZonedDateTime.of(fairyValidTimes.endTimeOpt.get, ZoneId.systemDefault()).toInstant - )} WHERE uuid = ${uuid.toString}".execute().apply() + sql"UPDATE playerdata SET newVotingFairyTime = ${fairyValidTimes.endTimeOpt.get} WHERE uuid = ${uuid.toString}" + .execute() + .apply() } } @@ -143,12 +143,10 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def fairyEndTime(uuid: UUID): F[Option[FairyValidTimes]] = Sync[F].delay { DB.readOnly { implicit session => val dateOpt = sql"SELECT newVotingFairyTime FROM playerdata WHERE uuid = ${uuid.toString}" - .map(_.date("newVotingFairyTime")) + .map(_.localDateTime("newVotingFairyTime")) .single() .apply() - dateOpt.map { date => - FairyValidTimes(Some(LocalDateTime.ofInstant(date.toInstant, ZoneId.systemDefault()))) - } + dateOpt.map { date => FairyValidTimes(Some(date)) } } } From a6adcaaf6bd8ae6b0c7f9b9c004107f4333ac785 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 26 Jul 2022 23:59:27 +0900 Subject: [PATCH 056/482] =?UTF-8?q?[Fix]=E5=A6=96=E7=B2=BE=E3=81=8B?= =?UTF-8?q?=E3=82=89=E3=81=AE=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=81=8C=E9=80=81=E4=BF=A1=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84?= =?UTF-8?q?=E4=B8=8D=E5=85=B7=E5=90=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/actions/BukkitFairySpeak.scala | 6 +++--- .../fairy/bukkit/actions/BukkitSummonFairy.scala | 3 ++- .../fairy/infrastructure/JdbcFairyPersistence.scala | 12 ++---------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala index f9448328fc..fb9d208eb5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala @@ -29,8 +29,8 @@ object BukkitFairySpeak { SequentialEffect( FocusedSoundEffect(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f), MessageEffect(fairyMessage.message) - ).apply(player) - else SequentialEffect(MessageEffect(fairyMessage.message)).apply(player) + ).run(player).unsafeRunSync() + else MessageEffect(fairyMessage.message).run(player).unsafeRunSync() } override def speakRandomly( @@ -61,7 +61,7 @@ object BukkitFairySpeak { else FairyMessageTable.nightMessages(nameCalledByFairy) - getMessageRandomly(fairyMessages).map(speak(player, _).toIO.unsafeRunSync()) + getMessageRandomly(fairyMessages).map(speak(player, _).toIO.unsafeRunAsyncAndForget()) } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index f3ef0d23d8..8b9bde0636 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -90,13 +90,14 @@ object BukkitSummonFairy { IO.contextShift(ExecutionContext.global) FairySpeechRoutine.start(player).start.unsafeRunSync() } + () } LiftIO[IO].liftIO { SequentialEffect( UnfocusedEffect { + eff.unsafeRunSync() BukkitFairySpeak[IO].speakStartMessage(player).unsafeRunSync() - eff.unsafeRunAsyncAndForget() }, MessageEffect( List( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 2c498f0b93..0370c8a6f9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -1,18 +1,10 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure import cats.effect.Sync -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - AppleOpenState, - FairyPersistence, - FairyRecoveryMana, - FairySummonCost, - FairyUsingState, - FairyValidTimes -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} -import java.time.{LocalDateTime, ZoneId, ZonedDateTime} -import java.util.{Date, UUID} +import java.util.UUID class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { From 3adb9d5e6e63ffe3f696af20c82aeafb01441dbd Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 27 Jul 2022 00:06:42 +0900 Subject: [PATCH 057/482] =?UTF-8?q?[Fix]=E3=83=A1=E3=83=83=E3=82=BB?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=81=8C=E3=83=9E=E3=83=8A=E5=A6=96=E7=B2=BE?= =?UTF-8?q?=E3=81=AB=E3=82=88=E3=82=8B=E3=82=82=E3=81=AE=E3=81=A0=E3=81=A8?= =?UTF-8?q?=E3=82=8F=E3=81=8B=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala index fb9d208eb5..70f2a7bcac 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala @@ -11,6 +11,7 @@ import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import org.bukkit.Sound import org.bukkit.entity.Player +import org.bukkit.ChatColor._ import java.time.LocalTime import scala.util.Random @@ -25,12 +26,13 @@ object BukkitFairySpeak { ): F[Unit] = for { playSound <- fairyAPI.fairyPlaySound(player.getUniqueId) } yield { + val message = s"$AQUA$BOLD<マナ妖精>$RESET${fairyMessage.message}" if (playSound == FairyPlaySound.on) SequentialEffect( FocusedSoundEffect(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f), - MessageEffect(fairyMessage.message) + MessageEffect(message) ).run(player).unsafeRunSync() - else MessageEffect(fairyMessage.message).run(player).unsafeRunSync() + else MessageEffect(message).run(player).unsafeRunSync() } override def speakRandomly( From 4de350f09ee2497c7f09b23cb48b60400c46ffcf Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 27 Jul 2022 00:13:51 +0900 Subject: [PATCH 058/482] [Rename]FairyValidTimes -> FairyEndTime --- .../github/unchama/seichiassist/menus/VoteMenu.scala | 2 +- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 6 +++--- .../subsystems/vote/subsystems/fairy/System.scala | 9 +++------ .../fairy/bukkit/actions/BukkitSummonFairy.scala | 6 +++--- .../{FairyValidTimes.scala => FairyEndTime.scala} | 2 +- .../subsystems/fairy/domain/FairyPersistence.scala | 4 ++-- .../vote/subsystems/fairy/domain/FairySummonCost.scala | 10 +++++----- .../fairy/infrastructure/JdbcFairyPersistence.scala | 8 ++++---- 8 files changed, 22 insertions(+), 25 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{FairyValidTimes.scala => FairyEndTime.scala} (64%) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index b9db74a97f..b9d6617719 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -275,7 +275,7 @@ object VoteMenu extends Menu { SequentialEffect( UnfocusedEffect { val endTime = - fairyAPI.fairyValidTimes(player).unsafeRunSync().get.endTimeOpt.get + fairyAPI.fairyEndTime(player).unsafeRunSync().get.endTimeOpt.get BukkitFairySpeak[IO] .speak( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 452e2abd99..1cb0e8f226 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -35,9 +35,9 @@ trait FairyWriteAPI[F[_], Player] { def updateFairyRecoveryManaAmount(uuid: UUID, fairyRecoveryMana: FairyRecoveryMana): F[Unit] /** - * 妖精が有効な時間を変更する + * 妖精の効果が終了する時間を変更する */ - def updateFairyValidTimes(player: Player, fairyValidTimes: FairyValidTimes): F[Unit] + def updateFairyEndTime(player: Player, fairyEndTime: FairyEndTime): F[Unit] } @@ -91,7 +91,7 @@ trait FairyReadAPI[F[_], Player] { /** * 妖精が有効な時間を返す */ - def fairyValidTimes(player: Player): F[Option[FairyValidTimes]] + def fairyEndTime(player: Player): F[Option[FairyEndTime]] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index b63cd00dd6..7fdd1301c1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -65,14 +65,11 @@ object System { else FairyPlaySound.on ) - override def fairyValidTimes(player: Player): F[Option[FairyValidTimes]] = + override def fairyEndTime(player: Player): F[Option[FairyEndTime]] = persistence.fairyEndTime(player.getUniqueId) - override def updateFairyValidTimes( - player: Player, - fairyValidTimes: FairyValidTimes - ): F[Unit] = - persistence.updateFairyEndTime(player.getUniqueId, fairyValidTimes) + override def updateFairyEndTime(player: Player, fairyEndTime: FairyEndTime): F[Unit] = + persistence.updateFairyEndTime(player.getUniqueId, fairyEndTime) override def fairyUsingState(uuid: UUID): F[FairyUsingState] = persistence.fairyUsingState(uuid) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 8b9bde0636..bcc88414bd 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -78,13 +78,13 @@ object BukkitSummonFairy { _ <- fairyAPI.updateFairyUsingState(uuid, FairyUsingState.Using) _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(fairySummonCost.value * 2)) _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) - isFairyValidTimeDefined <- fairyAPI.fairyValidTimes(player) - _ <- fairyAPI.updateFairyValidTimes(player, fairySummonCost.validTime) + isFairyEndTimeDefined <- fairyAPI.fairyEndTime(player) + _ <- fairyAPI.updateFairyEndTime(player, fairySummonCost.validTime) } yield { /* FairySpeechRoutineが一度も起動されていなければ起動する */ - if (isFairyValidTimeDefined.isEmpty) { + if (isFairyEndTimeDefined.isEmpty) { import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.sleepAndRoutineContext implicit val contextShift: ContextShift[IO] = IO.contextShift(ExecutionContext.global) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimes.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyEndTime.scala similarity index 64% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimes.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyEndTime.scala index 48e8761b06..898c69e164 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyValidTimes.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyEndTime.scala @@ -2,4 +2,4 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain import java.time.LocalDateTime -case class FairyValidTimes(endTimeOpt: Option[LocalDateTime]) +case class FairyEndTime(endTimeOpt: Option[LocalDateTime]) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index 2ea67b7358..a273730419 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -47,11 +47,11 @@ trait FairyPersistence[F[_]] { /** * 妖精の効果が終了する時刻を変更する */ - def updateFairyEndTime(uuid: UUID, fairyValidTimes: FairyValidTimes): F[Unit] + def updateFairyEndTime(uuid: UUID, fairyEndTime: FairyEndTime): F[Unit] /** * 妖精の効果が終了する時刻を取得する */ - def fairyEndTime(uuid: UUID): F[Option[FairyValidTimes]] + def fairyEndTime(uuid: UUID): F[Option[FairyEndTime]] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala index 63c5d679e6..d7c695a924 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala @@ -9,17 +9,17 @@ case class FairySummonCost(value: Int) { * @return 妖精が有効な時間 * NOTE: 妖精が有効な時間はコストによって定められる。 */ - def validTime: FairyValidTimes = { + def validTime: FairyEndTime = { val now = LocalDateTime.now() val validTime = value match { case 1 => - FairyValidTimes(Some(now.plusMonths(30))) + FairyEndTime(Some(now.plusMonths(30))) case 2 => - FairyValidTimes(Some(now.plusHours(1))) + FairyEndTime(Some(now.plusHours(1))) case 3 => - FairyValidTimes(Some(now.plusHours(1).plusMinutes(30))) + FairyEndTime(Some(now.plusHours(1).plusMinutes(30))) case 4 => - FairyValidTimes(Some(now.plusHours(2))) + FairyEndTime(Some(now.plusHours(2))) } validTime } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 0370c8a6f9..5631face79 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -120,10 +120,10 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { /** * 妖精の効果が終了する時刻を変更する */ - override def updateFairyEndTime(uuid: UUID, fairyValidTimes: FairyValidTimes): F[Unit] = + override def updateFairyEndTime(uuid: UUID, fairyEndTime: FairyEndTime): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET newVotingFairyTime = ${fairyValidTimes.endTimeOpt.get} WHERE uuid = ${uuid.toString}" + sql"UPDATE playerdata SET newVotingFairyTime = ${fairyEndTime.endTimeOpt.get} WHERE uuid = ${uuid.toString}" .execute() .apply() } @@ -132,13 +132,13 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { /** * 妖精の効果が終了する時刻を取得する */ - override def fairyEndTime(uuid: UUID): F[Option[FairyValidTimes]] = Sync[F].delay { + override def fairyEndTime(uuid: UUID): F[Option[FairyEndTime]] = Sync[F].delay { DB.readOnly { implicit session => val dateOpt = sql"SELECT newVotingFairyTime FROM playerdata WHERE uuid = ${uuid.toString}" .map(_.localDateTime("newVotingFairyTime")) .single() .apply() - dateOpt.map { date => FairyValidTimes(Some(date)) } + dateOpt.map { date => FairyEndTime(Some(date)) } } } From 5918999bfcd140dcff050dd9bc409d62db614c32 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 27 Jul 2022 00:17:56 +0900 Subject: [PATCH 059/482] =?UTF-8?q?[Chore]fairy.domain=E3=82=92=E3=83=91?= =?UTF-8?q?=E3=83=83=E3=82=B1=E3=83=BC=E3=82=B8=E3=83=B3=E3=82=B0=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/menus/VoteMenu.scala | 4 +--- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 9 +++++++++ .../subsystems/vote/subsystems/fairy/System.scala | 9 +++++++++ .../fairy/application/actions/FairySpeak.scala | 2 +- .../fairy/bukkit/actions/BukkitFairySpeak.scala | 6 ++++++ .../fairy/bukkit/actions/BukkitSummonFairy.scala | 2 +- .../subsystems/fairy/domain/FairyPersistence.scala | 8 ++++++++ .../fairy/domain/bukkit/FairyLoreTable.scala | 11 ++++++----- .../fairy/domain/{ => property}/AppleOpenState.scala | 2 +- .../fairy/domain/{ => property}/FairyEndTime.scala | 2 +- .../fairy/domain/{ => property}/FairyLore.scala | 2 +- .../fairy/domain/{ => property}/FairyMessage.scala | 2 +- .../fairy/domain/{ => property}/FairyMessages.scala | 2 +- .../fairy/domain/{ => property}/FairyPlaySound.scala | 2 +- .../domain/{ => property}/FairyRecoveryMana.scala | 2 +- .../{ => property}/FairyRecoveryManaAmount.scala | 2 +- .../fairy/domain/{ => property}/FairySummonCost.scala | 2 +- .../fairy/domain/{ => property}/FairyUsingState.scala | 2 +- .../domain/{ => property}/NameCalledByFairy.scala | 2 +- .../domain/{ => resources}/FairyMessageTable.scala | 8 +++++++- .../fairy/infrastructure/JdbcFairyPersistence.scala | 7 +++++++ 21 files changed, 66 insertions(+), 22 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{ => property}/AppleOpenState.scala (95%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{ => property}/FairyEndTime.scala (86%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{ => property}/FairyLore.scala (85%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{ => property}/FairyMessage.scala (84%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{ => property}/FairyMessages.scala (85%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{ => property}/FairyPlaySound.scala (89%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{ => property}/FairyRecoveryMana.scala (85%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{ => property}/FairyRecoveryManaAmount.scala (95%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{ => property}/FairySummonCost.scala (96%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{ => property}/FairyUsingState.scala (89%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{ => property}/NameCalledByFairy.scala (81%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{ => resources}/FairyMessageTable.scala (89%) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index b9d6617719..0e46304573 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -19,10 +19,8 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.a BukkitFairySpeak, BukkitSummonFairy } -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - AppleOpenState, +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ FairyMessage, - FairyPlaySound, FairySummonCost } import com.github.unchama.seichiassist.task.VotingFairyTask diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 1cb0e8f226..5af99a2398 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -3,6 +3,15 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.concurrent.Ref import com.github.unchama.datarepository.KeyedDataRepository import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + AppleOpenState, + FairyEndTime, + FairyLore, + FairyPlaySound, + FairyRecoveryMana, + FairySummonCost, + FairyUsingState +} import java.util.UUID diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 7fdd1301c1..eff1488cd1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -8,6 +8,15 @@ import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit.FairyLoreTable +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + AppleOpenState, + FairyEndTime, + FairyLore, + FairyPlaySound, + FairyRecoveryMana, + FairySummonCost, + FairyUsingState +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import org.bukkit.entity.Player diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala index 1c9359ea78..f5a9a5fc51 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala @@ -1,7 +1,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyMessage +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage trait FairySpeak[F[_], Player] { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala index 70f2a7bcac..cf4addcd81 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala @@ -6,6 +6,12 @@ import cats.effect.{ConcurrentEffect, Sync} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairySpeak import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + FairyMessage, + FairyMessages, + NameCalledByFairy +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.FairyMessageTable import com.github.unchama.targetedeffect.SequentialEffect import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index bcc88414bd..479909ab6c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -9,7 +9,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.FairySpeechRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyUsingState.Using -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ FairyRecoveryManaAmount, FairyUsingState } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index a273730419..9e6e51ee22 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -1,5 +1,13 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + AppleOpenState, + FairyEndTime, + FairyRecoveryMana, + FairySummonCost, + FairyUsingState +} + import java.util.UUID trait FairyPersistence[F[_]] { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/bukkit/FairyLoreTable.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/bukkit/FairyLoreTable.scala index 498156ee84..528a04cda0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/bukkit/FairyLoreTable.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/bukkit/FairyLoreTable.scala @@ -1,20 +1,21 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit import cats.data.NonEmptyList -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyLore +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyLore import org.bukkit.ChatColor._ object FairyLoreTable { val loreTable: List[FairyLore] = List( - FairyLore( + property.FairyLore( NonEmptyList.of( s"$RED$UNDERLINE${BOLD}ガンガンたべるぞ", s"$RESET${GRAY}とにかく妖精さんにりんごを開放します。", s"$RESET${GRAY}めっちゃ喜ばれます。" ) ), - FairyLore( + property.FairyLore( NonEmptyList.of( s"$YELLOW$UNDERLINE${BOLD}バッチリたべよう", s"$RESET${GRAY}食べ過ぎないように注意しつつ", @@ -22,14 +23,14 @@ object FairyLoreTable { s"$RESET${GRAY}喜ばれます。" ) ), - FairyLore( + property.FairyLore( NonEmptyList.of( s"$GREEN$UNDERLINE${BOLD}リンゴだいじに", s"$RESET${GRAY}少しだけ妖精さんにりんごを開放します。", s"$RESET${GRAY}伝えると大抵落ち込みます。" ) ), - FairyLore( + property.FairyLore( NonEmptyList.of(s"$BLUE$UNDERLINE${BOLD}リンゴつかうな", s"$RESET${GRAY}絶対にりんごを開放しません。", "") ) ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/AppleOpenState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala similarity index 95% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/AppleOpenState.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala index d1181f9f1e..0a2069a3c4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/AppleOpenState.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property import enumeratum._ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyEndTime.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyEndTime.scala similarity index 86% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyEndTime.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyEndTime.scala index 898c69e164..f40da12776 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyEndTime.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyEndTime.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property import java.time.LocalDateTime diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyLore.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyLore.scala similarity index 85% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyLore.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyLore.scala index d87b01fd17..b0d5b0846c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyLore.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyLore.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property import cats.data.NonEmptyList diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessage.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyMessage.scala similarity index 84% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessage.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyMessage.scala index dda9036a12..b40479eb77 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessage.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyMessage.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property case class FairyMessage(message: String) { require(message.nonEmpty) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessages.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyMessages.scala similarity index 85% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessages.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyMessages.scala index abf80c5058..aa58a9efa9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessages.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyMessages.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property case class FairyMessages(messages: FairyMessage*) { require(messages.nonEmpty) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPlaySound.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyPlaySound.scala similarity index 89% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPlaySound.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyPlaySound.scala index d76258e3cf..5373efa25f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPlaySound.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyPlaySound.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property sealed trait FairyPlaySound diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyRecoveryMana.scala similarity index 85% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyRecoveryMana.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyRecoveryMana.scala index 1db62c5d1b..8e14117d35 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyRecoveryMana.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property case class FairyRecoveryMana(recoveryMana: Int) { require(recoveryMana >= 0) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyRecoveryManaAmount.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyRecoveryManaAmount.scala similarity index 95% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyRecoveryManaAmount.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyRecoveryManaAmount.scala index cbe5e93f44..845a70de4c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyRecoveryManaAmount.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyRecoveryManaAmount.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property import scala.util.Random diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala similarity index 96% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala index d7c695a924..a0828263d3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonCost.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property import java.time.LocalDateTime diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyUsingState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyUsingState.scala similarity index 89% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyUsingState.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyUsingState.scala index b61d150598..245a4c78b6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyUsingState.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyUsingState.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property sealed trait FairyUsingState diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/NameCalledByFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/NameCalledByFairy.scala similarity index 81% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/NameCalledByFairy.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/NameCalledByFairy.scala index 452ee77bb5..141ed4aa63 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/NameCalledByFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/NameCalledByFairy.scala @@ -1,3 +1,3 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property case class NameCalledByFairy(value: String) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessageTable.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala similarity index 89% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessageTable.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala index 855738d0c9..38e73f879e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyMessageTable.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala @@ -1,4 +1,10 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources + +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + FairyMessage, + FairyMessages, + NameCalledByFairy +} object FairyMessageTable { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 5631face79..de7f005784 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -2,6 +2,13 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrast import cats.effect.Sync import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + AppleOpenState, + FairyEndTime, + FairyRecoveryMana, + FairySummonCost, + FairyUsingState +} import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} import java.util.UUID From 45eabe6fc532f23db2608ba533683244cbcfa84f Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 27 Jul 2022 00:29:39 +0900 Subject: [PATCH 060/482] =?UTF-8?q?[Add]=E5=A6=96=E7=B2=BE=E3=81=8C?= =?UTF-8?q?=E3=83=A9=E3=83=B3=E3=83=80=E3=83=A0=E3=81=A7=E7=99=BA=E8=A8=80?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=83=86=E3=83=BC=E3=83=96=E3=83=AB=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/resources/FairyMessageTable.scala | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala index 38e73f879e..21f95c1924 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala @@ -8,6 +8,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p object FairyMessageTable { + // 朝に妖精を召喚したときに表示されるメッセージ val morningMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( FairyMessage(s"おはよ!${name.value}"), @@ -17,6 +18,7 @@ object FairyMessageTable { FairyMessage(s"今日は整地日和だね!${name.value}") ) + // 昼に妖精を召喚したときに表示されるメッセージ val dayMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( FairyMessage(s"やあ!${name.value}"), @@ -26,6 +28,7 @@ object FairyMessageTable { FairyMessage("今日のおやつはがちゃりんごいっぱいだ!") ) + // 夜に妖精を召喚したときに表示されるメッセージ val nightMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( FairyMessage(s"やあ!${name.value}"), @@ -35,4 +38,35 @@ object FairyMessageTable { FairyMessage("こんな時間に呼ぶなんて…りんごははずんでもらうよ?") ) + // マナが満タンだったときに表示されるメッセージ + val manaFullMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => + FairyMessages( + FairyMessage("整地しないのー?"), + FairyMessage("たくさん働いて、たくさんりんごを食べようね!"), + FairyMessage("僕はいつか大きながちゃりんごを食べ尽して見せるっ!"), + FairyMessage("ちょっと食べ疲れちゃった"), + FairyMessage(s"${name.value}はどのりんごが好き?僕はがちゃりんご!"), + FairyMessage("動いてお腹を空かしていっぱい食べるぞー!") + ) + + // 妖精にりんごが消費されたときに表示されるメッセージ + val consumed: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => + FairyMessages( + FairyMessage("(´~`)モグモグ…"), + FairyMessage("がちゃりんごって美味しいよね!"), + FairyMessage("あぁ!幸せ!"), + FairyMessage(s"${name.value}のりんごはおいしいなぁ"), + FairyMessage("いつもりんごをありがとう!") + ) + + // 妖精がりんごを消費しなかったときに表示されるメッセージ + val notConsumed: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => + FairyMessages( + FairyMessage("お腹空いたなぁー。"), + FairyMessage("がちゃりんごがっ!食べたいっ!"), + FairyMessage("(´;ω;`)ウゥゥ ヒモジイ..."), + FairyMessage(s"@うんちゃま ${name.value}が意地悪するんだっ!"), + FairyMessage("うわーん!お腹空いたよー!") + ) + } From f34f9231bfb9b8dd76b60e202d2c82b2b4fbf911 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 27 Jul 2022 09:34:54 +0900 Subject: [PATCH 061/482] =?UTF-8?q?[Remove]=E4=B8=8D=E8=A6=81=E3=81=AAimpo?= =?UTF-8?q?rt=E3=81=AE=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/System.scala | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index eff1488cd1..98e5c73be8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -6,17 +6,8 @@ import com.github.unchama.datarepository.KeyedDataRepository import com.github.unchama.generic.ContextCoercion import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit.FairyLoreTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - AppleOpenState, - FairyEndTime, - FairyLore, - FairyPlaySound, - FairyRecoveryMana, - FairySummonCost, - FairyUsingState -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import org.bukkit.entity.Player From 62152b940c6cc51fff50fe7060e7c77c2fe706ad Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 27 Jul 2022 09:46:57 +0900 Subject: [PATCH 062/482] =?UTF-8?q?[Add]=E3=83=89=E3=82=AD=E3=83=A5?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/application/actions/FairySpeak.scala | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala index f5a9a5fc51..54313a4c45 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala @@ -5,12 +5,21 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p trait FairySpeak[F[_], Player] { + /** + * 単に妖精からのメッセージを発言する作用 + */ def speak(player: Player, fairyMessage: FairyMessage)( implicit fairyAPI: FairyAPI[F, Player] ): F[Unit] + /** + * 妖精からのランダムなメッセージを発言する作用 + */ def speakRandomly(player: Player)(implicit fairyAPI: FairyAPI[F, Player]): F[Unit] + /** + * 妖精からの召喚時メッセージを発言する作用 + */ def speakStartMessage(player: Player)(implicit fairyAPI: FairyAPI[F, Player]): F[Unit] } From 28c172c836caf6546cb01dd662859db7a4c5de2c Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 27 Jul 2022 11:03:47 +0900 Subject: [PATCH 063/482] =?UTF-8?q?[Add]FairySpeechGateway=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/actions/BukkitFairySpeak.scala | 9 ++----- .../gateway/BukkitFairySpeechGateway.scala | 24 +++++++++++++++++++ .../fairy/domain/FairySpeechGateway.scala | 11 +++++++++ 3 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeechGateway.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala index cf4addcd81..6a2c139682 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala @@ -5,19 +5,14 @@ import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import cats.effect.{ConcurrentEffect, Sync} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairySpeak -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - FairyMessage, - FairyMessages, - NameCalledByFairy -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.FairyMessageTable import com.github.unchama.targetedeffect.SequentialEffect import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect +import org.bukkit.ChatColor._ import org.bukkit.Sound import org.bukkit.entity.Player -import org.bukkit.ChatColor._ import java.time.LocalTime import scala.util.Random diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala new file mode 100644 index 0000000000..dfc3a57457 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala @@ -0,0 +1,24 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway + +import cats.effect.{IO, SyncIO} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage +import com.github.unchama.targetedeffect.commandsender.MessageEffect +import com.github.unchama.targetedeffect.player.FocusedSoundEffect +import org.bukkit.ChatColor.{AQUA, BOLD, RESET} +import org.bukkit.Sound +import org.bukkit.entity.Player + +class BukkitFairySpeechGateway(player: Player) extends FairySpeechGateway[SyncIO] { + + override def sendMessage(fairyMessage: FairyMessage): SyncIO[Unit] = { + MessageEffect(s"$AQUA$BOLD<マナ妖精>$RESET${fairyMessage.message}") + .run(player) + .runAsync(_ => IO.unit) + } + + override def playSpeechSound: SyncIO[Unit] = { + FocusedSoundEffect(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f).run(player).runAsync(_ => IO.unit) + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeechGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeechGateway.scala new file mode 100644 index 0000000000..fcb12dd557 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeechGateway.scala @@ -0,0 +1,11 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage + +trait FairySpeechGateway[F[_]] { + + def sendMessage(fairyMessage: FairyMessage): F[Unit] + + def playSpeechSound: F[Unit] + +} From acb8288d3a91930e999d4d31ed8e55b6a645592f Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 27 Jul 2022 11:16:08 +0900 Subject: [PATCH 064/482] =?UTF-8?q?[Add]FairySpeechService=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/service/FairySpeechService.scala | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala new file mode 100644 index 0000000000..b4e4a87ca3 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala @@ -0,0 +1,20 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service + +import cats.effect.Sync +import cats.implicits.catsSyntaxFlatMapOps +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + FairyMessage, + FairyPlaySound +} + +class FairySpeechService[F[_]: Sync](gateway: FairySpeechGateway[F]) { + + def makeSpeech(fairyMessage: FairyMessage, fairyPlaySound: FairyPlaySound): F[Unit] = { + if (fairyPlaySound == FairyPlaySound.on) + gateway.sendMessage(fairyMessage) >> gateway.playSpeechSound + else + gateway.sendMessage(fairyMessage) + } + +} From 679d7b79a7db5ccb215277fb0f43158c56b4f8d2 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 27 Jul 2022 16:56:16 +0900 Subject: [PATCH 065/482] =?UTF-8?q?[Add]SpeechServiceRepository=E3=82=84?= =?UTF-8?q?=E3=81=9D=E3=82=8C=E3=81=AB=E4=BB=98=E9=9A=8F=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=82=E3=81=AE=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/SeichiAssist.scala | 2 +- .../unchama/seichiassist/menus/VoteMenu.scala | 2 + .../vote/subsystems/fairy/System.scala | 163 +++++++++++------- .../SpeechServiceRepositoryDefinitions.scala | 22 +++ .../subsystems/fairy/bukkit/FairySpeech.scala | 54 ++++++ .../bukkit/actions/BukkitSummonFairy.scala | 3 +- 6 files changed, 179 insertions(+), 67 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 4842613563..5f512f6de2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -392,7 +392,7 @@ class SeichiAssist extends JavaPlugin() { subsystems.vote.System.wired[IO] private lazy val fairySystem: subsystems.vote.subsystems.fairy.System[IO, Player] = - subsystems.vote.subsystems.fairy.System.wired[IO, SyncIO] + subsystems.vote.subsystems.fairy.System.wired[IO, SyncIO].unsafeRunSync() private lazy val wiredSubsystems: List[Subsystem[IO]] = List( mebiusSystem, diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 0e46304573..126161f51d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -20,7 +20,9 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.a BukkitSummonFairy } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + AppleOpenState, FairyMessage, + FairyPlaySound, FairySummonCost } import com.github.unchama.seichiassist.task.VotingFairyTask diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 98e5c73be8..cd3f1d2aea 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -1,14 +1,23 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.concurrent.Ref -import cats.effect.{ConcurrentEffect, Sync, SyncEffect} +import cats.effect.{ConcurrentEffect, Sync, SyncEffect, SyncIO} import com.github.unchama.datarepository.KeyedDataRepository +import com.github.unchama.datarepository.bukkit.player.{ + BukkitRepositoryControls, + PlayerDataRepository +} +import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.generic.ContextCoercion import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.SpeechServiceRepositoryDefinitions +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit.FairyLoreTable import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player import java.util.UUID @@ -22,71 +31,95 @@ object System { def wired[F[_]: ConcurrentEffect: OnMinecraftServerThread, G[_]: SyncEffect: ContextCoercion[ *[_], F - ]]: System[F, Player] = { + ]]: SyncIO[System[F, Player]] = { val persistence = new JdbcFairyPersistence[F] - new System[F, Player] { - override val api: FairyAPI[F, Player] = new FairyAPI[F, Player] { - override def appleOpenState(uuid: UUID): F[AppleOpenState] = - persistence.appleOpenState(uuid) - - override def updateAppleOpenState(uuid: UUID, appleOpenState: AppleOpenState): F[Unit] = - persistence.changeAppleOpenState(uuid, appleOpenState) - - import cats.implicits._ - - override def getFairyLore(uuid: UUID): F[FairyLore] = for { - state <- appleOpenState(uuid) - } yield FairyLoreTable.loreTable(state.amount - 1) - - override def updateFairySummonCost( - uuid: UUID, - fairySummonCost: FairySummonCost - ): F[Unit] = - persistence.updateFairySummonCost(uuid, fairySummonCost) - - override def fairySummonCost(uuid: UUID): F[FairySummonCost] = - persistence.fairySummonCost(uuid) - - override protected val fairyPlaySoundRepository - : KeyedDataRepository[UUID, Ref[F, FairyPlaySound]] = - KeyedDataRepository.unlift[UUID, Ref[F, FairyPlaySound]] { _ => - Some(Ref.unsafe(FairyPlaySound.on)) - } - - override def fairyPlaySound(uuid: UUID): F[FairyPlaySound] = - if (fairyPlaySoundRepository.isDefinedAt(uuid)) - fairyPlaySoundRepository(uuid).get - else Sync[F].pure(FairyPlaySound.on) - - override def fairyPlaySoundToggle(uuid: UUID): F[Unit] = for { - nowSetting <- fairyPlaySound(uuid) - } yield fairyPlaySoundRepository(uuid).set( - if (nowSetting == FairyPlaySound.on) FairyPlaySound.off - else FairyPlaySound.on - ) - - override def fairyEndTime(player: Player): F[Option[FairyEndTime]] = - persistence.fairyEndTime(player.getUniqueId) - - override def updateFairyEndTime(player: Player, fairyEndTime: FairyEndTime): F[Unit] = - persistence.updateFairyEndTime(player.getUniqueId, fairyEndTime) - - override def fairyUsingState(uuid: UUID): F[FairyUsingState] = - persistence.fairyUsingState(uuid) - - override def updateFairyUsingState( - uuid: UUID, - fairyUsingState: FairyUsingState - ): F[Unit] = - persistence.updateFairyUsingState(uuid, fairyUsingState) - - override def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] = - persistence.fairyRecoveryMana(uuid) - - override def updateFairyRecoveryManaAmount( - uuid: UUID, - fairyRecoveryMana: FairyRecoveryMana - ): F[Unit] = persistence.updateFairyRecoveryMana(uuid, fairyRecoveryMana) + implicit val gatewayProvider: Player => FairySpeechGateway[SyncIO] = + new BukkitFairySpeechGateway(_) + + for { + speechServiceRepositoryControls <- BukkitRepositoryControls.createHandles( + RepositoryDefinition + .Phased + .TwoPhased( + SpeechServiceRepositoryDefinitions.initialization[SyncIO, Player], + SpeechServiceRepositoryDefinitions.finalization[SyncIO, Player] + ) + ) + } yield { + new System[F, Player] { + override val api: FairyAPI[F, Player] = new FairyAPI[F, Player] { + val repository: PlayerDataRepository[FairySpeechService[SyncIO]] = + speechServiceRepositoryControls.repository + + override def appleOpenState(uuid: UUID): F[AppleOpenState] = + persistence.appleOpenState(uuid) + + override def updateAppleOpenState( + uuid: UUID, + appleOpenState: AppleOpenState + ): F[Unit] = + persistence.changeAppleOpenState(uuid, appleOpenState) + + import cats.implicits._ + + override def getFairyLore(uuid: UUID): F[FairyLore] = for { + state <- appleOpenState(uuid) + } yield FairyLoreTable.loreTable(state.amount - 1) + + override def updateFairySummonCost( + uuid: UUID, + fairySummonCost: FairySummonCost + ): F[Unit] = + persistence.updateFairySummonCost(uuid, fairySummonCost) + + override def fairySummonCost(uuid: UUID): F[FairySummonCost] = + persistence.fairySummonCost(uuid) + + override protected val fairyPlaySoundRepository + : KeyedDataRepository[UUID, Ref[F, FairyPlaySound]] = + KeyedDataRepository.unlift[UUID, Ref[F, FairyPlaySound]] { _ => + Some(Ref.unsafe(FairyPlaySound.on)) + } + + override def fairyPlaySound(uuid: UUID): F[FairyPlaySound] = + if (fairyPlaySoundRepository.isDefinedAt(uuid)) + fairyPlaySoundRepository(uuid).get + else Sync[F].pure(FairyPlaySound.on) + + override def fairyPlaySoundToggle(uuid: UUID): F[Unit] = for { + nowSetting <- fairyPlaySound(uuid) + } yield fairyPlaySoundRepository(uuid).set( + if (nowSetting == FairyPlaySound.on) FairyPlaySound.off + else FairyPlaySound.on + ) + + override def fairyEndTime(player: Player): F[Option[FairyEndTime]] = + persistence.fairyEndTime(player.getUniqueId) + + override def updateFairyEndTime(player: Player, fairyEndTime: FairyEndTime): F[Unit] = + persistence.updateFairyEndTime(player.getUniqueId, fairyEndTime) + + override def fairyUsingState(uuid: UUID): F[FairyUsingState] = + persistence.fairyUsingState(uuid) + + override def updateFairyUsingState( + uuid: UUID, + fairyUsingState: FairyUsingState + ): F[Unit] = + persistence.updateFairyUsingState(uuid, fairyUsingState) + + override def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] = + persistence.fairyRecoveryMana(uuid) + + override def updateFairyRecoveryManaAmount( + uuid: UUID, + fairyRecoveryMana: FairyRecoveryMana + ): F[Unit] = persistence.updateFairyRecoveryMana(uuid, fairyRecoveryMana) + } + + override val managedRepositoryControls: Seq[BukkitRepositoryControls[F, _]] = + Seq(speechServiceRepositoryControls).map(_.coerceFinalizationContextTo[F]) + } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala new file mode 100644 index 0000000000..cd055a0050 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala @@ -0,0 +1,22 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository + +import cats.Applicative +import cats.effect.Sync +import com.github.unchama.datarepository.template.finalization.RepositoryFinalization +import com.github.unchama.datarepository.template.initialization.TwoPhasedRepositoryInitialization +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService + +object SpeechServiceRepositoryDefinitions { + + def initialization[F[_]: Applicative: Sync, Player]( + implicit gatewayProvider: Player => FairySpeechGateway[F] + ): TwoPhasedRepositoryInitialization[F, Player, FairySpeechService[F]] = + TwoPhasedRepositoryInitialization.withoutPrefetching[F, Player, FairySpeechService[F]] { + player => Sync[F].delay(new FairySpeechService[F](gatewayProvider(player))) + } + + def finalization[F[_]: Applicative, Player] + : RepositoryFinalization[F, Player, FairySpeechService[F]] = RepositoryFinalization.trivial + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala new file mode 100644 index 0000000000..38d31e258b --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -0,0 +1,54 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit + +import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps +import cats.effect.{ConcurrentEffect, Sync, SyncIO} +import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + FairyMessage, + FairyMessages, + NameCalledByFairy +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.FairyMessageTable +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService +import org.bukkit.entity.Player + +import java.time.LocalTime +import scala.util.Random + +class FairySpeech[F[_]: ConcurrentEffect]( + implicit serviceRepository: PlayerDataRepository[FairySpeechService[SyncIO]], + fairyAPI: FairyAPI[F, Player] +) { + + import cats.implicits._ + + def summonSpeech(player: Player): F[Unit] = + for { + startHour <- Sync[F].delay(LocalTime.now().getHour) + nameCalledByFairy = NameCalledByFairy(player.getName) + fairyMessages = + if (4 <= startHour && startHour < 10) + FairyMessageTable.morningMessages(nameCalledByFairy) + else if (10 <= startHour && startHour < 18) + FairyMessageTable.dayMessages(nameCalledByFairy) + else + FairyMessageTable.nightMessages(nameCalledByFairy) + message <- randomMessage(fairyMessages) + } yield { + serviceRepository(player) + .makeSpeech(message, fairyAPI.fairyPlaySound(player.getUniqueId).toIO.unsafeRunSync()) + } + + // TODO: 妖精によるマナ回復関連が定義されたこれを定義する +// def speechRandomly(player: Player): F[Unit] = { +// val nameCalledByFairy = NameCalledByFairy(player.getName) +// +// } + + private def randomMessage(fairyMessages: FairyMessages): F[FairyMessage] = Sync[F].delay { + val messages = fairyMessages.messages + messages(Random.nextInt(messages.size)) + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 479909ab6c..bd529a1aff 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -7,8 +7,8 @@ import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.FairySpeechRoutine -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyUsingState.Using import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ FairyRecoveryManaAmount, FairyUsingState @@ -97,6 +97,7 @@ object BukkitSummonFairy { SequentialEffect( UnfocusedEffect { eff.unsafeRunSync() + new FairySpeech().summonSpeech(player) BukkitFairySpeak[IO].speakStartMessage(player).unsafeRunSync() }, MessageEffect( From 8f7b4e21a3bc7ac7c1f79241b7f02bea3800b013 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 27 Jul 2022 17:56:17 +0900 Subject: [PATCH 066/482] =?UTF-8?q?[Add]FairySpawnGateway=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gateway/BukkitFairySpawnGateway.scala | 119 ++++++++++++++++++ .../fairy/domain/FairySpawnGateway.scala | 30 +++++ 2 files changed, 149 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpawnGateway.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnGateway.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpawnGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpawnGateway.scala new file mode 100644 index 0000000000..f7698c6b7f --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpawnGateway.scala @@ -0,0 +1,119 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway + +import cats.effect.{ConcurrentEffect, ContextShift, IO, LiftIO, SyncIO} +import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository +import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI +import com.github.unchama.seichiassist.subsystems.mana.ManaApi +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI +import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitFairySpeak +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.FairySpeechRoutine +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + FairyRecoveryManaAmount, + FairyUsingState +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService +import com.github.unchama.targetedeffect.commandsender.MessageEffect +import com.github.unchama.targetedeffect.player.FocusedSoundEffect +import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} +import org.bukkit.ChatColor.{BOLD, GOLD, RESET, YELLOW} +import org.bukkit.Sound +import org.bukkit.entity.Player + +import scala.concurrent.ExecutionContext + +class BukkitFairySpawnGateway extends FairySpawnGateway[SyncIO, Player] { + + /** + * 妖精をスポーンさせる作用 + */ + override def spawn(player: Player)( + implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], + fairyAPI: FairyAPI[IO, Player], + voteAPI: VoteAPI[IO], + manaApi: ManaApi[IO, SyncIO, Player], + serviceRepository: PlayerDataRepository[FairySpeechService[SyncIO]], + concurrentEffect: ConcurrentEffect[IO] + ): SyncIO[Unit] = { + val playerLevel = + breakCountAPI + .seichiAmountDataRepository(player) + .read + .unsafeRunSync() + .levelCorrespondingToExp + .level + + val uuid = player.getUniqueId + + val fairySummonCost = fairyAPI.fairySummonCost(uuid).unsafeRunSync() + + val failedEffect = spawnFailedEffect(player, _) + + if (playerLevel < 10) + return failedEffect(s"${GOLD}プレイヤーレベルが足りません") + + if (fairyAPI.fairyUsingState(uuid).unsafeRunSync() == FairyUsingState.Using) + return failedEffect(s"${GOLD}既に妖精を召喚しています") + + if (voteAPI.effectPoints(uuid).unsafeRunSync().value < fairySummonCost.value * 2) + return failedEffect(s"${GOLD}投票ptが足りません") + + val levelCappedManaAmount = + manaApi.readManaAmount(player).unsafeRunSync().cap.value + + // 回復するマナの量 + val recoveryMana = FairyRecoveryManaAmount.manaAmountAt(levelCappedManaAmount) + + val eff = for { + _ <- fairyAPI.updateFairyUsingState(uuid, FairyUsingState.Using) + _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(fairySummonCost.value * 2)) + _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) + isFairyEndTimeDefined <- fairyAPI.fairyEndTime(player) + _ <- fairyAPI.updateFairyEndTime(player, fairySummonCost.validTime) + } yield { + /* + FairySpeechRoutineが一度も起動されていなければ起動する + */ + if (isFairyEndTimeDefined.isEmpty) { + import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.sleepAndRoutineContext + implicit val contextShift: ContextShift[IO] = + IO.contextShift(ExecutionContext.global) + FairySpeechRoutine.start(player).start.unsafeRunSync() + } + } + + LiftIO[IO] + .liftIO { + SequentialEffect( + UnfocusedEffect { + eff.unsafeRunSync() + new FairySpeech().summonSpeech(player) + BukkitFairySpeak[IO].speakStartMessage(player).unsafeRunSync() + }, + MessageEffect( + List( + s"$RESET$YELLOW${BOLD}妖精を呼び出しました!", + s"$RESET$YELLOW${BOLD}この子は1分間に約${recoveryMana.recoveryMana}マナ", + s"$RESET$YELLOW${BOLD}回復させる力を持っているようです。" + ) + ) + ).apply(player) + } + .runAsync(_ => IO.unit) + } + + private def spawnFailedEffect(player: Player, message: String): SyncIO[Unit] = { + SequentialEffect( + MessageEffect(message), + FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) + ).run(player).runAsync(_ => IO.unit) + } + + /** + * 妖精をデスポーンさせる作用 + */ + override def despawn(): SyncIO[Unit] = ??? +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnGateway.scala new file mode 100644 index 0000000000..959ac770db --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnGateway.scala @@ -0,0 +1,30 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +import cats.effect.{ConcurrentEffect, IO, SyncIO} +import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository +import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI +import com.github.unchama.seichiassist.subsystems.mana.ManaApi +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService + +trait FairySpawnGateway[F[_], Player] { + + /** + * 妖精をスポーンさせる作用 + */ + def spawn(player: Player)( + implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], + fairyAPI: FairyAPI[IO, Player], + voteAPI: VoteAPI[IO], + manaApi: ManaApi[IO, SyncIO, Player], + serviceRepository: PlayerDataRepository[FairySpeechService[SyncIO]], + concurrentEffect: ConcurrentEffect[IO] + ): F[Unit] + + /** + * 妖精をデスポーンさせる作用 + */ + def despawn(): F[Unit] + +} From 0e92f1debedfab12f97e752371870e7d18de6d21 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 27 Jul 2022 19:18:31 +0900 Subject: [PATCH 067/482] =?UTF-8?q?[Add]FairySpawnRequest=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 28 +++++++----- .../seichiassist/subsystems/vote/System.scala | 17 +++---- .../subsystems/vote/VoteAPI.scala | 10 +++-- .../vote/bukkit/command/VoteCommand.scala | 3 +- .../vote/subsystems/fairy/FairyAPI.scala | 17 ++----- .../vote/subsystems/fairy/System.scala | 13 +++--- .../gateway/BukkitFairySpawnGateway.scala | 22 ++++----- .../fairy/domain/FairySpawnGateway.scala | 19 +------- .../fairy/domain/FairySpawnRequest.scala | 34 ++++++++++++++ .../property/FairySpawnRequestResult.scala | 15 +++++++ .../fairy/service/FairySpawnService.scala | 45 +++++++++++++++++++ 11 files changed, 148 insertions(+), 75 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestResult.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpawnService.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 126161f51d..1c8a886ac0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -1,6 +1,7 @@ package com.github.unchama.seichiassist.menus import cats.effect.{ConcurrentEffect, IO, SyncIO} +import cats.instances.uuid import com.github.unchama.itemstackbuilder.IconItemStackBuilder import com.github.unchama.menuinventory.router.CanOpen import com.github.unchama.menuinventory.slot.button.Button @@ -39,7 +40,7 @@ import java.util.UUID object VoteMenu extends Menu { class Environment( - implicit val voteAPI: VoteAPI[IO], + implicit val voteAPI: VoteAPI[IO, Player], val fairyAPI: FairyAPI[IO, Player], val breakCountAPI: BreakCountAPI[IO, SyncIO, Player], val manaApi: ManaApi[IO, SyncIO, Player], @@ -66,8 +67,8 @@ object VoteMenu extends Menu { val buttons = Map( - ChestSlotRef(0, 0) -> receiveVoteBenefitsButton(uuid), - ChestSlotRef(0, 2) -> fairySummonTimeToggleButton(uuid), + ChestSlotRef(0, 0) -> receiveVoteBenefitsButton(player), + ChestSlotRef(0, 2) -> fairySummonTimeToggleButton(player), ChestSlotRef(0, 4) -> fairySummonButton(player), ChestSlotRef(1, 0) -> showVoteURLButton, ChestSlotRef(1, 2) -> fairyContractSettingToggle(uuid), @@ -83,14 +84,15 @@ object VoteMenu extends Menu { implicit val ioCE: ConcurrentEffect[IO] = IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) - def receiveVoteBenefitsButton(uuid: UUID)( - implicit voteAPI: VoteAPI[IO], + def receiveVoteBenefitsButton(player: Player)( + implicit voteAPI: VoteAPI[IO, Player], breakCountAPI: BreakCountAPI[IO, SyncIO, Player] ): Button = { + val uuid = player.getUniqueId for { benefits <- voteAPI.receivedVoteBenefits(uuid) voteCounter <- voteAPI.voteCounter(uuid) - effectPoint <- voteAPI.effectPoints(uuid) + effectPoint <- voteAPI.effectPoints(player) } yield { Button( new IconItemStackBuilder(Material.DIAMOND) @@ -149,9 +151,9 @@ object VoteMenu extends Menu { ) def fairySummonTimeToggleButton( - uuid: UUID + player: Player )(implicit fairyAPI: FairyAPI[IO, Player]): Button = { - val fairySummonCost = fairyAPI.fairySummonCost(uuid).unsafeRunSync() + val fairySummonCost = fairyAPI.fairySummonCost(player).unsafeRunSync() Button( new IconItemStackBuilder(Material.WATCH) .title(s"$AQUA$UNDERLINE${BOLD}マナ妖精 時間設定") @@ -170,8 +172,10 @@ object VoteMenu extends Menu { SequentialEffect( FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), UnfocusedEffect( - fairyAPI - .updateFairySummonCost(uuid, FairySummonCost(fairySummonCost.value % 4 + 1)) + fairyAPI.updateFairySummonCost( + player.getUniqueId, + FairySummonCost(fairySummonCost.value % 4 + 1) + ) ) ) } @@ -234,12 +238,12 @@ object VoteMenu extends Menu { def fairySummonButton(player: Player)( implicit fairyAPI: FairyAPI[IO, Player], - voteAPI: VoteAPI[IO], + voteAPI: VoteAPI[IO, Player], breakCountAPI: BreakCountAPI[IO, SyncIO, Player], manaApi: ManaApi[IO, SyncIO, Player] ): Button = { val fairySummonState = - fairyAPI.fairySummonCost(player.getUniqueId).unsafeRunSync().value + fairyAPI.fairySummonCost(player).unsafeRunSync().value Button( new IconItemStackBuilder(Material.GHAST_TEAR) .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}マナ妖精 召喚") diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index e68cce3358..2c63956a89 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -4,20 +4,15 @@ import cats.effect.ConcurrentEffect import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.vote.bukkit.command.VoteCommand -import com.github.unchama.seichiassist.subsystems.vote.domain.{ - ChainVoteDayNumber, - EffectPoint, - PlayerName, - VoteBenefit, - VoteCounter -} +import com.github.unchama.seichiassist.subsystems.vote.domain._ import com.github.unchama.seichiassist.subsystems.vote.infrastructure.JdbcVotePersistence import org.bukkit.command.TabExecutor +import org.bukkit.entity.Player import java.util.UUID trait System[F[_]] extends Subsystem[F] { - val api: VoteAPI[F] + val api: VoteAPI[F, Player] } object System { @@ -26,7 +21,7 @@ object System { val votePersistence = new JdbcVotePersistence[F] new System[F] { - override implicit val api: VoteAPI[F] = new VoteAPI[F] { + override implicit val api: VoteAPI[F, Player] = new VoteAPI[F, Player] { override def voteCounterIncrement(playerName: PlayerName): F[Unit] = votePersistence.voteCounterIncrement(playerName) @@ -45,8 +40,8 @@ object System { override def increaseEffectPointsByTen(uuid: UUID): F[Unit] = votePersistence.increaseEffectPointsByTen(uuid) - override def effectPoints(uuid: UUID): F[EffectPoint] = - votePersistence.effectPoints(uuid) + override def effectPoints(player: Player): F[EffectPoint] = + votePersistence.effectPoints(player.getUniqueId) override def increaseVoteBenefits(uuid: UUID, benefit: VoteBenefit): F[Unit] = votePersistence.increaseVoteBenefits(uuid, benefit) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index e2097bd70d..e0ec94e06d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -39,7 +39,7 @@ object VoteWriteAPI { } -trait VoteReadAPI[F[_]] { +trait VoteReadAPI[F[_], Player] { /** * 投票回数を返す作用 @@ -54,7 +54,7 @@ trait VoteReadAPI[F[_]] { /** * effectPointを返す作用 */ - def effectPoints(uuid: UUID): F[EffectPoint] + def effectPoints(player: Player): F[EffectPoint] /** * 投票特典を受け取った回数を返す作用 @@ -70,8 +70,10 @@ trait VoteReadAPI[F[_]] { object VoteReadAPI { - def apply[F[_]](implicit voteReadAPI: VoteReadAPI[F]): VoteReadAPI[F] = implicitly + def apply[F[_], Player]( + implicit voteReadAPI: VoteReadAPI[F, Player] + ): VoteReadAPI[F, Player] = implicitly } -trait VoteAPI[F[_]] extends VoteReadAPI[F] with VoteWriteAPI[F] +trait VoteAPI[F[_], Player] extends VoteReadAPI[F, Player] with VoteWriteAPI[F] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala index 88548743f6..d091a98192 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala @@ -11,8 +11,9 @@ import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} import com.github.unchama.targetedeffect.commandsender.MessageEffect import org.bukkit.ChatColor._ import org.bukkit.command.TabExecutor +import org.bukkit.entity.Player -class VoteCommand[F[_]: ConcurrentEffect](implicit voteAPI: VoteAPI[F]) { +class VoteCommand[F[_]: ConcurrentEffect](implicit voteAPI: VoteAPI[F, Player]) { private val usageEchoExecutor: EchoExecutor = EchoExecutor( MessageEffect(List(s"$RED/vote record <プレイヤー名>", "投票特典配布用コマンドです")) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 5af99a2398..6afe8bdef0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -2,16 +2,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.concurrent.Ref import com.github.unchama.datarepository.KeyedDataRepository -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - AppleOpenState, - FairyEndTime, - FairyLore, - FairyPlaySound, - FairyRecoveryMana, - FairySummonCost, - FairyUsingState -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import java.util.UUID @@ -36,7 +27,7 @@ trait FairyWriteAPI[F[_], Player] { /** * 妖精を使っているかどうかを切り替える */ - def updateFairyUsingState(uuid: UUID, fairyUsingState: FairyUsingState): F[Unit] + def updateFairyUsingState(player: Player, fairyUsingState: FairyUsingState): F[Unit] /** * 妖精が回復するマナの量を変更する @@ -66,7 +57,7 @@ trait FairyReadAPI[F[_], Player] { /** * 妖精を召喚するためのコストを取得する */ - def fairySummonCost(uuid: UUID): F[FairySummonCost] + def fairySummonCost(player: Player): F[FairySummonCost] /** * `FairyLoreTable`からLoreを取得する @@ -81,7 +72,7 @@ trait FairyReadAPI[F[_], Player] { /** * 妖精を使っているかを取得する */ - def fairyUsingState(uuid: UUID): F[FairyUsingState] + def fairyUsingState(player: Player): F[FairyUsingState] /** * 妖精が回復するマナの量を取得する diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index cd3f1d2aea..fdadb5838e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -2,6 +2,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.concurrent.Ref import cats.effect.{ConcurrentEffect, Sync, SyncEffect, SyncIO} +import cats.instances.uuid import com.github.unchama.datarepository.KeyedDataRepository import com.github.unchama.datarepository.bukkit.player.{ BukkitRepositoryControls, @@ -72,8 +73,8 @@ object System { ): F[Unit] = persistence.updateFairySummonCost(uuid, fairySummonCost) - override def fairySummonCost(uuid: UUID): F[FairySummonCost] = - persistence.fairySummonCost(uuid) + override def fairySummonCost(player: Player): F[FairySummonCost] = + persistence.fairySummonCost(player.getUniqueId) override protected val fairyPlaySoundRepository : KeyedDataRepository[UUID, Ref[F, FairyPlaySound]] = @@ -99,14 +100,14 @@ object System { override def updateFairyEndTime(player: Player, fairyEndTime: FairyEndTime): F[Unit] = persistence.updateFairyEndTime(player.getUniqueId, fairyEndTime) - override def fairyUsingState(uuid: UUID): F[FairyUsingState] = - persistence.fairyUsingState(uuid) + override def fairyUsingState(player: Player): F[FairyUsingState] = + persistence.fairyUsingState(player.getUniqueId) override def updateFairyUsingState( - uuid: UUID, + player: Player, fairyUsingState: FairyUsingState ): F[Unit] = - persistence.updateFairyUsingState(uuid, fairyUsingState) + persistence.updateFairyUsingState(player.getUniqueId, fairyUsingState) override def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] = persistence.fairyRecoveryMana(uuid) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpawnGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpawnGateway.scala index f7698c6b7f..6fe4a13720 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpawnGateway.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpawnGateway.scala @@ -25,19 +25,19 @@ import org.bukkit.entity.Player import scala.concurrent.ExecutionContext -class BukkitFairySpawnGateway extends FairySpawnGateway[SyncIO, Player] { +class BukkitFairySpawnGateway(player: Player)( + implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], + fairyAPI: FairyAPI[IO, Player], + voteAPI: VoteAPI[IO], + manaApi: ManaApi[IO, SyncIO, Player], + serviceRepository: PlayerDataRepository[FairySpeechService[SyncIO]], + concurrentEffect: ConcurrentEffect[IO] +) extends FairySpawnGateway[SyncIO] { /** * 妖精をスポーンさせる作用 */ - override def spawn(player: Player)( - implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], - fairyAPI: FairyAPI[IO, Player], - voteAPI: VoteAPI[IO], - manaApi: ManaApi[IO, SyncIO, Player], - serviceRepository: PlayerDataRepository[FairySpeechService[SyncIO]], - concurrentEffect: ConcurrentEffect[IO] - ): SyncIO[Unit] = { + override def spawn: SyncIO[Unit] = { val playerLevel = breakCountAPI .seichiAmountDataRepository(player) @@ -48,7 +48,7 @@ class BukkitFairySpawnGateway extends FairySpawnGateway[SyncIO, Player] { val uuid = player.getUniqueId - val fairySummonCost = fairyAPI.fairySummonCost(uuid).unsafeRunSync() + val fairySummonCost = fairyAPI.fairySummonCost(player).unsafeRunSync() val failedEffect = spawnFailedEffect(player, _) @@ -105,7 +105,7 @@ class BukkitFairySpawnGateway extends FairySpawnGateway[SyncIO, Player] { .runAsync(_ => IO.unit) } - private def spawnFailedEffect(player: Player, message: String): SyncIO[Unit] = { + private def spawnFailedEffect(message: String): SyncIO[Unit] = { SequentialEffect( MessageEffect(message), FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnGateway.scala index 959ac770db..d954dd029f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnGateway.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnGateway.scala @@ -1,26 +1,11 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain -import cats.effect.{ConcurrentEffect, IO, SyncIO} -import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository -import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI -import com.github.unchama.seichiassist.subsystems.mana.ManaApi -import com.github.unchama.seichiassist.subsystems.vote.VoteAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService - -trait FairySpawnGateway[F[_], Player] { +trait FairySpawnGateway[F[_]] { /** * 妖精をスポーンさせる作用 */ - def spawn(player: Player)( - implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], - fairyAPI: FairyAPI[IO, Player], - voteAPI: VoteAPI[IO], - manaApi: ManaApi[IO, SyncIO, Player], - serviceRepository: PlayerDataRepository[FairySpeechService[SyncIO]], - concurrentEffect: ConcurrentEffect[IO] - ): F[Unit] + def spawn(): F[Unit] /** * 妖精をデスポーンさせる作用 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala new file mode 100644 index 0000000000..b14b6e79e1 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala @@ -0,0 +1,34 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +import cats.effect.ConcurrentEffect +import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + FairySpawnRequestResult, + FairyUsingState +} + +class FairySpawnRequest[F[_]: ConcurrentEffect, G[_], Player] { + + import cats.implicits._ + + def spawnRequest(player: Player)( + implicit breakCountAPI: BreakCountAPI[G, F, Player], + fairyAPI: FairyAPI[F, Player], + voteAPI: VoteAPI[F, Player] + ): F[FairySpawnRequestResult] = for { + seichiAmountDataRepository <- breakCountAPI.seichiAmountDataRepository(player).read + usingState <- fairyAPI.fairyUsingState(player) + effectPoints <- voteAPI.effectPoints(player) + fairySummonCost <- fairyAPI.fairySummonCost(player) + } yield { + if (seichiAmountDataRepository.levelCorrespondingToExp.level < 10) + FairySpawnRequestResult.NotEnoughSeichiLevel + else if (usingState == FairyUsingState.Using) FairySpawnRequestResult.AlreadyFairySpawned + else if (effectPoints.value < fairySummonCost.value * 2) + FairySpawnRequestResult.NotEnoughEffectPoint + else FairySpawnRequestResult.Success + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestResult.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestResult.scala new file mode 100644 index 0000000000..1660fe7395 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestResult.scala @@ -0,0 +1,15 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property + +sealed trait FairySpawnRequestResult + +object FairySpawnRequestResult { + + case object Success extends FairySpawnRequestResult + + case object NotEnoughSeichiLevel extends FairySpawnRequestResult + + case object AlreadyFairySpawned extends FairySpawnRequestResult + + case object NotEnoughEffectPoint extends FairySpawnRequestResult + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpawnService.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpawnService.scala new file mode 100644 index 0000000000..521689d3f6 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpawnService.scala @@ -0,0 +1,45 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service + +import cats.data +import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps +import cats.effect.{ConcurrentEffect, IO, LiftIO, Sync} +import com.github.unchama.generic.syntax.KleisliCombine +import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestResult +import com.github.unchama.targetedeffect.SequentialEffect +import com.github.unchama.targetedeffect.commandsender.MessageEffect +import com.github.unchama.targetedeffect.player.FocusedSoundEffect +import org.bukkit.Sound + +class FairySpawnService[F[_]: ConcurrentEffect, G[_], Player]( + player: Player, + gateway: FairySpawnGateway[F] +) { + + def spawn(implicit breakCountAPI: BreakCountAPI[G, F, Player]): F[FairySpawnRequestResult] = + Sync[F].delay { + val playerLevel = breakCountAPI + .seichiAmountDataRepository(player) + .read + .toIO + .unsafeRunSync() + .levelCorrespondingToExp + .level + + if (playerLevel < 10) + return Sync[F].pure(FairySpawnRequestResult.NotEnoughSeichiLevel) + + + } + + private def spawnFailedEffect(message: String): F[Unit] = { + LiftIO[IO].liftIO { + SequentialEffect( + MessageEffect(message), + FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) + ).followedBy(data.Kleisli {player => }) + }. + } + +} From 714f4ddba4c9ce366349360c8004a02e09568383 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 27 Jul 2022 21:18:32 +0900 Subject: [PATCH 068/482] =?UTF-8?q?[Refactor]=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E6=B6=88=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=82=8A=E5=87=A6=E7=90=86=E3=82=92=E3=81=BE=E3=81=A8?= =?UTF-8?q?=E3=82=81=E3=81=9F=E3=82=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/SeichiAssist.scala | 6 +- .../seichiassist/menus/TopLevelRouter.scala | 2 +- .../unchama/seichiassist/menus/VoteMenu.scala | 8 +- .../seichiassist/subsystems/vote/System.scala | 6 +- .../actions/ReceiveVoteBenefits.scala | 2 +- .../actions/BukkitReceiveVoteBenefits.scala | 7 +- .../vote/bukkit/command/VoteCommand.scala | 2 +- .../vote/subsystems/fairy/FairyAPI.scala | 5 + .../vote/subsystems/fairy/System.scala | 18 +-- .../application/actions/FairySpeak.scala | 32 ---- .../subsystems/fairy/bukkit/FairySpeech.scala | 10 +- .../bukkit/actions/BukkitFairySpeak.scala | 77 ---------- .../bukkit/actions/BukkitSummonFairy.scala | 141 ++++++++---------- .../gateway/BukkitFairySpawnGateway.scala | 119 --------------- .../bukkit/routines/FairySpeechRoutine.scala | 1 - .../fairy/domain/FairySpawnGateway.scala | 15 -- .../fairy/domain/FairySpawnRequest.scala | 35 +++-- .../fairy/service/FairySpawnService.scala | 45 ------ 18 files changed, 115 insertions(+), 416 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpawnGateway.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnGateway.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpawnService.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 5f512f6de2..c781a833fa 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -388,11 +388,11 @@ class SeichiAssist extends JavaPlugin() { private lazy val sharedInventorySystem: subsystems.sharedinventory.System[IO] = subsystems.sharedinventory.System.wired[IO] - private lazy val voteSystem: subsystems.vote.System[IO] = + private lazy val voteSystem: subsystems.vote.System[IO, Player] = subsystems.vote.System.wired[IO] private lazy val fairySystem: subsystems.vote.subsystems.fairy.System[IO, Player] = - subsystems.vote.subsystems.fairy.System.wired[IO, SyncIO].unsafeRunSync() + subsystems.vote.subsystems.fairy.System.wired[IO].unsafeRunSync() private lazy val wiredSubsystems: List[Subsystem[IO]] = List( mebiusSystem, @@ -572,7 +572,7 @@ class SeichiAssist extends JavaPlugin() { anywhereEnderSystem.accessApi implicit val sharedInventoryAPI: SharedInventoryAPI[IO, Player] = sharedInventorySystem.api - implicit val voteAPI: VoteAPI[IO] = voteSystem.api + implicit val voteAPI: VoteAPI[IO, Player] = voteSystem.api implicit val fairyAPI: FairyAPI[IO, Player] = fairySystem.api val menuRouter = TopLevelRouter.apply diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala index cf36ecaef5..7af6db3d7b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala @@ -73,7 +73,7 @@ object TopLevelRouter { subHomeReadApi: SubHomeReadAPI[IO], enderChestAccessApi: AnywhereEnderChestAPI[IO], sharedInventoryAPI: SharedInventoryAPI[IO, Player], - voteAPI: VoteAPI[IO], + voteAPI: VoteAPI[IO, Player], fairyAPI: FairyAPI[IO, Player] ): TopLevelRouter[IO] = new TopLevelRouter[IO] { import assortedRankingApi._ diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 1c8a886ac0..7cc9b12090 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -1,7 +1,7 @@ package com.github.unchama.seichiassist.menus import cats.effect.{ConcurrentEffect, IO, SyncIO} -import cats.instances.uuid +import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository import com.github.unchama.itemstackbuilder.IconItemStackBuilder import com.github.unchama.menuinventory.router.CanOpen import com.github.unchama.menuinventory.slot.button.Button @@ -16,16 +16,14 @@ import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.{ - BukkitFairySpeak, - BukkitSummonFairy -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleOpenState, FairyMessage, FairyPlaySound, FairySummonCost } +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import com.github.unchama.seichiassist.task.VotingFairyTask import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index 2c63956a89..4a7ff6fae3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -11,16 +11,16 @@ import org.bukkit.entity.Player import java.util.UUID -trait System[F[_]] extends Subsystem[F] { +trait System[F[_], Player] extends Subsystem[F] { val api: VoteAPI[F, Player] } object System { - def wired[F[_]: ConcurrentEffect: OnMinecraftServerThread]: System[F] = { + def wired[F[_]: ConcurrentEffect: OnMinecraftServerThread]: System[F, Player] = { val votePersistence = new JdbcVotePersistence[F] - new System[F] { + new System[F, Player] { override implicit val api: VoteAPI[F, Player] = new VoteAPI[F, Player] { override def voteCounterIncrement(playerName: PlayerName): F[Unit] = votePersistence.voteCounterIncrement(playerName) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala index daeadd24fb..fba8d39447 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala @@ -7,7 +7,7 @@ trait ReceiveVoteBenefits[F[_], G[_], Player] { def receive( player: Player - )(implicit voteAPI: VoteAPI[F], breakCountAPI: BreakCountAPI[F, G, Player]): F[Unit] + )(implicit voteAPI: VoteAPI[F, Player], breakCountAPI: BreakCountAPI[F, G, Player]): F[Unit] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 91759864f3..9c035a40da 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -23,9 +23,10 @@ object BukkitReceiveVoteBenefits { F ]]: ReceiveVoteBenefits[F, G, Player] = new ReceiveVoteBenefits[F, G, Player] { - override def receive( - player: Player - )(implicit voteAPI: VoteAPI[F], breakCountAPI: BreakCountAPI[F, G, Player]): F[Unit] = { + override def receive(player: Player)( + implicit voteAPI: VoteAPI[F, Player], + breakCountAPI: BreakCountAPI[F, G, Player] + ): F[Unit] = { val uuid = player.getUniqueId for { notReceivedBenefits <- voteAPI.notReceivedVoteBenefits(uuid) // 受け取っていない投票特典数 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala index d091a98192..cb019ee07a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala @@ -7,8 +7,8 @@ import com.github.unchama.contextualexecutor.builder.ContextualExecutorBuilder import com.github.unchama.contextualexecutor.executors.{BranchedExecutor, EchoExecutor} import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.domain.PlayerName -import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} import com.github.unchama.targetedeffect.commandsender.MessageEffect +import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} import org.bukkit.ChatColor._ import org.bukkit.command.TabExecutor import org.bukkit.entity.Player diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 6afe8bdef0..4d2ab6369e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -1,8 +1,11 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy +import cats.effect.SyncIO import cats.effect.concurrent.Ref import com.github.unchama.datarepository.KeyedDataRepository +import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import java.util.UUID @@ -88,6 +91,8 @@ trait FairyReadAPI[F[_], Player] { Ref[F, FairyPlaySound] ] + val fairySpeechServiceRepository: PlayerDataRepository[FairySpeechService[SyncIO]] + /** * 妖精が有効な時間を返す */ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index fdadb5838e..3693c563a2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -1,15 +1,13 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.concurrent.Ref -import cats.effect.{ConcurrentEffect, Sync, SyncEffect, SyncIO} -import cats.instances.uuid +import cats.effect.{ConcurrentEffect, Sync, SyncIO} import com.github.unchama.datarepository.KeyedDataRepository import com.github.unchama.datarepository.bukkit.player.{ BukkitRepositoryControls, PlayerDataRepository } import com.github.unchama.datarepository.template.RepositoryDefinition -import com.github.unchama.generic.ContextCoercion import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.SpeechServiceRepositoryDefinitions @@ -29,12 +27,9 @@ trait System[F[_], Player] extends Subsystem[F] { object System { - def wired[F[_]: ConcurrentEffect: OnMinecraftServerThread, G[_]: SyncEffect: ContextCoercion[ - *[_], - F - ]]: SyncIO[System[F, Player]] = { + def wired[F[_]: ConcurrentEffect: OnMinecraftServerThread]: SyncIO[System[F, Player]] = { val persistence = new JdbcFairyPersistence[F] - implicit val gatewayProvider: Player => FairySpeechGateway[SyncIO] = + implicit val fairySpeechGatewayProvider: Player => FairySpeechGateway[SyncIO] = new BukkitFairySpeechGateway(_) for { @@ -49,9 +44,6 @@ object System { } yield { new System[F, Player] { override val api: FairyAPI[F, Player] = new FairyAPI[F, Player] { - val repository: PlayerDataRepository[FairySpeechService[SyncIO]] = - speechServiceRepositoryControls.repository - override def appleOpenState(uuid: UUID): F[AppleOpenState] = persistence.appleOpenState(uuid) @@ -116,6 +108,10 @@ object System { uuid: UUID, fairyRecoveryMana: FairyRecoveryMana ): F[Unit] = persistence.updateFairyRecoveryMana(uuid, fairyRecoveryMana) + + override val fairySpeechServiceRepository + : PlayerDataRepository[FairySpeechService[SyncIO]] = + speechServiceRepositoryControls.repository } override val managedRepositoryControls: Seq[BukkitRepositoryControls[F, _]] = diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala deleted file mode 100644 index 54313a4c45..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairySpeak.scala +++ /dev/null @@ -1,32 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions - -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage - -trait FairySpeak[F[_], Player] { - - /** - * 単に妖精からのメッセージを発言する作用 - */ - def speak(player: Player, fairyMessage: FairyMessage)( - implicit fairyAPI: FairyAPI[F, Player] - ): F[Unit] - - /** - * 妖精からのランダムなメッセージを発言する作用 - */ - def speakRandomly(player: Player)(implicit fairyAPI: FairyAPI[F, Player]): F[Unit] - - /** - * 妖精からの召喚時メッセージを発言する作用 - */ - def speakStartMessage(player: Player)(implicit fairyAPI: FairyAPI[F, Player]): F[Unit] - -} - -object FairySpeak { - - def apply[F[_], Player](implicit ev: FairySpeak[F, Player]): FairySpeak[F, Player] = - ev - -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index 38d31e258b..81ffdb0397 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -1,8 +1,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps -import cats.effect.{ConcurrentEffect, Sync, SyncIO} -import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository +import cats.effect.{ConcurrentEffect, Sync} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ FairyMessage, @@ -10,16 +9,12 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p NameCalledByFairy } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.FairyMessageTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player import java.time.LocalTime import scala.util.Random -class FairySpeech[F[_]: ConcurrentEffect]( - implicit serviceRepository: PlayerDataRepository[FairySpeechService[SyncIO]], - fairyAPI: FairyAPI[F, Player] -) { +class FairySpeech[F[_]: ConcurrentEffect](implicit fairyAPI: FairyAPI[F, Player]) { import cats.implicits._ @@ -36,6 +31,7 @@ class FairySpeech[F[_]: ConcurrentEffect]( FairyMessageTable.nightMessages(nameCalledByFairy) message <- randomMessage(fairyMessages) } yield { + val serviceRepository = fairyAPI.fairySpeechServiceRepository serviceRepository(player) .makeSpeech(message, fairyAPI.fairyPlaySound(player.getUniqueId).toIO.unsafeRunSync()) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala deleted file mode 100644 index 6a2c139682..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitFairySpeak.scala +++ /dev/null @@ -1,77 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions - -import cats.Monad -import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps -import cats.effect.{ConcurrentEffect, Sync} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairySpeak -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.FairyMessageTable -import com.github.unchama.targetedeffect.SequentialEffect -import com.github.unchama.targetedeffect.commandsender.MessageEffect -import com.github.unchama.targetedeffect.player.FocusedSoundEffect -import org.bukkit.ChatColor._ -import org.bukkit.Sound -import org.bukkit.entity.Player - -import java.time.LocalTime -import scala.util.Random - -object BukkitFairySpeak { - - import cats.implicits._ - - def apply[F[_]: ConcurrentEffect]: FairySpeak[F, Player] = new FairySpeak[F, Player] { - override def speak(player: Player, fairyMessage: FairyMessage)( - implicit fairyAPI: FairyAPI[F, Player] - ): F[Unit] = for { - playSound <- fairyAPI.fairyPlaySound(player.getUniqueId) - } yield { - val message = s"$AQUA$BOLD<マナ妖精>$RESET${fairyMessage.message}" - if (playSound == FairyPlaySound.on) - SequentialEffect( - FocusedSoundEffect(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f), - MessageEffect(message) - ).run(player).unsafeRunSync() - else MessageEffect(message).run(player).unsafeRunSync() - } - - override def speakRandomly( - player: Player - )(implicit fairyAPI: FairyAPI[F, Player]): F[Unit] = { - Sync[F].unit - } - - override def speakStartMessage( - player: Player - )(implicit fairyAPI: FairyAPI[F, Player]): F[Unit] = { - val nameCalledByFairy = NameCalledByFairy(player.getName) - val uuid = player.getUniqueId - - implicit val F: Monad[F] = implicitly - - F.ifM(fairyAPI.fairyUsingState(uuid).map(_ == FairyUsingState.NotUsing))( - return Sync[F].unit, - Sync[F].unit - ) - val startHour = LocalTime.now().getHour - - val fairyMessages = - if (4 <= startHour && startHour < 10) - FairyMessageTable.morningMessages(nameCalledByFairy) - else if (10 <= startHour && startHour < 18) - FairyMessageTable.dayMessages(nameCalledByFairy) - else - FairyMessageTable.nightMessages(nameCalledByFairy) - - getMessageRandomly(fairyMessages).map(speak(player, _).toIO.unsafeRunAsyncAndForget()) - } - } - - private def getMessageRandomly[F[_]: Sync](fairyMessages: FairyMessages): F[FairyMessage] = - Sync[F].delay { - val messages = fairyMessages.messages - messages(Random.nextInt(messages.size)) - } - -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index bd529a1aff..641bc4ccbb 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -1,6 +1,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions import cats.effect.{ConcurrentEffect, ContextShift, IO, LiftIO, SyncIO} +import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI @@ -9,10 +10,13 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.FairySpeechRoutine +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequest +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestResult._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ FairyRecoveryManaAmount, FairyUsingState } +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} @@ -27,90 +31,71 @@ object BukkitSummonFairy { def apply(player: Player)( implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], fairyAPI: FairyAPI[IO, Player], - voteAPI: VoteAPI[IO], + voteAPI: VoteAPI[IO, Player], manaApi: ManaApi[IO, SyncIO, Player], concurrentEffect: ConcurrentEffect[IO] ): SummonFairy[IO] = new SummonFairy[IO] { override def summon: IO[Unit] = { - val playerLevel = - breakCountAPI - .seichiAmountDataRepository(player) - .read - .unsafeRunSync() - .levelCorrespondingToExp - .level - - val notEnoughLevelEffect = - SequentialEffect( - MessageEffect(s"${GOLD}プレイヤーレベルが足りません"), - FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) - ) - val alreadySummoned = - SequentialEffect( - MessageEffect(s"${GOLD}既に妖精を召喚しています"), - FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) - ) - val notEnoughEffectPoint = - SequentialEffect( - MessageEffect(s"${GOLD}投票ptが足りません"), - FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) - ) - - val uuid = player.getUniqueId - - val fairySummonCost = fairyAPI.fairySummonCost(uuid).unsafeRunSync() - - if (playerLevel < 10) return notEnoughLevelEffect(player) // レベル不足 - - if (fairyAPI.fairyUsingState(uuid).unsafeRunSync() == Using) - return alreadySummoned(player) // 既に召喚している - - if (voteAPI.effectPoints(uuid).unsafeRunSync().value < fairySummonCost.value * 2) - return notEnoughEffectPoint(player) // 投票ptがたりなかった - - val levelCappedManaAmount = - manaApi.readManaAmount(player).unsafeRunSync().cap.value - - // 回復するマナの量 - val recoveryMana = FairyRecoveryManaAmount.manaAmountAt(levelCappedManaAmount) - - val eff = for { - _ <- fairyAPI.updateFairyUsingState(uuid, FairyUsingState.Using) - _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(fairySummonCost.value * 2)) - _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) - isFairyEndTimeDefined <- fairyAPI.fairyEndTime(player) - _ <- fairyAPI.updateFairyEndTime(player, fairySummonCost.validTime) - } yield { - /* - FairySpeechRoutineが一度も起動されていなければ起動する - */ - if (isFairyEndTimeDefined.isEmpty) { - import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.sleepAndRoutineContext - implicit val contextShift: ContextShift[IO] = - IO.contextShift(ExecutionContext.global) - FairySpeechRoutine.start(player).start.unsafeRunSync() - } - () - } - - LiftIO[IO].liftIO { - SequentialEffect( - UnfocusedEffect { - eff.unsafeRunSync() - new FairySpeech().summonSpeech(player) - BukkitFairySpeak[IO].speakStartMessage(player).unsafeRunSync() - }, - MessageEffect( - List( - s"$RESET$YELLOW${BOLD}妖精を呼び出しました!", - s"$RESET$YELLOW${BOLD}この子は1分間に約${recoveryMana.recoveryMana}マナ", - s"$RESET$YELLOW${BOLD}回復させる力を持っているようです。" - ) - ) - ).apply(player) + val failedEffect = spawnFailedEffect(player, _) + + new FairySpawnRequest[IO, SyncIO, Player].spawnRequest(player).unsafeRunSync() match { + case NotEnoughSeichiLevel => + failedEffect(s"${GOLD}プレイヤーレベルが足りません") + case AlreadyFairySpawned => + failedEffect(s"${GOLD}既に妖精を召喚しています") + case NotEnoughEffectPoint => + failedEffect(s"${GOLD}投票ptが足りません") + case Success => + val levelCappedManaAmount = + manaApi.readManaAmount(player).unsafeRunSync().cap.value + + // 回復するマナの量 + val recoveryMana = FairyRecoveryManaAmount.manaAmountAt(levelCappedManaAmount) + + val eff = for { + fairySummonCost <- fairyAPI.fairySummonCost(player) + _ <- fairyAPI.updateFairyUsingState(player, FairyUsingState.Using) + uuid = player.getUniqueId + _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(fairySummonCost.value * 2)) + _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) + isFairyEndTimeDefined <- fairyAPI.fairyEndTime(player) + _ <- fairyAPI.updateFairyEndTime(player, fairySummonCost.validTime) + } yield { + /* + FairySpeechRoutineが一度も起動されていなければ起動する + */ + if (isFairyEndTimeDefined.isEmpty) { + import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.sleepAndRoutineContext + implicit val contextShift: ContextShift[IO] = + IO.contextShift(ExecutionContext.global) + FairySpeechRoutine.start(player).start.unsafeRunSync() + } + } + + LiftIO[IO].liftIO { + SequentialEffect( + UnfocusedEffect { + eff.unsafeRunSync() + new FairySpeech().summonSpeech(player) + }, + MessageEffect( + List( + s"$RESET$YELLOW${BOLD}妖精を呼び出しました!", + s"$RESET$YELLOW${BOLD}この子は1分間に約${recoveryMana.recoveryMana}マナ", + s"$RESET$YELLOW${BOLD}回復させる力を持っているようです。" + ) + ) + ).apply(player) + } } - } } + private def spawnFailedEffect(player: Player, message: String): IO[Unit] = { + SequentialEffect( + MessageEffect(message), + FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) + ).run(player) + } + } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpawnGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpawnGateway.scala deleted file mode 100644 index 6fe4a13720..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpawnGateway.scala +++ /dev/null @@ -1,119 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway - -import cats.effect.{ConcurrentEffect, ContextShift, IO, LiftIO, SyncIO} -import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository -import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI -import com.github.unchama.seichiassist.subsystems.mana.ManaApi -import com.github.unchama.seichiassist.subsystems.vote.VoteAPI -import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitFairySpeak -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.FairySpeechRoutine -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnGateway -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - FairyRecoveryManaAmount, - FairyUsingState -} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService -import com.github.unchama.targetedeffect.commandsender.MessageEffect -import com.github.unchama.targetedeffect.player.FocusedSoundEffect -import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} -import org.bukkit.ChatColor.{BOLD, GOLD, RESET, YELLOW} -import org.bukkit.Sound -import org.bukkit.entity.Player - -import scala.concurrent.ExecutionContext - -class BukkitFairySpawnGateway(player: Player)( - implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], - fairyAPI: FairyAPI[IO, Player], - voteAPI: VoteAPI[IO], - manaApi: ManaApi[IO, SyncIO, Player], - serviceRepository: PlayerDataRepository[FairySpeechService[SyncIO]], - concurrentEffect: ConcurrentEffect[IO] -) extends FairySpawnGateway[SyncIO] { - - /** - * 妖精をスポーンさせる作用 - */ - override def spawn: SyncIO[Unit] = { - val playerLevel = - breakCountAPI - .seichiAmountDataRepository(player) - .read - .unsafeRunSync() - .levelCorrespondingToExp - .level - - val uuid = player.getUniqueId - - val fairySummonCost = fairyAPI.fairySummonCost(player).unsafeRunSync() - - val failedEffect = spawnFailedEffect(player, _) - - if (playerLevel < 10) - return failedEffect(s"${GOLD}プレイヤーレベルが足りません") - - if (fairyAPI.fairyUsingState(uuid).unsafeRunSync() == FairyUsingState.Using) - return failedEffect(s"${GOLD}既に妖精を召喚しています") - - if (voteAPI.effectPoints(uuid).unsafeRunSync().value < fairySummonCost.value * 2) - return failedEffect(s"${GOLD}投票ptが足りません") - - val levelCappedManaAmount = - manaApi.readManaAmount(player).unsafeRunSync().cap.value - - // 回復するマナの量 - val recoveryMana = FairyRecoveryManaAmount.manaAmountAt(levelCappedManaAmount) - - val eff = for { - _ <- fairyAPI.updateFairyUsingState(uuid, FairyUsingState.Using) - _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(fairySummonCost.value * 2)) - _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) - isFairyEndTimeDefined <- fairyAPI.fairyEndTime(player) - _ <- fairyAPI.updateFairyEndTime(player, fairySummonCost.validTime) - } yield { - /* - FairySpeechRoutineが一度も起動されていなければ起動する - */ - if (isFairyEndTimeDefined.isEmpty) { - import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.sleepAndRoutineContext - implicit val contextShift: ContextShift[IO] = - IO.contextShift(ExecutionContext.global) - FairySpeechRoutine.start(player).start.unsafeRunSync() - } - } - - LiftIO[IO] - .liftIO { - SequentialEffect( - UnfocusedEffect { - eff.unsafeRunSync() - new FairySpeech().summonSpeech(player) - BukkitFairySpeak[IO].speakStartMessage(player).unsafeRunSync() - }, - MessageEffect( - List( - s"$RESET$YELLOW${BOLD}妖精を呼び出しました!", - s"$RESET$YELLOW${BOLD}この子は1分間に約${recoveryMana.recoveryMana}マナ", - s"$RESET$YELLOW${BOLD}回復させる力を持っているようです。" - ) - ) - ).apply(player) - } - .runAsync(_ => IO.unit) - } - - private def spawnFailedEffect(message: String): SyncIO[Unit] = { - SequentialEffect( - MessageEffect(message), - FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) - ).run(player).runAsync(_ => IO.unit) - } - - /** - * 妖精をデスポーンさせる作用 - */ - override def despawn(): SyncIO[Unit] = ??? -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala index 8b8c554f35..36de63f2e7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala @@ -5,7 +5,6 @@ import com.github.unchama.concurrent.{RepeatingRoutine, RepeatingTaskContext} import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitFairySpeak import org.bukkit.entity.Player import scala.concurrent.duration.FiniteDuration diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnGateway.scala deleted file mode 100644 index d954dd029f..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnGateway.scala +++ /dev/null @@ -1,15 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain - -trait FairySpawnGateway[F[_]] { - - /** - * 妖精をスポーンさせる作用 - */ - def spawn(): F[Unit] - - /** - * 妖精をデスポーンさせる作用 - */ - def despawn(): F[Unit] - -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala index b14b6e79e1..a74eafea19 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala @@ -1,6 +1,8 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain import cats.effect.ConcurrentEffect +import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps +import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI @@ -9,26 +11,31 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p FairyUsingState } -class FairySpawnRequest[F[_]: ConcurrentEffect, G[_], Player] { +class FairySpawnRequest[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F], Player] { import cats.implicits._ def spawnRequest(player: Player)( - implicit breakCountAPI: BreakCountAPI[G, F, Player], + implicit breakCountAPI: BreakCountAPI[F, G, Player], fairyAPI: FairyAPI[F, Player], voteAPI: VoteAPI[F, Player] - ): F[FairySpawnRequestResult] = for { - seichiAmountDataRepository <- breakCountAPI.seichiAmountDataRepository(player).read - usingState <- fairyAPI.fairyUsingState(player) - effectPoints <- voteAPI.effectPoints(player) - fairySummonCost <- fairyAPI.fairySummonCost(player) - } yield { - if (seichiAmountDataRepository.levelCorrespondingToExp.level < 10) - FairySpawnRequestResult.NotEnoughSeichiLevel - else if (usingState == FairyUsingState.Using) FairySpawnRequestResult.AlreadyFairySpawned - else if (effectPoints.value < fairySummonCost.value * 2) - FairySpawnRequestResult.NotEnoughEffectPoint - else FairySpawnRequestResult.Success + ): F[FairySpawnRequestResult] = { + val seichiAmountRepository = ContextCoercion( + breakCountAPI.seichiAmountDataRepository(player).read + ).toIO.unsafeRunSync().levelCorrespondingToExp.level + + for { + usingState <- fairyAPI.fairyUsingState(player) + effectPoints <- voteAPI.effectPoints(player) + fairySummonCost <- fairyAPI.fairySummonCost(player) + } yield { + if (seichiAmountRepository < 10) + FairySpawnRequestResult.NotEnoughSeichiLevel + else if (usingState == FairyUsingState.Using) FairySpawnRequestResult.AlreadyFairySpawned + else if (effectPoints.value < fairySummonCost.value * 2) + FairySpawnRequestResult.NotEnoughEffectPoint + else FairySpawnRequestResult.Success + } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpawnService.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpawnService.scala deleted file mode 100644 index 521689d3f6..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpawnService.scala +++ /dev/null @@ -1,45 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service - -import cats.data -import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps -import cats.effect.{ConcurrentEffect, IO, LiftIO, Sync} -import com.github.unchama.generic.syntax.KleisliCombine -import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnGateway -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestResult -import com.github.unchama.targetedeffect.SequentialEffect -import com.github.unchama.targetedeffect.commandsender.MessageEffect -import com.github.unchama.targetedeffect.player.FocusedSoundEffect -import org.bukkit.Sound - -class FairySpawnService[F[_]: ConcurrentEffect, G[_], Player]( - player: Player, - gateway: FairySpawnGateway[F] -) { - - def spawn(implicit breakCountAPI: BreakCountAPI[G, F, Player]): F[FairySpawnRequestResult] = - Sync[F].delay { - val playerLevel = breakCountAPI - .seichiAmountDataRepository(player) - .read - .toIO - .unsafeRunSync() - .levelCorrespondingToExp - .level - - if (playerLevel < 10) - return Sync[F].pure(FairySpawnRequestResult.NotEnoughSeichiLevel) - - - } - - private def spawnFailedEffect(message: String): F[Unit] = { - LiftIO[IO].liftIO { - SequentialEffect( - MessageEffect(message), - FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) - ).followedBy(data.Kleisli {player => }) - }. - } - -} From 6a604dd43188f0e368fbaadc24a6ce0162751fa5 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 28 Jul 2022 10:40:25 +0900 Subject: [PATCH 069/482] =?UTF-8?q?[Add]RecoveryMana=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 15 +- .../application/actions/RecoveryMana.scala | 16 ++ .../subsystems/fairy/bukkit/FairySpeech.scala | 26 ++- .../bukkit/actions/BukkitRecoveryMana.scala | 170 ++++++++++++++++++ .../bukkit/actions/BukkitSummonFairy.scala | 8 +- ...SpeechRoutine.scala => FairyRoutine.scala} | 18 +- .../domain/property/AppleOpenState.scala | 8 +- .../property/FairyManaRecoveryState.scala | 13 ++ 8 files changed, 246 insertions(+), 28 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/RecoveryMana.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/{FairySpeechRoutine.scala => FairyRoutine.scala} (61%) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyManaRecoveryState.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 7cc9b12090..fd77b44518 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -1,7 +1,6 @@ package com.github.unchama.seichiassist.menus import cats.effect.{ConcurrentEffect, IO, SyncIO} -import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository import com.github.unchama.itemstackbuilder.IconItemStackBuilder import com.github.unchama.menuinventory.router.CanOpen import com.github.unchama.menuinventory.slot.button.Button @@ -19,11 +18,9 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleOpenState, - FairyMessage, FairyPlaySound, FairySummonCost } -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import com.github.unchama.seichiassist.task.VotingFairyTask import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect @@ -279,12 +276,12 @@ object VoteMenu extends Menu { val endTime = fairyAPI.fairyEndTime(player).unsafeRunSync().get.endTimeOpt.get - BukkitFairySpeak[IO] - .speak( - player, - FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。") - ) - .unsafeRunAsyncAndForget() +// BukkitFairySpeak[IO] +// .speak( +// player, +// FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。") +// ) +// .unsafeRunAsyncAndForget() }, closeInventoryEffect ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/RecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/RecoveryMana.scala new file mode 100644 index 0000000000..3596325e57 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/RecoveryMana.scala @@ -0,0 +1,16 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions + +trait RecoveryMana[F[_]] { + + /** + * 妖精がマナを回復する作用 + */ + def recovery: F[Unit] + +} + +object RecoveryMana { + + def apply[F[_]](implicit ev: RecoveryMana[F]): RecoveryMana[F] = ev + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index 81ffdb0397..ec9e1b64d1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -4,6 +4,7 @@ import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import cats.effect.{ConcurrentEffect, Sync} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + FairyManaRecoveryState, FairyMessage, FairyMessages, NameCalledByFairy @@ -36,11 +37,26 @@ class FairySpeech[F[_]: ConcurrentEffect](implicit fairyAPI: FairyAPI[F, Player] .makeSpeech(message, fairyAPI.fairyPlaySound(player.getUniqueId).toIO.unsafeRunSync()) } - // TODO: 妖精によるマナ回復関連が定義されたこれを定義する -// def speechRandomly(player: Player): F[Unit] = { -// val nameCalledByFairy = NameCalledByFairy(player.getName) -// -// } + def speechRandomly( + player: Player, + fairyManaRecoveryState: FairyManaRecoveryState + ): F[Unit] = { + val nameCalledByFairy = NameCalledByFairy(player.getName) + val messages = fairyManaRecoveryState match { + case FairyManaRecoveryState.full => + FairyMessageTable.manaFullMessages + case FairyManaRecoveryState.consumptionApple => + FairyMessageTable.consumed + case FairyMessageTable.notConsumed => + FairyMessageTable.notConsumed + } + randomMessage(messages(nameCalledByFairy)).map { message => + fairyAPI + .fairySpeechServiceRepository(player) + .makeSpeech(message, fairyAPI.fairyPlaySound(player.getUniqueId).toIO.unsafeRunSync()) + .unsafeRunSync() + } + } private def randomMessage(fairyMessages: FairyMessages): F[FairyMessage] = Sync[F].delay { val messages = fairyMessages.messages diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala new file mode 100644 index 0000000000..c97f1e7f9d --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -0,0 +1,170 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions + +import cats.effect.{ConcurrentEffect, IO, SyncIO} +import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI +import com.github.unchama.seichiassist.subsystems.mana.ManaApi +import com.github.unchama.seichiassist.subsystems.mana.domain.ManaAmount +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.RecoveryMana +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + AppleOpenState, + FairyManaRecoveryState +} +import com.github.unchama.seichiassist.{MineStackObjectList, SeichiAssist} +import com.github.unchama.targetedeffect.commandsender.MessageEffect +import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} +import org.bukkit.ChatColor._ +import org.bukkit.entity.Player + +import scala.util.Random + +object BukkitRecoveryMana { + + def apply(player: Player)( + implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], + fairyAPI: FairyAPI[IO, Player], + voteAPI: VoteAPI[IO, Player], + manaApi: ManaApi[IO, SyncIO, Player], + concurrentEffect: ConcurrentEffect[IO] + ): RecoveryMana[IO] = new RecoveryMana[IO] { + override def recovery: IO[Unit] = + manaApi + .readManaAmount(player) + .map { oldManaAmount => + if (oldManaAmount.isFull) + return new FairySpeech[IO].speechRandomly(player, FairyManaRecoveryState.full) + val uuid = player.getUniqueId + + for { + seichiAmountData <- breakCountAPI.seichiAmountDataRepository(player).read.toIO + defaultRecoveryManaAmount <- fairyAPI.fairyRecoveryMana(uuid) + chainVoteNumber <- voteAPI.chainVoteDayNumber(uuid) + appleOpenState <- fairyAPI.appleOpenState(uuid) + gachaimoObjectOpt <- MineStackObjectList.findByName("gachaimo") + } yield { + val playerLevel = seichiAmountData.levelCorrespondingToExp + + val playerdata = SeichiAssist.playermap(player.getUniqueId) + val gachaRingoObject = gachaimoObjectOpt.get + val mineStackedGachaRingoAmount = + playerdata.minestack.getStackedAmountOf(gachaRingoObject) + + val isAppleOpenStateIsOpenOROpenALittle = + appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open + val isManaExistsSeventyFivePercent = oldManaAmount.ratioToCap.exists(_ >= 0.75) + + val defaultAmount = Math.pow(playerLevel.level / 10, 2) + + val chainVoteDayNumber = chainVoteNumber.value + // 連続投票を適用した除算量 + val chainVoteDivisionAmount = + if (chainVoteDayNumber >= 30) 2 + else if (chainVoteDayNumber >= 10) 1.2 + else if (chainVoteDayNumber >= 3) 1.25 + else 1 + + // りんごの開放状況を適用した除算量 + val appleOpenStateDivisionAmount = + if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 + else 1 + + // りんごの開放状況まで適用したりんごの消費量 (暫定) + val appleOpenStateReflectedAmount = + (defaultAmount / chainVoteDivisionAmount).toInt / appleOpenStateDivisionAmount + + // 妖精がつまみ食いする量 + val amountEatenByKnob = + if (appleOpenStateReflectedAmount >= 10) + new Random().nextInt(appleOpenStateReflectedAmount / 10) + else 0 + + /* + 最終的に算出されたりんごの消費量 + (現時点では持っているりんごの数を + 考慮していないので消費量は確定していない) + */ + val finallyAppleConsumptionAmount = + Math.max(appleOpenStateReflectedAmount + amountEatenByKnob, 1) + + // りんごの消費量 + val appleConsumptionAmount = + if (appleOpenState == AppleOpenState.NotOpen) { + 0 + } else { + Math.max(finallyAppleConsumptionAmount, mineStackedGachaRingoAmount) + } + + // マナの回復量を算出する + val recoveryManaAmount = { + val appleOpenStateDivision = { + if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 + else if (appleOpenState == AppleOpenState.NotOpen) 4 + else 1 + } + + val reflectedAppleOpenStateAmount = + defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision + + // minestackに入っているりんごの数を適用したマナの回復量 + val reflectedMineStackedAmount: Int = + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { + if (mineStackedGachaRingoAmount == 0) { + reflectedAppleOpenStateAmount / { + if (appleOpenState == AppleOpenState.Open) 4 + else if (appleOpenState == AppleOpenState.OpenALittle) 4 + else 2 + } + } else { + if ((mineStackedGachaRingoAmount / finallyAppleConsumptionAmount) <= 0.5) + (reflectedAppleOpenStateAmount * 0.5).toInt + else + (reflectedAppleOpenStateAmount * mineStackedGachaRingoAmount / finallyAppleConsumptionAmount).toInt + } + } else reflectedAppleOpenStateAmount + + (reflectedMineStackedAmount - reflectedMineStackedAmount / 100) + Random.nextInt( + reflectedMineStackedAmount / 50 + ) + } + + // minestackからりんごを消費する + playerdata + .minestack + .subtractStackedAmountOf(gachaRingoObject, appleConsumptionAmount) + + // マナを回復する + manaApi + .manaAmount(player) + .restoreAbsolute(ManaAmount(recoveryManaAmount)) + .unsafeRunSync() + + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { + MessageEffect(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") + .apply(player) + .unsafeRunSync() + } + + SequentialEffect( + UnfocusedEffect { + new FairySpeech[IO]().speechRandomly( + player, + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) + FairyManaRecoveryState.notConsumptionApple + else FairyManaRecoveryState.consumptionApple + ) + }, + MessageEffect(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), + if (appleConsumptionAmount != 0) + MessageEffect( + s"$RESET$YELLOW${BOLD}あっ!${appleConsumptionAmount}個のがちゃりんごが食べられてる!" + ) + else MessageEffect(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") + ).apply(player).unsafeRunSync() + } + } + .unsafeRunSync() + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 641bc4ccbb..916d8e5d99 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -1,7 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions import cats.effect.{ConcurrentEffect, ContextShift, IO, LiftIO, SyncIO} -import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI @@ -9,14 +8,13 @@ import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.FairySpeechRoutine +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.FairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequest import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestResult._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ FairyRecoveryManaAmount, FairyUsingState } -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} @@ -68,7 +66,7 @@ object BukkitSummonFairy { import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.sleepAndRoutineContext implicit val contextShift: ContextShift[IO] = IO.contextShift(ExecutionContext.global) - FairySpeechRoutine.start(player).start.unsafeRunSync() + FairyRoutine.start(player).start.unsafeRunSync() } } @@ -76,7 +74,7 @@ object BukkitSummonFairy { SequentialEffect( UnfocusedEffect { eff.unsafeRunSync() - new FairySpeech().summonSpeech(player) + new FairySpeech().summonSpeech(player).unsafeRunSync() }, MessageEffect( List( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairyRoutine.scala similarity index 61% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairyRoutine.scala index 36de63f2e7..a81becd552 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairySpeechRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairyRoutine.scala @@ -4,16 +4,24 @@ import cats.effect.{ConcurrentEffect, IO, SyncIO, Timer} import com.github.unchama.concurrent.{RepeatingRoutine, RepeatingTaskContext} import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts +import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI +import com.github.unchama.seichiassist.subsystems.mana.ManaApi +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitRecoveryMana import org.bukkit.entity.Player import scala.concurrent.duration.FiniteDuration -object FairySpeechRoutine { +object FairyRoutine { - def start( - player: Player - )(implicit fairyAPI: FairyAPI[IO, Player], context: RepeatingTaskContext): IO[Nothing] = { + def start(player: Player)( + implicit fairyAPI: FairyAPI[IO, Player], + breakCountAPI: BreakCountAPI[IO, SyncIO, Player], + voteAPI: VoteAPI[IO, Player], + manaApi: ManaApi[IO, SyncIO, Player], + context: RepeatingTaskContext + ): IO[Nothing] = { val repeatInterval: IO[FiniteDuration] = IO { import scala.concurrent.duration._ @@ -31,7 +39,7 @@ object FairySpeechRoutine { repeatInterval, onMainThread.runAction { SyncIO { - BukkitFairySpeak[IO].speakRandomly(player).unsafeRunSync() + BukkitRecoveryMana(player).recovery.runAsync(_ => IO.unit) } } ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala index 0a2069a3c4..0725c0fdcd 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala @@ -8,12 +8,12 @@ case object AppleOpenState extends Enum[AppleOpenState] { override val values: IndexedSeq[AppleOpenState] = findValues - case object OpenAnyway extends AppleOpenState(4) + case object OpenAnyway extends AppleOpenState(1) - case object Open extends AppleOpenState(3) + case object Open extends AppleOpenState(2) - case object OpenALittle extends AppleOpenState(2) + case object OpenALittle extends AppleOpenState(3) - case object NotOpen extends AppleOpenState(1) + case object NotOpen extends AppleOpenState(4) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyManaRecoveryState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyManaRecoveryState.scala new file mode 100644 index 0000000000..0185ab2401 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyManaRecoveryState.scala @@ -0,0 +1,13 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property + +sealed trait FairyManaRecoveryState + +object FairyManaRecoveryState { + + case object full extends FairyManaRecoveryState + + case object notConsumptionApple extends FairyManaRecoveryState + + case object consumptionApple extends FairyManaRecoveryState + +} From c63a2beddd6857e43a3b39cfd574ea3670200f97 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 28 Jul 2022 11:22:11 +0900 Subject: [PATCH 070/482] =?UTF-8?q?[Fix]=E5=A6=96=E7=B2=BE=E3=81=8C?= =?UTF-8?q?=E5=8F=AC=E5=96=9A=E3=81=95=E3=82=8C=E3=81=9F=E3=81=A8=E3=81=8D?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=82=83=E3=81=B9=E3=82=89=E3=81=AA=E3=81=84?= =?UTF-8?q?=E4=B8=8D=E5=85=B7=E5=90=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/SeichiAssist.scala | 4 +++- .../unchama/seichiassist/menus/VoteMenu.scala | 3 +-- .../SpeechServiceRepositoryDefinitions.scala | 2 +- .../vote/subsystems/fairy/bukkit/FairySpeech.scala | 5 +++-- .../fairy/bukkit/actions/BukkitRecoveryMana.scala | 14 ++++++++------ .../fairy/bukkit/routines/FairyRoutine.scala | 4 +--- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index c781a833fa..10b416eda0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -414,7 +414,9 @@ class SeichiAssist extends JavaPlugin() { subhomeSystem, presentSystem, anywhereEnderSystem, - sharedInventorySystem + sharedInventorySystem, + voteSystem, + fairySystem ) private lazy val buildAssist: BuildAssist = { diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index fd77b44518..01400a0fb5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -273,8 +273,7 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( UnfocusedEffect { - val endTime = - fairyAPI.fairyEndTime(player).unsafeRunSync().get.endTimeOpt.get + fairyAPI.fairyEndTime(player).unsafeRunSync().get.endTimeOpt.get // BukkitFairySpeak[IO] // .speak( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala index cd055a0050..ee8fa36fab 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala @@ -13,7 +13,7 @@ object SpeechServiceRepositoryDefinitions { implicit gatewayProvider: Player => FairySpeechGateway[F] ): TwoPhasedRepositoryInitialization[F, Player, FairySpeechService[F]] = TwoPhasedRepositoryInitialization.withoutPrefetching[F, Player, FairySpeechService[F]] { - player => Sync[F].delay(new FairySpeechService[F](gatewayProvider(player))) + player => Applicative[F].pure(new FairySpeechService[F](gatewayProvider(player))) } def finalization[F[_]: Applicative, Player] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index ec9e1b64d1..7f8a87d471 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -32,9 +32,10 @@ class FairySpeech[F[_]: ConcurrentEffect](implicit fairyAPI: FairyAPI[F, Player] FairyMessageTable.nightMessages(nameCalledByFairy) message <- randomMessage(fairyMessages) } yield { - val serviceRepository = fairyAPI.fairySpeechServiceRepository - serviceRepository(player) + val serviceRepository = fairyAPI.fairySpeechServiceRepository(player) + serviceRepository .makeSpeech(message, fairyAPI.fairyPlaySound(player.getUniqueId).toIO.unsafeRunSync()) + .unsafeRunSync() } def speechRandomly( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index c97f1e7f9d..81f6ac7cb5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -148,12 +148,14 @@ object BukkitRecoveryMana { SequentialEffect( UnfocusedEffect { - new FairySpeech[IO]().speechRandomly( - player, - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) - FairyManaRecoveryState.notConsumptionApple - else FairyManaRecoveryState.consumptionApple - ) + new FairySpeech[IO]() + .speechRandomly( + player, + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) + FairyManaRecoveryState.notConsumptionApple + else FairyManaRecoveryState.consumptionApple + ) + .unsafeRunSync() }, MessageEffect(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), if (appleConsumptionAmount != 0) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairyRoutine.scala index a81becd552..79954ac897 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairyRoutine.scala @@ -38,9 +38,7 @@ object FairyRoutine { RepeatingRoutine.permanentRoutine( repeatInterval, onMainThread.runAction { - SyncIO { - BukkitRecoveryMana(player).recovery.runAsync(_ => IO.unit) - } + BukkitRecoveryMana(player).recovery.runAsync(_ => IO.unit) } ) } From d546cfae4e37135340f85ba4d9394822babaaf31 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 28 Jul 2022 13:18:19 +0900 Subject: [PATCH 071/482] =?UTF-8?q?[Fix]=E3=83=9E=E3=83=8A=E5=A6=96?= =?UTF-8?q?=E7=B2=BE=E3=81=8C=E3=83=9E=E3=83=8A=E3=82=92=E5=9B=9E=E5=BE=A9?= =?UTF-8?q?=E3=81=95=E3=81=9B=E3=81=AA=E3=81=84=E4=B8=8D=E5=85=B7=E5=90=88?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/bukkit/FairySpeech.scala | 2 +- .../bukkit/actions/BukkitRecoveryMana.scala | 247 +++++++++--------- .../bukkit/actions/BukkitSummonFairy.scala | 1 + .../fairy/bukkit/routines/FairyRoutine.scala | 1 + 4 files changed, 130 insertions(+), 121 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index 7f8a87d471..88e2737e62 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -48,7 +48,7 @@ class FairySpeech[F[_]: ConcurrentEffect](implicit fairyAPI: FairyAPI[F, Player] FairyMessageTable.manaFullMessages case FairyManaRecoveryState.consumptionApple => FairyMessageTable.consumed - case FairyMessageTable.notConsumed => + case FairyManaRecoveryState.notConsumptionApple => FairyMessageTable.notConsumed } randomMessage(messages(nameCalledByFairy)).map { message => diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 81f6ac7cb5..643717cb0c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -34,139 +34,146 @@ object BukkitRecoveryMana { .readManaAmount(player) .map { oldManaAmount => if (oldManaAmount.isFull) - return new FairySpeech[IO].speechRandomly(player, FairyManaRecoveryState.full) - val uuid = player.getUniqueId - - for { - seichiAmountData <- breakCountAPI.seichiAmountDataRepository(player).read.toIO - defaultRecoveryManaAmount <- fairyAPI.fairyRecoveryMana(uuid) - chainVoteNumber <- voteAPI.chainVoteDayNumber(uuid) - appleOpenState <- fairyAPI.appleOpenState(uuid) - gachaimoObjectOpt <- MineStackObjectList.findByName("gachaimo") - } yield { - val playerLevel = seichiAmountData.levelCorrespondingToExp - - val playerdata = SeichiAssist.playermap(player.getUniqueId) - val gachaRingoObject = gachaimoObjectOpt.get - val mineStackedGachaRingoAmount = - playerdata.minestack.getStackedAmountOf(gachaRingoObject) - - val isAppleOpenStateIsOpenOROpenALittle = - appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open - val isManaExistsSeventyFivePercent = oldManaAmount.ratioToCap.exists(_ >= 0.75) - - val defaultAmount = Math.pow(playerLevel.level / 10, 2) - - val chainVoteDayNumber = chainVoteNumber.value - // 連続投票を適用した除算量 - val chainVoteDivisionAmount = - if (chainVoteDayNumber >= 30) 2 - else if (chainVoteDayNumber >= 10) 1.2 - else if (chainVoteDayNumber >= 3) 1.25 - else 1 - - // りんごの開放状況を適用した除算量 - val appleOpenStateDivisionAmount = - if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 - else 1 - - // りんごの開放状況まで適用したりんごの消費量 (暫定) - val appleOpenStateReflectedAmount = - (defaultAmount / chainVoteDivisionAmount).toInt / appleOpenStateDivisionAmount - - // 妖精がつまみ食いする量 - val amountEatenByKnob = - if (appleOpenStateReflectedAmount >= 10) - new Random().nextInt(appleOpenStateReflectedAmount / 10) - else 0 - - /* - 最終的に算出されたりんごの消費量 - (現時点では持っているりんごの数を - 考慮していないので消費量は確定していない) - */ - val finallyAppleConsumptionAmount = - Math.max(appleOpenStateReflectedAmount + amountEatenByKnob, 1) - - // りんごの消費量 - val appleConsumptionAmount = - if (appleOpenState == AppleOpenState.NotOpen) { - 0 - } else { - Math.max(finallyAppleConsumptionAmount, mineStackedGachaRingoAmount) - } + new FairySpeech[IO] + .speechRandomly(player, FairyManaRecoveryState.full) + .unsafeRunSync() + else { + val uuid = player.getUniqueId + + val eff = for { + seichiAmountData <- breakCountAPI.seichiAmountDataRepository(player).read.toIO + defaultRecoveryManaAmount <- fairyAPI.fairyRecoveryMana(uuid) + chainVoteNumber <- voteAPI.chainVoteDayNumber(uuid) + appleOpenState <- fairyAPI.appleOpenState(uuid) + gachaimoObjectOpt <- MineStackObjectList.findByName("gachaimo") + } yield { + val playerLevel = seichiAmountData.levelCorrespondingToExp + + val playerdata = SeichiAssist.playermap(player.getUniqueId) + val gachaRingoObject = gachaimoObjectOpt.get + val mineStackedGachaRingoAmount = + playerdata.minestack.getStackedAmountOf(gachaRingoObject) + + val isAppleOpenStateIsOpenOROpenALittle = + appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open + val isManaExistsSeventyFivePercent = oldManaAmount.ratioToCap.exists(_ >= 0.75) + + val defaultAmount = Math.pow(playerLevel.level / 10, 2) + + val chainVoteDayNumber = chainVoteNumber.value + // 連続投票を適用した除算量 + val chainVoteDivisionAmount = + if (chainVoteDayNumber >= 30) 2 + else if (chainVoteDayNumber >= 10) 1.2 + else if (chainVoteDayNumber >= 3) 1.25 + else 1 - // マナの回復量を算出する - val recoveryManaAmount = { - val appleOpenStateDivision = { + // りんごの開放状況を適用した除算量 + val appleOpenStateDivisionAmount = if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 - else if (appleOpenState == AppleOpenState.NotOpen) 4 else 1 - } - val reflectedAppleOpenStateAmount = - defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision - - // minestackに入っているりんごの数を適用したマナの回復量 - val reflectedMineStackedAmount: Int = - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { - if (mineStackedGachaRingoAmount == 0) { - reflectedAppleOpenStateAmount / { - if (appleOpenState == AppleOpenState.Open) 4 - else if (appleOpenState == AppleOpenState.OpenALittle) 4 - else 2 + // りんごの開放状況まで適用したりんごの消費量 (暫定) + val appleOpenStateReflectedAmount = + (defaultAmount / chainVoteDivisionAmount).toInt / appleOpenStateDivisionAmount + + // 妖精がつまみ食いする量 + val amountEatenByKnob = + if (appleOpenStateReflectedAmount >= 10) + new Random().nextInt(appleOpenStateReflectedAmount / 10) + else 0 + + /* + 最終的に算出されたりんごの消費量 + (現時点では持っているりんごの数を + 考慮していないので消費量は確定していない) + */ + val finallyAppleConsumptionAmount = + Math.max(appleOpenStateReflectedAmount + amountEatenByKnob, 1) + + // りんごの消費量 + val appleConsumptionAmount = + if (appleOpenState == AppleOpenState.NotOpen) { + 0 + } else { + Math.max(finallyAppleConsumptionAmount, mineStackedGachaRingoAmount) + } + + // マナの回復量を算出する + val recoveryManaAmount = { + val appleOpenStateDivision = { + if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 + else if (appleOpenState == AppleOpenState.NotOpen) 4 + else 1 + } + + val reflectedAppleOpenStateAmount = + defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision + + // minestackに入っているりんごの数を適用したマナの回復量 + val reflectedMineStackedAmount = + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { + if (mineStackedGachaRingoAmount == 0) { + reflectedAppleOpenStateAmount / { + if (appleOpenState == AppleOpenState.Open) 4 + else if (appleOpenState == AppleOpenState.OpenALittle) 4 + else 2 + } + } else { + if ((mineStackedGachaRingoAmount / finallyAppleConsumptionAmount) <= 0.5) + (reflectedAppleOpenStateAmount * 0.5).toInt + else + (reflectedAppleOpenStateAmount * mineStackedGachaRingoAmount / finallyAppleConsumptionAmount).toInt } - } else { - if ((mineStackedGachaRingoAmount / finallyAppleConsumptionAmount) <= 0.5) - (reflectedAppleOpenStateAmount * 0.5).toInt - else - (reflectedAppleOpenStateAmount * mineStackedGachaRingoAmount / finallyAppleConsumptionAmount).toInt - } - } else reflectedAppleOpenStateAmount - - (reflectedMineStackedAmount - reflectedMineStackedAmount / 100) + Random.nextInt( - reflectedMineStackedAmount / 50 - ) - } + } else reflectedAppleOpenStateAmount - // minestackからりんごを消費する - playerdata - .minestack - .subtractStackedAmountOf(gachaRingoObject, appleConsumptionAmount) + (reflectedMineStackedAmount - reflectedMineStackedAmount / 100) + + (if (reflectedMineStackedAmount >= 50) + Random.nextInt(reflectedMineStackedAmount / 50) + else 0) + } - // マナを回復する - manaApi - .manaAmount(player) - .restoreAbsolute(ManaAmount(recoveryManaAmount)) - .unsafeRunSync() + // minestackからりんごを消費する + playerdata + .minestack + .subtractStackedAmountOf(gachaRingoObject, appleConsumptionAmount) - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { - MessageEffect(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") - .apply(player) + // マナを回復する + manaApi + .manaAmount(player) + .restoreAbsolute(ManaAmount(recoveryManaAmount)) .unsafeRunSync() - } - SequentialEffect( - UnfocusedEffect { - new FairySpeech[IO]() - .speechRandomly( - player, - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) - FairyManaRecoveryState.notConsumptionApple - else FairyManaRecoveryState.consumptionApple - ) + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { + MessageEffect(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") + .apply(player) .unsafeRunSync() - }, - MessageEffect(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), - if (appleConsumptionAmount != 0) - MessageEffect( - s"$RESET$YELLOW${BOLD}あっ!${appleConsumptionAmount}個のがちゃりんごが食べられてる!" - ) - else MessageEffect(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") - ).apply(player).unsafeRunSync() + } + + SequentialEffect( + UnfocusedEffect { + new FairySpeech[IO] + .speechRandomly( + player, + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) + FairyManaRecoveryState.notConsumptionApple + else FairyManaRecoveryState.consumptionApple + ) + .unsafeRunSync() + }, + MessageEffect(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), + if (appleConsumptionAmount != 0) + MessageEffect( + s"$RESET$YELLOW${BOLD}あっ!${appleConsumptionAmount}個のがちゃりんごが食べられてる!" + ) + else MessageEffect(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") + ).apply(player).unsafeRunSync() + } + eff.unsafeRunAsyncAndForget() } } - .unsafeRunSync() + .toIO + } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 916d8e5d99..506ceb50ec 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -63,6 +63,7 @@ object BukkitSummonFairy { FairySpeechRoutineが一度も起動されていなければ起動する */ if (isFairyEndTimeDefined.isEmpty) { + println("empty") import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.sleepAndRoutineContext implicit val contextShift: ContextShift[IO] = IO.contextShift(ExecutionContext.global) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairyRoutine.scala index 79954ac897..64a35c378d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairyRoutine.scala @@ -22,6 +22,7 @@ object FairyRoutine { manaApi: ManaApi[IO, SyncIO, Player], context: RepeatingTaskContext ): IO[Nothing] = { + println("startRoutine") val repeatInterval: IO[FiniteDuration] = IO { import scala.concurrent.duration._ From 6f1ee32578fcd832e6960f5edce5cafa7f23f4cf Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 28 Jul 2022 14:57:11 +0900 Subject: [PATCH 072/482] =?UTF-8?q?[Chore]SeechRoutine=E3=82=92Repository?= =?UTF-8?q?=E5=8C=96=E3=81=97=E3=81=A6=E5=91=A8=E3=82=8A=E3=82=92=E8=AA=BF?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/SeichiAssist.scala | 10 ++- .../unchama/seichiassist/menus/VoteMenu.scala | 2 +- .../vote/subsystems/fairy/System.scala | 82 +++++++++++++------ .../application/actions/FairyRoutine.scala | 19 +++++ ...veryRoutineFiberRepositoryDefinition.scala | 55 +++++++++++++ .../bukkit/actions/BukkitSummonFairy.scala | 19 +---- ...Routine.scala => BukkitFairyRoutine.scala} | 10 +-- 7 files changed, 146 insertions(+), 51 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/{FairyRoutine.scala => BukkitFairyRoutine.scala} (83%) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 10b416eda0..77e40feb51 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -391,8 +391,14 @@ class SeichiAssist extends JavaPlugin() { private lazy val voteSystem: subsystems.vote.System[IO, Player] = subsystems.vote.System.wired[IO] - private lazy val fairySystem: subsystems.vote.subsystems.fairy.System[IO, Player] = - subsystems.vote.subsystems.fairy.System.wired[IO].unsafeRunSync() + private lazy val fairySystem: subsystems.vote.subsystems.fairy.System[IO, Player] = { + import PluginExecutionContexts.sleepAndRoutineContext + implicit val breakCountAPI: BreakCountAPI[IO, SyncIO, Player] = breakCountSystem.api + implicit val voteAPI: VoteAPI[IO, Player] = voteSystem.api + implicit val manaApi: ManaApi[IO, SyncIO, Player] = manaSystem.manaApi + + subsystems.vote.subsystems.fairy.System.wired.unsafeRunSync() + } private lazy val wiredSubsystems: List[Subsystem[IO]] = List( mebiusSystem, diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 01400a0fb5..64a14837a4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -76,7 +76,7 @@ object VoteMenu extends Menu { private object ConstantButtons { - implicit val ioCE: ConcurrentEffect[IO] = + private implicit val ioCE: ConcurrentEffect[IO] = IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) def receiveVoteBenefitsButton(player: Player)( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 3693c563a2..f43caaff60 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -1,17 +1,25 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.concurrent.Ref -import cats.effect.{ConcurrentEffect, Sync, SyncIO} +import cats.effect.{IO, SyncIO} +import com.github.unchama.concurrent.RepeatingTaskContext import com.github.unchama.datarepository.KeyedDataRepository import com.github.unchama.datarepository.bukkit.player.{ BukkitRepositoryControls, PlayerDataRepository } import com.github.unchama.datarepository.template.RepositoryDefinition -import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.SpeechServiceRepositoryDefinitions +import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI +import com.github.unchama.seichiassist.subsystems.mana.ManaApi +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{ + FairyManaRecoveryRoutineFiberRepositoryDefinition, + SpeechServiceRepositoryDefinitions +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit.FairyLoreTable import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ @@ -27,10 +35,16 @@ trait System[F[_], Player] extends Subsystem[F] { object System { - def wired[F[_]: ConcurrentEffect: OnMinecraftServerThread]: SyncIO[System[F, Player]] = { - val persistence = new JdbcFairyPersistence[F] + def wired( + implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], + voteAPI: VoteAPI[IO, Player], + manaApi: ManaApi[IO, SyncIO, Player], + context: RepeatingTaskContext + ): SyncIO[System[IO, Player]] = { + val persistence = new JdbcFairyPersistence[IO] implicit val fairySpeechGatewayProvider: Player => FairySpeechGateway[SyncIO] = new BukkitFairySpeechGateway(_) + implicit val fairyRoutine: FairyRoutine[IO, SyncIO, Player] = BukkitFairyRoutine for { speechServiceRepositoryControls <- BukkitRepositoryControls.createHandles( @@ -42,81 +56,97 @@ object System { ) ) } yield { - new System[F, Player] { - override val api: FairyAPI[F, Player] = new FairyAPI[F, Player] { - override def appleOpenState(uuid: UUID): F[AppleOpenState] = + new System[IO, Player] { + override implicit val api: FairyAPI[IO, Player] = new FairyAPI[IO, Player] { + override def appleOpenState(uuid: UUID): IO[AppleOpenState] = persistence.appleOpenState(uuid) override def updateAppleOpenState( uuid: UUID, appleOpenState: AppleOpenState - ): F[Unit] = + ): IO[Unit] = persistence.changeAppleOpenState(uuid, appleOpenState) import cats.implicits._ - override def getFairyLore(uuid: UUID): F[FairyLore] = for { + override def getFairyLore(uuid: UUID): IO[FairyLore] = for { state <- appleOpenState(uuid) } yield FairyLoreTable.loreTable(state.amount - 1) override def updateFairySummonCost( uuid: UUID, fairySummonCost: FairySummonCost - ): F[Unit] = + ): IO[Unit] = persistence.updateFairySummonCost(uuid, fairySummonCost) - override def fairySummonCost(player: Player): F[FairySummonCost] = + override def fairySummonCost(player: Player): IO[FairySummonCost] = persistence.fairySummonCost(player.getUniqueId) override protected val fairyPlaySoundRepository - : KeyedDataRepository[UUID, Ref[F, FairyPlaySound]] = - KeyedDataRepository.unlift[UUID, Ref[F, FairyPlaySound]] { _ => + : KeyedDataRepository[UUID, Ref[IO, FairyPlaySound]] = + KeyedDataRepository.unlift[UUID, Ref[IO, FairyPlaySound]] { _ => Some(Ref.unsafe(FairyPlaySound.on)) } - override def fairyPlaySound(uuid: UUID): F[FairyPlaySound] = + override def fairyPlaySound(uuid: UUID): IO[FairyPlaySound] = if (fairyPlaySoundRepository.isDefinedAt(uuid)) fairyPlaySoundRepository(uuid).get - else Sync[F].pure(FairyPlaySound.on) + else IO.pure(FairyPlaySound.on) - override def fairyPlaySoundToggle(uuid: UUID): F[Unit] = for { + override def fairyPlaySoundToggle(uuid: UUID): IO[Unit] = for { nowSetting <- fairyPlaySound(uuid) } yield fairyPlaySoundRepository(uuid).set( if (nowSetting == FairyPlaySound.on) FairyPlaySound.off else FairyPlaySound.on ) - override def fairyEndTime(player: Player): F[Option[FairyEndTime]] = + override def fairyEndTime(player: Player): IO[Option[FairyEndTime]] = persistence.fairyEndTime(player.getUniqueId) - override def updateFairyEndTime(player: Player, fairyEndTime: FairyEndTime): F[Unit] = + override def updateFairyEndTime( + player: Player, + fairyEndTime: FairyEndTime + ): IO[Unit] = persistence.updateFairyEndTime(player.getUniqueId, fairyEndTime) - override def fairyUsingState(player: Player): F[FairyUsingState] = + override def fairyUsingState(player: Player): IO[FairyUsingState] = persistence.fairyUsingState(player.getUniqueId) override def updateFairyUsingState( player: Player, fairyUsingState: FairyUsingState - ): F[Unit] = + ): IO[Unit] = persistence.updateFairyUsingState(player.getUniqueId, fairyUsingState) - override def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] = + override def fairyRecoveryMana(uuid: UUID): IO[FairyRecoveryMana] = persistence.fairyRecoveryMana(uuid) override def updateFairyRecoveryManaAmount( uuid: UUID, fairyRecoveryMana: FairyRecoveryMana - ): F[Unit] = persistence.updateFairyRecoveryMana(uuid, fairyRecoveryMana) + ): IO[Unit] = persistence.updateFairyRecoveryMana(uuid, fairyRecoveryMana) override val fairySpeechServiceRepository : PlayerDataRepository[FairySpeechService[SyncIO]] = speechServiceRepositoryControls.repository } - override val managedRepositoryControls: Seq[BukkitRepositoryControls[F, _]] = - Seq(speechServiceRepositoryControls).map(_.coerceFinalizationContextTo[F]) - + override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = + BukkitRepositoryControls + .createHandles( + RepositoryDefinition + .Phased + .TwoPhased( + FairyManaRecoveryRoutineFiberRepositoryDefinition + .initialization[SyncIO, Player], + FairyManaRecoveryRoutineFiberRepositoryDefinition.finalization[SyncIO, Player] + ) + ) + .map { fairyRecoveryRoutineFiberRepositoryControls => + Seq(speechServiceRepositoryControls, fairyRecoveryRoutineFiberRepositoryControls) + .map(_.coerceFinalizationContextTo[IO]) + } + .unsafeRunSync() } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala new file mode 100644 index 0000000000..6b052b0491 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala @@ -0,0 +1,19 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions + +import com.github.unchama.concurrent.RepeatingTaskContext +import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI +import com.github.unchama.seichiassist.subsystems.mana.ManaApi +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI + +trait FairyRoutine[F[_], G[_], Player] { + + def start(player: Player)( + implicit breakCountAPI: BreakCountAPI[F, G, Player], + fairyAPI: FairyAPI[F, Player], + voteAPI: VoteAPI[F, Player], + manaApi: ManaApi[F, G, Player], + context: RepeatingTaskContext + ): F[Nothing] + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala new file mode 100644 index 0000000000..f21211fd8b --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala @@ -0,0 +1,55 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository + +import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps +import cats.effect.concurrent.Deferred +import cats.effect.{ConcurrentEffect, Fiber, IO, Sync, SyncIO} +import com.github.unchama.concurrent.RepeatingTaskContext +import com.github.unchama.datarepository.template.finalization.RepositoryFinalization +import com.github.unchama.datarepository.template.initialization.TwoPhasedRepositoryInitialization +import com.github.unchama.generic.effect.EffectExtra +import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts +import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI +import com.github.unchama.seichiassist.subsystems.mana.ManaApi +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine + +object FairyManaRecoveryRoutineFiberRepositoryDefinition { + + import cats.implicits._ + + implicit val ioCE: ConcurrentEffect[IO] = + IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) + + def initialization[F[_]: Sync, Player]( + implicit fairyRoutine: FairyRoutine[IO, SyncIO, Player], + fairyAPI: FairyAPI[IO, Player], + breakCountAPI: BreakCountAPI[IO, SyncIO, Player], + voteAPI: VoteAPI[IO, Player], + manaApi: ManaApi[IO, SyncIO, Player], + context: RepeatingTaskContext + ): TwoPhasedRepositoryInitialization[F, Player, Deferred[IO, Fiber[IO, Nothing]]] = + TwoPhasedRepositoryInitialization + .withoutPrefetching[F, Player, Deferred[IO, Fiber[IO, Nothing]]] { player => + for { + promise <- Deferred.in[F, IO, Fiber[IO, Nothing]] + _ <- EffectExtra.runAsyncAndForget[IO, F, Unit] { + fairyRoutine + .start(player) + .toIO + .start(IO.contextShift(context)) + .flatMap(fiber => promise.complete(fiber)) + } + } yield promise + } + + def finalization[F[_]: Sync, Player] + : RepositoryFinalization[F, Player, Deferred[IO, Fiber[IO, Nothing]]] = + RepositoryFinalization.withoutAnyPersistence[F, Player, Deferred[IO, Fiber[IO, Nothing]]] { + (_, promise) => + EffectExtra.runAsyncAndForget[IO, F, Unit] { + promise.get.flatMap(_.cancel) + } + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 506ceb50ec..b8b32956b6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions -import cats.effect.{ConcurrentEffect, ContextShift, IO, LiftIO, SyncIO} +import cats.effect.{ConcurrentEffect, IO, LiftIO, SyncIO} import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI @@ -8,7 +8,6 @@ import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.FairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequest import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestResult._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ @@ -22,8 +21,6 @@ import org.bukkit.ChatColor._ import org.bukkit.Sound import org.bukkit.entity.Player -import scala.concurrent.ExecutionContext - object BukkitSummonFairy { def apply(player: Player)( @@ -56,20 +53,8 @@ object BukkitSummonFairy { uuid = player.getUniqueId _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(fairySummonCost.value * 2)) _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) - isFairyEndTimeDefined <- fairyAPI.fairyEndTime(player) _ <- fairyAPI.updateFairyEndTime(player, fairySummonCost.validTime) - } yield { - /* - FairySpeechRoutineが一度も起動されていなければ起動する - */ - if (isFairyEndTimeDefined.isEmpty) { - println("empty") - import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.sleepAndRoutineContext - implicit val contextShift: ContextShift[IO] = - IO.contextShift(ExecutionContext.global) - FairyRoutine.start(player).start.unsafeRunSync() - } - } + } yield () LiftIO[IO].liftIO { SequentialEffect( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala similarity index 83% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairyRoutine.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index 64a35c378d..6e3318da07 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/FairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -8,21 +8,21 @@ import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitRecoveryMana import org.bukkit.entity.Player import scala.concurrent.duration.FiniteDuration -object FairyRoutine { +object BukkitFairyRoutine extends FairyRoutine[IO, SyncIO, Player] { - def start(player: Player)( - implicit fairyAPI: FairyAPI[IO, Player], - breakCountAPI: BreakCountAPI[IO, SyncIO, Player], + override def start(player: Player)( + implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], + fairyAPI: FairyAPI[IO, Player], voteAPI: VoteAPI[IO, Player], manaApi: ManaApi[IO, SyncIO, Player], context: RepeatingTaskContext ): IO[Nothing] = { - println("startRoutine") val repeatInterval: IO[FiniteDuration] = IO { import scala.concurrent.duration._ From fb4842667114499f68697cbe823eac01b581e8b4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 28 Jul 2022 18:35:25 +0900 Subject: [PATCH 073/482] =?UTF-8?q?[Fix]=E5=9E=8B=E3=82=92=E6=8A=BD?= =?UTF-8?q?=E8=B1=A1=E5=8C=96=E3=81=A7=E3=81=8D=E3=82=8B=E3=81=A8=E3=81=93?= =?UTF-8?q?=E3=82=8D=E3=81=AF=E7=9B=B4=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/SeichiAssist.scala | 7 +- .../seichiassist/menus/TopLevelRouter.scala | 2 +- .../unchama/seichiassist/menus/VoteMenu.scala | 14 +- .../vote/subsystems/fairy/FairyAPI.scala | 13 +- .../vote/subsystems/fairy/System.scala | 186 ++++++------ .../application/actions/FairyRoutine.scala | 2 +- ...veryRoutineFiberRepositoryDefinition.scala | 37 ++- .../subsystems/fairy/bukkit/FairySpeech.scala | 23 +- .../bukkit/actions/BukkitRecoveryMana.scala | 282 +++++++++--------- .../bukkit/actions/BukkitSummonFairy.scala | 4 +- .../gateway/BukkitFairySpeechGateway.scala | 14 +- .../bukkit/routines/BukkitFairyRoutine.scala | 37 ++- .../fairy/domain/FairySpawnRequest.scala | 2 +- .../fairy/domain/property/FairyLore.scala | 5 +- 14 files changed, 327 insertions(+), 301 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 77e40feb51..c2b3838f9f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -391,8 +391,9 @@ class SeichiAssist extends JavaPlugin() { private lazy val voteSystem: subsystems.vote.System[IO, Player] = subsystems.vote.System.wired[IO] - private lazy val fairySystem: subsystems.vote.subsystems.fairy.System[IO, Player] = { - import PluginExecutionContexts.sleepAndRoutineContext + private lazy val fairySystem: subsystems.vote.subsystems.fairy.System[IO, SyncIO, Player] = { + import PluginExecutionContexts.{asyncShift, sleepAndRoutineContext} + implicit val concurrentEffect: ConcurrentEffect[IO] = IO.ioConcurrentEffect(asyncShift) implicit val breakCountAPI: BreakCountAPI[IO, SyncIO, Player] = breakCountSystem.api implicit val voteAPI: VoteAPI[IO, Player] = voteSystem.api implicit val manaApi: ManaApi[IO, SyncIO, Player] = manaSystem.manaApi @@ -581,7 +582,7 @@ class SeichiAssist extends JavaPlugin() { implicit val sharedInventoryAPI: SharedInventoryAPI[IO, Player] = sharedInventorySystem.api implicit val voteAPI: VoteAPI[IO, Player] = voteSystem.api - implicit val fairyAPI: FairyAPI[IO, Player] = fairySystem.api + implicit val fairyAPI: FairyAPI[IO, SyncIO, Player] = fairySystem.api val menuRouter = TopLevelRouter.apply import menuRouter.{canOpenStickMenu, ioCanOpenCategorizedMineStackMenu} diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala index 7af6db3d7b..79ce1fd7de 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala @@ -74,7 +74,7 @@ object TopLevelRouter { enderChestAccessApi: AnywhereEnderChestAPI[IO], sharedInventoryAPI: SharedInventoryAPI[IO, Player], voteAPI: VoteAPI[IO, Player], - fairyAPI: FairyAPI[IO, Player] + fairyAPI: FairyAPI[IO, SyncIO, Player] ): TopLevelRouter[IO] = new TopLevelRouter[IO] { import assortedRankingApi._ diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 64a14837a4..8ec1be5903 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -36,7 +36,7 @@ object VoteMenu extends Menu { class Environment( implicit val voteAPI: VoteAPI[IO, Player], - val fairyAPI: FairyAPI[IO, Player], + val fairyAPI: FairyAPI[IO, SyncIO, Player], val breakCountAPI: BreakCountAPI[IO, SyncIO, Player], val manaApi: ManaApi[IO, SyncIO, Player], val ioCanOpenFirstPage: IO CanOpen FirstPage.type @@ -147,7 +147,7 @@ object VoteMenu extends Menu { def fairySummonTimeToggleButton( player: Player - )(implicit fairyAPI: FairyAPI[IO, Player]): Button = { + )(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]): Button = { val fairySummonCost = fairyAPI.fairySummonCost(player).unsafeRunSync() Button( new IconItemStackBuilder(Material.WATCH) @@ -179,7 +179,7 @@ object VoteMenu extends Menu { def fairyContractSettingToggle( uuid: UUID - )(implicit fairyAPI: FairyAPI[IO, Player]): Button = + )(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]): Button = Button( new IconItemStackBuilder(Material.PAPER) .title(s"$GOLD$UNDERLINE${BOLD}妖精とのお約束") @@ -205,7 +205,7 @@ object VoteMenu extends Menu { def fairyPlaySoundToggleButton( uuid: UUID - )(implicit fairyAPI: FairyAPI[IO, Player]): Button = { + )(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]): Button = { val description = List(s"$RESET$DARK_GRAY※この機能はデフォルトでONです。", s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え") val playSoundOnLore = List(s"$RESET${GREEN}現在音が鳴る設定になっています。") ++ description @@ -232,7 +232,7 @@ object VoteMenu extends Menu { } def fairySummonButton(player: Player)( - implicit fairyAPI: FairyAPI[IO, Player], + implicit fairyAPI: FairyAPI[IO, SyncIO, Player], voteAPI: VoteAPI[IO, Player], breakCountAPI: BreakCountAPI[IO, SyncIO, Player], manaApi: ManaApi[IO, SyncIO, Player] @@ -263,7 +263,9 @@ object VoteMenu extends Menu { ) } - def checkTimeButton(player: Player)(implicit fairyAPI: FairyAPI[IO, Player]): Button = { + def checkTimeButton( + player: Player + )(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]): Button = { Button( new IconItemStackBuilder(Material.COMPASS) .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}マナ妖精に時間を聞く") diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 4d2ab6369e..efe9370221 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -1,6 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy -import cats.effect.SyncIO import cats.effect.concurrent.Ref import com.github.unchama.datarepository.KeyedDataRepository import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository @@ -50,7 +49,7 @@ object FairyWriteAPI { } -trait FairyReadAPI[F[_], Player] { +trait FairyReadAPI[F[_], G[_], Player] { /** * 妖精にあげるりんごの開放状態を取得する @@ -91,7 +90,7 @@ trait FairyReadAPI[F[_], Player] { Ref[F, FairyPlaySound] ] - val fairySpeechServiceRepository: PlayerDataRepository[FairySpeechService[SyncIO]] + val fairySpeechServiceRepository: PlayerDataRepository[FairySpeechService[G]] /** * 妖精が有効な時間を返す @@ -102,8 +101,12 @@ trait FairyReadAPI[F[_], Player] { object FairyReadAPI { - def apply[F[_], Player](implicit ev: FairyReadAPI[F, Player]): FairyReadAPI[F, Player] = ev + def apply[F[_], G[_], Player]( + implicit ev: FairyReadAPI[F, G, Player] + ): FairyReadAPI[F, G, Player] = ev } -trait FairyAPI[F[_], Player] extends FairyReadAPI[F, Player] with FairyWriteAPI[F, Player] +trait FairyAPI[F[_], G[_], Player] + extends FairyReadAPI[F, G, Player] + with FairyWriteAPI[F, Player] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index f43caaff60..4a2e225651 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -1,7 +1,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.concurrent.Ref -import cats.effect.{IO, SyncIO} +import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.concurrent.RepeatingTaskContext import com.github.unchama.datarepository.KeyedDataRepository import com.github.unchama.datarepository.bukkit.player.{ @@ -29,8 +29,8 @@ import org.bukkit.entity.Player import java.util.UUID -trait System[F[_], Player] extends Subsystem[F] { - val api: FairyAPI[F, Player] +trait System[F[_], G[_], Player] extends Subsystem[F] { + val api: FairyAPI[F, G, Player] } object System { @@ -39,106 +39,108 @@ object System { implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], voteAPI: VoteAPI[IO, Player], manaApi: ManaApi[IO, SyncIO, Player], - context: RepeatingTaskContext - ): SyncIO[System[IO, Player]] = { + context: RepeatingTaskContext, + concurrentEffect: ConcurrentEffect[IO] + ): SyncIO[System[IO, SyncIO, Player]] = { val persistence = new JdbcFairyPersistence[IO] implicit val fairySpeechGatewayProvider: Player => FairySpeechGateway[SyncIO] = - new BukkitFairySpeechGateway(_) - implicit val fairyRoutine: FairyRoutine[IO, SyncIO, Player] = BukkitFairyRoutine + new BukkitFairySpeechGateway[SyncIO](_) + implicit val fairyRoutine: FairyRoutine[IO, SyncIO, Player] = + new BukkitFairyRoutine[IO, SyncIO] for { - speechServiceRepositoryControls <- BukkitRepositoryControls.createHandles( - RepositoryDefinition - .Phased - .TwoPhased( - SpeechServiceRepositoryDefinitions.initialization[SyncIO, Player], - SpeechServiceRepositoryDefinitions.finalization[SyncIO, Player] - ) - ) + speechServiceRepositoryControls <- { + BukkitRepositoryControls.createHandles( + RepositoryDefinition + .Phased + .TwoPhased( + SpeechServiceRepositoryDefinitions.initialization[SyncIO, Player], + SpeechServiceRepositoryDefinitions.finalization[SyncIO, Player] + ) + ) + } } yield { - new System[IO, Player] { - override implicit val api: FairyAPI[IO, Player] = new FairyAPI[IO, Player] { - override def appleOpenState(uuid: UUID): IO[AppleOpenState] = - persistence.appleOpenState(uuid) - - override def updateAppleOpenState( - uuid: UUID, - appleOpenState: AppleOpenState - ): IO[Unit] = - persistence.changeAppleOpenState(uuid, appleOpenState) - - import cats.implicits._ - - override def getFairyLore(uuid: UUID): IO[FairyLore] = for { - state <- appleOpenState(uuid) - } yield FairyLoreTable.loreTable(state.amount - 1) - - override def updateFairySummonCost( - uuid: UUID, - fairySummonCost: FairySummonCost - ): IO[Unit] = - persistence.updateFairySummonCost(uuid, fairySummonCost) - - override def fairySummonCost(player: Player): IO[FairySummonCost] = - persistence.fairySummonCost(player.getUniqueId) - - override protected val fairyPlaySoundRepository - : KeyedDataRepository[UUID, Ref[IO, FairyPlaySound]] = - KeyedDataRepository.unlift[UUID, Ref[IO, FairyPlaySound]] { _ => - Some(Ref.unsafe(FairyPlaySound.on)) - } + new System[IO, SyncIO, Player] { + override implicit val api: FairyAPI[IO, SyncIO, Player] = + new FairyAPI[IO, SyncIO, Player] { + override def appleOpenState(uuid: UUID): IO[AppleOpenState] = + persistence.appleOpenState(uuid) + + override def updateAppleOpenState( + uuid: UUID, + appleOpenState: AppleOpenState + ): IO[Unit] = + persistence.changeAppleOpenState(uuid, appleOpenState) + + override def getFairyLore(uuid: UUID): IO[FairyLore] = for { + state <- appleOpenState(uuid) + } yield FairyLoreTable.loreTable(state.amount - 1) + + override def updateFairySummonCost( + uuid: UUID, + fairySummonCost: FairySummonCost + ): IO[Unit] = + persistence.updateFairySummonCost(uuid, fairySummonCost) + + override def fairySummonCost(player: Player): IO[FairySummonCost] = + persistence.fairySummonCost(player.getUniqueId) + + override protected val fairyPlaySoundRepository + : KeyedDataRepository[UUID, Ref[IO, FairyPlaySound]] = + KeyedDataRepository.unlift[UUID, Ref[IO, FairyPlaySound]] { _ => + Some(Ref.unsafe(FairyPlaySound.on)) + } + + override def fairyPlaySound(uuid: UUID): IO[FairyPlaySound] = + if (fairyPlaySoundRepository.isDefinedAt(uuid)) + fairyPlaySoundRepository(uuid).get + else IO.pure(FairyPlaySound.on) + + override def fairyPlaySoundToggle(uuid: UUID): IO[Unit] = for { + nowSetting <- fairyPlaySound(uuid) + } yield fairyPlaySoundRepository(uuid).set( + if (nowSetting == FairyPlaySound.on) FairyPlaySound.off + else FairyPlaySound.on + ) - override def fairyPlaySound(uuid: UUID): IO[FairyPlaySound] = - if (fairyPlaySoundRepository.isDefinedAt(uuid)) - fairyPlaySoundRepository(uuid).get - else IO.pure(FairyPlaySound.on) - - override def fairyPlaySoundToggle(uuid: UUID): IO[Unit] = for { - nowSetting <- fairyPlaySound(uuid) - } yield fairyPlaySoundRepository(uuid).set( - if (nowSetting == FairyPlaySound.on) FairyPlaySound.off - else FairyPlaySound.on - ) - - override def fairyEndTime(player: Player): IO[Option[FairyEndTime]] = - persistence.fairyEndTime(player.getUniqueId) - - override def updateFairyEndTime( - player: Player, - fairyEndTime: FairyEndTime - ): IO[Unit] = - persistence.updateFairyEndTime(player.getUniqueId, fairyEndTime) - - override def fairyUsingState(player: Player): IO[FairyUsingState] = - persistence.fairyUsingState(player.getUniqueId) - - override def updateFairyUsingState( - player: Player, - fairyUsingState: FairyUsingState - ): IO[Unit] = - persistence.updateFairyUsingState(player.getUniqueId, fairyUsingState) - - override def fairyRecoveryMana(uuid: UUID): IO[FairyRecoveryMana] = - persistence.fairyRecoveryMana(uuid) - - override def updateFairyRecoveryManaAmount( - uuid: UUID, - fairyRecoveryMana: FairyRecoveryMana - ): IO[Unit] = persistence.updateFairyRecoveryMana(uuid, fairyRecoveryMana) - - override val fairySpeechServiceRepository - : PlayerDataRepository[FairySpeechService[SyncIO]] = - speechServiceRepositoryControls.repository - } + override def fairyEndTime(player: Player): IO[Option[FairyEndTime]] = + persistence.fairyEndTime(player.getUniqueId) + + override def updateFairyEndTime( + player: Player, + fairyEndTime: FairyEndTime + ): IO[Unit] = + persistence.updateFairyEndTime(player.getUniqueId, fairyEndTime) + + override def fairyUsingState(player: Player): IO[FairyUsingState] = + persistence.fairyUsingState(player.getUniqueId) - override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = + override def updateFairyUsingState( + player: Player, + fairyUsingState: FairyUsingState + ): IO[Unit] = + persistence.updateFairyUsingState(player.getUniqueId, fairyUsingState) + + override def fairyRecoveryMana(uuid: UUID): IO[FairyRecoveryMana] = + persistence.fairyRecoveryMana(uuid) + + override def updateFairyRecoveryManaAmount( + uuid: UUID, + fairyRecoveryMana: FairyRecoveryMana + ): IO[Unit] = persistence.updateFairyRecoveryMana(uuid, fairyRecoveryMana) + + override val fairySpeechServiceRepository + : PlayerDataRepository[FairySpeechService[SyncIO]] = + speechServiceRepositoryControls.repository + } + + override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = { BukkitRepositoryControls .createHandles( RepositoryDefinition .Phased .TwoPhased( - FairyManaRecoveryRoutineFiberRepositoryDefinition - .initialization[SyncIO, Player], + FairyManaRecoveryRoutineFiberRepositoryDefinition.initialization[Player], FairyManaRecoveryRoutineFiberRepositoryDefinition.finalization[SyncIO, Player] ) ) @@ -147,6 +149,8 @@ object System { .map(_.coerceFinalizationContextTo[IO]) } .unsafeRunSync() + + } } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala index 6b052b0491..cfb945920a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala @@ -10,7 +10,7 @@ trait FairyRoutine[F[_], G[_], Player] { def start(player: Player)( implicit breakCountAPI: BreakCountAPI[F, G, Player], - fairyAPI: FairyAPI[F, Player], + fairyAPI: FairyAPI[F, G, Player], voteAPI: VoteAPI[F, Player], manaApi: ManaApi[F, G, Player], context: RepeatingTaskContext diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala index f21211fd8b..6455ee9b32 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala @@ -1,6 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository -import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import cats.effect.concurrent.Deferred import cats.effect.{ConcurrentEffect, Fiber, IO, Sync, SyncIO} import com.github.unchama.concurrent.RepeatingTaskContext @@ -16,40 +15,38 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applicat object FairyManaRecoveryRoutineFiberRepositoryDefinition { - import cats.implicits._ - implicit val ioCE: ConcurrentEffect[IO] = IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) - def initialization[F[_]: Sync, Player]( + def initialization[Player]( implicit fairyRoutine: FairyRoutine[IO, SyncIO, Player], - fairyAPI: FairyAPI[IO, Player], + fairyAPI: FairyAPI[IO, SyncIO, Player], breakCountAPI: BreakCountAPI[IO, SyncIO, Player], voteAPI: VoteAPI[IO, Player], manaApi: ManaApi[IO, SyncIO, Player], context: RepeatingTaskContext - ): TwoPhasedRepositoryInitialization[F, Player, Deferred[IO, Fiber[IO, Nothing]]] = + ): TwoPhasedRepositoryInitialization[SyncIO, Player, Deferred[IO, Fiber[IO, Nothing]]] = TwoPhasedRepositoryInitialization - .withoutPrefetching[F, Player, Deferred[IO, Fiber[IO, Nothing]]] { player => + .withoutPrefetching[SyncIO, Player, Deferred[IO, Fiber[IO, Nothing]]] { player => for { - promise <- Deferred.in[F, IO, Fiber[IO, Nothing]] - _ <- EffectExtra.runAsyncAndForget[IO, F, Unit] { - fairyRoutine - .start(player) - .toIO - .start(IO.contextShift(context)) - .flatMap(fiber => promise.complete(fiber)) - } + promise <- Deferred.in[SyncIO, IO, Fiber[IO, Nothing]] + _ <- + EffectExtra.runAsyncAndForget[IO, SyncIO, Unit] { + fairyRoutine + .start(player) + .start(IO.contextShift(context)) + .flatMap(fiber => promise.complete(fiber)) + } } yield promise } def finalization[F[_]: Sync, Player] - : RepositoryFinalization[F, Player, Deferred[IO, Fiber[IO, Nothing]]] = - RepositoryFinalization.withoutAnyPersistence[F, Player, Deferred[IO, Fiber[IO, Nothing]]] { - (_, promise) => - EffectExtra.runAsyncAndForget[IO, F, Unit] { + : RepositoryFinalization[SyncIO, Player, Deferred[IO, Fiber[IO, Nothing]]] = + RepositoryFinalization + .withoutAnyPersistence[SyncIO, Player, Deferred[IO, Fiber[IO, Nothing]]] { (_, promise) => + EffectExtra.runAsyncAndForget[IO, SyncIO, Unit] { promise.get.flatMap(_.cancel) } - } + } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index 88e2737e62..ba92aa7ddb 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -2,6 +2,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import cats.effect.{ConcurrentEffect, Sync} +import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ FairyManaRecoveryState, @@ -15,7 +16,9 @@ import org.bukkit.entity.Player import java.time.LocalTime import scala.util.Random -class FairySpeech[F[_]: ConcurrentEffect](implicit fairyAPI: FairyAPI[F, Player]) { +class FairySpeech[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( + implicit fairyAPI: FairyAPI[F, G, Player] +) { import cats.implicits._ @@ -33,9 +36,12 @@ class FairySpeech[F[_]: ConcurrentEffect](implicit fairyAPI: FairyAPI[F, Player] message <- randomMessage(fairyMessages) } yield { val serviceRepository = fairyAPI.fairySpeechServiceRepository(player) - serviceRepository - .makeSpeech(message, fairyAPI.fairyPlaySound(player.getUniqueId).toIO.unsafeRunSync()) - .unsafeRunSync() + ContextCoercion { + serviceRepository.makeSpeech( + message, + fairyAPI.fairyPlaySound(player.getUniqueId).toIO.unsafeRunSync() + ) + }.toIO.unsafeRunSync() } def speechRandomly( @@ -52,10 +58,11 @@ class FairySpeech[F[_]: ConcurrentEffect](implicit fairyAPI: FairyAPI[F, Player] FairyMessageTable.notConsumed } randomMessage(messages(nameCalledByFairy)).map { message => - fairyAPI - .fairySpeechServiceRepository(player) - .makeSpeech(message, fairyAPI.fairyPlaySound(player.getUniqueId).toIO.unsafeRunSync()) - .unsafeRunSync() + ContextCoercion { + fairyAPI + .fairySpeechServiceRepository(player) + .makeSpeech(message, fairyAPI.fairyPlaySound(player.getUniqueId).toIO.unsafeRunSync()) + }.toIO.unsafeRunSync() } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 643717cb0c..5f454f15e3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -1,6 +1,8 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions -import cats.effect.{ConcurrentEffect, IO, SyncIO} +import cats.effect.ConcurrentEffect +import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps +import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.mana.domain.ManaAmount @@ -22,157 +24,159 @@ import scala.util.Random object BukkitRecoveryMana { - def apply(player: Player)( - implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], - fairyAPI: FairyAPI[IO, Player], - voteAPI: VoteAPI[IO, Player], - manaApi: ManaApi[IO, SyncIO, Player], - concurrentEffect: ConcurrentEffect[IO] - ): RecoveryMana[IO] = new RecoveryMana[IO] { - override def recovery: IO[Unit] = - manaApi - .readManaAmount(player) - .map { oldManaAmount => - if (oldManaAmount.isFull) - new FairySpeech[IO] - .speechRandomly(player, FairyManaRecoveryState.full) - .unsafeRunSync() - else { - val uuid = player.getUniqueId - - val eff = for { - seichiAmountData <- breakCountAPI.seichiAmountDataRepository(player).read.toIO - defaultRecoveryManaAmount <- fairyAPI.fairyRecoveryMana(uuid) - chainVoteNumber <- voteAPI.chainVoteDayNumber(uuid) - appleOpenState <- fairyAPI.appleOpenState(uuid) - gachaimoObjectOpt <- MineStackObjectList.findByName("gachaimo") - } yield { - val playerLevel = seichiAmountData.levelCorrespondingToExp - - val playerdata = SeichiAssist.playermap(player.getUniqueId) - val gachaRingoObject = gachaimoObjectOpt.get - val mineStackedGachaRingoAmount = - playerdata.minestack.getStackedAmountOf(gachaRingoObject) - - val isAppleOpenStateIsOpenOROpenALittle = - appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open - val isManaExistsSeventyFivePercent = oldManaAmount.ratioToCap.exists(_ >= 0.75) - - val defaultAmount = Math.pow(playerLevel.level / 10, 2) - - val chainVoteDayNumber = chainVoteNumber.value - // 連続投票を適用した除算量 - val chainVoteDivisionAmount = - if (chainVoteDayNumber >= 30) 2 - else if (chainVoteDayNumber >= 10) 1.2 - else if (chainVoteDayNumber >= 3) 1.25 - else 1 + import cats.implicits._ + + def apply[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]](player: Player)( + implicit breakCountAPI: BreakCountAPI[F, G, Player], + fairyAPI: FairyAPI[F, G, Player], + voteAPI: VoteAPI[F, Player], + manaApi: ManaApi[F, G, Player] + ): RecoveryMana[F] = new RecoveryMana[F] { + override def recovery: F[Unit] = { + ContextCoercion(manaApi.readManaAmount(player)).map { oldManaAmount => + if (oldManaAmount.isFull) + new FairySpeech[F, G] + .speechRandomly(player, FairyManaRecoveryState.full) + .toIO + .unsafeRunSync() + else { + val uuid = player.getUniqueId + + val eff = for { + seichiAmountData <- ContextCoercion( + breakCountAPI.seichiAmountDataRepository(player).read + ) + defaultRecoveryManaAmount <- fairyAPI.fairyRecoveryMana(uuid) + chainVoteNumber <- voteAPI.chainVoteDayNumber(uuid) + appleOpenState <- fairyAPI.appleOpenState(uuid) + } yield { + val playerLevel = seichiAmountData.levelCorrespondingToExp + + val playerdata = SeichiAssist.playermap(player.getUniqueId) + val gachaRingoObject = + MineStackObjectList.findByName("gachaimo").unsafeRunSync().get + val mineStackedGachaRingoAmount = + playerdata.minestack.getStackedAmountOf(gachaRingoObject) + + val isAppleOpenStateIsOpenOROpenALittle = + appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open + val isManaExistsSeventyFivePercent = oldManaAmount.ratioToCap.exists(_ >= 0.75) + + val defaultAmount = Math.pow(playerLevel.level / 10, 2) + + val chainVoteDayNumber = chainVoteNumber.value + // 連続投票を適用した除算量 + val chainVoteDivisionAmount = + if (chainVoteDayNumber >= 30) 2 + else if (chainVoteDayNumber >= 10) 1.2 + else if (chainVoteDayNumber >= 3) 1.25 + else 1 + + // りんごの開放状況を適用した除算量 + val appleOpenStateDivisionAmount = + if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 + else 1 + + // りんごの開放状況まで適用したりんごの消費量 (暫定) + val appleOpenStateReflectedAmount = + (defaultAmount / chainVoteDivisionAmount).toInt / appleOpenStateDivisionAmount + + // 妖精がつまみ食いする量 + val amountEatenByKnob = + if (appleOpenStateReflectedAmount >= 10) + new Random().nextInt(appleOpenStateReflectedAmount / 10) + else 0 + + /* + 最終的に算出されたりんごの消費量 + (現時点では持っているりんごの数を + 考慮していないので消費量は確定していない) + */ + val finallyAppleConsumptionAmount = + Math.max(appleOpenStateReflectedAmount + amountEatenByKnob, 1) + + // りんごの消費量 + val appleConsumptionAmount = + if (appleOpenState == AppleOpenState.NotOpen) { + 0 + } else { + Math.max(finallyAppleConsumptionAmount, mineStackedGachaRingoAmount) + } - // りんごの開放状況を適用した除算量 - val appleOpenStateDivisionAmount = + // マナの回復量を算出する + val recoveryManaAmount = { + val appleOpenStateDivision = { if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 + else if (appleOpenState == AppleOpenState.NotOpen) 4 else 1 + } - // りんごの開放状況まで適用したりんごの消費量 (暫定) - val appleOpenStateReflectedAmount = - (defaultAmount / chainVoteDivisionAmount).toInt / appleOpenStateDivisionAmount - - // 妖精がつまみ食いする量 - val amountEatenByKnob = - if (appleOpenStateReflectedAmount >= 10) - new Random().nextInt(appleOpenStateReflectedAmount / 10) - else 0 - - /* - 最終的に算出されたりんごの消費量 - (現時点では持っているりんごの数を - 考慮していないので消費量は確定していない) - */ - val finallyAppleConsumptionAmount = - Math.max(appleOpenStateReflectedAmount + amountEatenByKnob, 1) - - // りんごの消費量 - val appleConsumptionAmount = - if (appleOpenState == AppleOpenState.NotOpen) { - 0 - } else { - Math.max(finallyAppleConsumptionAmount, mineStackedGachaRingoAmount) - } - - // マナの回復量を算出する - val recoveryManaAmount = { - val appleOpenStateDivision = { - if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 - else if (appleOpenState == AppleOpenState.NotOpen) 4 - else 1 - } - - val reflectedAppleOpenStateAmount = - defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision - - // minestackに入っているりんごの数を適用したマナの回復量 - val reflectedMineStackedAmount = - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { - if (mineStackedGachaRingoAmount == 0) { - reflectedAppleOpenStateAmount / { - if (appleOpenState == AppleOpenState.Open) 4 - else if (appleOpenState == AppleOpenState.OpenALittle) 4 - else 2 - } - } else { - if ((mineStackedGachaRingoAmount / finallyAppleConsumptionAmount) <= 0.5) - (reflectedAppleOpenStateAmount * 0.5).toInt - else - (reflectedAppleOpenStateAmount * mineStackedGachaRingoAmount / finallyAppleConsumptionAmount).toInt + val reflectedAppleOpenStateAmount = + defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision + + // minestackに入っているりんごの数を適用したマナの回復量 + val reflectedMineStackedAmount = + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { + if (mineStackedGachaRingoAmount == 0) { + reflectedAppleOpenStateAmount / { + if (appleOpenState == AppleOpenState.Open) 4 + else if (appleOpenState == AppleOpenState.OpenALittle) 4 + else 2 } - } else reflectedAppleOpenStateAmount + } else { + if ((mineStackedGachaRingoAmount / finallyAppleConsumptionAmount) <= 0.5) + (reflectedAppleOpenStateAmount * 0.5).toInt + else + (reflectedAppleOpenStateAmount * mineStackedGachaRingoAmount / finallyAppleConsumptionAmount).toInt + } + } else reflectedAppleOpenStateAmount + + (reflectedMineStackedAmount - reflectedMineStackedAmount / 100) + + (if (reflectedMineStackedAmount >= 50) + Random.nextInt(reflectedMineStackedAmount / 50) + else 0) + } - (reflectedMineStackedAmount - reflectedMineStackedAmount / 100) + - (if (reflectedMineStackedAmount >= 50) - Random.nextInt(reflectedMineStackedAmount / 50) - else 0) - } + // minestackからりんごを消費する + playerdata + .minestack + .subtractStackedAmountOf(gachaRingoObject, appleConsumptionAmount) - // minestackからりんごを消費する - playerdata - .minestack - .subtractStackedAmountOf(gachaRingoObject, appleConsumptionAmount) + // マナを回復する + ContextCoercion( + manaApi.manaAmount(player).restoreAbsolute(ManaAmount(recoveryManaAmount)) + ).toIO.unsafeRunSync() - // マナを回復する - manaApi - .manaAmount(player) - .restoreAbsolute(ManaAmount(recoveryManaAmount)) + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { + MessageEffect(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") + .apply(player) .unsafeRunSync() + } - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { - MessageEffect(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") - .apply(player) - .unsafeRunSync() - } - - SequentialEffect( - UnfocusedEffect { - new FairySpeech[IO] - .speechRandomly( - player, - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) - FairyManaRecoveryState.notConsumptionApple - else FairyManaRecoveryState.consumptionApple - ) - .unsafeRunSync() - }, - MessageEffect(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), - if (appleConsumptionAmount != 0) - MessageEffect( - s"$RESET$YELLOW${BOLD}あっ!${appleConsumptionAmount}個のがちゃりんごが食べられてる!" + SequentialEffect( + UnfocusedEffect { + new FairySpeech[F, G] + .speechRandomly( + player, + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) + FairyManaRecoveryState.notConsumptionApple + else FairyManaRecoveryState.consumptionApple ) - else MessageEffect(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") - ).apply(player).unsafeRunSync() - } - eff.unsafeRunAsyncAndForget() + .toIO + .unsafeRunSync() + }, + MessageEffect(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), + if (appleConsumptionAmount != 0) + MessageEffect( + s"$RESET$YELLOW${BOLD}あっ!${appleConsumptionAmount}個のがちゃりんごが食べられてる!" + ) + else MessageEffect(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") + ).apply(player).unsafeRunSync() } + eff.toIO.unsafeRunSync() } - .toIO + } + } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index b8b32956b6..b068ba4de6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -25,7 +25,7 @@ object BukkitSummonFairy { def apply(player: Player)( implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], - fairyAPI: FairyAPI[IO, Player], + fairyAPI: FairyAPI[IO, SyncIO, Player], voteAPI: VoteAPI[IO, Player], manaApi: ManaApi[IO, SyncIO, Player], concurrentEffect: ConcurrentEffect[IO] @@ -60,7 +60,7 @@ object BukkitSummonFairy { SequentialEffect( UnfocusedEffect { eff.unsafeRunSync() - new FairySpeech().summonSpeech(player).unsafeRunSync() + new FairySpeech[IO, SyncIO]().summonSpeech(player).unsafeRunSync() }, MessageEffect( List( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala index dfc3a57457..3d746b7ef1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway -import cats.effect.{IO, SyncIO} +import cats.effect.Sync import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage import com.github.unchama.targetedeffect.commandsender.MessageEffect @@ -9,16 +9,14 @@ import org.bukkit.ChatColor.{AQUA, BOLD, RESET} import org.bukkit.Sound import org.bukkit.entity.Player -class BukkitFairySpeechGateway(player: Player) extends FairySpeechGateway[SyncIO] { +class BukkitFairySpeechGateway[G[_]: Sync](player: Player) extends FairySpeechGateway[G] { - override def sendMessage(fairyMessage: FairyMessage): SyncIO[Unit] = { - MessageEffect(s"$AQUA$BOLD<マナ妖精>$RESET${fairyMessage.message}") - .run(player) - .runAsync(_ => IO.unit) + override def sendMessage(fairyMessage: FairyMessage): G[Unit] = Sync[G].delay { + MessageEffect(s"$AQUA$BOLD<マナ妖精>$RESET${fairyMessage.message}").run(player).unsafeRunSync() } - override def playSpeechSound: SyncIO[Unit] = { - FocusedSoundEffect(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f).run(player).runAsync(_ => IO.unit) + override def playSpeechSound: G[Unit] = Sync[G].delay { + FocusedSoundEffect(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f).run(player).unsafeRunSync() } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index 6e3318da07..1e5f1e5ff3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -1,7 +1,8 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines -import cats.effect.{ConcurrentEffect, IO, SyncIO, Timer} +import cats.effect.{ConcurrentEffect, IO, Sync, SyncEffect, SyncIO, Timer} import com.github.unchama.concurrent.{RepeatingRoutine, RepeatingTaskContext} +import com.github.unchama.generic.ContextCoercion import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI @@ -14,15 +15,16 @@ import org.bukkit.entity.Player import scala.concurrent.duration.FiniteDuration -object BukkitFairyRoutine extends FairyRoutine[IO, SyncIO, Player] { +class BukkitFairyRoutine[F[_]: ConcurrentEffect, G[_]: SyncEffect: ContextCoercion[*[_], F]] + extends FairyRoutine[F, G, Player] { override def start(player: Player)( - implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], - fairyAPI: FairyAPI[IO, Player], - voteAPI: VoteAPI[IO, Player], - manaApi: ManaApi[IO, SyncIO, Player], + implicit breakCountAPI: BreakCountAPI[F, G, Player], + fairyAPI: FairyAPI[F, G, Player], + voteAPI: VoteAPI[F, Player], + manaApi: ManaApi[F, G, Player], context: RepeatingTaskContext - ): IO[Nothing] = { + ): F[Nothing] = { val repeatInterval: IO[FiniteDuration] = IO { import scala.concurrent.duration._ @@ -31,17 +33,22 @@ object BukkitFairyRoutine extends FairyRoutine[IO, SyncIO, Player] { } implicit val timer: Timer[IO] = IO.timer(context) - implicit val ioCE: ConcurrentEffect[IO] = - IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) implicit val onMainThread: OnMinecraftServerThread[IO] = PluginExecutionContexts.onMainThread - RepeatingRoutine.permanentRoutine( - repeatInterval, - onMainThread.runAction { - BukkitRecoveryMana(player).recovery.runAsync(_ => IO.unit) - } - ) + + Sync[F].delay { + RepeatingRoutine + .permanentRoutine( + repeatInterval, + onMainThread.runAction { + SyncIO { + BukkitRecoveryMana[F, G](player).recovery + } + } + ) + .unsafeRunSync() + } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala index a74eafea19..141c0bc406 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala @@ -17,7 +17,7 @@ class FairySpawnRequest[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F], def spawnRequest(player: Player)( implicit breakCountAPI: BreakCountAPI[F, G, Player], - fairyAPI: FairyAPI[F, Player], + fairyAPI: FairyAPI[F, G, Player], voteAPI: VoteAPI[F, Player] ): F[FairySpawnRequestResult] = { val seichiAmountRepository = ContextCoercion( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyLore.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyLore.scala index b0d5b0846c..4354028677 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyLore.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyLore.scala @@ -2,4 +2,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain. import cats.data.NonEmptyList -case class FairyLore(lore: NonEmptyList[String]) +case class FairyLore(lore: NonEmptyList[String]) { + + object toIO +} From d925c066b0df260f6af2b965f92e72b824e0d4e3 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 28 Jul 2022 19:04:36 +0900 Subject: [PATCH 074/482] =?UTF-8?q?[Fix]=E5=9B=9E=E5=BE=A9=E3=83=AB?= =?UTF-8?q?=E3=83=BC=E3=83=86=E3=82=A3=E3=83=B3=E3=81=8C=E8=B5=B7=E5=8B=95?= =?UTF-8?q?=E3=81=97=E3=81=AA=E3=81=84=E4=B8=8D=E5=85=B7=E5=90=88=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 2 +- .../bukkit/routines/BukkitFairyRoutine.scala | 39 ++++++++----------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 4a2e225651..1774a6af03 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -46,7 +46,7 @@ object System { implicit val fairySpeechGatewayProvider: Player => FairySpeechGateway[SyncIO] = new BukkitFairySpeechGateway[SyncIO](_) implicit val fairyRoutine: FairyRoutine[IO, SyncIO, Player] = - new BukkitFairyRoutine[IO, SyncIO] + new BukkitFairyRoutine for { speechServiceRepositoryControls <- { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index 1e5f1e5ff3..d563a1092e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -1,8 +1,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines -import cats.effect.{ConcurrentEffect, IO, Sync, SyncEffect, SyncIO, Timer} +import cats.effect.{ConcurrentEffect, IO, SyncIO, Timer} import com.github.unchama.concurrent.{RepeatingRoutine, RepeatingTaskContext} -import com.github.unchama.generic.ContextCoercion import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI @@ -15,16 +14,14 @@ import org.bukkit.entity.Player import scala.concurrent.duration.FiniteDuration -class BukkitFairyRoutine[F[_]: ConcurrentEffect, G[_]: SyncEffect: ContextCoercion[*[_], F]] - extends FairyRoutine[F, G, Player] { - +class BukkitFairyRoutine extends FairyRoutine[IO, SyncIO, Player] { override def start(player: Player)( - implicit breakCountAPI: BreakCountAPI[F, G, Player], - fairyAPI: FairyAPI[F, G, Player], - voteAPI: VoteAPI[F, Player], - manaApi: ManaApi[F, G, Player], + implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], + fairyAPI: FairyAPI[IO, SyncIO, Player], + voteAPI: VoteAPI[IO, Player], + manaApi: ManaApi[IO, SyncIO, Player], context: RepeatingTaskContext - ): F[Nothing] = { + ): IO[Nothing] = { val repeatInterval: IO[FiniteDuration] = IO { import scala.concurrent.duration._ @@ -37,18 +34,14 @@ class BukkitFairyRoutine[F[_]: ConcurrentEffect, G[_]: SyncEffect: ContextCoerci implicit val onMainThread: OnMinecraftServerThread[IO] = PluginExecutionContexts.onMainThread - Sync[F].delay { - RepeatingRoutine - .permanentRoutine( - repeatInterval, - onMainThread.runAction { - SyncIO { - BukkitRecoveryMana[F, G](player).recovery - } - } - ) - .unsafeRunSync() - } - } + implicit val ioCE: ConcurrentEffect[IO] = + IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) + RepeatingRoutine.permanentRoutine( + repeatInterval, + onMainThread.runAction { + BukkitRecoveryMana[IO, SyncIO](player).recovery.runAsync(_ => IO.unit) + } + ) + } } From 3f0a7b6402f4f08ffff4d7e367d6b6517c6c0ae8 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 28 Jul 2022 19:07:38 +0900 Subject: [PATCH 075/482] =?UTF-8?q?[Fix]=E5=A6=96=E7=B2=BE=E3=81=8C?= =?UTF-8?q?=E5=8F=AC=E5=96=9A=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=81=A8=E3=81=8D=E3=81=AF=E5=9B=9E=E5=BE=A9=E3=81=AE?= =?UTF-8?q?=E3=83=AB=E3=83=BC=E3=83=86=E3=82=A3=E3=83=B3=E3=81=A7=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92=E8=A1=8C=E3=82=8F=E3=81=AA=E3=81=84=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/actions/BukkitRecoveryMana.scala | 269 +++++++++--------- 1 file changed, 137 insertions(+), 132 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 5f454f15e3..202893c94c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions -import cats.effect.ConcurrentEffect +import cats.effect.{ConcurrentEffect, Sync} import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI @@ -12,7 +12,8 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applicat import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleOpenState, - FairyManaRecoveryState + FairyManaRecoveryState, + FairyUsingState } import com.github.unchama.seichiassist.{MineStackObjectList, SeichiAssist} import com.github.unchama.targetedeffect.commandsender.MessageEffect @@ -33,147 +34,151 @@ object BukkitRecoveryMana { manaApi: ManaApi[F, G, Player] ): RecoveryMana[F] = new RecoveryMana[F] { override def recovery: F[Unit] = { - ContextCoercion(manaApi.readManaAmount(player)).map { oldManaAmount => - if (oldManaAmount.isFull) - new FairySpeech[F, G] - .speechRandomly(player, FairyManaRecoveryState.full) - .toIO - .unsafeRunSync() - else { - val uuid = player.getUniqueId - - val eff = for { - seichiAmountData <- ContextCoercion( - breakCountAPI.seichiAmountDataRepository(player).read - ) - defaultRecoveryManaAmount <- fairyAPI.fairyRecoveryMana(uuid) - chainVoteNumber <- voteAPI.chainVoteDayNumber(uuid) - appleOpenState <- fairyAPI.appleOpenState(uuid) - } yield { - val playerLevel = seichiAmountData.levelCorrespondingToExp - - val playerdata = SeichiAssist.playermap(player.getUniqueId) - val gachaRingoObject = - MineStackObjectList.findByName("gachaimo").unsafeRunSync().get - val mineStackedGachaRingoAmount = - playerdata.minestack.getStackedAmountOf(gachaRingoObject) - - val isAppleOpenStateIsOpenOROpenALittle = - appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open - val isManaExistsSeventyFivePercent = oldManaAmount.ratioToCap.exists(_ >= 0.75) - - val defaultAmount = Math.pow(playerLevel.level / 10, 2) - - val chainVoteDayNumber = chainVoteNumber.value - // 連続投票を適用した除算量 - val chainVoteDivisionAmount = - if (chainVoteDayNumber >= 30) 2 - else if (chainVoteDayNumber >= 10) 1.2 - else if (chainVoteDayNumber >= 3) 1.25 - else 1 - - // りんごの開放状況を適用した除算量 - val appleOpenStateDivisionAmount = - if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 - else 1 - - // りんごの開放状況まで適用したりんごの消費量 (暫定) - val appleOpenStateReflectedAmount = - (defaultAmount / chainVoteDivisionAmount).toInt / appleOpenStateDivisionAmount - - // 妖精がつまみ食いする量 - val amountEatenByKnob = - if (appleOpenStateReflectedAmount >= 10) - new Random().nextInt(appleOpenStateReflectedAmount / 10) - else 0 - - /* - 最終的に算出されたりんごの消費量 - (現時点では持っているりんごの数を - 考慮していないので消費量は確定していない) - */ - val finallyAppleConsumptionAmount = - Math.max(appleOpenStateReflectedAmount + amountEatenByKnob, 1) - - // りんごの消費量 - val appleConsumptionAmount = - if (appleOpenState == AppleOpenState.NotOpen) { - 0 - } else { - Math.max(finallyAppleConsumptionAmount, mineStackedGachaRingoAmount) - } + if (fairyAPI.fairyUsingState(player).toIO.unsafeRunSync() == FairyUsingState.NotUsing) { + Sync[F].unit + } else { + ContextCoercion(manaApi.readManaAmount(player)).map { oldManaAmount => + if (oldManaAmount.isFull) { + new FairySpeech[F, G] + .speechRandomly(player, FairyManaRecoveryState.full) + .toIO + .unsafeRunSync() + } else { + val uuid = player.getUniqueId + + val eff = for { + seichiAmountData <- ContextCoercion( + breakCountAPI.seichiAmountDataRepository(player).read + ) + defaultRecoveryManaAmount <- fairyAPI.fairyRecoveryMana(uuid) + chainVoteNumber <- voteAPI.chainVoteDayNumber(uuid) + appleOpenState <- fairyAPI.appleOpenState(uuid) + } yield { + val playerLevel = seichiAmountData.levelCorrespondingToExp + + val playerdata = SeichiAssist.playermap(player.getUniqueId) + val gachaRingoObject = + MineStackObjectList.findByName("gachaimo").unsafeRunSync().get + val mineStackedGachaRingoAmount = + playerdata.minestack.getStackedAmountOf(gachaRingoObject) + + val isAppleOpenStateIsOpenOROpenALittle = + appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open + val isManaExistsSeventyFivePercent = oldManaAmount.ratioToCap.exists(_ >= 0.75) + + val defaultAmount = Math.pow(playerLevel.level / 10, 2) + + val chainVoteDayNumber = chainVoteNumber.value + // 連続投票を適用した除算量 + val chainVoteDivisionAmount = + if (chainVoteDayNumber >= 30) 2 + else if (chainVoteDayNumber >= 10) 1.2 + else if (chainVoteDayNumber >= 3) 1.25 + else 1 - // マナの回復量を算出する - val recoveryManaAmount = { - val appleOpenStateDivision = { + // りんごの開放状況を適用した除算量 + val appleOpenStateDivisionAmount = if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 - else if (appleOpenState == AppleOpenState.NotOpen) 4 else 1 - } - val reflectedAppleOpenStateAmount = - defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision - - // minestackに入っているりんごの数を適用したマナの回復量 - val reflectedMineStackedAmount = - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { - if (mineStackedGachaRingoAmount == 0) { - reflectedAppleOpenStateAmount / { - if (appleOpenState == AppleOpenState.Open) 4 - else if (appleOpenState == AppleOpenState.OpenALittle) 4 - else 2 + // りんごの開放状況まで適用したりんごの消費量 (暫定) + val appleOpenStateReflectedAmount = + (defaultAmount / chainVoteDivisionAmount).toInt / appleOpenStateDivisionAmount + + // 妖精がつまみ食いする量 + val amountEatenByKnob = + if (appleOpenStateReflectedAmount >= 10) + new Random().nextInt(appleOpenStateReflectedAmount / 10) + else 0 + + /* + 最終的に算出されたりんごの消費量 + (現時点では持っているりんごの数を + 考慮していないので消費量は確定していない) + */ + val finallyAppleConsumptionAmount = + Math.max(appleOpenStateReflectedAmount + amountEatenByKnob, 1) + + // りんごの消費量 + val appleConsumptionAmount = + if (appleOpenState == AppleOpenState.NotOpen) { + 0 + } else { + Math.max(finallyAppleConsumptionAmount, mineStackedGachaRingoAmount) + } + + // マナの回復量を算出する + val recoveryManaAmount = { + val appleOpenStateDivision = { + if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 + else if (appleOpenState == AppleOpenState.NotOpen) 4 + else 1 + } + + val reflectedAppleOpenStateAmount = + defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision + + // minestackに入っているりんごの数を適用したマナの回復量 + val reflectedMineStackedAmount = + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { + if (mineStackedGachaRingoAmount == 0) { + reflectedAppleOpenStateAmount / { + if (appleOpenState == AppleOpenState.Open) 4 + else if (appleOpenState == AppleOpenState.OpenALittle) 4 + else 2 + } + } else { + if ((mineStackedGachaRingoAmount / finallyAppleConsumptionAmount) <= 0.5) + (reflectedAppleOpenStateAmount * 0.5).toInt + else + (reflectedAppleOpenStateAmount * mineStackedGachaRingoAmount / finallyAppleConsumptionAmount).toInt } - } else { - if ((mineStackedGachaRingoAmount / finallyAppleConsumptionAmount) <= 0.5) - (reflectedAppleOpenStateAmount * 0.5).toInt - else - (reflectedAppleOpenStateAmount * mineStackedGachaRingoAmount / finallyAppleConsumptionAmount).toInt - } - } else reflectedAppleOpenStateAmount - - (reflectedMineStackedAmount - reflectedMineStackedAmount / 100) + - (if (reflectedMineStackedAmount >= 50) - Random.nextInt(reflectedMineStackedAmount / 50) - else 0) - } + } else reflectedAppleOpenStateAmount - // minestackからりんごを消費する - playerdata - .minestack - .subtractStackedAmountOf(gachaRingoObject, appleConsumptionAmount) + (reflectedMineStackedAmount - reflectedMineStackedAmount / 100) + + (if (reflectedMineStackedAmount >= 50) + Random.nextInt(reflectedMineStackedAmount / 50) + else 0) + } - // マナを回復する - ContextCoercion( - manaApi.manaAmount(player).restoreAbsolute(ManaAmount(recoveryManaAmount)) - ).toIO.unsafeRunSync() + // minestackからりんごを消費する + playerdata + .minestack + .subtractStackedAmountOf(gachaRingoObject, appleConsumptionAmount) - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { - MessageEffect(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") - .apply(player) - .unsafeRunSync() - } + // マナを回復する + ContextCoercion( + manaApi.manaAmount(player).restoreAbsolute(ManaAmount(recoveryManaAmount)) + ).toIO.unsafeRunSync() - SequentialEffect( - UnfocusedEffect { - new FairySpeech[F, G] - .speechRandomly( - player, - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) - FairyManaRecoveryState.notConsumptionApple - else FairyManaRecoveryState.consumptionApple - ) - .toIO + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { + MessageEffect(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") + .apply(player) .unsafeRunSync() - }, - MessageEffect(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), - if (appleConsumptionAmount != 0) - MessageEffect( - s"$RESET$YELLOW${BOLD}あっ!${appleConsumptionAmount}個のがちゃりんごが食べられてる!" - ) - else MessageEffect(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") - ).apply(player).unsafeRunSync() + } + + SequentialEffect( + UnfocusedEffect { + new FairySpeech[F, G] + .speechRandomly( + player, + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) + FairyManaRecoveryState.notConsumptionApple + else FairyManaRecoveryState.consumptionApple + ) + .toIO + .unsafeRunSync() + }, + MessageEffect(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), + if (appleConsumptionAmount != 0) + MessageEffect( + s"$RESET$YELLOW${BOLD}あっ!${appleConsumptionAmount}個のがちゃりんごが食べられてる!" + ) + else MessageEffect(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") + ).apply(player).unsafeRunSync() + } + eff.toIO.unsafeRunSync() } - eff.toIO.unsafeRunSync() } } } From 0a976cb337b0240503bb27a20ea87de27818dd26 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 28 Jul 2022 19:48:16 +0900 Subject: [PATCH 076/482] =?UTF-8?q?[Add]=E5=A6=96=E7=B2=BE=E3=81=8C?= =?UTF-8?q?=E9=A3=9F=E3=81=B9=E3=81=9F=E3=82=8A=E3=82=93=E3=81=94=E3=81=AE?= =?UTF-8?q?=E6=95=B0=E3=82=92DB=E3=81=AB=E8=A8=98=E9=8C=B2=E3=81=99?= =?UTF-8?q?=E3=82=8BAPI=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/FairyAPI.scala | 10 ++++++ .../vote/subsystems/fairy/System.scala | 12 +++++++ .../bukkit/actions/BukkitRecoveryMana.scala | 7 ++++ .../fairy/domain/FairyPersistence.scala | 11 +++++++ .../fairy/domain/property/AppleAmount.scala | 5 +++ .../infrastructure/JdbcFairyPersistence.scala | 32 +++++++++++++++---- 6 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAmount.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index efe9370221..e18b572bf9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -41,6 +41,11 @@ trait FairyWriteAPI[F[_], Player] { */ def updateFairyEndTime(player: Player, fairyEndTime: FairyEndTime): F[Unit] + /** + * 妖精が食べたりんごの数を増加させる + */ + def increaseAppleAteByFairy(uuid: UUID, appleAmount: AppleAmount): F[Unit] + } object FairyWriteAPI { @@ -81,6 +86,11 @@ trait FairyReadAPI[F[_], G[_], Player] { */ def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] + /** + * 妖精が食べたりんごの量を取得する + */ + def appleAteByFairy(uuid: UUID): F[AppleAmount] + /** * 妖精の音を鳴らすかどうか保持するようのリポジトリ * ※永続化は必要ない diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 1774a6af03..34bdd213d7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -132,6 +132,18 @@ object System { override val fairySpeechServiceRepository : PlayerDataRepository[FairySpeechService[SyncIO]] = speechServiceRepositoryControls.repository + + override def increaseAppleAteByFairy( + uuid: UUID, + appleAmount: AppleAmount + ): IO[Unit] = + persistence.increaseAppleAteByFairy(uuid, appleAmount) + + /** + * 妖精が食べたりんごの量を取得する + */ + override def appleAteByFairy(uuid: UUID): IO[AppleAmount] = + persistence.appleAteByFairy(uuid) } override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 202893c94c..36015edac1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -11,6 +11,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.RecoveryMana import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + AppleAmount, AppleOpenState, FairyManaRecoveryState, FairyUsingState @@ -146,6 +147,12 @@ object BukkitRecoveryMana { .minestack .subtractStackedAmountOf(gachaRingoObject, appleConsumptionAmount) + // 消費したりんごの量を保存する + fairyAPI + .increaseAppleAteByFairy(uuid, AppleAmount(appleConsumptionAmount.toInt)) + .toIO + .unsafeRunSync() + // マナを回復する ContextCoercion( manaApi.manaAmount(player).restoreAbsolute(ManaAmount(recoveryManaAmount)) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index 9e6e51ee22..575bbb658e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -1,6 +1,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + AppleAmount, AppleOpenState, FairyEndTime, FairyRecoveryMana, @@ -62,4 +63,14 @@ trait FairyPersistence[F[_]] { */ def fairyEndTime(uuid: UUID): F[Option[FairyEndTime]] + /** + * 妖精が食べたりんごの量を増加させる + */ + def increaseAppleAteByFairy(uuid: UUID, appleAmount: AppleAmount): F[Unit] + + /** + * 妖精が食べたりんごの量を取得する + */ + def appleAteByFairy(uuid: UUID): F[AppleAmount] + } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAmount.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAmount.scala new file mode 100644 index 0000000000..5bf4fd31d5 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAmount.scala @@ -0,0 +1,5 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property + +case class AppleAmount(amount: Int) { + require(amount >= 0) +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index de7f005784..0df5428824 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -2,13 +2,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrast import cats.effect.Sync import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain._ -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - AppleOpenState, - FairyEndTime, - FairyRecoveryMana, - FairySummonCost, - FairyUsingState -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} import java.util.UUID @@ -149,4 +143,28 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } + /** + * 妖精が食べたりんごの量を増加させる + */ + override def increaseAppleAteByFairy(uuid: UUID, appleAmount: AppleAmount): F[Unit] = + Sync[F].delay { + DB.localTx { implicit session => + sql"UPDATE playerdata SET p_apple = p_apple + ${appleAmount.amount} WHERE uuid = ${uuid.toString}" + .execute() + .apply() + } + } + + /** + * 妖精が食べたりんごの量を取得する + */ + override def appleAteByFairy(uuid: UUID): F[AppleAmount] = Sync[F].delay { + DB.readOnly { implicit session => + val appleAmountOpt = sql"SELECT p_apple FROM playerdata WHERE uuid = ${uuid.toString}" + .map(_.int("p_apple")) + .single() + .apply() + AppleAmount(appleAmountOpt.get) + } + } } From 6124d36408eabc17baeeefa1fb117ffeee291ccd Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 28 Jul 2022 20:34:55 +0900 Subject: [PATCH 077/482] =?UTF-8?q?[Add]=E8=87=AA=E5=88=86=E3=81=AE?= =?UTF-8?q?=E5=A6=96=E7=B2=BE=E3=81=AB=E9=A3=9F=E3=81=B9=E3=81=95=E3=81=9B?= =?UTF-8?q?=E3=81=9F=E3=82=8A=E3=82=93=E3=81=94=E3=81=AE=E9=87=8F=E3=81=AE?= =?UTF-8?q?=E9=A0=86=E4=BD=8D=E3=82=92=E8=BF=94=E3=81=99API=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 29 ++++++++++++++----- .../vote/subsystems/fairy/FairyAPI.scala | 5 ++++ .../subsystems/fairy/bukkit/FairySpeech.scala | 10 +++++++ .../fairy/domain/FairyPersistence.scala | 6 ++++ .../domain/property/AppleAteByFairyRank.scala | 5 ++++ .../infrastructure/JdbcFairyPersistence.scala | 13 +++++++++ 6 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRank.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 8ec1be5903..859aa46237 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -15,6 +15,7 @@ import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleOpenState, @@ -275,14 +276,7 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( UnfocusedEffect { - fairyAPI.fairyEndTime(player).unsafeRunSync().get.endTimeOpt.get - -// BukkitFairySpeak[IO] -// .speak( -// player, -// FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。") -// ) -// .unsafeRunAsyncAndForget() + new FairySpeech[IO, SyncIO]().speechEndTime(player).unsafeRunSync() }, closeInventoryEffect ) @@ -290,5 +284,24 @@ object VoteMenu extends Menu { ) } + def gachaRingoInformation(player: Player): Button = { + Button( + new IconItemStackBuilder(Material.GOLDEN_APPLE) + .title(s"$YELLOW$UNDERLINE$BOLD㊙ がちゃりんご情報 ㊙") + .lore( + List( + s"$RESET$RED$BOLD※ニンゲンに見られないように気を付けること!", + s"$RESET$RED$BOLD 毎日大妖精からデータを更新すること!", + "", + s"$RESET$GOLD${BOLD}昨日までにがちゃりんごを", + s"$RESET$GOLD${BOLD}たくさんくれたニンゲンたち", + s"$RESET${DARK_GRAY}召喚されたらラッキーだよ!" + ) + ) + .enchanted() + .build() + ) + } + } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index e18b572bf9..65a2077a27 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -107,6 +107,11 @@ trait FairyReadAPI[F[_], G[_], Player] { */ def fairyEndTime(player: Player): F[Option[FairyEndTime]] + /** + * 自分の妖精に食べさせたりんごの量の順位を返す + */ + def appleAteByFairyMyRanking(player: Player): F[AppleAteByFairyRank] + } object FairyReadAPI { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index ba92aa7ddb..856c2b3294 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -66,6 +66,16 @@ class FairySpeech[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( } } + def speechEndTime(player: Player): F[Unit] = for { + endTimeOpt <- fairyAPI.fairyEndTime(player) + playSound <- fairyAPI.fairyPlaySound(player.getUniqueId) + } yield { + val endTime = endTimeOpt.get.endTimeOpt.get + fairyAPI + .fairySpeechServiceRepository(player) + .makeSpeech(FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。"), playSound) + } + private def randomMessage(fairyMessages: FairyMessages): F[FairyMessage] = Sync[F].delay { val messages = fairyMessages.messages messages(Random.nextInt(messages.size)) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index 575bbb658e..f02216e418 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -2,6 +2,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleAmount, + AppleAteByFairyRank, AppleOpenState, FairyEndTime, FairyRecoveryMana, @@ -73,4 +74,9 @@ trait FairyPersistence[F[_]] { */ def appleAteByFairy(uuid: UUID): F[AppleAmount] + /** + * 自分の妖精に食べさせたりんごの量の順位を返す + */ + def appleAteByFairyMyRanking(uuid: UUID): F[AppleAteByFairyRank] + } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRank.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRank.scala new file mode 100644 index 0000000000..ed9cf8403d --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRank.scala @@ -0,0 +1,5 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property + +case class AppleAteByFairyRank(rank: Int) { + require(rank >= 1) +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 0df5428824..9a2481f203 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -167,4 +167,17 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { AppleAmount(appleAmountOpt.get) } } + + /** + * 自分の妖精に食べさせたりんごの量の順位を返す + */ + override def appleAteByFairyMyRanking(uuid: UUID): F[AppleAteByFairyRank] = Sync[F].delay { + DB.readOnly { implicit session => + val rank = sql"SELECT name,p_apple,COUNT(*) AS rank FROM playerdata;" + .map(_.int("rank")) + .single() + .apply() + AppleAteByFairyRank(rank.get) + } + } } From 2b451ffe9ecc3aeb2c5e32ee09f2353dd3e9581f Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 28 Jul 2022 21:26:37 +0900 Subject: [PATCH 078/482] =?UTF-8?q?[Add]=E5=A6=96=E7=B2=BE=E3=81=AB?= =?UTF-8?q?=E9=A3=9F=E3=81=B9=E3=81=95=E3=81=9B=E3=81=9F=E3=83=AA=E3=83=B3?= =?UTF-8?q?=E3=82=B4=E3=81=AE=E6=95=B0=E3=81=AETOP4=E3=82=92=E6=8C=81?= =?UTF-8?q?=E3=81=A3=E3=81=A6=E3=81=8F=E3=82=8BAPi=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/FairyAPI.scala | 5 +++++ .../vote/subsystems/fairy/System.scala | 14 ++++++++++++++ .../fairy/domain/FairyPersistence.scala | 6 ++++++ .../property/AppleAteByFairyRankTopFour.scala | 8 ++++++++ .../infrastructure/JdbcFairyPersistence.scala | 19 ++++++++++++++++++- 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRankTopFour.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 65a2077a27..2e03b0e477 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -112,6 +112,11 @@ trait FairyReadAPI[F[_], G[_], Player] { */ def appleAteByFairyMyRanking(player: Player): F[AppleAteByFairyRank] + /** + * 妖精に食べさせたりんごの量の順位上位3件を返す + */ + def appleAteByFairyRankingTopThree(player: Player): F[AppleAteByFairyRankTopFour] + } object FairyReadAPI { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 34bdd213d7..fd72c40a28 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -144,6 +144,20 @@ object System { */ override def appleAteByFairy(uuid: UUID): IO[AppleAmount] = persistence.appleAteByFairy(uuid) + + /** + * 自分の妖精に食べさせたりんごの量の順位を返す + */ + override def appleAteByFairyMyRanking(player: Player): IO[AppleAteByFairyRank] = + persistence.appleAteByFairyMyRanking(player.getUniqueId) + + /** + * 妖精に食べさせたりんごの量の順位上位3件を返す + */ + override def appleAteByFairyRankingTopThree( + player: Player + ): IO[AppleAteByFairyRankTopFour] = + persistence.appleAteByFairyRankingTopFour(player.getUniqueId) } override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index f02216e418..6742b70216 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -3,6 +3,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleAmount, AppleAteByFairyRank, + AppleAteByFairyRankTopFour, AppleOpenState, FairyEndTime, FairyRecoveryMana, @@ -79,4 +80,9 @@ trait FairyPersistence[F[_]] { */ def appleAteByFairyMyRanking(uuid: UUID): F[AppleAteByFairyRank] + /** + * 妖精に食べさせたりんごの量の順位上位4件を返す + */ + def appleAteByFairyRankingTopFour(uuid: UUID): F[AppleAteByFairyRankTopFour] + } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRankTopFour.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRankTopFour.scala new file mode 100644 index 0000000000..afce654467 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRankTopFour.scala @@ -0,0 +1,8 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property + +case class AppleAteByFairyRankTopFour( + one: AppleAteByFairyRank, + two: Option[AppleAteByFairyRank], + three: Option[AppleAteByFairyRank], + four: Option[AppleAteByFairyRank] +) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 9a2481f203..48c61b3c5b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -173,11 +173,28 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { */ override def appleAteByFairyMyRanking(uuid: UUID): F[AppleAteByFairyRank] = Sync[F].delay { DB.readOnly { implicit session => - val rank = sql"SELECT name,p_apple,COUNT(*) AS rank FROM playerdata;" + val rank = sql"SELECT name,p_apple,COUNT(*) AS rank FROM playerdata ORDER BY DESC;" .map(_.int("rank")) .single() .apply() AppleAteByFairyRank(rank.get) } } + + /** + * 妖精に食べさせたりんごの量の順位上位4件を返す + */ + override def appleAteByFairyRankingTopFour(uuid: UUID): F[AppleAteByFairyRankTopFour] = + Sync[F].delay { + DB.readOnly { implicit session => + val topFour = + sql"SELECT name,p_apple,COUNT(*) AS rank FROM playerdata ORDER BY DESC LIMIT 4;" + .map(_.intOpt("rank")) + .toList() + .apply() + .map(_.map(AppleAteByFairyRank)) + + AppleAteByFairyRankTopFour(topFour.head.get, topFour(1), topFour(2), topFour(3)) + } + } } From fc3e5d412d221a91e71f506c24bd2c5dca224ef3 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 28 Jul 2022 22:00:49 +0900 Subject: [PATCH 079/482] =?UTF-8?q?[Add]gachaRingoInformation=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 28 ++++++++++++++-- .../vote/subsystems/fairy/FairyAPI.scala | 9 ++++-- .../vote/subsystems/fairy/System.scala | 14 +++----- .../fairy/domain/FairyPersistence.scala | 5 +++ .../domain/property/AppleAteByFairyRank.scala | 2 +- .../infrastructure/JdbcFairyPersistence.scala | 32 +++++++++++++++---- 6 files changed, 69 insertions(+), 21 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 859aa46237..fae378024a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -284,7 +284,9 @@ object VoteMenu extends Menu { ) } - def gachaRingoInformation(player: Player): Button = { + def gachaRingoInformation( + player: Player + )(fairyAPI: FairyAPI[IO, SyncIO, Player]): Button = { Button( new IconItemStackBuilder(Material.GOLDEN_APPLE) .title(s"$YELLOW$UNDERLINE$BOLD㊙ がちゃりんご情報 ㊙") @@ -296,7 +298,29 @@ object VoteMenu extends Menu { s"$RESET$GOLD${BOLD}昨日までにがちゃりんごを", s"$RESET$GOLD${BOLD}たくさんくれたニンゲンたち", s"$RESET${DARK_GRAY}召喚されたらラッキーだよ!" - ) + ) ++ { + // TOP4のランキングロール + val topFour = fairyAPI.appleAteByFairyRankingTopFour(player).unsafeRunSync() + List(Some(topFour.one), topFour.two, topFour.three, topFour.four).flatMap { + rankDataOpt => + if (rankDataOpt.nonEmpty) { + val rankData = rankDataOpt.get + List( + s"${GRAY}たくさんくれたニンゲン第${rankData.rank}位!", + s"${GRAY}なまえ:${rankData.name} りんご:${rankData.appleAmount.amount}個" + ) + } else Nil + } + } ++ { + val myRank = fairyAPI.appleAteByFairyMyRanking(player).unsafeRunSync() + List( + s"${AQUA}ぜーんぶで${fairyAPI.allEatenAppleAmount.unsafeRunSync().amount}個もらえた!", + "", + s"$GREEN↓呼び出したニンゲンの情報↓", + s"${GREEN}今までに${myRank.appleAmount.amount}個もらった", + s"${GREEN}ニンゲンの中では${myRank.rank}番目にたくさんくれる!" + ) + } ) .enchanted() .build() diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 2e03b0e477..025aea9bde 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -113,9 +113,14 @@ trait FairyReadAPI[F[_], G[_], Player] { def appleAteByFairyMyRanking(player: Player): F[AppleAteByFairyRank] /** - * 妖精に食べさせたりんごの量の順位上位3件を返す + * 妖精に食べさせたりんごの量の順位上位4件を返す */ - def appleAteByFairyRankingTopThree(player: Player): F[AppleAteByFairyRankTopFour] + def appleAteByFairyRankingTopFour(player: Player): F[AppleAteByFairyRankTopFour] + + /** + * 妖精が食べたりんごの合計数を返す + */ + def allEatenAppleAmount: F[AppleAmount] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index fd72c40a28..c84b21d990 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -139,25 +139,19 @@ object System { ): IO[Unit] = persistence.increaseAppleAteByFairy(uuid, appleAmount) - /** - * 妖精が食べたりんごの量を取得する - */ override def appleAteByFairy(uuid: UUID): IO[AppleAmount] = persistence.appleAteByFairy(uuid) - /** - * 自分の妖精に食べさせたりんごの量の順位を返す - */ override def appleAteByFairyMyRanking(player: Player): IO[AppleAteByFairyRank] = persistence.appleAteByFairyMyRanking(player.getUniqueId) - /** - * 妖精に食べさせたりんごの量の順位上位3件を返す - */ - override def appleAteByFairyRankingTopThree( + override def appleAteByFairyRankingTopFour( player: Player ): IO[AppleAteByFairyRankTopFour] = persistence.appleAteByFairyRankingTopFour(player.getUniqueId) + + override def allEatenAppleAmount: IO[AppleAmount] = + persistence.allEatenAppleAmount } override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index 6742b70216..78b8dfbc68 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -85,4 +85,9 @@ trait FairyPersistence[F[_]] { */ def appleAteByFairyRankingTopFour(uuid: UUID): F[AppleAteByFairyRankTopFour] + /** + * 妖精が食べたりんごの合計数を返す + */ + def allEatenAppleAmount: F[AppleAmount] + } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRank.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRank.scala index ed9cf8403d..020ae93301 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRank.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRank.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property -case class AppleAteByFairyRank(rank: Int) { +case class AppleAteByFairyRank(name: String, rank: Int, appleAmount: AppleAmount) { require(rank >= 1) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 48c61b3c5b..da40055cc5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -173,11 +173,13 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { */ override def appleAteByFairyMyRanking(uuid: UUID): F[AppleAteByFairyRank] = Sync[F].delay { DB.readOnly { implicit session => - val rank = sql"SELECT name,p_apple,COUNT(*) AS rank FROM playerdata ORDER BY DESC;" - .map(_.int("rank")) + sql"SELECT name,p_apple,COUNT(*) AS rank FROM playerdata ORDER BY rank DESC;" + .map(rs => + AppleAteByFairyRank(rs.string("name"), rs.int("rank"), AppleAmount(rs.int("p_apple"))) + ) .single() .apply() - AppleAteByFairyRank(rank.get) + .get } } @@ -188,13 +190,31 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { Sync[F].delay { DB.readOnly { implicit session => val topFour = - sql"SELECT name,p_apple,COUNT(*) AS rank FROM playerdata ORDER BY DESC LIMIT 4;" - .map(_.intOpt("rank")) + sql"SELECT name,p_apple,COUNT(*) AS rank FROM playerdata ORDER BY rank DESC LIMIT 4;" + .map(rs => (rs.stringOpt("name"), rs.intOpt("rank"), rs.intOpt("p_apple"))) .toList() .apply() - .map(_.map(AppleAteByFairyRank)) + .map(data => + if (data._1.nonEmpty) + Some(AppleAteByFairyRank(data._1.get, data._2.get, AppleAmount(data._3.get))) + else None + ) AppleAteByFairyRankTopFour(topFour.head.get, topFour(1), topFour(2), topFour(3)) } } + + /** + * 妖精が食べたりんごの合計数を返す + */ + override def allEatenAppleAmount: F[AppleAmount] = Sync[F].delay { + DB.readOnly { implicit session => + val amount = sql"SELECT SUM(p_apple) AS allAppleAmount FROM playerdata;" + .map(_.int("p_apple")) + .single() + .apply() + .get + AppleAmount(amount) + } + } } From 914c30b8a450b9978eeb6cf1658275263d447467 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 28 Jul 2022 22:08:44 +0900 Subject: [PATCH 080/482] =?UTF-8?q?[Add]=E8=A1=A8=E7=A4=BA=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=82=8B=E3=83=9C=E3=82=BF=E3=83=B3=E3=81=A8=E3=81=97?= =?UTF-8?q?=E3=81=A6dynamicButtons=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index fae378024a..7a1da790dd 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -20,7 +20,8 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.a import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleOpenState, FairyPlaySound, - FairySummonCost + FairySummonCost, + FairyUsingState } import com.github.unchama.seichiassist.task.VotingFairyTask import com.github.unchama.targetedeffect.commandsender.MessageEffect @@ -72,7 +73,19 @@ object VoteMenu extends Menu { ChestSlotRef(3, 0) -> CommonButtons.openStickMenu ) - IO(MenuSlotLayout(buttons)) + val dynamicButtons = + Map( + ChestSlotRef(0, 6) -> gachaRingoInformation(player), + ChestSlotRef(1, 4) -> checkTimeButton(player) + ) + + fairyAPI.fairyUsingState(player).map { usingState => + MenuSlotLayout(buttons).merge( + if (usingState == FairyUsingState.Using) + MenuSlotLayout(dynamicButtons) + else MenuSlotLayout.emptyLayout + ) + } } private object ConstantButtons { @@ -286,7 +299,7 @@ object VoteMenu extends Menu { def gachaRingoInformation( player: Player - )(fairyAPI: FairyAPI[IO, SyncIO, Player]): Button = { + )(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]): Button = { Button( new IconItemStackBuilder(Material.GOLDEN_APPLE) .title(s"$YELLOW$UNDERLINE$BOLD㊙ がちゃりんご情報 ㊙") From dcf03a3e68eaa8bc82ed5109de700522e7af8517 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 28 Jul 2022 22:34:38 +0900 Subject: [PATCH 081/482] =?UTF-8?q?[Fix]=E3=83=A1=E3=83=8B=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=81=8C=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=81=AA?= =?UTF-8?q?=E3=81=84=E4=B8=8D=E5=85=B7=E5=90=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/bukkit/FairySpeech.scala | 11 ++++++++--- .../fairy/infrastructure/JdbcFairyPersistence.scala | 7 ++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index 856c2b3294..bd51d1fa3e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -71,9 +71,14 @@ class FairySpeech[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( playSound <- fairyAPI.fairyPlaySound(player.getUniqueId) } yield { val endTime = endTimeOpt.get.endTimeOpt.get - fairyAPI - .fairySpeechServiceRepository(player) - .makeSpeech(FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。"), playSound) + ContextCoercion { + fairyAPI + .fairySpeechServiceRepository(player) + .makeSpeech( + FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。"), + playSound + ) + }.toIO.unsafeRunSync() } private def randomMessage(fairyMessages: FairyMessages): F[FairyMessage] = Sync[F].delay { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index da40055cc5..09afadcf8b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -198,8 +198,9 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { if (data._1.nonEmpty) Some(AppleAteByFairyRank(data._1.get, data._2.get, AppleAmount(data._3.get))) else None - ) - + ) ++ Seq.fill(3)(None) + /* このSeqは最低一人しか参加していなかった場合に + 2位以降を取り出したときにIndexOutOfBoundsを起こさせないためのやつ */ AppleAteByFairyRankTopFour(topFour.head.get, topFour(1), topFour(2), topFour(3)) } } @@ -210,7 +211,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def allEatenAppleAmount: F[AppleAmount] = Sync[F].delay { DB.readOnly { implicit session => val amount = sql"SELECT SUM(p_apple) AS allAppleAmount FROM playerdata;" - .map(_.int("p_apple")) + .map(_.int("allAppleAmount")) .single() .apply() .get From a56681822a02771bcecbee1ae38a1799257eedcb Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 28 Jul 2022 22:37:44 +0900 Subject: [PATCH 082/482] =?UTF-8?q?[Move]FairyLoreTable=E3=82=92resources?= =?UTF-8?q?=E3=81=AB=E5=90=AB=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/subsystems/fairy/System.scala | 2 +- .../fairy/domain/{ => resources}/bukkit/FairyLoreTable.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{ => resources}/bukkit/FairyLoreTable.scala (97%) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index c84b21d990..783561aca0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -21,8 +21,8 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applicat import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit.FairyLoreTable import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/bukkit/FairyLoreTable.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala similarity index 97% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/bukkit/FairyLoreTable.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala index 528a04cda0..06fc550a83 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/bukkit/FairyLoreTable.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.bukkit +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit import cats.data.NonEmptyList import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property From 1246ec4d0ef678d258356aaccd52a6cee09fefc1 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 28 Jul 2022 22:42:32 +0900 Subject: [PATCH 083/482] =?UTF-8?q?[Fix]=E5=A6=96=E7=B2=BE=E3=81=8C?= =?UTF-8?q?=E7=B5=82=E4=BA=86=E3=81=99=E3=82=8B=E6=99=82=E9=96=93=E3=81=AB?= =?UTF-8?q?=E3=83=97=E3=83=A9=E3=82=B930=E3=83=B6=E6=9C=88=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=9F=E4=B8=8D=E5=85=B7=E5=90=88=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/actions/BukkitSummonFairy.scala | 2 +- .../fairy/domain/property/FairySummonCost.scala | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index b068ba4de6..2e058aa424 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -53,7 +53,7 @@ object BukkitSummonFairy { uuid = player.getUniqueId _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(fairySummonCost.value * 2)) _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) - _ <- fairyAPI.updateFairyEndTime(player, fairySummonCost.validTime) + _ <- fairyAPI.updateFairyEndTime(player, fairySummonCost.endTime) } yield () LiftIO[IO].liftIO { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala index a0828263d3..11b5bc6a5b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala @@ -6,14 +6,14 @@ case class FairySummonCost(value: Int) { require(1 <= value && value <= 4, "FairySummonCostは1~4の間で指定してください。") /** - * @return 妖精が有効な時間 - * NOTE: 妖精が有効な時間はコストによって定められる。 + * @return 妖精の効果が終了する時間 + * NOTE: 妖精の効果が終了する時間はコストによって定められる。 */ - def validTime: FairyEndTime = { + def endTime: FairyEndTime = { val now = LocalDateTime.now() val validTime = value match { case 1 => - FairyEndTime(Some(now.plusMonths(30))) + FairyEndTime(Some(now.plusMinutes(30))) case 2 => FairyEndTime(Some(now.plusHours(1))) case 3 => From b28bf8f6e67827d391da36492ae490fdc2cfcf96 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 28 Jul 2022 23:19:14 +0900 Subject: [PATCH 084/482] =?UTF-8?q?[Add]FairyPlayerJoinGreeter=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 4 +- .../subsystems/fairy/bukkit/FairySpeech.scala | 10 +++++ .../listeners/FairyPlayerJoinGreeter.scala | 43 +++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 783561aca0..c3c7120fb3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -19,6 +19,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applicat SpeechServiceRepositoryDefinitions } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ @@ -26,6 +27,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.r import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player +import org.bukkit.event.Listener import java.util.UUID @@ -169,8 +171,8 @@ object System { .map(_.coerceFinalizationContextTo[IO]) } .unsafeRunSync() - } + override val listeners: Seq[Listener] = Seq(new FairyPlayerJoinGreeter) } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index bd51d1fa3e..f0632229d8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -81,6 +81,16 @@ class FairySpeech[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( }.toIO.unsafeRunSync() } + def welcomeBack(player: Player): F[Unit] = for { + playSound <- fairyAPI.fairyPlaySound(player.getUniqueId) + } yield { + ContextCoercion { + fairyAPI + .fairySpeechServiceRepository(player) + .makeSpeech(FairyMessage(s"おかえり!${player.getName}"), playSound) + }.toIO.unsafeRunSync() + } + private def randomMessage(fairyMessages: FairyMessages): F[FairyMessage] = Sync[F].delay { val messages = fairyMessages.messages messages(Random.nextInt(messages.size)) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala new file mode 100644 index 0000000000..d577244834 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -0,0 +1,43 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners + +import cats.effect.{ConcurrentEffect, IO, SyncIO} +import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyUsingState +import org.bukkit.entity.Player +import org.bukkit.event.player.PlayerJoinEvent +import org.bukkit.event.{EventHandler, Listener} +import org.bukkit.ChatColor._ + +import java.time.LocalDateTime + +class FairyPlayerJoinGreeter(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]) extends Listener { + + @EventHandler + def onJoin(e: PlayerJoinEvent): Unit = { + val player = e.getPlayer + val eff = for { + usingState <- fairyAPI.fairyUsingState(player) + endTime <- fairyAPI.fairyEndTime(player) + } yield { + if ( + usingState == FairyUsingState.Using && endTime + .get + .endTimeOpt + .get + .isBefore(LocalDateTime.now()) + ) { + player.sendMessage(s"$LIGHT_PURPLE${BOLD}妖精は何処かへ行ってしまったようだ...") + fairyAPI.updateFairyUsingState(player, FairyUsingState.NotUsing).unsafeRunSync() + } else { + implicit val ioCE: ConcurrentEffect[IO] = + IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) + + new FairySpeech[IO, SyncIO]().welcomeBack(player).unsafeRunSync() + } + } + eff.unsafeRunSync() + } + +} From 445769a2828130b492b117aae4703001aaf66a24 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 00:24:55 +0900 Subject: [PATCH 085/482] =?UTF-8?q?[Fix]=E3=83=AD=E3=82=B0=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E6=99=82=E3=81=AE=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E5=87=A6=E7=90=86=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/bukkit/FairySpeech.scala | 15 + .../bukkit/actions/BukkitRecoveryMana.scala | 279 +++++++++--------- .../listeners/FairyPlayerJoinGreeter.scala | 26 +- .../bukkit/routines/BukkitFairyRoutine.scala | 21 +- .../infrastructure/JdbcFairyPersistence.scala | 6 +- 5 files changed, 188 insertions(+), 159 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index f0632229d8..9bc559183d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -91,6 +91,21 @@ class FairySpeech[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( }.toIO.unsafeRunSync() } + def bye(player: Player): F[Unit] = for { + playSound <- fairyAPI.fairyPlaySound(player.getUniqueId) + } yield { + ContextCoercion { + fairyAPI + .fairySpeechServiceRepository(player) + .makeSpeech( + FairyMessage(s"""あっ、もうこんな時間だ! + |じゃーねー!${player.getName} + |""".stripMargin), + playSound + ) + }.toIO.unsafeRunSync() + } + private def randomMessage(fairyMessages: FairyMessages): F[FairyMessage] = Sync[F].delay { val messages = fairyMessages.messages messages(Random.nextInt(messages.size)) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 36015edac1..351b5d9c63 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions -import cats.effect.{ConcurrentEffect, Sync} +import cats.effect.ConcurrentEffect import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI @@ -13,8 +13,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.F import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleAmount, AppleOpenState, - FairyManaRecoveryState, - FairyUsingState + FairyManaRecoveryState } import com.github.unchama.seichiassist.{MineStackObjectList, SeichiAssist} import com.github.unchama.targetedeffect.commandsender.MessageEffect @@ -35,157 +34,153 @@ object BukkitRecoveryMana { manaApi: ManaApi[F, G, Player] ): RecoveryMana[F] = new RecoveryMana[F] { override def recovery: F[Unit] = { - if (fairyAPI.fairyUsingState(player).toIO.unsafeRunSync() == FairyUsingState.NotUsing) { - Sync[F].unit - } else { - ContextCoercion(manaApi.readManaAmount(player)).map { oldManaAmount => - if (oldManaAmount.isFull) { - new FairySpeech[F, G] - .speechRandomly(player, FairyManaRecoveryState.full) - .toIO - .unsafeRunSync() - } else { - val uuid = player.getUniqueId - - val eff = for { - seichiAmountData <- ContextCoercion( - breakCountAPI.seichiAmountDataRepository(player).read - ) - defaultRecoveryManaAmount <- fairyAPI.fairyRecoveryMana(uuid) - chainVoteNumber <- voteAPI.chainVoteDayNumber(uuid) - appleOpenState <- fairyAPI.appleOpenState(uuid) - } yield { - val playerLevel = seichiAmountData.levelCorrespondingToExp - - val playerdata = SeichiAssist.playermap(player.getUniqueId) - val gachaRingoObject = - MineStackObjectList.findByName("gachaimo").unsafeRunSync().get - val mineStackedGachaRingoAmount = - playerdata.minestack.getStackedAmountOf(gachaRingoObject) - - val isAppleOpenStateIsOpenOROpenALittle = - appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open - val isManaExistsSeventyFivePercent = oldManaAmount.ratioToCap.exists(_ >= 0.75) - - val defaultAmount = Math.pow(playerLevel.level / 10, 2) - - val chainVoteDayNumber = chainVoteNumber.value - // 連続投票を適用した除算量 - val chainVoteDivisionAmount = - if (chainVoteDayNumber >= 30) 2 - else if (chainVoteDayNumber >= 10) 1.2 - else if (chainVoteDayNumber >= 3) 1.25 - else 1 - - // りんごの開放状況を適用した除算量 - val appleOpenStateDivisionAmount = - if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 - else 1 - - // りんごの開放状況まで適用したりんごの消費量 (暫定) - val appleOpenStateReflectedAmount = - (defaultAmount / chainVoteDivisionAmount).toInt / appleOpenStateDivisionAmount - - // 妖精がつまみ食いする量 - val amountEatenByKnob = - if (appleOpenStateReflectedAmount >= 10) - new Random().nextInt(appleOpenStateReflectedAmount / 10) - else 0 - - /* + ContextCoercion(manaApi.readManaAmount(player)).map { oldManaAmount => + if (oldManaAmount.isFull) { + new FairySpeech[F, G] + .speechRandomly(player, FairyManaRecoveryState.full) + .toIO + .unsafeRunSync() + } else { + val uuid = player.getUniqueId + + val eff = for { + seichiAmountData <- ContextCoercion( + breakCountAPI.seichiAmountDataRepository(player).read + ) + defaultRecoveryManaAmount <- fairyAPI.fairyRecoveryMana(uuid) + chainVoteNumber <- voteAPI.chainVoteDayNumber(uuid) + appleOpenState <- fairyAPI.appleOpenState(uuid) + } yield { + val playerLevel = seichiAmountData.levelCorrespondingToExp + + val playerdata = SeichiAssist.playermap(player.getUniqueId) + val gachaRingoObject = + MineStackObjectList.findByName("gachaimo").unsafeRunSync().get + val mineStackedGachaRingoAmount = + playerdata.minestack.getStackedAmountOf(gachaRingoObject) + + val isAppleOpenStateIsOpenOROpenALittle = + appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open + val isManaExistsSeventyFivePercent = oldManaAmount.ratioToCap.exists(_ >= 0.75) + + val defaultAmount = Math.pow(playerLevel.level / 10, 2) + + val chainVoteDayNumber = chainVoteNumber.value + // 連続投票を適用した除算量 + val chainVoteDivisionAmount = + if (chainVoteDayNumber >= 30) 2 + else if (chainVoteDayNumber >= 10) 1.2 + else if (chainVoteDayNumber >= 3) 1.25 + else 1 + + // りんごの開放状況を適用した除算量 + val appleOpenStateDivisionAmount = + if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 + else 1 + + // りんごの開放状況まで適用したりんごの消費量 (暫定) + val appleOpenStateReflectedAmount = + (defaultAmount / chainVoteDivisionAmount).toInt / appleOpenStateDivisionAmount + + // 妖精がつまみ食いする量 + val amountEatenByKnob = + if (appleOpenStateReflectedAmount >= 10) + new Random().nextInt(appleOpenStateReflectedAmount / 10) + else 0 + + /* 最終的に算出されたりんごの消費量 (現時点では持っているりんごの数を 考慮していないので消費量は確定していない) - */ - val finallyAppleConsumptionAmount = - Math.max(appleOpenStateReflectedAmount + amountEatenByKnob, 1) - - // りんごの消費量 - val appleConsumptionAmount = - if (appleOpenState == AppleOpenState.NotOpen) { - 0 - } else { - Math.max(finallyAppleConsumptionAmount, mineStackedGachaRingoAmount) - } - - // マナの回復量を算出する - val recoveryManaAmount = { - val appleOpenStateDivision = { - if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 - else if (appleOpenState == AppleOpenState.NotOpen) 4 - else 1 - } - - val reflectedAppleOpenStateAmount = - defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision - - // minestackに入っているりんごの数を適用したマナの回復量 - val reflectedMineStackedAmount = - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { - if (mineStackedGachaRingoAmount == 0) { - reflectedAppleOpenStateAmount / { - if (appleOpenState == AppleOpenState.Open) 4 - else if (appleOpenState == AppleOpenState.OpenALittle) 4 - else 2 - } - } else { - if ((mineStackedGachaRingoAmount / finallyAppleConsumptionAmount) <= 0.5) - (reflectedAppleOpenStateAmount * 0.5).toInt - else - (reflectedAppleOpenStateAmount * mineStackedGachaRingoAmount / finallyAppleConsumptionAmount).toInt - } - } else reflectedAppleOpenStateAmount + */ + val finallyAppleConsumptionAmount = + Math.max(appleOpenStateReflectedAmount + amountEatenByKnob, 1) + + // りんごの消費量 + val appleConsumptionAmount = + if (appleOpenState == AppleOpenState.NotOpen) { + 0 + } else { + Math.max(finallyAppleConsumptionAmount, mineStackedGachaRingoAmount) + } - (reflectedMineStackedAmount - reflectedMineStackedAmount / 100) + - (if (reflectedMineStackedAmount >= 50) - Random.nextInt(reflectedMineStackedAmount / 50) - else 0) + // マナの回復量を算出する + val recoveryManaAmount = { + val appleOpenStateDivision = { + if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 + else if (appleOpenState == AppleOpenState.NotOpen) 4 + else 1 } - // minestackからりんごを消費する - playerdata - .minestack - .subtractStackedAmountOf(gachaRingoObject, appleConsumptionAmount) + val reflectedAppleOpenStateAmount = + defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision + + // minestackに入っているりんごの数を適用したマナの回復量 + val reflectedMineStackedAmount = + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { + if (mineStackedGachaRingoAmount == 0) { + reflectedAppleOpenStateAmount / { + if (appleOpenState == AppleOpenState.Open) 4 + else if (appleOpenState == AppleOpenState.OpenALittle) 4 + else 2 + } + } else { + if ((mineStackedGachaRingoAmount / finallyAppleConsumptionAmount) <= 0.5) + (reflectedAppleOpenStateAmount * 0.5).toInt + else + (reflectedAppleOpenStateAmount * mineStackedGachaRingoAmount / finallyAppleConsumptionAmount).toInt + } + } else reflectedAppleOpenStateAmount + + (reflectedMineStackedAmount - reflectedMineStackedAmount / 100) + + (if (reflectedMineStackedAmount >= 50) + Random.nextInt(reflectedMineStackedAmount / 50) + else 0) + } - // 消費したりんごの量を保存する - fairyAPI - .increaseAppleAteByFairy(uuid, AppleAmount(appleConsumptionAmount.toInt)) - .toIO - .unsafeRunSync() + // minestackからりんごを消費する + playerdata + .minestack + .subtractStackedAmountOf(gachaRingoObject, appleConsumptionAmount) - // マナを回復する - ContextCoercion( - manaApi.manaAmount(player).restoreAbsolute(ManaAmount(recoveryManaAmount)) - ).toIO.unsafeRunSync() + // 消費したりんごの量を保存する + fairyAPI + .increaseAppleAteByFairy(uuid, AppleAmount(appleConsumptionAmount.toInt)) + .toIO + .unsafeRunSync() - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { - MessageEffect(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") - .apply(player) - .unsafeRunSync() - } + // マナを回復する + ContextCoercion( + manaApi.manaAmount(player).restoreAbsolute(ManaAmount(recoveryManaAmount)) + ).toIO.unsafeRunSync() - SequentialEffect( - UnfocusedEffect { - new FairySpeech[F, G] - .speechRandomly( - player, - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) - FairyManaRecoveryState.notConsumptionApple - else FairyManaRecoveryState.consumptionApple - ) - .toIO - .unsafeRunSync() - }, - MessageEffect(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), - if (appleConsumptionAmount != 0) - MessageEffect( - s"$RESET$YELLOW${BOLD}あっ!${appleConsumptionAmount}個のがちゃりんごが食べられてる!" - ) - else MessageEffect(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") - ).apply(player).unsafeRunSync() + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { + MessageEffect(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") + .apply(player) + .unsafeRunSync() } - eff.toIO.unsafeRunSync() + + SequentialEffect( + UnfocusedEffect { + new FairySpeech[F, G] + .speechRandomly( + player, + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) + FairyManaRecoveryState.notConsumptionApple + else FairyManaRecoveryState.consumptionApple + ) + .toIO + .unsafeRunSync() + }, + MessageEffect(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), + if (appleConsumptionAmount != 0) + MessageEffect( + s"$RESET$YELLOW${BOLD}あっ!${appleConsumptionAmount}個のがちゃりんごが食べられてる!" + ) + else MessageEffect(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") + ).apply(player).unsafeRunSync() } + eff.toIO.unsafeRunSync() } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index d577244834..8e917d09bf 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -21,21 +21,19 @@ class FairyPlayerJoinGreeter(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]) ex usingState <- fairyAPI.fairyUsingState(player) endTime <- fairyAPI.fairyEndTime(player) } yield { - if ( - usingState == FairyUsingState.Using && endTime - .get - .endTimeOpt - .get - .isBefore(LocalDateTime.now()) - ) { - player.sendMessage(s"$LIGHT_PURPLE${BOLD}妖精は何処かへ行ってしまったようだ...") - fairyAPI.updateFairyUsingState(player, FairyUsingState.NotUsing).unsafeRunSync() - } else { - implicit val ioCE: ConcurrentEffect[IO] = - IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) + if (usingState == FairyUsingState.Using) { + if (endTime.get.endTimeOpt.get.isBefore(LocalDateTime.now())) { + // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) + player.sendMessage(s"$LIGHT_PURPLE${BOLD}妖精は何処かへ行ってしまったようだ...") + fairyAPI.updateFairyUsingState(player, FairyUsingState.NotUsing).unsafeRunSync() + } else { + // まだ終了時間ではない(つまり有効時間内) + implicit val ioCE: ConcurrentEffect[IO] = + IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) - new FairySpeech[IO, SyncIO]().welcomeBack(player).unsafeRunSync() - } + new FairySpeech[IO, SyncIO]().welcomeBack(player).unsafeRunSync() + } + } else SyncIO.unit } eff.unsafeRunSync() } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index d563a1092e..e3e65b07af 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -9,9 +9,12 @@ import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitRecoveryMana +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyUsingState import org.bukkit.entity.Player +import java.time.LocalDateTime import scala.concurrent.duration.FiniteDuration class BukkitFairyRoutine extends FairyRoutine[IO, SyncIO, Player] { @@ -40,7 +43,23 @@ class BukkitFairyRoutine extends FairyRoutine[IO, SyncIO, Player] { RepeatingRoutine.permanentRoutine( repeatInterval, onMainThread.runAction { - BukkitRecoveryMana[IO, SyncIO](player).recovery.runAsync(_ => IO.unit) + if (fairyAPI.fairyUsingState(player).unsafeRunSync() == FairyUsingState.Using) { + if ( + fairyAPI + .fairyEndTime(player) + .unsafeRunSync() + .get + .endTimeOpt + .get + .isBefore(LocalDateTime.now()) + ) { + new FairySpeech[IO, SyncIO].bye(player).runAsync(_ => IO.unit) + } else { + BukkitRecoveryMana[IO, SyncIO](player).recovery.runAsync(_ => IO.unit) + } + } else { + SyncIO.unit + } } ) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 09afadcf8b..ecae10b2b7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -70,8 +70,10 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { Sync[F].delay { DB.localTx { implicit session => sql"""UPDATE playerdata - | SET canVotingFairyUse = ${if (fairyUsingState == FairyUsingState.Using) true - else false} WHERE uuid = ${uuid.toString}""".stripMargin.execute().apply() + | SET canVotingFairyUse = ${fairyUsingState == FairyUsingState.Using} WHERE uuid = ${uuid.toString}""" + .stripMargin + .execute() + .apply() } } From 705d9b9ddb6930e2430fb94643dcd227c3df1bb6 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 00:28:03 +0900 Subject: [PATCH 086/482] =?UTF-8?q?[Fix]Routine=E3=81=AE=E3=83=A1=E3=83=83?= =?UTF-8?q?=E3=82=BB=E3=83=BC=E3=82=B8=E5=87=A6=E7=90=86=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/routines/BukkitFairyRoutine.scala | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index e3e65b07af..1f72fc99c4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -1,6 +1,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines import cats.effect.{ConcurrentEffect, IO, SyncIO, Timer} +import cats.implicits.catsSyntaxFlatMapOps import com.github.unchama.concurrent.{RepeatingRoutine, RepeatingTaskContext} import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts @@ -43,6 +44,7 @@ class BukkitFairyRoutine extends FairyRoutine[IO, SyncIO, Player] { RepeatingRoutine.permanentRoutine( repeatInterval, onMainThread.runAction { + println(s"UsingState: ${fairyAPI.fairyUsingState(player).unsafeRunSync()}") if (fairyAPI.fairyUsingState(player).unsafeRunSync() == FairyUsingState.Using) { if ( fairyAPI @@ -53,13 +55,16 @@ class BukkitFairyRoutine extends FairyRoutine[IO, SyncIO, Player] { .get .isBefore(LocalDateTime.now()) ) { - new FairySpeech[IO, SyncIO].bye(player).runAsync(_ => IO.unit) + // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) + new FairySpeech[IO, SyncIO].bye(player).runAsync(_ => IO.unit) >> + fairyAPI + .updateFairyUsingState(player, FairyUsingState.NotUsing) + .runAsync(_ => IO.unit) } else { + // まだ終了時間ではない(つまり有効時間内) BukkitRecoveryMana[IO, SyncIO](player).recovery.runAsync(_ => IO.unit) } - } else { - SyncIO.unit - } + } else SyncIO.unit } ) } From cee1322658eb1193be1527074721b465fb6c7485 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 00:46:00 +0900 Subject: [PATCH 087/482] =?UTF-8?q?[Fix]=E5=A6=96=E7=B2=BE=E3=81=AE?= =?UTF-8?q?=E6=9C=89=E5=8A=B9=E6=9C=9F=E9=99=90=E3=81=8C=E5=88=87=E3=82=8C?= =?UTF-8?q?=E3=81=9F=E3=81=A8=E3=81=8D=E3=81=AB=E5=9B=9E=E5=BE=A9=E7=AD=89?= =?UTF-8?q?=E3=82=92=E8=A1=8C=E3=82=8F=E3=81=AA=E3=81=84=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/actions/BukkitRecoveryMana.scala | 306 ++++++++++-------- .../bukkit/routines/BukkitFairyRoutine.scala | 26 +- 2 files changed, 165 insertions(+), 167 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 351b5d9c63..a880bbbd13 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -1,8 +1,9 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions -import cats.effect.ConcurrentEffect import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps +import cats.effect.{ConcurrentEffect, Sync} import com.github.unchama.generic.ContextCoercion +import com.github.unchama.seichiassist.{MineStackObjectList, SeichiAssist} import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.mana.domain.ManaAmount @@ -13,14 +14,15 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.F import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleAmount, AppleOpenState, - FairyManaRecoveryState + FairyManaRecoveryState, + FairyUsingState } -import com.github.unchama.seichiassist.{MineStackObjectList, SeichiAssist} -import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} +import com.github.unchama.targetedeffect.commandsender.MessageEffect import org.bukkit.ChatColor._ import org.bukkit.entity.Player +import java.time.LocalDateTime import scala.util.Random object BukkitRecoveryMana { @@ -35,153 +37,173 @@ object BukkitRecoveryMana { ): RecoveryMana[F] = new RecoveryMana[F] { override def recovery: F[Unit] = { ContextCoercion(manaApi.readManaAmount(player)).map { oldManaAmount => - if (oldManaAmount.isFull) { - new FairySpeech[F, G] - .speechRandomly(player, FairyManaRecoveryState.full) - .toIO - .unsafeRunSync() - } else { - val uuid = player.getUniqueId - - val eff = for { - seichiAmountData <- ContextCoercion( - breakCountAPI.seichiAmountDataRepository(player).read - ) - defaultRecoveryManaAmount <- fairyAPI.fairyRecoveryMana(uuid) - chainVoteNumber <- voteAPI.chainVoteDayNumber(uuid) - appleOpenState <- fairyAPI.appleOpenState(uuid) - } yield { - val playerLevel = seichiAmountData.levelCorrespondingToExp - - val playerdata = SeichiAssist.playermap(player.getUniqueId) - val gachaRingoObject = - MineStackObjectList.findByName("gachaimo").unsafeRunSync().get - val mineStackedGachaRingoAmount = - playerdata.minestack.getStackedAmountOf(gachaRingoObject) - - val isAppleOpenStateIsOpenOROpenALittle = - appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open - val isManaExistsSeventyFivePercent = oldManaAmount.ratioToCap.exists(_ >= 0.75) - - val defaultAmount = Math.pow(playerLevel.level / 10, 2) - - val chainVoteDayNumber = chainVoteNumber.value - // 連続投票を適用した除算量 - val chainVoteDivisionAmount = - if (chainVoteDayNumber >= 30) 2 - else if (chainVoteDayNumber >= 10) 1.2 - else if (chainVoteDayNumber >= 3) 1.25 - else 1 - - // りんごの開放状況を適用した除算量 - val appleOpenStateDivisionAmount = - if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 - else 1 - - // りんごの開放状況まで適用したりんごの消費量 (暫定) - val appleOpenStateReflectedAmount = - (defaultAmount / chainVoteDivisionAmount).toInt / appleOpenStateDivisionAmount - - // 妖精がつまみ食いする量 - val amountEatenByKnob = - if (appleOpenStateReflectedAmount >= 10) - new Random().nextInt(appleOpenStateReflectedAmount / 10) - else 0 - - /* - 最終的に算出されたりんごの消費量 - (現時点では持っているりんごの数を - 考慮していないので消費量は確定していない) - */ - val finallyAppleConsumptionAmount = - Math.max(appleOpenStateReflectedAmount + amountEatenByKnob, 1) - - // りんごの消費量 - val appleConsumptionAmount = - if (appleOpenState == AppleOpenState.NotOpen) { - 0 - } else { - Math.max(finallyAppleConsumptionAmount, mineStackedGachaRingoAmount) - } - - // マナの回復量を算出する - val recoveryManaAmount = { - val appleOpenStateDivision = { - if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 - else if (appleOpenState == AppleOpenState.NotOpen) 4 - else 1 - } - - val reflectedAppleOpenStateAmount = - defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision - - // minestackに入っているりんごの数を適用したマナの回復量 - val reflectedMineStackedAmount = - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { - if (mineStackedGachaRingoAmount == 0) { - reflectedAppleOpenStateAmount / { - if (appleOpenState == AppleOpenState.Open) 4 - else if (appleOpenState == AppleOpenState.OpenALittle) 4 - else 2 - } - } else { - if ((mineStackedGachaRingoAmount / finallyAppleConsumptionAmount) <= 0.5) - (reflectedAppleOpenStateAmount * 0.5).toInt - else - (reflectedAppleOpenStateAmount * mineStackedGachaRingoAmount / finallyAppleConsumptionAmount).toInt - } - } else reflectedAppleOpenStateAmount - - (reflectedMineStackedAmount - reflectedMineStackedAmount / 100) + - (if (reflectedMineStackedAmount >= 50) - Random.nextInt(reflectedMineStackedAmount / 50) - else 0) - } - - // minestackからりんごを消費する - playerdata - .minestack - .subtractStackedAmountOf(gachaRingoObject, appleConsumptionAmount) - - // 消費したりんごの量を保存する + if (fairyAPI.fairyUsingState(player).toIO.unsafeRunSync() == FairyUsingState.Using) { + if ( fairyAPI - .increaseAppleAteByFairy(uuid, AppleAmount(appleConsumptionAmount.toInt)) + .fairyEndTime(player) .toIO .unsafeRunSync() + .get + .endTimeOpt + .get + .isBefore(LocalDateTime.now()) + ) { + // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) + new FairySpeech[F, G] + .bye(player) >> fairyAPI.updateFairyUsingState(player, FairyUsingState.NotUsing) + } else { + // 有効期限内 + if (oldManaAmount.isFull) { + new FairySpeech[F, G] + .speechRandomly(player, FairyManaRecoveryState.full) + .toIO + .unsafeRunSync() + } else { + val uuid = player.getUniqueId - // マナを回復する - ContextCoercion( - manaApi.manaAmount(player).restoreAbsolute(ManaAmount(recoveryManaAmount)) - ).toIO.unsafeRunSync() + val eff = for { + seichiAmountData <- ContextCoercion( + breakCountAPI.seichiAmountDataRepository(player).read + ) + defaultRecoveryManaAmount <- fairyAPI.fairyRecoveryMana(uuid) + chainVoteNumber <- voteAPI.chainVoteDayNumber(uuid) + appleOpenState <- fairyAPI.appleOpenState(uuid) + } yield { + val playerLevel = seichiAmountData.levelCorrespondingToExp + + val playerdata = SeichiAssist.playermap(player.getUniqueId) + val gachaRingoObject = + MineStackObjectList.findByName("gachaimo").unsafeRunSync().get + val mineStackedGachaRingoAmount = + playerdata.minestack.getStackedAmountOf(gachaRingoObject) + + val isAppleOpenStateIsOpenOROpenALittle = + appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open + val isManaExistsSeventyFivePercent = oldManaAmount.ratioToCap.exists(_ >= 0.75) + + val defaultAmount = Math.pow(playerLevel.level / 10, 2) + + val chainVoteDayNumber = chainVoteNumber.value + // 連続投票を適用した除算量 + val chainVoteDivisionAmount = + if (chainVoteDayNumber >= 30) 2 + else if (chainVoteDayNumber >= 10) 1.2 + else if (chainVoteDayNumber >= 3) 1.25 + else 1 + + // りんごの開放状況を適用した除算量 + val appleOpenStateDivisionAmount = + if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 + else 1 + + // りんごの開放状況まで適用したりんごの消費量 (暫定) + val appleOpenStateReflectedAmount = + (defaultAmount / chainVoteDivisionAmount).toInt / appleOpenStateDivisionAmount + + // 妖精がつまみ食いする量 + val amountEatenByKnob = + if (appleOpenStateReflectedAmount >= 10) + new Random().nextInt(appleOpenStateReflectedAmount / 10) + else 0 + + /* + 最終的に算出されたりんごの消費量 + (現時点では持っているりんごの数を + 考慮していないので消費量は確定していない) + */ + val finallyAppleConsumptionAmount = + Math.max(appleOpenStateReflectedAmount + amountEatenByKnob, 1) + + // りんごの消費量 + val appleConsumptionAmount = + if (appleOpenState == AppleOpenState.NotOpen) { + 0 + } else { + Math.max(finallyAppleConsumptionAmount, mineStackedGachaRingoAmount) + } - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { - MessageEffect(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") - .apply(player) - .unsafeRunSync() - } + // マナの回復量を算出する + val recoveryManaAmount = { + val appleOpenStateDivision = { + if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 + else if (appleOpenState == AppleOpenState.NotOpen) 4 + else 1 + } - SequentialEffect( - UnfocusedEffect { - new FairySpeech[F, G] - .speechRandomly( - player, - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) - FairyManaRecoveryState.notConsumptionApple - else FairyManaRecoveryState.consumptionApple - ) + val reflectedAppleOpenStateAmount = + defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision + + // minestackに入っているりんごの数を適用したマナの回復量 + val reflectedMineStackedAmount = + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { + if (mineStackedGachaRingoAmount == 0) { + reflectedAppleOpenStateAmount / { + if (appleOpenState == AppleOpenState.Open) 4 + else if (appleOpenState == AppleOpenState.OpenALittle) 4 + else 2 + } + } else { + if ( + (mineStackedGachaRingoAmount / finallyAppleConsumptionAmount) <= 0.5 + ) + (reflectedAppleOpenStateAmount * 0.5).toInt + else + (reflectedAppleOpenStateAmount * mineStackedGachaRingoAmount / finallyAppleConsumptionAmount).toInt + } + } else reflectedAppleOpenStateAmount + + (reflectedMineStackedAmount - reflectedMineStackedAmount / 100) + + (if (reflectedMineStackedAmount >= 50) + Random.nextInt(reflectedMineStackedAmount / 50) + else 0) + } + + // minestackからりんごを消費する + playerdata + .minestack + .subtractStackedAmountOf(gachaRingoObject, appleConsumptionAmount) + + // 消費したりんごの量を保存する + fairyAPI + .increaseAppleAteByFairy(uuid, AppleAmount(appleConsumptionAmount.toInt)) .toIO .unsafeRunSync() - }, - MessageEffect(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), - if (appleConsumptionAmount != 0) - MessageEffect( - s"$RESET$YELLOW${BOLD}あっ!${appleConsumptionAmount}個のがちゃりんごが食べられてる!" - ) - else MessageEffect(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") - ).apply(player).unsafeRunSync() + + // マナを回復する + ContextCoercion( + manaApi.manaAmount(player).restoreAbsolute(ManaAmount(recoveryManaAmount)) + ).toIO.unsafeRunSync() + + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { + MessageEffect(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") + .apply(player) + .unsafeRunSync() + } + + SequentialEffect( + UnfocusedEffect { + new FairySpeech[F, G] + .speechRandomly( + player, + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) + FairyManaRecoveryState.notConsumptionApple + else FairyManaRecoveryState.consumptionApple + ) + .toIO + .unsafeRunSync() + }, + MessageEffect(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), + if (appleConsumptionAmount != 0) + MessageEffect( + s"$RESET$YELLOW${BOLD}あっ!${appleConsumptionAmount}個のがちゃりんごが食べられてる!" + ) + else MessageEffect(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") + ).apply(player).unsafeRunSync() + } + eff.toIO.unsafeRunSync() + } } - eff.toIO.unsafeRunSync() - } + } else Sync[F].unit } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index 1f72fc99c4..d563a1092e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -1,7 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines import cats.effect.{ConcurrentEffect, IO, SyncIO, Timer} -import cats.implicits.catsSyntaxFlatMapOps import com.github.unchama.concurrent.{RepeatingRoutine, RepeatingTaskContext} import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts @@ -10,12 +9,9 @@ import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitRecoveryMana -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyUsingState import org.bukkit.entity.Player -import java.time.LocalDateTime import scala.concurrent.duration.FiniteDuration class BukkitFairyRoutine extends FairyRoutine[IO, SyncIO, Player] { @@ -44,27 +40,7 @@ class BukkitFairyRoutine extends FairyRoutine[IO, SyncIO, Player] { RepeatingRoutine.permanentRoutine( repeatInterval, onMainThread.runAction { - println(s"UsingState: ${fairyAPI.fairyUsingState(player).unsafeRunSync()}") - if (fairyAPI.fairyUsingState(player).unsafeRunSync() == FairyUsingState.Using) { - if ( - fairyAPI - .fairyEndTime(player) - .unsafeRunSync() - .get - .endTimeOpt - .get - .isBefore(LocalDateTime.now()) - ) { - // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) - new FairySpeech[IO, SyncIO].bye(player).runAsync(_ => IO.unit) >> - fairyAPI - .updateFairyUsingState(player, FairyUsingState.NotUsing) - .runAsync(_ => IO.unit) - } else { - // まだ終了時間ではない(つまり有効時間内) - BukkitRecoveryMana[IO, SyncIO](player).recovery.runAsync(_ => IO.unit) - } - } else SyncIO.unit + BukkitRecoveryMana[IO, SyncIO](player).recovery.runAsync(_ => IO.unit) } ) } From f8ca1ce61fb40080f6a26b27529e544c2aabac4b Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 09:37:09 +0900 Subject: [PATCH 088/482] =?UTF-8?q?[Fix]=E5=A6=96=E7=B2=BE=E3=81=8C?= =?UTF-8?q?=E5=B8=B0=E3=82=8B=E3=81=A8=E3=81=8D=E3=81=AE=E3=83=A1=E3=83=83?= =?UTF-8?q?=E3=82=BB=E3=83=BC=E3=82=B8=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/bukkit/FairySpeech.scala | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index 9bc559183d..b4193bc438 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -8,6 +8,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p FairyManaRecoveryState, FairyMessage, FairyMessages, + FairyPlaySound, NameCalledByFairy } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.FairyMessageTable @@ -94,16 +95,12 @@ class FairySpeech[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( def bye(player: Player): F[Unit] = for { playSound <- fairyAPI.fairyPlaySound(player.getUniqueId) } yield { - ContextCoercion { - fairyAPI - .fairySpeechServiceRepository(player) - .makeSpeech( - FairyMessage(s"""あっ、もうこんな時間だ! - |じゃーねー!${player.getName} - |""".stripMargin), - playSound - ) - }.toIO.unsafeRunSync() + val repository = fairyAPI.fairySpeechServiceRepository(player) + (ContextCoercion { + repository.makeSpeech(FairyMessage(s"あっ、もうこんな時間だ!"), FairyPlaySound.off) + } >> ContextCoercion { + repository.makeSpeech(FairyMessage(s"じゃーねー!${player.getName}"), playSound) + }).toIO.unsafeRunSync() } private def randomMessage(fairyMessages: FairyMessages): F[FairyMessage] = Sync[F].delay { From 7e9d59a8e9ad8e14fae71a1b84e6277317ded0b2 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 12:28:28 +0900 Subject: [PATCH 089/482] =?UTF-8?q?[Fix]VoteMenu=E3=81=AE=E9=9F=B3?= =?UTF-8?q?=E3=81=AE=E3=83=88=E3=82=B0=E3=83=AB=E3=81=8C=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=81=AA=E3=81=84=E4=B8=8D=E5=85=B7=E5=90=88=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration/V2.0.1__Add_fairy_columns.sql | 3 + .../unchama/seichiassist/menus/VoteMenu.scala | 230 +++++++++--------- .../vote/subsystems/fairy/FairyAPI.scala | 39 ++- .../vote/subsystems/fairy/System.scala | 51 ++-- .../subsystems/fairy/bukkit/FairySpeech.scala | 39 +-- .../fairy/domain/FairyPersistence.scala | 11 + .../infrastructure/JdbcFairyPersistence.scala | 28 +++ 7 files changed, 216 insertions(+), 185 deletions(-) create mode 100644 src/main/resources/db/migration/V2.0.1__Add_fairy_columns.sql diff --git a/src/main/resources/db/migration/V2.0.1__Add_fairy_columns.sql b/src/main/resources/db/migration/V2.0.1__Add_fairy_columns.sql new file mode 100644 index 0000000000..df8a9c7128 --- /dev/null +++ b/src/main/resources/db/migration/V2.0.1__Add_fairy_columns.sql @@ -0,0 +1,3 @@ +use seichiassist; + +ALTER TABLE playerdata ADD is_fairy_speech_play_sound BOOLEAN DEFAULT TRUE AFTER toggleVotingFairy ; diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 7a1da790dd..cc20185724 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -1,12 +1,14 @@ package com.github.unchama.seichiassist.menus import cats.effect.{ConcurrentEffect, IO, SyncIO} +import cats.implicits.toTraverseOps import com.github.unchama.itemstackbuilder.IconItemStackBuilder import com.github.unchama.menuinventory.router.CanOpen -import com.github.unchama.menuinventory.slot.button.Button +import com.github.unchama.menuinventory.slot.button.{Button, RecomputedButton} import com.github.unchama.menuinventory.slot.button.action.LeftClickButtonEffect import com.github.unchama.menuinventory.syntax.IntInventorySizeOps import com.github.unchama.menuinventory.{ChestSlotRef, Menu, MenuFrame, MenuSlotLayout} +import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMainThread import com.github.unchama.seichiassist.menus.stickmenu.FirstPage @@ -32,8 +34,6 @@ import org.bukkit.ChatColor._ import org.bukkit.entity.Player import org.bukkit.{Material, Sound} -import java.util.UUID - object VoteMenu extends Menu { class Environment( @@ -41,7 +41,8 @@ object VoteMenu extends Menu { val fairyAPI: FairyAPI[IO, SyncIO, Player], val breakCountAPI: BreakCountAPI[IO, SyncIO, Player], val manaApi: ManaApi[IO, SyncIO, Player], - val ioCanOpenFirstPage: IO CanOpen FirstPage.type + val ioCanOpenFirstPage: IO CanOpen FirstPage.type, + onMainThread: OnMinecraftServerThread[IO] ) /** @@ -56,47 +57,57 @@ object VoteMenu extends Menu { override def computeMenuLayout( player: Player )(implicit environment: Environment): IO[MenuSlotLayout] = { - import ConstantButtons._ import environment._ import eu.timepit.refined.auto._ + val constantButtons = ConstantButtons(player) + import constantButtons._ - val uuid = player.getUniqueId - - val buttons = + val staticButtons = Map( - ChestSlotRef(0, 0) -> receiveVoteBenefitsButton(player), - ChestSlotRef(0, 2) -> fairySummonTimeToggleButton(player), - ChestSlotRef(0, 4) -> fairySummonButton(player), + ChestSlotRef(0, 0) -> receiveVoteBenefitsButton, + ChestSlotRef(0, 4) -> fairySummonButton, ChestSlotRef(1, 0) -> showVoteURLButton, - ChestSlotRef(1, 2) -> fairyContractSettingToggle(uuid), - ChestSlotRef(2, 2) -> fairyPlaySoundToggleButton(uuid), ChestSlotRef(3, 0) -> CommonButtons.openStickMenu ) + val computeButtonsIO = + Seq( + ChestSlotRef(0, 2) -> fairySummonTimeToggleButton, + ChestSlotRef(1, 2) -> fairyContractSettingToggle, + ChestSlotRef(2, 2) -> fairyPlaySoundToggleButton + ).traverse(_.sequence) + val dynamicButtons = - Map( - ChestSlotRef(0, 6) -> gachaRingoInformation(player), - ChestSlotRef(1, 4) -> checkTimeButton(player) - ) + Map(ChestSlotRef(0, 6) -> gachaRingoInformation, ChestSlotRef(1, 4) -> checkTimeButton) - fairyAPI.fairyUsingState(player).map { usingState => - MenuSlotLayout(buttons).merge( - if (usingState == FairyUsingState.Using) + for { + fairyUsingState <- environment.fairyAPI.fairyUsingState(constantButtons.player) + computeButtons <- computeButtonsIO + } yield { + val exceptDynamicButtons = staticButtons ++ computeButtons + MenuSlotLayout(exceptDynamicButtons).merge( + if (fairyUsingState == FairyUsingState.Using) MenuSlotLayout(dynamicButtons) else MenuSlotLayout.emptyLayout ) } } - private object ConstantButtons { + private case class ConstantButtons(player: Player)( + implicit voteAPI: VoteAPI[IO, Player], + fairyAPI: FairyAPI[IO, SyncIO, Player], + breakCountAPI: BreakCountAPI[IO, SyncIO, Player], + manaApi: ManaApi[IO, SyncIO, Player] + ) { + + import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.layoutPreparationContext + + private val uuid = player.getUniqueId private implicit val ioCE: ConcurrentEffect[IO] = IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) - def receiveVoteBenefitsButton(player: Player)( - implicit voteAPI: VoteAPI[IO, Player], - breakCountAPI: BreakCountAPI[IO, SyncIO, Player] - ): Button = { + val receiveVoteBenefitsButton: Button = { val uuid = player.getUniqueId for { benefits <- voteAPI.receivedVoteBenefits(uuid) @@ -159,98 +170,97 @@ object VoteMenu extends Menu { } ) - def fairySummonTimeToggleButton( - player: Player - )(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]): Button = { - val fairySummonCost = fairyAPI.fairySummonCost(player).unsafeRunSync() - Button( - new IconItemStackBuilder(Material.WATCH) - .title(s"$AQUA$UNDERLINE${BOLD}マナ妖精 時間設定") - .lore( - List( - s"$RESET$GREEN$BOLD${VotingFairyTask.dispToggleVFTime(fairySummonCost.value)}", - "", - s"$RESET${GRAY}コスト", - s"$RESET$RED$BOLD${fairySummonCost.value * 2}投票pt", - "", - s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え" + val fairySummonTimeToggleButton: IO[Button] = { + RecomputedButton(IO { + val fairySummonCost = fairyAPI.fairySummonCost(player).unsafeRunSync() + Button( + new IconItemStackBuilder(Material.WATCH) + .title(s"$AQUA$UNDERLINE${BOLD}マナ妖精 時間設定") + .lore( + List( + s"$RESET$GREEN$BOLD${VotingFairyTask.dispToggleVFTime(fairySummonCost.value)}", + "", + s"$RESET${GRAY}コスト", + s"$RESET$RED$BOLD${fairySummonCost.value * 2}投票pt", + "", + s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え" + ) ) - ) - .build(), - LeftClickButtonEffect { - SequentialEffect( - FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), - UnfocusedEffect( - fairyAPI.updateFairySummonCost( - player.getUniqueId, - FairySummonCost(fairySummonCost.value % 4 + 1) + .build(), + LeftClickButtonEffect { + SequentialEffect( + FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), + UnfocusedEffect( + fairyAPI.updateFairySummonCost( + player.getUniqueId, + FairySummonCost(fairySummonCost.value % 4 + 1) + ) ) ) - ) - } - ) + } + ) + }) } - def fairyContractSettingToggle( - uuid: UUID - )(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]): Button = - Button( - new IconItemStackBuilder(Material.PAPER) - .title(s"$GOLD$UNDERLINE${BOLD}妖精とのお約束") - .lore(fairyAPI.getFairyLore(uuid).unsafeRunSync().lore.toList) - .build(), - LeftClickButtonEffect { - SequentialEffect( - UnfocusedEffect { - fairyAPI.updateAppleOpenState( - uuid, - AppleOpenState - .values - .find( - _.amount == fairyAPI.appleOpenState(uuid).unsafeRunSync().amount % 4 + 1 - ) - .get - ) - }, - FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) - ) - } - ) + val fairyContractSettingToggle: IO[Button] = + RecomputedButton(IO { + Button( + new IconItemStackBuilder(Material.PAPER) + .title(s"$GOLD$UNDERLINE${BOLD}妖精とのお約束") + .lore(fairyAPI.getFairyLore(uuid).unsafeRunSync().lore.toList) + .build(), + LeftClickButtonEffect { + SequentialEffect( + UnfocusedEffect { + fairyAPI.updateAppleOpenState( + uuid, + AppleOpenState + .values + .find( + _.amount == fairyAPI.appleOpenState(uuid).unsafeRunSync().amount % 4 + 1 + ) + .get + ) + }, + FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) + ) + } + ) + }) - def fairyPlaySoundToggleButton( - uuid: UUID - )(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]): Button = { + val fairyPlaySoundToggleButton: IO[Button] = { val description = List(s"$RESET$DARK_GRAY※この機能はデフォルトでONです。", s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え") val playSoundOnLore = List(s"$RESET${GREEN}現在音が鳴る設定になっています。") ++ description - val playSoundOffLore = List(s"$RESET${GREEN}現在音が鳴らない設定になっています。") ++ description + val playSoundOffLore = List(s"$RESET${RED}現在音が鳴らない設定になっています。") ++ description - Button( - new IconItemStackBuilder(Material.JUKEBOX) - .title(s"$GOLD$UNDERLINE${BOLD}マナ妖精の音トグル") - .lore( - if (fairyAPI.fairyPlaySound(uuid).unsafeRunSync() == FairyPlaySound.on) - playSoundOnLore - else playSoundOffLore - ) - .build(), - LeftClickButtonEffect { - SequentialEffect( - FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), - UnfocusedEffect { - fairyAPI.fairyPlaySoundToggle(uuid).unsafeRunAsyncAndForget() - } - ) - } - ) + RecomputedButton(IO { + Button( + new IconItemStackBuilder(Material.JUKEBOX) + .title(s"$GOLD$UNDERLINE${BOLD}マナ妖精の音トグル") + .lore( + if ( + fairyAPI + .fairySpeechSound(player.getUniqueId) + .unsafeRunSync() == FairyPlaySound.on + ) + playSoundOnLore + else playSoundOffLore + ) + .build(), + LeftClickButtonEffect { + SequentialEffect( + FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), + UnfocusedEffect { + fairyAPI.toggleFairySpeechSound(player.getUniqueId).unsafeRunSync() + } + ) + } + ) + }) } - def fairySummonButton(player: Player)( - implicit fairyAPI: FairyAPI[IO, SyncIO, Player], - voteAPI: VoteAPI[IO, Player], - breakCountAPI: BreakCountAPI[IO, SyncIO, Player], - manaApi: ManaApi[IO, SyncIO, Player] - ): Button = { + val fairySummonButton: Button = { val fairySummonState = fairyAPI.fairySummonCost(player).unsafeRunSync().value Button( @@ -277,9 +287,7 @@ object VoteMenu extends Menu { ) } - def checkTimeButton( - player: Player - )(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]): Button = { + val checkTimeButton: Button = Button( new IconItemStackBuilder(Material.COMPASS) .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}マナ妖精に時間を聞く") @@ -295,11 +303,8 @@ object VoteMenu extends Menu { ) } ) - } - def gachaRingoInformation( - player: Player - )(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]): Button = { + val gachaRingoInformation: Button = Button( new IconItemStackBuilder(Material.GOLDEN_APPLE) .title(s"$YELLOW$UNDERLINE$BOLD㊙ がちゃりんご情報 ㊙") @@ -338,7 +343,6 @@ object VoteMenu extends Menu { .enchanted() .build() ) - } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 025aea9bde..5849731ed0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -1,14 +1,12 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy -import cats.effect.concurrent.Ref -import com.github.unchama.datarepository.KeyedDataRepository import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import java.util.UUID -trait FairyWriteAPI[F[_], Player] { +trait FairyWriteAPI[F[_], G[_], Player] { /** * 妖精にあげるりんごの開放状態を変更する @@ -21,11 +19,6 @@ trait FairyWriteAPI[F[_], Player] { */ def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] - /** - * fairyPlaySoundRepositoryの音を鳴らすかどうかの設定を切り替える - */ - def fairyPlaySoundToggle(uuid: UUID): F[Unit] - /** * 妖精を使っているかどうかを切り替える */ @@ -46,11 +39,18 @@ trait FairyWriteAPI[F[_], Player] { */ def increaseAppleAteByFairy(uuid: UUID, appleAmount: AppleAmount): F[Unit] + /** + * 妖精が喋るときに音をだすかをトグルする + */ + def toggleFairySpeechSound(uuid: UUID): F[Unit] + } object FairyWriteAPI { - def apply[F[_], Player](implicit ev: FairyWriteAPI[F, Player]): FairyWriteAPI[F, Player] = ev + def apply[F[_], G[_], Player]( + implicit ev: FairyWriteAPI[F, G, Player] + ): FairyWriteAPI[F, G, Player] = ev } @@ -71,11 +71,6 @@ trait FairyReadAPI[F[_], G[_], Player] { */ def getFairyLore(uuid: UUID): F[FairyLore] - /** - * fairyPlaySoundRepositoryから音を鳴らすかどうかを取得する - */ - def fairyPlaySound(uuid: UUID): F[FairyPlaySound] - /** * 妖精を使っているかを取得する */ @@ -91,15 +86,6 @@ trait FairyReadAPI[F[_], G[_], Player] { */ def appleAteByFairy(uuid: UUID): F[AppleAmount] - /** - * 妖精の音を鳴らすかどうか保持するようのリポジトリ - * ※永続化は必要ない - */ - protected[this] val fairyPlaySoundRepository: KeyedDataRepository[ - UUID, - Ref[F, FairyPlaySound] - ] - val fairySpeechServiceRepository: PlayerDataRepository[FairySpeechService[G]] /** @@ -122,6 +108,11 @@ trait FairyReadAPI[F[_], G[_], Player] { */ def allEatenAppleAmount: F[AppleAmount] + /** + * 妖精が喋ったときに音を再生するか取得する + */ + def fairySpeechSound(uuid: UUID): F[FairyPlaySound] + } object FairyReadAPI { @@ -134,4 +125,4 @@ object FairyReadAPI { trait FairyAPI[F[_], G[_], Player] extends FairyReadAPI[F, G, Player] - with FairyWriteAPI[F, Player] + with FairyWriteAPI[F, G, Player] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index c3c7120fb3..6ec1c922a4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -1,9 +1,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy -import cats.effect.concurrent.Ref import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.concurrent.RepeatingTaskContext -import com.github.unchama.datarepository.KeyedDataRepository import com.github.unchama.datarepository.bukkit.player.{ BukkitRepositoryControls, PlayerDataRepository @@ -21,9 +19,9 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applicat import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player @@ -51,16 +49,14 @@ object System { new BukkitFairyRoutine for { - speechServiceRepositoryControls <- { - BukkitRepositoryControls.createHandles( - RepositoryDefinition - .Phased - .TwoPhased( - SpeechServiceRepositoryDefinitions.initialization[SyncIO, Player], - SpeechServiceRepositoryDefinitions.finalization[SyncIO, Player] - ) - ) - } + speechServiceRepositoryControls <- BukkitRepositoryControls.createHandles( + RepositoryDefinition + .Phased + .TwoPhased( + SpeechServiceRepositoryDefinitions.initialization[SyncIO, Player], + SpeechServiceRepositoryDefinitions.finalization[SyncIO, Player] + ) + ) } yield { new System[IO, SyncIO, Player] { override implicit val api: FairyAPI[IO, SyncIO, Player] = @@ -87,24 +83,6 @@ object System { override def fairySummonCost(player: Player): IO[FairySummonCost] = persistence.fairySummonCost(player.getUniqueId) - override protected val fairyPlaySoundRepository - : KeyedDataRepository[UUID, Ref[IO, FairyPlaySound]] = - KeyedDataRepository.unlift[UUID, Ref[IO, FairyPlaySound]] { _ => - Some(Ref.unsafe(FairyPlaySound.on)) - } - - override def fairyPlaySound(uuid: UUID): IO[FairyPlaySound] = - if (fairyPlaySoundRepository.isDefinedAt(uuid)) - fairyPlaySoundRepository(uuid).get - else IO.pure(FairyPlaySound.on) - - override def fairyPlaySoundToggle(uuid: UUID): IO[Unit] = for { - nowSetting <- fairyPlaySound(uuid) - } yield fairyPlaySoundRepository(uuid).set( - if (nowSetting == FairyPlaySound.on) FairyPlaySound.off - else FairyPlaySound.on - ) - override def fairyEndTime(player: Player): IO[Option[FairyEndTime]] = persistence.fairyEndTime(player.getUniqueId) @@ -154,6 +132,17 @@ object System { override def allEatenAppleAmount: IO[AppleAmount] = persistence.allEatenAppleAmount + + override def fairySpeechSound(uuid: UUID): IO[FairyPlaySound] = + persistence.fairySpeechSound(uuid) + + override def toggleFairySpeechSound(uuid: UUID): IO[Unit] = + persistence.toggleFairySpeechSound( + uuid, + if (fairySpeechSound(uuid).unsafeRunSync() == FairyPlaySound.on) + FairyPlaySound.off + else FairyPlaySound.on + ) } override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index b4193bc438..7fbf49460d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -40,7 +40,7 @@ class FairySpeech[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( ContextCoercion { serviceRepository.makeSpeech( message, - fairyAPI.fairyPlaySound(player.getUniqueId).toIO.unsafeRunSync() + ContextCoercion(fairyAPI.fairySpeechSound(player.getUniqueId)).toIO.unsafeRunSync() ) }.toIO.unsafeRunSync() } @@ -62,28 +62,33 @@ class FairySpeech[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( ContextCoercion { fairyAPI .fairySpeechServiceRepository(player) - .makeSpeech(message, fairyAPI.fairyPlaySound(player.getUniqueId).toIO.unsafeRunSync()) + .makeSpeech( + message, + fairyAPI.fairySpeechSound(player.getUniqueId).toIO.unsafeRunSync() + ) }.toIO.unsafeRunSync() } } - def speechEndTime(player: Player): F[Unit] = for { - endTimeOpt <- fairyAPI.fairyEndTime(player) - playSound <- fairyAPI.fairyPlaySound(player.getUniqueId) - } yield { - val endTime = endTimeOpt.get.endTimeOpt.get - ContextCoercion { - fairyAPI - .fairySpeechServiceRepository(player) - .makeSpeech( - FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。"), - playSound - ) - }.toIO.unsafeRunSync() + def speechEndTime(player: Player): F[Unit] = { + for { + endTimeOpt <- fairyAPI.fairyEndTime(player) + playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) + } yield { + val endTime = endTimeOpt.get.endTimeOpt.get + ContextCoercion { + fairyAPI + .fairySpeechServiceRepository(player) + .makeSpeech( + FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。"), + playSound + ) + }.toIO.unsafeRunSync() + } } def welcomeBack(player: Player): F[Unit] = for { - playSound <- fairyAPI.fairyPlaySound(player.getUniqueId) + playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) } yield { ContextCoercion { fairyAPI @@ -93,7 +98,7 @@ class FairySpeech[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( } def bye(player: Player): F[Unit] = for { - playSound <- fairyAPI.fairyPlaySound(player.getUniqueId) + playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) } yield { val repository = fairyAPI.fairySpeechServiceRepository(player) (ContextCoercion { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index 78b8dfbc68..d1cf78bb6e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -6,6 +6,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p AppleAteByFairyRankTopFour, AppleOpenState, FairyEndTime, + FairyPlaySound, FairyRecoveryMana, FairySummonCost, FairyUsingState @@ -90,4 +91,14 @@ trait FairyPersistence[F[_]] { */ def allEatenAppleAmount: F[AppleAmount] + /** + * 妖精が喋るときに音をだすかをトグルする + */ + def toggleFairySpeechSound(uuid: UUID, fairyPlaySound: FairyPlaySound): F[Unit] + + /** + * 妖精が喋ったときに音を再生するか取得する + */ + def fairySpeechSound(uuid: UUID): F[FairyPlaySound] + } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index ecae10b2b7..f4b53832c5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -220,4 +220,32 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { AppleAmount(amount) } } + + /** + * 妖精が喋るときに音をだすかをトグルする + */ + override def toggleFairySpeechSound(uuid: UUID, fairyPlaySound: FairyPlaySound): F[Unit] = + Sync[F].delay { + DB.localTx { implicit session => + sql"UPDATE playerdata SET is_fairy_speech_play_sound = ${fairyPlaySound == FairyPlaySound.on} WHERE uuid = ${uuid.toString}" + .execute() + .apply() + } + } + + /** + * 妖精が喋ったときに音を再生するか取得する + */ + override def fairySpeechSound(uuid: UUID): F[FairyPlaySound] = + Sync[F].delay { + DB.readOnly { implicit session => + val isPlaySound = + sql"SELECT is_fairy_speech_play_sound FROM playerdata WHERE uuid=${uuid.toString}" + .map(_.boolean("is_fairy_speech_play_sound")) + .single() + .apply() + .get + if (isPlaySound) FairyPlaySound.on else FairyPlaySound.off + } + } } From 2f8d18392fc5fc06817b9dd997778c78af7f2676 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 12:34:22 +0900 Subject: [PATCH 090/482] =?UTF-8?q?[Fix]fairyConstractSettingToggle?= =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3=E3=81=8C=E5=8B=95=E3=81=84=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=AA=E3=81=84=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index cc20185724..a7edc2e984 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -212,15 +212,17 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( UnfocusedEffect { - fairyAPI.updateAppleOpenState( - uuid, - AppleOpenState - .values - .find( - _.amount == fairyAPI.appleOpenState(uuid).unsafeRunSync().amount % 4 + 1 - ) - .get - ) + fairyAPI + .updateAppleOpenState( + uuid, + AppleOpenState + .values + .find( + _.amount == fairyAPI.appleOpenState(uuid).unsafeRunSync().amount % 4 + 1 + ) + .get + ) + .unsafeRunSync() }, FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) ) From 9a3db9379263a653948de228193f74437110522c Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 12:40:38 +0900 Subject: [PATCH 091/482] =?UTF-8?q?[Fix]=E6=8A=95=E7=A5=A8=E3=83=9D?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=83=88=E3=82=92=E4=BD=BF=E7=94=A8=E3=81=99?= =?UTF-8?q?=E3=82=8B=E9=87=8F=E3=82=92=E8=AA=BF=E6=95=B4=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3=E3=81=8C=E6=A9=9F=E8=83=BD=E3=81=97?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1q | 8 ++++++++ .../github/unchama/seichiassist/menus/VoteMenu.scala | 10 ++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 1q diff --git a/1q b/1q new file mode 100644 index 0000000000..8a57bde6c1 --- /dev/null +++ b/1q @@ -0,0 +1,8 @@ +[Fix]fairyConstractSettingToggleボタンが動いていないのを修正 +# Please enter the commit message for your changes. Lines starting +# with '#' will be ignored, and an empty message aborts the commit. +# +# On branch refactorVote +# Changes to be committed: +# modified: src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +# diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index a7edc2e984..aff0163ea2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -191,10 +191,12 @@ object VoteMenu extends Menu { SequentialEffect( FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), UnfocusedEffect( - fairyAPI.updateFairySummonCost( - player.getUniqueId, - FairySummonCost(fairySummonCost.value % 4 + 1) - ) + fairyAPI + .updateFairySummonCost( + player.getUniqueId, + FairySummonCost(fairySummonCost.value % 4 + 1) + ) + .unsafeRunSync() ) ) } From aa79598355735186d5d5afd0fb4fcd8129190dc8 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 12:45:28 +0900 Subject: [PATCH 092/482] =?UTF-8?q?[Fix]=E7=B5=82=E4=BA=86=E6=99=82?= =?UTF-8?q?=E9=96=93=E3=81=AB=E5=88=B0=E9=81=94=E3=81=97=E3=81=9F=E9=9A=9B?= =?UTF-8?q?=E3=81=AB=E6=99=82=E9=96=93=E3=81=AE=E6=9B=B4=E6=96=B0=E3=81=8C?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=E4=B8=8D=E5=85=B7=E5=90=88?= =?UTF-8?q?,=E5=9B=9E=E5=BE=A9=E3=81=99=E3=82=8B=E3=81=A8=E3=81=8D?= =?UTF-8?q?=E3=81=AB=E3=83=AA=E3=83=B3=E3=82=B4=E3=82=92=E3=81=99=E3=81=B9?= =?UTF-8?q?=E3=81=A6=E6=B6=88=E8=B2=BB=E3=81=97=E3=81=A6=E3=81=97=E3=81=BE?= =?UTF-8?q?=E3=81=86=E4=B8=8D=E5=85=B7=E5=90=88=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/actions/BukkitRecoveryMana.scala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index a880bbbd13..8245196cd5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -49,8 +49,10 @@ object BukkitRecoveryMana { .isBefore(LocalDateTime.now()) ) { // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) - new FairySpeech[F, G] - .bye(player) >> fairyAPI.updateFairyUsingState(player, FairyUsingState.NotUsing) + (new FairySpeech[F, G].bye(player) >> fairyAPI.updateFairyUsingState( + player, + FairyUsingState.NotUsing + )).toIO.unsafeRunSync() } else { // 有効期限内 if (oldManaAmount.isFull) { @@ -119,7 +121,9 @@ object BukkitRecoveryMana { if (appleOpenState == AppleOpenState.NotOpen) { 0 } else { - Math.max(finallyAppleConsumptionAmount, mineStackedGachaRingoAmount) + if (mineStackedGachaRingoAmount > finallyAppleConsumptionAmount) + finallyAppleConsumptionAmount + else mineStackedGachaRingoAmount } // マナの回復量を算出する From d51891ddbb17cc9fb5fb40623153e0f250196135 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 13:22:35 +0900 Subject: [PATCH 093/482] =?UTF-8?q?[Remove]=E6=B6=88=E3=81=9B=E3=82=8B?= =?UTF-8?q?=E3=81=A8=E3=81=93=E3=82=8D=E3=81=BE=E3=81=A7=E3=81=A8=E3=82=8A?= =?UTF-8?q?=E3=81=82=E3=81=88=E3=81=9A=E6=B6=88=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/SeichiAssist.scala | 9 - .../seichiassist/data/MenuInventoryData.java | 258 ------------------ .../seichiassist/data/player/PlayerData.scala | 113 +------- .../manipulators/PlayerDataManipulator.scala | 142 +--------- .../listener/PlayerInventoryListener.scala | 210 +------------- .../listener/VotingFairyListener.scala | 224 --------------- .../unchama/seichiassist/menus/VoteMenu.scala | 21 +- .../seichiassist/task/PlayerDataLoading.scala | 9 - .../seichiassist/task/VotingFairyTask.scala | 70 ----- .../task/global/PlayerDataBackupRoutine.scala | 8 - .../PlayerDataRecalculationRoutine.scala | 6 - .../unchama/seichiassist/util/TimeUtils.scala | 35 --- 12 files changed, 22 insertions(+), 1083 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/listener/VotingFairyListener.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/task/VotingFairyTask.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/util/TimeUtils.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index c2b3838f9f..a9f84c3e5a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -652,11 +652,6 @@ class SeichiAssist extends JavaPlugin() { getServer.getPluginManager.registerEvents(_, this) } - // ランキングリストを最新情報に更新する - if (!SeichiAssist.databaseGateway.playerDataManipulator.successRankingUpdate()) { - throw new RuntimeException("ランキングデータの作成に失敗しました。サーバーを停止します…") - } - startRepeatedJobs() // サブシステムのリポジトリのバックアップ処理を走らせる @@ -809,8 +804,6 @@ object SeichiAssist { val ranklist_playtick: mutable.ArrayBuffer[RankData] = mutable.ArrayBuffer() // 投票ポイント表示用データリスト val ranklist_p_vote: mutable.ArrayBuffer[RankData] = mutable.ArrayBuffer() - // マナ妖精表示用のデータリスト - val ranklist_p_apple: mutable.ArrayBuffer[RankData] = mutable.ArrayBuffer() var instance: SeichiAssist = _ // デバッグフラグ(デバッグモード使用時はここで変更するのではなくconfig.ymlの設定値を変更すること!) @@ -821,8 +814,6 @@ object SeichiAssist { var seichiAssistConfig: Config = _ // (minestackに格納する)Gachadataに依存するデータリスト val msgachadatalist: mutable.ArrayBuffer[MineStackGachaData] = mutable.ArrayBuffer() - var allplayergiveapplelong = 0L - object Scopes { implicit val globalChatInterceptionScope: InterceptionScope[UUID, String] = { import PluginExecutionContexts.asyncShift diff --git a/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java b/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java index 14986ef4bd..44218715c2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java +++ b/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java @@ -5,7 +5,6 @@ import com.github.unchama.seichiassist.data.player.AchievementPoint; import com.github.unchama.seichiassist.data.player.PlayerData; import com.github.unchama.seichiassist.data.player.PlayerNickname; -import com.github.unchama.seichiassist.task.VotingFairyTask; import com.github.unchama.seichiassist.util.AsyncInventorySetter; import com.github.unchama.seichiassist.util.ItemMetaFactory; import org.bukkit.Bukkit; @@ -43,31 +42,6 @@ private MenuInventoryData() { private static final Map shopIndex = new HashMap<>(60, 0.75); private static final Map taihiIndex = new HashMap<>(60, 0.75); - private static final List> loreTable = Arrays.asList( - Collections.emptyList(), - Arrays.asList( - ChatColor.RED + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "ガンガンたべるぞ", - ChatColor.RESET + "" + ChatColor.GRAY + "とにかく妖精さんにりんごを開放します。", - ChatColor.RESET + "" + ChatColor.GRAY + "めっちゃ喜ばれます。" - ), - Arrays.asList( - ChatColor.YELLOW + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "バッチリたべよう", - ChatColor.RESET + "" + ChatColor.GRAY + "食べ過ぎないように注意しつつ", - ChatColor.RESET + "" + ChatColor.GRAY + "妖精さんにりんごを開放します。", - ChatColor.RESET + "" + ChatColor.GRAY + "喜ばれます。" - ), - Arrays.asList( - ChatColor.GREEN + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "リンゴだいじに", - ChatColor.RESET + "" + ChatColor.GRAY + "少しだけ妖精さんにりんごを開放します。", - ChatColor.RESET + "" + ChatColor.GRAY + "伝えると大抵落ち込みます。" - ), - Arrays.asList( - ChatColor.BLUE + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "リンゴつかうな", - ChatColor.RESET + "" + ChatColor.GRAY + "絶対にりんごを開放しません。", - ChatColor.RESET + "" + ChatColor.GRAY + "" - ) - ); - /** * (short) 3はダサいし、マジックコンスタントみたいだよね。 */ @@ -79,8 +53,6 @@ private MenuInventoryData() { */ private static final Function0 FALSE = () -> false; - private static final Consumer DIG100 = meta -> meta.addEnchant(Enchantment.DIG_SPEED, 100, false); - private static final ItemStack toMoveNicknameMenu = build( Material.BARRIER, @@ -88,18 +60,6 @@ private MenuInventoryData() { ChatColor.RESET + "" + ChatColor.DARK_RED + "" + ChatColor.UNDERLINE + "クリックで移動" ); - //投票特典受け取りボタン - private static List getVoteButtonLore(final PlayerData playerdata) { - return Arrays.asList( - ChatColor.RESET + "" + ChatColor.GRAY + "投票特典を受け取るには", - ChatColor.RESET + "" + ChatColor.GRAY + "投票ページで投票した後", - ChatColor.RESET + "" + ChatColor.GRAY + "このボタンをクリックします", - ChatColor.RESET + "" + ChatColor.AQUA + "特典受取済投票回数:" + playerdata.p_givenvote(), - ChatColor.RESET + "" + ChatColor.AQUA + "特典未受取投票回数:" + (playerdata.p_vote_forT() - playerdata.p_givenvote()), - ChatColor.RESET + "" + ChatColor.AQUA + "所有投票pt:" + playerdata.effectPoint() - ); - } - /** * 二つ名組み合わせ * @param p プレイヤー @@ -593,224 +553,6 @@ public static Inventory computePartsShopMenu(final Player p) { return inventory; } - /** - * 投票妖精メニュー - * @param p プレイヤー - * @return メニュー - */ - public static Inventory getVotingMenuData(final Player p) { - //UUID取得 - final UUID uuid = p.getUniqueId(); - //プレイヤーデータ - final PlayerData playerdata = SeichiAssist.playermap().apply(uuid); - //念のためエラー分岐 - if (isError(p, playerdata, "投票妖精")) return null; - final Inventory inventory = getEmptyInventory(4, ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "投票ptメニュー"); - - //投票pt受け取り - { - // dynamic button - final ItemStack itemstack = build( - Material.DIAMOND, - ChatColor.LIGHT_PURPLE + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "クリックで投票特典を受け取れます", - getVoteButtonLore(playerdata), - DIG100 - ); - AsyncInventorySetter.setItemAsync(inventory, 0, itemstack); - } - - // ver0.3.2 投票ページ表示 - // const button - { - final List lore = Arrays.asList(ChatColor.RESET + "" + ChatColor.GREEN + "投票すると様々な特典が!", - ChatColor.RESET + "" + ChatColor.GREEN + "1日1回投票出来ます", - ChatColor.RESET + "" + ChatColor.DARK_GRAY + "クリックするとチャット欄に", - ChatColor.RESET + "" + ChatColor.DARK_GRAY + "URLが表示されますので", - ChatColor.RESET + "" + ChatColor.DARK_GRAY + "Tキーを押してから", - ChatColor.RESET + "" + ChatColor.DARK_GRAY + "そのURLをクリックしてください" - ); - - final ItemStack itemstack = build( - Material.BOOK_AND_QUILL, - ChatColor.YELLOW + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "投票ページにアクセス", - lore - ); - AsyncInventorySetter.setItemAsync(inventory, 9, itemstack); - } - - //棒メニューに戻る - { - // const button - final List lore = Collections.singletonList(ChatColor.RESET + "" + ChatColor.DARK_RED + "" + ChatColor.UNDERLINE + "クリックで移動"); - final ItemStack itemstack = buildPlayerSkull(ChatColor.YELLOW + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "ホームへ", lore, "MHF_ArrowLeft"); - AsyncInventorySetter.setItemAsync(inventory, 27, itemstack.clone()); - } - - //妖精召喚時間設定トグルボタン - { - // const button - final List list = Arrays.asList( - ChatColor.RESET + "" + ChatColor.GREEN + "" + ChatColor.BOLD + "" + VotingFairyTask.dispToggleVFTime(playerdata.toggleVotingFairy()), - "", - ChatColor.RESET + "" + ChatColor.GRAY + "コスト", - ChatColor.RESET + "" + ChatColor.RED + "" + ChatColor.BOLD + "" + playerdata.toggleVotingFairy() * 2 + "投票pt", - "", - ChatColor.RESET + "" + ChatColor.DARK_RED + "" + ChatColor.UNDERLINE + "クリックで切替" - ); - - final ItemStack itemStack = build( - Material.WATCH, - ChatColor.AQUA + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "マナ妖精 時間設定", - list - ); - - AsyncInventorySetter.setItemAsync(inventory, 2, itemStack); - } - - //妖精契約設定トグル - { - final ItemStack itemStack = new ItemStack(Material.PAPER); - itemStack.setItemMeta(getVotingFairyContractMeta(playerdata)); - AsyncInventorySetter.setItemAsync(inventory, 11, itemStack); - } - //妖精音トグル - { - final ItemStack itemStack = new ItemStack(Material.JUKEBOX); - itemStack.setItemMeta(getVotingFairySoundsToggleMeta(playerdata.toggleVFSound())); - AsyncInventorySetter.setItemAsync(inventory, 20, itemStack); - } - - //妖精召喚 - { - final List lore = Arrays.asList( - ChatColor.RESET + "" + ChatColor.GRAY + "" + playerdata.toggleVotingFairy() * 2 + "投票ptを消費して", - ChatColor.RESET + "" + ChatColor.GRAY + "マナ妖精を呼びます", - ChatColor.RESET + "" + ChatColor.GRAY + "時間 : " + VotingFairyTask.dispToggleVFTime(playerdata.toggleVotingFairy()), - ChatColor.RESET + "" + ChatColor.DARK_RED + "Lv.10以上で解放" - ); - - // dynamic button - final ItemStack itemStack = build( - Material.GHAST_TEAR, - ChatColor.LIGHT_PURPLE + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "マナ妖精 召喚", - lore, - DIG100 - ); - - AsyncInventorySetter.setItemAsync(inventory, 4, itemStack); - } - - - if (playerdata.usingVotingFairy()) { - //妖精 時間確認 - { - // const button - final List lore = Arrays.asList( - ChatColor.RESET + "" + ChatColor.GRAY + "妖精さんはいそがしい。", - ChatColor.GRAY + "帰っちゃう時間を教えてくれる" - ); - - final ItemStack itemStack = build( - Material.COMPASS, - ChatColor.LIGHT_PURPLE + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "マナ妖精に時間を聞く", - lore, - DIG100 - ); - - AsyncInventorySetter.setItemAsync(inventory, 13, itemStack); - } - - { - // dynamic button - final int yourRank = playerdata.calcPlayerApple(); - final List lore = new ArrayList<>(6 + 2 * 4 + 5); - - // 6 - lore.addAll(Arrays.asList( - ChatColor.RESET + "" + ChatColor.RED + "" + ChatColor.BOLD + "※ニンゲンに見られないように気を付けること!", - ChatColor.RESET + "" + ChatColor.RED + "" + ChatColor.BOLD + " 毎日大妖精からデータを更新すること!", - "", - ChatColor.RESET + "" + ChatColor.GOLD + "" + ChatColor.BOLD + "昨日までにがちゃりんごを", - ChatColor.RESET + "" + ChatColor.GOLD + "" + ChatColor.BOLD + "たくさんくれたニンゲンたち", - ChatColor.RESET + "" + ChatColor.DARK_GRAY + "召喚されたらラッキーだよ!" - )); - for (int rank = 0; rank <= 3; rank++) { - if (rank >= SeichiAssist.ranklist_p_apple().size()) { - break; - } - final RankData rankdata = SeichiAssist.ranklist_p_apple().apply(rank); - if (rankdata.p_apple == 0) { - break; - } - // 2 x 4 = 8 - lore.add(ChatColor.GRAY + "たくさんくれたニンゲン第" + (rank + 1) + "位!"); - lore.add(ChatColor.GRAY + "なまえ:" + rankdata.name + " りんご:" + rankdata.p_apple + "個"); - } - - // 5 - lore.add(ChatColor.AQUA + "ぜーんぶで" + SeichiAssist.allplayergiveapplelong() + "個もらえた!"); - lore.add(""); - lore.add(ChatColor.GREEN + "↓呼び出したニンゲンの情報↓"); - lore.add(ChatColor.GREEN + "今までに" + playerdata.p_apple() + "個もらった"); - lore.add(ChatColor.GREEN + "ニンゲンの中では" + yourRank + "番目にたくさんくれる!"); - - final ItemStack itemStack = build( - Material.GOLDEN_APPLE, - ChatColor.YELLOW + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "㊙ がちゃりんご情報 ㊙", - lore, - DIG100 - ); - AsyncInventorySetter.setItemAsync(inventory, 6, itemStack); - } - } - - return inventory; - } - - /** - * 投票妖精音切り替え - * @param playSound trueなら鳴らす - * @return ラベルがついたアイテム - */ - private static ItemMeta getVotingFairySoundsToggleMeta(final boolean playSound) { - final ItemMeta itemmeta = Bukkit.getItemFactory().getItemMeta(Material.JUKEBOX); - final List lore; - itemmeta.setDisplayName(ChatColor.GOLD + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "マナ妖精の音トグル"); - if (playSound) { - lore = Arrays.asList( - ChatColor.RESET + "" + ChatColor.GREEN + "現在音が鳴る設定になっています。", - ChatColor.RESET + "" + ChatColor.DARK_GRAY + "※この機能はデフォルトでONです。", - ChatColor.RESET + "" + ChatColor.DARK_RED + "" + ChatColor.UNDERLINE + "クリックで切替" - ); - } else { - lore = Arrays.asList( - ChatColor.RESET + "" + ChatColor.RED + "現在音が鳴らない設定になっています。", - ChatColor.RESET + "" + ChatColor.DARK_GRAY + "※この機能はデフォルトでONです。", - ChatColor.RESET + "" + ChatColor.DARK_RED + "" + ChatColor.UNDERLINE + "クリックで切替" - ); - itemmeta.addEnchant(Enchantment.DIG_SPEED, 100, false); - } - itemmeta.setLore(lore); - - return itemmeta; - } - - /** - * 投票妖精戦略 - * @param playerdata プレイヤーの設定 - * @return ラベルが付いたアイテム - */ - private static ItemMeta getVotingFairyContractMeta(final PlayerData playerdata) { - final ItemMeta itemmeta = Bukkit.getItemFactory().getItemMeta(Material.PAPER); - itemmeta.setDisplayName(ChatColor.GOLD + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "妖精とのお約束"); - // n % 4 + 1 -> 1..4 - final int strategy = playerdata.toggleGiveApple(); - final List lore = loreTable.get(strategy); - - itemmeta.setLore(lore); - return itemmeta; - } - /** * GiganticBerserk進化設定 * @param p diff --git a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala index e3d0d96229..a46743daed 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala +++ b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala @@ -2,24 +2,21 @@ package com.github.unchama.seichiassist.data.player import cats.effect.IO import cats.effect.concurrent.Ref -import com.github.unchama.generic.ClosedRange import com.github.unchama.seichiassist._ import com.github.unchama.seichiassist.achievement.Nicknames import com.github.unchama.seichiassist.data.GridTemplate import com.github.unchama.seichiassist.data.player.settings.PlayerSettings import com.github.unchama.seichiassist.minestack.MineStackUsageHistory import com.github.unchama.seichiassist.subsystems.breakcount.domain.level.SeichiStarLevel -import com.github.unchama.seichiassist.task.VotingFairyTask +import com.github.unchama.seichiassist.util.RelativeDirection import com.github.unchama.seichiassist.util.exp.{ExperienceManager, IExperienceManager} -import com.github.unchama.seichiassist.util.{RelativeDirection, TimeUtils} import com.github.unchama.targetedeffect.commandsender.MessageEffect import org.bukkit.ChatColor._ import org.bukkit._ import org.bukkit.command.CommandSender import org.bukkit.entity.Player -import java.text.SimpleDateFormat -import java.util.{GregorianCalendar, NoSuchElementException, UUID} +import java.util.{NoSuchElementException, UUID} import scala.collection.mutable /** @@ -48,7 +45,6 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { // プレイヤー名 val lowercaseName: String = name.toLowerCase() - private val dummyDate = new GregorianCalendar(2100, 1, 1, 0, 0, 0) // チェスト破壊トグル var chestflag = true @@ -101,7 +97,6 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { // region スキル関連のデータ val skillState: Ref[IO, PlayerSkillState] = Ref.unsafe(PlayerSkillState.initial) var skillEffectState: PlayerSkillEffectState = PlayerSkillEffectState.initial - var effectPoint: Int = 0 // endregion // 二つ名解禁フラグ保存用 @@ -117,15 +112,6 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { // n周年記念 var anniversary = false var templateMap: mutable.Map[Int, GridTemplate] = mutable.HashMap() - // 投票妖精関連 - var usingVotingFairy = false - var voteFairyPeriod = new ClosedRange(dummyDate, dummyDate) - var hasVotingFairyMana = 0 - var VotingFairyRecoveryValue = 0 - var toggleGiveApple = 1 - var toggleVotingFairy = 1 - var p_apple: Long = 0 - var toggleVFSound = true var giganticBerserk: GiganticBerserk = GiganticBerserk() // ハーフブロック破壊抑制用 @@ -171,7 +157,6 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { synchronizeDisplayNameToLevelState() loadTotalExp() - isVotingFairy() } // レベルを更新 @@ -260,27 +245,6 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { expmanager.setExp(totalexp) } - private def isVotingFairy(): Unit = { - // 効果は継続しているか - if ( - this.usingVotingFairy && !TimeUtils.isVotingFairyPeriod( - this.votingFairyStartTime, - this.votingFairyEndTime - ) - ) { - this.usingVotingFairy = false - player.sendMessage(s"$LIGHT_PURPLE${BOLD}妖精は何処かへ行ってしまったようだ...") - } else if (this.usingVotingFairy) { - VotingFairyTask.speak(player, "おかえり!" + player.getName, true) - } - } - - def votingFairyEndTime: GregorianCalendar = voteFairyPeriod.endInclusive - - def votingFairyEndTime_=(value: GregorianCalendar): Unit = { - voteFairyPeriod = new ClosedRange(voteFairyPeriod.start, value) - } - def updateNickname( id1: Int = settings.nickname.id1, id2: Int = settings.nickname.id2, @@ -338,24 +302,6 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { effectPoint -= 10 } - def calcPlayerApple(): Int = { - // ランク用関数 - var i = 0 - val t = p_apple - - if (SeichiAssist.ranklist_p_apple.isEmpty) return 1 - - var rankdata = SeichiAssist.ranklist_p_apple(i) - - // ランクが上がらなくなるまで処理 - while (rankdata.p_apple > t) { - i += 1 - rankdata = SeichiAssist.ranklist_p_apple(i) - } - - i + 1 - } - // パッシブスキルの獲得量表示 def getPassiveExp: Double = { val level = @@ -435,8 +381,6 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { } } - import com.github.unchama.seichiassist.AntiTypesafe - def addUnitAmount(direction: RelativeDirection, amount: Int): Unit = { direction match { case RelativeDirection.AHEAD => @@ -458,59 +402,6 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { } } - @AntiTypesafe - def getVotingFairyStartTimeAsString: String = { - val cal = this.votingFairyStartTime - - if (votingFairyStartTime == dummyDate) { - // 設定されてない場合 - ",,,,," - } else { - // 設定されてる場合 - val date = cal.getTime - val format = new SimpleDateFormat("yyyy,MM,dd,HH,mm,") - format.format(date) - } - } - - def votingFairyStartTime: GregorianCalendar = voteFairyPeriod.start - - def votingFairyStartTime_=(value: GregorianCalendar): Unit = { - voteFairyPeriod = new ClosedRange(value, voteFairyPeriod.endInclusive) - } - - def setVotingFairyTime(@AntiTypesafe str: String): Unit = { - val s = str.split(",") - if (s.size < 5) return - if (!s.slice(0, 5).contains("")) { - val year = s(0).toInt - val month = s(1).toInt - 1 - val dayOfMonth = s(2).toInt - val starts = new GregorianCalendar( - year, - month, - dayOfMonth, - Integer.parseInt(s(3)), - Integer.parseInt(s(4)) - ) - - var min = Integer.parseInt(s(4)) + 1 - var hour = Integer.parseInt(s(3)) - - min = if (this.toggleVotingFairy % 2 != 0) min + 30 else min - hour = this.toggleVotingFairy match { - case 2 | 3 => hour + 1 - case 4 => hour + 2 - case _ => hour - } - - val ends = new GregorianCalendar(year, month, dayOfMonth, hour, min) - - this.votingFairyStartTime = starts - this.votingFairyEndTime = ends - } - } - /** * 運営権限により強制的に実績を解除することを試みる。 * 解除に成功し、このインスタンスが指す[Player]がオンラインであるならばその[Player]に解除の旨がチャットにて通知される。 diff --git a/src/main/scala/com/github/unchama/seichiassist/database/manipulators/PlayerDataManipulator.scala b/src/main/scala/com/github/unchama/seichiassist/database/manipulators/PlayerDataManipulator.scala index f65fe2b769..2fae25c4d5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/database/manipulators/PlayerDataManipulator.scala +++ b/src/main/scala/com/github/unchama/seichiassist/database/manipulators/PlayerDataManipulator.scala @@ -4,10 +4,9 @@ import cats.data.EitherT import cats.effect.IO import com.github.unchama.contextualexecutor.builder.ResponseEffectOrResult import com.github.unchama.seichiassist.SeichiAssist -import com.github.unchama.seichiassist.data.RankData import com.github.unchama.seichiassist.data.player.PlayerData import com.github.unchama.seichiassist.database.{DatabaseConstants, DatabaseGateway} -import com.github.unchama.seichiassist.task.{CoolDownTask, PlayerDataLoading} +import com.github.unchama.seichiassist.task.PlayerDataLoading import com.github.unchama.seichiassist.util.BukkitSerialization import com.github.unchama.targetedeffect.TargetedEffect import com.github.unchama.targetedeffect.commandsender.MessageEffect @@ -26,63 +25,9 @@ class PlayerDataManipulator(private val gateway: DatabaseGateway) { import com.github.unchama.util.syntax.ResultSetSyntax._ - private val plugin = SeichiAssist.instance - private val tableReference: String = s"${gateway.databaseName}.${DatabaseConstants.PLAYERDATA_TABLENAME}" - // 投票特典配布時の処理(p_givenvoteの値の更新もココ) - def compareVotePoint(player: Player, playerdata: PlayerData): Int = { - ifCoolDownDoneThenGet(player, playerdata) { - val struuid = playerdata.uuid.toString - - var p_vote = 0 - var p_givenvote = 0 - - var command = s"select p_vote,p_givenvote from $tableReference where uuid = '$struuid'" - try { - gateway.executeQuery(command).recordIteration { lrs => - p_vote = lrs.getInt("p_vote") - p_givenvote = lrs.getInt("p_givenvote") - } - } catch { - case e: SQLException => - println("sqlクエリの実行に失敗しました。以下にエラーを表示します") - e.printStackTrace() - player.sendMessage(RED.toString + "投票特典の受け取りに失敗しました") - return 0 - } - - // 比較して差があればその差の値を返す(同時にp_givenvoteも更新しておく) - if (p_vote > p_givenvote) { - command = ("update " + tableReference - + " set p_givenvote = " + p_vote - + s" where uuid = '$struuid'") - if (gateway.executeUpdate(command) == ActionStatus.Fail) { - player.sendMessage(RED.toString + "投票特典の受け取りに失敗しました") - return 0 - } - - return p_vote - p_givenvote - } - player.sendMessage(YELLOW.toString + "投票特典は全て受け取り済みのようです") - 0 - } - } - - @inline private def ifCoolDownDoneThenGet(player: Player, playerdata: PlayerData)( - supplier: => Int - ): Int = { - // 連打による負荷防止の為クールダウン処理 - if (!playerdata.votecooldownflag) { - player.sendMessage(RED.toString + "しばらく待ってからやり直してください") - return 0 - } - new CoolDownTask(player, true, false).runTaskLater(plugin, 1200) - - supplier - } - // 最新のnumofsorryforbug値を返してmysqlのnumofsorrybug値を初期化する処理 def givePlayerBug(player: Player): Int = { val uuid = player.getUniqueId.toString @@ -175,91 +120,6 @@ class PlayerDataManipulator(private val gateway: DatabaseGateway) { uuidList.toList } - /** - * 全ランキングリストの更新処理 - * - * @return - * 成否…true: 成功、false: 失敗 TODO この処理はDB上と通信を行う為非同期にすべき - */ - def successRankingUpdate(): Boolean = { - if (!successPlayTickRankingUpdate()) return false - if (!successVoteRankingUpdate()) return false - successAppleNumberRankingUpdate() - } - - // ランキング表示用にプレイ時間のカラムだけ全員分引っ張る - private def successPlayTickRankingUpdate(): Boolean = { - val ranklist = mutable.ArrayBuffer[RankData]() - val command = ("select name,playtick from " + tableReference - + " order by playtick desc") - try { - gateway.executeQuery(command).recordIteration { lrs => - val rankdata = new RankData() - rankdata.name = lrs.getString("name") - rankdata.playtick = lrs.getInt("playtick") - ranklist += rankdata - } - } catch { - case e: SQLException => - println("sqlクエリの実行に失敗しました。以下にエラーを表示します") - e.printStackTrace() - return false - } - - SeichiAssist.ranklist_playtick.clear() - SeichiAssist.ranklist_playtick.addAll(ranklist) - true - } - - // ランキング表示用に投票数のカラムだけ全員分引っ張る - private def successVoteRankingUpdate(): Boolean = { - val ranklist = mutable.ArrayBuffer[RankData]() - val command = ("select name,p_vote from " + tableReference - + " order by p_vote desc") - try { - gateway.executeQuery(command).recordIteration { lrs => - val rankdata = new RankData() - rankdata.name = lrs.getString("name") - rankdata.p_vote = lrs.getInt("p_vote") - ranklist += rankdata - } - } catch { - case e: SQLException => - println("sqlクエリの実行に失敗しました。以下にエラーを表示します") - e.printStackTrace() - return false - } - - SeichiAssist.ranklist_p_vote.clear() - SeichiAssist.ranklist_p_vote.addAll(ranklist) - true - } - - // ランキング表示用に上げたりんご数のカラムだけ全員分引っ張る - private def successAppleNumberRankingUpdate(): Boolean = { - val ranklist = mutable.ArrayBuffer[RankData]() - SeichiAssist.allplayergiveapplelong = 0 - val command = s"select name,p_apple from $tableReference order by p_apple desc" - try { - gateway.executeQuery(command).recordIteration { lrs => - val rankdata = new RankData() - rankdata.name = lrs.getString("name") - rankdata.p_apple = lrs.getInt("p_apple") - ranklist += rankdata - SeichiAssist.allplayergiveapplelong += rankdata.p_apple.toLong - } - } catch { - case e: SQLException => - println("sqlクエリの実行に失敗しました。以下にエラーを表示します") - e.printStackTrace() - return false - } - - SeichiAssist.ranklist_p_apple.clear() - SeichiAssist.ranklist_p_apple.addAll(ranklist) - true - } - // 全員に詫びガチャの配布 def addAllPlayerBug(amount: Int): ActionStatus = { val command = s"update $tableReference set numofsorryforbug = numofsorryforbug + $amount" diff --git a/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala b/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala index 217b112af4..6f8297c30a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala +++ b/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala @@ -6,26 +6,19 @@ import com.github.unchama.menuinventory.router.CanOpen import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist._ import com.github.unchama.seichiassist.data.player.GiganticBerserk -import com.github.unchama.seichiassist.data.{GachaSkullData, ItemData, MenuInventoryData} -import com.github.unchama.seichiassist.effects.player.CommonSoundEffects +import com.github.unchama.seichiassist.data.{GachaSkullData, MenuInventoryData} import com.github.unchama.seichiassist.listener.invlistener.OnClickTitleMenu import com.github.unchama.seichiassist.menus.achievement.AchievementMenu -import com.github.unchama.seichiassist.menus.stickmenu.{FirstPage, StickMenu} +import com.github.unchama.seichiassist.menus.stickmenu.FirstPage import com.github.unchama.seichiassist.subsystems.mana.ManaApi -import com.github.unchama.seichiassist.task.VotingFairyTask -import com.github.unchama.seichiassist.util.{ - InventoryOperations, - StaticGachaPrizeFactory, - TimeUtils -} +import com.github.unchama.seichiassist.util.{InventoryOperations, StaticGachaPrizeFactory} import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import org.bukkit.ChatColor._ import org.bukkit.enchantments.Enchantment import org.bukkit.entity.{EntityType, Player} -import org.bukkit.event.inventory.{InventoryClickEvent, InventoryCloseEvent, InventoryType} +import org.bukkit.event.inventory.{InventoryClickEvent, InventoryCloseEvent} import org.bukkit.event.{EventHandler, Listener} -import org.bukkit.inventory.meta.SkullMeta import org.bukkit.inventory.{ItemFlag, ItemStack} import org.bukkit.{Bukkit, Material, Sound} @@ -45,7 +38,6 @@ class PlayerInventoryListener( private val playerMap = SeichiAssist.playermap private val gachaDataList = SeichiAssist.gachadatalist - private val databaseGateway = SeichiAssist.databaseGateway // ガチャ交換システム @EventHandler @@ -385,200 +377,6 @@ class PlayerInventoryListener( } - // 投票ptメニュー -// @EventHandler - def onVotingMenuEvent(event: InventoryClickEvent): Unit = { - // 外枠のクリック処理なら終了 - if (event.getClickedInventory == null) { - return - } - - val itemstackcurrent = event.getCurrentItem - val view = event.getView - val he = view.getPlayer - // インベントリを開けたのがプレイヤーではない時終了 - if (he.getType != EntityType.PLAYER) { - return - } - - val topinventory = view.getTopInventory.ifNull { - return - } - // インベントリが存在しない時終了 - // インベントリサイズが4列でない時終了 - if (topinventory.row != 4) { - return - } - val player = he.asInstanceOf[Player] - val uuid = player.getUniqueId - val playerdata = playerMap(uuid) - - val playerLevel = SeichiAssist - .instance - .breakCountSystem - .api - .seichiAmountDataRepository(player) - .read - .unsafeRunSync() - .levelCorrespondingToExp - .level - - // インベントリ名が以下の時処理 - if (topinventory.getTitle == DARK_PURPLE.toString + "" + BOLD + "投票ptメニュー") { - event.setCancelled(true) - - if (event.getClickedInventory.getType == InventoryType.PLAYER) { - return - } - - val isSkull = itemstackcurrent.getType == Material.SKULL_ITEM - - /* - * クリックしたボタンに応じた各処理内容の記述ここから - */ - - // 投票pt受取 - if (itemstackcurrent.getType == Material.DIAMOND) { - // nは特典をまだ受け取ってない投票分 - var n = databaseGateway.playerDataManipulator.compareVotePoint(player, playerdata) - // 投票数に変化が無ければ処理終了 - if (n == 0) { - return - } - // 先にp_voteの値を更新しておく - playerdata.p_givenvote = playerdata.p_givenvote + n - - var count = 0 - while (n > 0) { - // ここに投票1回につきプレゼントする特典の処理を書く - - // ガチャ券プレゼント処理 - val skull = GachaSkullData.gachaForVoting - for { _ <- 0 to 9 } { - if ( - player.getInventory.contains(skull) || !InventoryOperations.isPlayerInventoryFull( - player - ) - ) { - InventoryOperations.addItem(player, skull) - } else { - InventoryOperations.dropItem(player, skull) - } - } - - // ピッケルプレゼント処理(レベル50になるまで) - if (playerLevel < 50) { - val pickaxe = ItemData.getSuperPickaxe(1) - if (InventoryOperations.isPlayerInventoryFull(player)) { - InventoryOperations.dropItem(player, pickaxe) - } else { - InventoryOperations.addItem(player, pickaxe) - } - } - - // 投票ギフト処理(レベル50から) - if (playerLevel >= 50) { - val gift = ItemData.getVotingGift(1) - if (InventoryOperations.isPlayerInventoryFull(player)) { - InventoryOperations.dropItem(player, gift) - } else { - InventoryOperations.addItem(player, gift) - } - } - // エフェクトポイント加算処理 - playerdata.effectPoint += 10 - - n -= 1 - count += 1 - } - - player.sendMessage(GOLD.toString + "投票特典" + WHITE + "(" + count + "票分)を受け取りました") - player.playSound(player.getLocation, Sound.BLOCK_ANVIL_PLACE, 1f, 1f) - - val itemmeta = itemstackcurrent.getItemMeta - itemstackcurrent.setItemMeta(itemmeta) - player.openInventory(MenuInventoryData.getVotingMenuData(player)) - } else if (itemstackcurrent.getType == Material.BOOK_AND_QUILL) { - // 投票リンク表示 - player.sendMessage( - RED.toString + "" + UNDERLINE + "https://minecraft.jp/servers/54d3529e4ddda180780041a7/vote" - ) - player.sendMessage( - RED.toString + "" + UNDERLINE + "https://monocraft.net/servers/Cf3BffNIRMERDNbAfWQm" - ) - player.playSound(player.getLocation, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) - player.closeInventory() - } else if ( - isSkull && itemstackcurrent - .getItemMeta - .asInstanceOf[SkullMeta] - .getOwningPlayer - .getName == "MHF_ArrowLeft" - ) { - - effectEnvironment.unsafeRunAsyncTargetedEffect(player)( - SequentialEffect( - CommonSoundEffects.menuTransitionFenceSound, - ioCanOpenFirstPage.open(StickMenu.firstPage) - ), - "棒メニューの1ページ目を開く" - ) - - // NOTE: WHEN - } else if (itemstackcurrent.getType == Material.WATCH) { - player.playSound(player.getLocation, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) - playerdata.toggleVotingFairy = playerdata.toggleVotingFairy % 4 + 1 - player.openInventory(MenuInventoryData.getVotingMenuData(player)) - } else if (itemstackcurrent.getType == Material.PAPER) { - player.playSound(player.getLocation, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) - playerdata.toggleGiveApple = playerdata.toggleGiveApple % 4 + 1 - player.openInventory(MenuInventoryData.getVotingMenuData(player)) - } else if (itemstackcurrent.getType == Material.JUKEBOX) { - player.playSound(player.getLocation, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) - playerdata.toggleVFSound = !playerdata.toggleVFSound - player.openInventory(MenuInventoryData.getVotingMenuData(player)) - } else if (itemstackcurrent.getType == Material.GHAST_TEAR) { - player.closeInventory() - - // プレイヤーレベルが10に達していないとき - if (playerLevel < 10) { - player.sendMessage(GOLD.toString + "プレイヤーレベルが足りません") - player.playSound(player.getLocation, Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) - return - } - - // 既に妖精召喚している場合終了 - if (playerdata.usingVotingFairy) { - player.sendMessage(GOLD.toString + "既に妖精を召喚しています") - player.playSound(player.getLocation, Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) - return - } - - // 投票ptが足りない場合終了 - if (playerdata.effectPoint < playerdata.toggleVotingFairy * 2) { - player.sendMessage(GOLD.toString + "投票ptが足りません") - player.playSound(player.getLocation, Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) - return - } - - VotingFairyListener.summon(player) - player.closeInventory() - } else if (itemstackcurrent.getType == Material.COMPASS) { - VotingFairyTask.speak( - player, - "僕は" + TimeUtils.showHour(playerdata.votingFairyEndTime) + "には帰るよー。", - playerdata.toggleVFSound - ) - player.closeInventory() - } // 妖精召喚 - // 妖精音トグル - // 妖精リンゴトグル - // 妖精時間トグル - // 棒メニューに戻る - - } - } - @EventHandler def onGiganticBerserkMenuEvent(event: InventoryClickEvent): Unit = { // 外枠のクリック処理なら終了 diff --git a/src/main/scala/com/github/unchama/seichiassist/listener/VotingFairyListener.scala b/src/main/scala/com/github/unchama/seichiassist/listener/VotingFairyListener.scala deleted file mode 100644 index 26bd6e7626..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/listener/VotingFairyListener.scala +++ /dev/null @@ -1,224 +0,0 @@ -package com.github.unchama.seichiassist.listener - -import cats.effect.{IO, SyncIO} -import com.github.unchama.seichiassist.subsystems.breakcount.domain.level.SeichiLevel -import com.github.unchama.seichiassist.subsystems.mana.domain.ManaAmount -import com.github.unchama.seichiassist.subsystems.mana.{ManaApi, ManaReadApi} -import com.github.unchama.seichiassist.task.VotingFairyTask -import com.github.unchama.seichiassist.util.TimeUtils -import com.github.unchama.seichiassist.{MineStackObjectList, SeichiAssist} -import org.bukkit.ChatColor._ -import org.bukkit.entity.Player -import org.bukkit.event.Listener - -import java.util.{Calendar, GregorianCalendar} -import scala.util.Random - -object VotingFairyListener { - def summon(p: Player)(implicit manaApi: ManaReadApi[IO, SyncIO, Player]): Unit = { - val playermap = SeichiAssist.playermap - val uuid = p.getUniqueId - val playerdata = playermap.apply(uuid) - - // 召喚した時間を取り出す - playerdata.votingFairyStartTime = new GregorianCalendar( - Calendar.getInstance.get(Calendar.YEAR), - Calendar.getInstance.get(Calendar.MONTH), - Calendar.getInstance.get(Calendar.DATE), - Calendar.getInstance.get(Calendar.HOUR_OF_DAY), - Calendar.getInstance.get(Calendar.MINUTE) - ) - - var min = Calendar.getInstance.get(Calendar.MINUTE) + 1 - var hour = Calendar.getInstance.get(Calendar.HOUR_OF_DAY) - min = if ((playerdata.toggleVotingFairy % 2) != 0) min + 30 else min - hour = - if (playerdata.toggleVotingFairy == 2) hour + 1 - else if (playerdata.toggleVotingFairy == 3) hour + 1 - else if (playerdata.toggleVotingFairy == 4) hour + 2 - else hour - - playerdata.votingFairyEndTime = new GregorianCalendar( - Calendar.getInstance.get(Calendar.YEAR), - Calendar.getInstance.get(Calendar.MONTH), - Calendar.getInstance.get(Calendar.DATE), - hour, - min - ) - - // 投票ptを減らす - playerdata.effectPoint_$eq(playerdata.effectPoint - playerdata.toggleVotingFairy * 2) - - // フラグ - playerdata.usingVotingFairy = true - - // マナ回復量最大値の決定 - val n = manaApi.readManaAmount(p).unsafeRunSync().cap.value - playerdata.VotingFairyRecoveryValue = - ((n / 10 - n / 30 + new Random().nextInt((n / 20).toInt)) / 2.9).toInt + 200 - - p.sendMessage(s"$RESET$YELLOW${BOLD}妖精を呼び出しました!") - p.sendMessage(s"$RESET$YELLOW${BOLD}この子は1分間に約${playerdata.VotingFairyRecoveryValue}マナ") - p.sendMessage(s"$RESET$YELLOW${BOLD}回復させる力を持っているようです。") - - // メッセージ - - val morning = List( - "おはよ![str1]", - "ヤッホー[str1]!", - "ふわぁ。。。[str1]の朝は早いね。", - "うーん、今日も一日頑張ろ!", - "今日は整地日和だね![str1]!" - ) - val day = List( - "やあ![str1]", - "ヤッホー[str1]!", - "あっ、[str1]じゃん。丁度お腹空いてたんだ!", - "この匂い…[str1]ってがちゃりんごいっぱい持ってる…?", - "今日のおやつはがちゃりんごいっぱいだ!" - ) - val night = List( - "やあ![str1]", - "ヤッホー[str1]!", - "ふわぁ。。。[str1]は夜も元気だね。", - "もう寝ようと思ってたのにー。[str1]はしょうがないなぁ", - "こんな時間に呼ぶなんて…りんごははずんでもらうよ?" - ) - - if (TimeUtils.getTimeZone(playerdata.votingFairyStartTime) == "morning") { - VotingFairyTask.speak(p, getMessage(morning, p.getName), playerdata.toggleVFSound) - } else if (TimeUtils.getTimeZone(playerdata.votingFairyStartTime) == "day") { - VotingFairyTask.speak(p, getMessage(day, p.getName), playerdata.toggleVFSound) - } else VotingFairyTask.speak(p, getMessage(night, p.getName), playerdata.toggleVFSound) - } - - private def getMessage(messages: List[String], str1: String) = { - val msg = messages(Random.nextInt(messages.size)) - if (str1.nonEmpty) msg.replace("[str1]", str1 + RESET) - else msg - } - - def regeneMana(player: Player)(implicit manaApi: ManaApi[IO, SyncIO, Player]): Unit = { - val playermap = SeichiAssist.playermap - val uuid = player.getUniqueId - val playerdata = playermap.apply(uuid) - - val oldManaAmount = manaApi.readManaAmount(player).unsafeRunSync() - - if (oldManaAmount.isFull) { - // マナが最大だった場合はメッセージを送信して終わり - val msg = List( - "整地しないのー?", - "たくさん働いて、たくさんりんごを食べようね!", - "僕はいつか大きながちゃりんごを食べ尽して見せるっ!", - "ちょっと食べ疲れちゃった", - "[str1]はどのりんごが好き?僕はがちゃりんご!", - "動いてお腹を空かしていっぱい食べるぞー!" - ) - VotingFairyTask.speak(player, getMessage(msg, player.getName), playerdata.toggleVFSound) - } else { - val playerLevel = - SeichiAssist - .instance - .breakCountSystem - .api - .seichiAmountDataRepository(player) - .read - .unsafeRunSync() - .levelCorrespondingToExp - - var n = playerdata.VotingFairyRecoveryValue // 実際のマナ回復量 - var m = getGiveAppleValue(playerLevel) // りんご消費量 - - // 連続投票によってりんご消費量を抑える - if (playerdata.ChainVote >= 30) m /= 2 - else if (playerdata.ChainVote >= 10) m = (m / 1.5).toInt - else if (playerdata.ChainVote >= 3) m = (m / 1.25).toInt - - // トグルで数値変更 - if (playerdata.toggleGiveApple == 2) - if (oldManaAmount.ratioToCap.exists(_ >= 0.75)) { - n /= 2 - m /= 2 - } else if (playerdata.toggleGiveApple == 3) { - n /= 2 - m /= 2 - } - - if (m == 0) m = 1 - - if (playerdata.toggleGiveApple == 4) { - n /= 4 - m = 0 - } else { - // ちょっとつまみ食いする - if (m >= 10) m += new Random().nextInt(m / 10) - } - - // りんご所持数で値変更 - val gachaimoObject = MineStackObjectList.findByName("gachaimo").unsafeRunSync().get - val l = playerdata.minestack.getStackedAmountOf(gachaimoObject) - if (m > l) { - if (l == 0) { - n /= 2 - if (playerdata.toggleGiveApple == 1) n /= 2 - if (playerdata.toggleGiveApple == 2 && oldManaAmount.ratioToCap.exists(_ < 0.75)) - n /= 2 - player.sendMessage(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") - } else { - val M = m - val L = l - n = if ((L / M) <= 0.5) (n * 0.5).toInt else (n * L / M).toInt - } - - m = l.toInt - } - - // 回復量に若干乱数をつける - n = (n - n / 100) + Random.nextInt(n / 50) - - // マナ回復 - manaApi.manaAmount(player).restoreAbsolute(ManaAmount(n)).unsafeRunSync() - - // りんごを減らす - playerdata - .minestack - .subtractStackedAmountOf( - MineStackObjectList.findByName("gachaimo").unsafeRunSync().get, - m - ) - - // 減ったりんごの数をplayerdataに加算 - playerdata.p_apple += m - - val yes = - List("(´~`)モグモグ…", "がちゃりんごって美味しいよね!", "あぁ!幸せ!", "[str1]のりんごはおいしいなぁ", "いつもりんごをありがとう!") - val no = List( - "お腹空いたなぁー。", - "がちゃりんごがっ!食べたいっ!", - "(´;ω;`)ウゥゥ ヒモジイ...", - "@うんちゃま [str1]が意地悪するんだっ!", - "うわーん!お腹空いたよー!" - ) - - player.sendMessage(s"$RESET$YELLOW${BOLD}マナ妖精が${n}マナを回復してくれました") - - if (m != 0) { - player.sendMessage(s"$RESET$YELLOW${BOLD}あっ!${m}個のがちゃりんごが食べられてる!") - VotingFairyTask.speak(player, getMessage(yes, player.getName), playerdata.toggleVFSound) - } else { - player.sendMessage(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") - VotingFairyTask.speak(player, getMessage(no, player.getName), playerdata.toggleVFSound) - } - } - } - - private def getGiveAppleValue(playerLevel: SeichiLevel): Int = { - // 10で切り捨て除算して二乗する。最低でも1は返す。 - val levelDividedByTen = playerLevel.level / 10 - - (levelDividedByTen * levelDividedByTen) max 1 - } -} - -class VotingFairyListener extends Listener {} diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index aff0163ea2..db40c6b2fd 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -4,8 +4,8 @@ import cats.effect.{ConcurrentEffect, IO, SyncIO} import cats.implicits.toTraverseOps import com.github.unchama.itemstackbuilder.IconItemStackBuilder import com.github.unchama.menuinventory.router.CanOpen -import com.github.unchama.menuinventory.slot.button.{Button, RecomputedButton} import com.github.unchama.menuinventory.slot.button.action.LeftClickButtonEffect +import com.github.unchama.menuinventory.slot.button.{Button, RecomputedButton} import com.github.unchama.menuinventory.syntax.IntInventorySizeOps import com.github.unchama.menuinventory.{ChestSlotRef, Menu, MenuFrame, MenuSlotLayout} import com.github.unchama.minecraft.actions.OnMinecraftServerThread @@ -25,7 +25,6 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p FairySummonCost, FairyUsingState } -import com.github.unchama.seichiassist.task.VotingFairyTask import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.player.PlayerEffects.closeInventoryEffect @@ -170,15 +169,25 @@ object VoteMenu extends Menu { } ) + def getFairyValidTime(fairySummonCost: FairySummonCost): String = { + fairySummonCost match { + case FairySummonCost(1) => "30分" + case FairySummonCost(2) => "1時間" + case FairySummonCost(3) => "1時間30分" + case FairySummonCost(4) => "2時間" + } + } + val fairySummonTimeToggleButton: IO[Button] = { RecomputedButton(IO { val fairySummonCost = fairyAPI.fairySummonCost(player).unsafeRunSync() + Button( new IconItemStackBuilder(Material.WATCH) .title(s"$AQUA$UNDERLINE${BOLD}マナ妖精 時間設定") .lore( List( - s"$RESET$GREEN$BOLD${VotingFairyTask.dispToggleVFTime(fairySummonCost.value)}", + s"$RESET$GREEN$BOLD${getFairyValidTime(fairySummonCost)}", "", s"$RESET${GRAY}コスト", s"$RESET$RED$BOLD${fairySummonCost.value * 2}投票pt", @@ -266,15 +275,15 @@ object VoteMenu extends Menu { val fairySummonButton: Button = { val fairySummonState = - fairyAPI.fairySummonCost(player).unsafeRunSync().value + fairyAPI.fairySummonCost(player).unsafeRunSync() Button( new IconItemStackBuilder(Material.GHAST_TEAR) .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}マナ妖精 召喚") .lore( List( - s"$RESET$GRAY${fairySummonState * 2}投票ptを消費して", + s"$RESET$GRAY${fairySummonState.value * 2}投票ptを消費して", s"$RESET${GRAY}マナ妖精を呼びます", - s"$RESET${GRAY}時間: ${VotingFairyTask.dispToggleVFTime(fairySummonState)}", + s"$RESET${GRAY}時間: ${getFairyValidTime(fairySummonState)}", s"$RESET${DARK_RED}Lv.10以上で開放" ) ) diff --git a/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala b/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala index cf19625120..3b250d0d4d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala +++ b/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala @@ -312,15 +312,6 @@ object PlayerDataLoading { playerData.TitleFlags.addOne(1) } - // マナ妖精 - playerData.usingVotingFairy = rs.getBoolean("canVotingFairyUse") - playerData.VotingFairyRecoveryValue = rs.getInt("VotingFairyRecoveryValue") - playerData.hasVotingFairyMana = rs.getInt("hasVotingFairyMana") - playerData.toggleGiveApple = rs.getInt("toggleGiveApple") - playerData.toggleVotingFairy = rs.getInt("toggleVotingFairy") - playerData.setVotingFairyTime(rs.getString("newVotingFairyTime")) - playerData.p_apple = rs.getLong("p_apple") - playerData.giganticBerserk = GiganticBerserk( rs.getInt("GBlevel"), rs.getInt("GBexp"), diff --git a/src/main/scala/com/github/unchama/seichiassist/task/VotingFairyTask.scala b/src/main/scala/com/github/unchama/seichiassist/task/VotingFairyTask.scala deleted file mode 100644 index ae4e62d4d6..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/task/VotingFairyTask.scala +++ /dev/null @@ -1,70 +0,0 @@ -package com.github.unchama.seichiassist.task - -import cats.effect.{IO, SyncIO} -import com.github.unchama.seichiassist.SeichiAssist -import com.github.unchama.seichiassist.listener.VotingFairyListener -import com.github.unchama.seichiassist.subsystems.mana.ManaApi -import com.github.unchama.seichiassist.util.TimeUtils -import net.md_5.bungee.api.ChatColor -import org.bukkit.ChatColor._ -import org.bukkit.entity.Player -import org.bukkit.{Bukkit, Sound} - -object VotingFairyTask { - // MinuteTaskRunnableから、妖精召喚中のプレイヤーを対象に毎分実行される - def run(p: Player)(implicit manaApi: ManaApi[IO, SyncIO, Player]): Unit = { - val playermap = SeichiAssist.playermap - val uuid = p.getUniqueId - val playerdata = playermap.apply(uuid) - // マナ回復 - VotingFairyListener.regeneMana(p) - // 効果時間中か - if ( - !TimeUtils.isVotingFairyPeriod( - playerdata.votingFairyStartTime, - playerdata.votingFairyEndTime - ) - ) { - speak(p, "あっ、もうこんな時間だ!", b = false) - speak(p, s"じゃーねー!${p.getName}", b = true) - p.sendMessage(s"$RESET$YELLOW${BOLD}妖精はどこかへ行ってしまった") - playerdata.usingVotingFairy_$eq(false) - } - } - - def speak(p: Player, msg: String, b: Boolean): Unit = { - if (b) playSe(p) - p.sendMessage(s"${ChatColor.AQUA}${ChatColor.BOLD}<マナ妖精>${ChatColor.RESET}$msg") - } - - // 妖精効果音 - private def playSe(p: Player): Unit = { - p.playSound(p.getLocation, Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f) - Bukkit - .getServer - .getScheduler - .runTaskLater( - SeichiAssist.instance, - (() => { - p.playSound(p.getLocation, Sound.BLOCK_NOTE_PLING, 2.0f, 1.5f) - Bukkit - .getServer - .getScheduler - .runTaskLater( - SeichiAssist.instance, - (() => p.playSound(p.getLocation, Sound.BLOCK_NOTE_PLING, 2.0f, 2.0f)): Runnable, - 2 - ) - }): Runnable, - 2 - ) - } - - def dispToggleVFTime(toggle: Int): String = { - if (toggle == 1) "30分" - else if (toggle == 2) "1時間" - else if (toggle == 3) "1時間30分" - else if (toggle == 4) "2時間" - else "エラー" - } -} diff --git a/src/main/scala/com/github/unchama/seichiassist/task/global/PlayerDataBackupRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/task/global/PlayerDataBackupRoutine.scala index 7edbb40a2f..957646237c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/task/global/PlayerDataBackupRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/task/global/PlayerDataBackupRoutine.scala @@ -45,19 +45,11 @@ object PlayerDataBackupRoutine { } yield () } - val updateRankingData = IO { - // ランキングリストを最新情報に更新する - if (!SeichiAssist.databaseGateway.playerDataManipulator.successRankingUpdate()) { - SeichiAssist.instance.getLogger.info("ランキングデータの作成に失敗しました") - } - } - for { saveRequired <- IO { SeichiAssist.playermap.nonEmpty } _ <- if (saveRequired) save else IO.unit - _ <- updateRankingData } yield true } diff --git a/src/main/scala/com/github/unchama/seichiassist/task/global/PlayerDataRecalculationRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/task/global/PlayerDataRecalculationRoutine.scala index 5d7ac38c1e..5d1deb5ef6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/task/global/PlayerDataRecalculationRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/task/global/PlayerDataRecalculationRoutine.scala @@ -6,7 +6,6 @@ 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.subsystems.mana.ManaApi -import com.github.unchama.seichiassist.task.VotingFairyTask import org.bukkit.Bukkit import org.bukkit.entity.Player @@ -77,11 +76,6 @@ object PlayerDataRecalculationRoutine { ) .unsafeRunSync() - // 投票妖精関連 - if (playerData.usingVotingFairy) { - VotingFairyTask.run(player) - } - // GiganticBerserk playerData.GBcd = 0 diff --git a/src/main/scala/com/github/unchama/seichiassist/util/TimeUtils.scala b/src/main/scala/com/github/unchama/seichiassist/util/TimeUtils.scala deleted file mode 100644 index b159dd3d4f..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/util/TimeUtils.scala +++ /dev/null @@ -1,35 +0,0 @@ -package com.github.unchama.seichiassist.util - -import java.text.SimpleDateFormat -import java.util.Calendar - -object TimeUtils { - def showTime(cal: Calendar): String = { - val date = cal.getTime - val format = new SimpleDateFormat("yyyy/MM/dd HH:mm") - format.format(date) - } - - def showHour(cal: Calendar): String = { - val date = cal.getTime - val format = new SimpleDateFormat("HH:mm") - format.format(date) - } - - def getTimeZone(cal: Calendar): String = { - val date = cal.getTime - val format = new SimpleDateFormat("HH") - val n = Integer.parseInt(format.format(date)) - if (4 <= n && n < 10) - "morning" - else if (10 <= n && n < 18) - "day" - else - "night" - } - - def isVotingFairyPeriod(start: Calendar, end: Calendar): Boolean = { - val cur = Calendar.getInstance() - cur.after(start) && cur.before(end) - } -} From 4464cf6ef6b17af5c2095c9f10d7d9447f648dcd Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 13:27:16 +0900 Subject: [PATCH 094/482] =?UTF-8?q?[Remove]=E5=8F=A4=E3=81=84=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=82=92=E6=B6=88=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/task/PlayerDataLoading.scala | 1 - .../unchama/seichiassist/task/PlayerDataSaveTask.scala | 10 ---------- 2 files changed, 11 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala b/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala index 3b250d0d4d..33a5413297 100644 --- a/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala +++ b/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala @@ -222,7 +222,6 @@ object PlayerDataLoading { playerData.regionCount = rs.getInt("rgnum") playerData.playTick = rs.getInt("playtick") playerData.p_givenvote = rs.getInt("p_givenvote") - playerData.effectPoint = rs.getInt("effectpoint") playerData.totalexp = rs.getInt("totalexp") diff --git a/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataSaveTask.scala b/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataSaveTask.scala index 0279ef00b0..553473f637 100644 --- a/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataSaveTask.scala +++ b/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataSaveTask.scala @@ -139,7 +139,6 @@ object PlayerDataSaveTask { .performMultipleIDBlockBreakWhenOutsideSeichiWorld + ",pvpflag = " + playerdata.settings.pvpflag - + ",effectpoint = " + playerdata.effectPoint + ",totalexp = " + playerdata.totalexp + ",everysound = " + playerdata .settings @@ -166,15 +165,6 @@ object PlayerDataSaveTask { + ",TotalJoin = " + playerdata.loginStatus.totalLoginDay + ",LimitedLoginCount = " + playerdata.LimitedLoginCount - // 投票 - + ",canVotingFairyUse = " + playerdata.usingVotingFairy - + ",newVotingFairyTime = '" + playerdata.getVotingFairyStartTimeAsString + "'" - + ",VotingFairyRecoveryValue = " + playerdata.VotingFairyRecoveryValue - + ",hasVotingFairyMana = " + playerdata.hasVotingFairyMana - + ",toggleGiveApple = " + playerdata.toggleGiveApple - + ",toggleVotingFairy = " + playerdata.toggleVotingFairy - + ",p_apple = " + playerdata.p_apple - + ",GBstage = " + playerdata.giganticBerserk.stage + ",GBexp = " + playerdata.giganticBerserk.exp + ",GBlevel = " + playerdata.giganticBerserk.level From 21c4abdbd2d782f90c41698e15e26f916801b0fc Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 13:59:02 +0900 Subject: [PATCH 095/482] =?UTF-8?q?[Fix]=E4=BB=A5=E5=89=8D=E3=81=AE?= =?UTF-8?q?=E3=82=B7=E3=82=B9=E3=83=86=E3=83=A0=E3=81=AB=E4=BE=9D=E5=AD=98?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=84=E3=81=9F=E3=82=82=E3=81=AE=E3=82=92?= =?UTF-8?q?=E6=96=B0=E3=82=B7=E3=82=B9=E3=83=86=E3=83=A0=E3=81=AB=E4=BE=9D?= =?UTF-8?q?=E5=AD=98=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/skill/ActiveSkillEffectMenu.scala | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/skill/ActiveSkillEffectMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/skill/ActiveSkillEffectMenu.scala index 6772a7051c..dd38562569 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/skill/ActiveSkillEffectMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/skill/ActiveSkillEffectMenu.scala @@ -16,6 +16,8 @@ import com.github.unchama.seichiassist.seichiskill.effect.{ ActiveSkillPremiumEffect, UnlockableActiveSkillEffect } +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI +import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint import com.github.unchama.seichiassist.{SeichiAssist, SkullOwners} import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect @@ -35,7 +37,8 @@ object ActiveSkillEffectMenu extends Menu { implicit val ioCanOpenActiveSkillEffectMenu: IO CanOpen ActiveSkillEffectMenu.type, val ioCanOpenActiveSkillMenu: IO CanOpen ActiveSkillMenu.type, val ioCanOpenTransactionHistoryMenu: IO CanOpen PremiumPointTransactionHistoryMenu, - val ioOnMainThread: OnMinecraftServerThread[IO] + val ioOnMainThread: OnMinecraftServerThread[IO], + val voteAPI: VoteAPI[IO, Player] ) override val frame: MenuFrame = MenuFrame(6.chestRows, s"$DARK_PURPLE${BOLD}整地スキルエフェクト選択") @@ -48,30 +51,32 @@ object ActiveSkillEffectMenu extends Menu { } } - def unlockOrSet(effect: ActiveSkillEffect): TargetedEffect[Player] = Kleisli { player => + def unlockOrSet( + effect: ActiveSkillEffect + )(implicit voteAPI: VoteAPI[IO, Player]): TargetedEffect[Player] = Kleisli { player => val playerData = SeichiAssist.playermap(player.getUniqueId) def unlockNormalEffect(effect: ActiveSkillNormalEffect): IO[Unit] = for { - effectPoint <- IO { playerData.effectPoint } + effectPoint <- voteAPI.effectPoints(player) _ <- - if (effectPoint < effect.usePoint) { + if (effectPoint.value < effect.usePoint) { SequentialEffect( MessageEffect(s"${DARK_RED}エフェクトポイントが足りません"), FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1.0f, 0.5f) ).apply(player) } else { - IO { - playerData.effectPoint -= effect.usePoint - val state = playerData.skillEffectState - playerData.skillEffectState = - state.copy(obtainedEffects = state.obtainedEffects + effect) - } >> SequentialEffect( - MessageEffect( - s"${LIGHT_PURPLE}エフェクト:${effect.nameOnUI}$RESET$LIGHT_PURPLE${BOLD}を解除しました" - ), - FocusedSoundEffect(Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1.0f, 1.2f) - ).apply(player) + voteAPI.decreaseEffectPoint(player.getUniqueId, EffectPoint(effect.usePoint)) >> + IO { + val state = playerData.skillEffectState + playerData.skillEffectState = + state.copy(obtainedEffects = state.obtainedEffects + effect) + } >> SequentialEffect( + MessageEffect( + s"${LIGHT_PURPLE}エフェクト:${effect.nameOnUI}$RESET$LIGHT_PURPLE${BOLD}を解除しました" + ), + FocusedSoundEffect(Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1.0f, 1.2f) + ).apply(player) } } yield () @@ -171,7 +176,7 @@ object ActiveSkillEffectMenu extends Menu { itemStackComputation.map(itemStack => ReloadingButton(ActiveSkillEffectMenu)( - Button(itemStack, LeftClickButtonEffect(unlockOrSet(effect))) + Button(itemStack, LeftClickButtonEffect(unlockOrSet(effect)(environment.voteAPI))) ) ) } @@ -193,7 +198,7 @@ object ActiveSkillEffectMenu extends Menu { .lore( List( s"$RESET${GREEN}現在選択しているエフェクト:${playerData.skillEffectState.selection.nameOnUI}", - s"$RESET${YELLOW}使えるエフェクトポイント:${playerData.effectPoint}", + s"$RESET${YELLOW}使えるエフェクトポイント:${voteAPI.effectPoints(player).unsafeRunSync().value}", s"$RESET$DARK_GRAY※投票すると獲得できます", s"$RESET${LIGHT_PURPLE}使えるプレミアムポイント$premiumEffectPoint", s"$RESET$DARK_GRAY※寄付をすると獲得できます" From 61e703865b1d60611d608d0ae94f28a97e30680b Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 14:16:44 +0900 Subject: [PATCH 096/482] =?UTF-8?q?[Fix]=E6=97=A7=E3=82=B7=E3=82=B9?= =?UTF-8?q?=E3=83=86=E3=83=A0=E4=BE=9D=E5=AD=98=E3=82=92=E6=96=B0=E3=82=B7?= =?UTF-8?q?=E3=82=B9=E3=83=86=E3=83=A0=E4=BE=9D=E5=AD=98=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/data/MenuInventoryData.java | 9 +++++-- .../seichiassist/data/player/PlayerData.scala | 6 +++-- .../listener/PlayerInventoryListener.scala | 2 ++ .../invlistener/OnClickTitleMenu.scala | 27 ++++++++++++++----- .../menus/achievement/AchievementMenu.scala | 11 ++++++-- 5 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java b/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java index 44218715c2..451bca7d8c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java +++ b/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java @@ -1,10 +1,13 @@ package com.github.unchama.seichiassist.data; +import cats.effect.IO; import com.github.unchama.seichiassist.SeichiAssist; import com.github.unchama.seichiassist.achievement.Nicknames; import com.github.unchama.seichiassist.data.player.AchievementPoint; import com.github.unchama.seichiassist.data.player.PlayerData; import com.github.unchama.seichiassist.data.player.PlayerNickname; +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI; +import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint; import com.github.unchama.seichiassist.util.AsyncInventorySetter; import com.github.unchama.seichiassist.util.ItemMetaFactory; import org.bukkit.Bukkit; @@ -64,8 +67,10 @@ private MenuInventoryData() { * 二つ名組み合わせ * @param p プレイヤー * @return メニュー + * 本来ならここにeffectPointではなくVoteAPIを渡したいところだが、 + * VoteAPIを呼び出すにはcats.ioが必要で、Javaではcats.ioが呼び出せないのでこうするしかない。 */ - public static Inventory computeRefreshedCombineMenu(final Player p) { + public static Inventory computeRefreshedCombineMenu(final Player p, EffectPoint effectPoint) { final UUID uuid = p.getUniqueId(); final PlayerData playerdata = SeichiAssist.playermap().apply(uuid); //念のためエラー分岐 @@ -118,7 +123,7 @@ public static Inventory computeRefreshedCombineMenu(final Player p) { ChatColor.RESET + "" + ChatColor.RED + "実績ポイントに変換できます。", ChatColor.RESET + "" + ChatColor.YELLOW + "" + ChatColor.BOLD + "投票pt 10pt → 実績pt 3pt", ChatColor.RESET + "" + ChatColor.AQUA + "クリックで変換を一回行います。", - ChatColor.RESET + "" + ChatColor.GREEN + "所有投票pt :" + playerdata.effectPoint(), + ChatColor.RESET + "" + ChatColor.GREEN + "所有投票pt :" + effectPoint.value(), ChatColor.RESET + "" + ChatColor.GREEN + "所有実績pt :" + playerdata.achievePoint().left() ); diff --git a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala index a46743daed..ccce951648 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala +++ b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala @@ -8,6 +8,8 @@ import com.github.unchama.seichiassist.data.GridTemplate import com.github.unchama.seichiassist.data.player.settings.PlayerSettings import com.github.unchama.seichiassist.minestack.MineStackUsageHistory import com.github.unchama.seichiassist.subsystems.breakcount.domain.level.SeichiStarLevel +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI +import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint import com.github.unchama.seichiassist.util.RelativeDirection import com.github.unchama.seichiassist.util.exp.{ExperienceManager, IExperienceManager} import com.github.unchama.targetedeffect.commandsender.MessageEffect @@ -297,9 +299,9 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { achievePoint = achievePoint.copy(used = achievePoint.used + amount) } - def convertEffectPointToAchievePoint(): Unit = { + def convertEffectPointToAchievePoint(voteAPI: VoteAPI[IO, Player]): Unit = { achievePoint = achievePoint.copy(conversionCount = achievePoint.conversionCount + 1) - effectPoint -= 10 + voteAPI.decreaseEffectPoint(uuid, EffectPoint(10)) } // パッシブスキルの獲得量表示 diff --git a/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala b/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala index 6f8297c30a..cb4a0e4a1e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala +++ b/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala @@ -11,6 +11,7 @@ import com.github.unchama.seichiassist.listener.invlistener.OnClickTitleMenu import com.github.unchama.seichiassist.menus.achievement.AchievementMenu import com.github.unchama.seichiassist.menus.stickmenu.FirstPage import com.github.unchama.seichiassist.subsystems.mana.ManaApi +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.util.{InventoryOperations, StaticGachaPrizeFactory} import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect @@ -27,6 +28,7 @@ import scala.collection.mutable.ArrayBuffer class PlayerInventoryListener( implicit effectEnvironment: EffectEnvironment, manaApi: ManaApi[IO, SyncIO, Player], + voteAPI: VoteAPI[IO, Player], ioCanOpenFirstPage: IO CanOpen FirstPage.type, ioCanOpenAchievementMenu: IO CanOpen AchievementMenu.type, ioOnMainThread: OnMinecraftServerThread[IO] diff --git a/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala b/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala index d671dca91c..d0d0419a0d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala @@ -9,6 +9,7 @@ import com.github.unchama.seichiassist.data.MenuInventoryData import com.github.unchama.seichiassist.data.MenuInventoryData.MenuType import com.github.unchama.seichiassist.effects.player.CommonSoundEffects import com.github.unchama.seichiassist.menus.achievement.AchievementMenu +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.targetedeffect.SequentialEffect import org.bukkit.entity.{EntityType, Player} import org.bukkit.event.inventory.{InventoryClickEvent, InventoryType} @@ -32,6 +33,7 @@ object OnClickTitleMenu { def onPlayerClickTitleMenuEvent(event: InventoryClickEvent)( implicit effectEnvironment: EffectEnvironment, + voteAPI: VoteAPI[IO, Player], ioCanOpenAchievementMenu: IO CanOpen AchievementMenu.type ): Unit = { import com.github.unchama.util.syntax.Nullability.NullabilityExtensionReceiver @@ -76,6 +78,7 @@ object OnClickTitleMenu { val mat = current.getType val isSkull = mat == Material.SKULL_ITEM + val effectPoint = voteAPI.effectPoints(player).unsafeRunSync() topInventory.getTitle match { case MenuType.COMBINE.invName => event.setCancelled(true) @@ -88,8 +91,8 @@ object OnClickTitleMenu { // エフェクトポイント→実績ポイント変換 case Material.EMERALD => clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) - if (pd.effectPoint >= 10) { - pd.convertEffectPointToAchievePoint() + if (voteAPI.effectPoints(player).unsafeRunSync().value >= 10) { + pd.convertEffectPointToAchievePoint(voteAPI) } else { player.sendMessage("エフェクトポイントが不足しています。") } @@ -130,7 +133,9 @@ object OnClickTitleMenu { mat match { case Material.EMERALD_ORE | Material.EMERALD => pd.recalculateAchievePoint() - player.openInventory(MenuInventoryData.computeRefreshedCombineMenu(player)) + player.openInventory( + MenuInventoryData.computeRefreshedCombineMenu(player, effectPoint) + ) case _ => } @@ -165,7 +170,9 @@ object OnClickTitleMenu { case Material.BARRIER => clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - player.openInventory(MenuInventoryData.computeRefreshedCombineMenu(player)) + player.openInventory( + MenuInventoryData.computeRefreshedCombineMenu(player, effectPoint) + ) case _ if isSkull && isApplicableAsNextPageButton(current) => // 次ページ @@ -211,7 +218,9 @@ object OnClickTitleMenu { case Material.BARRIER => clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - player.openInventory(MenuInventoryData.computeRefreshedCombineMenu(player)) + player.openInventory( + MenuInventoryData.computeRefreshedCombineMenu(player, effectPoint) + ) case _ if isSkull && isApplicableAsNextPageButton(current) => clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) @@ -256,7 +265,9 @@ object OnClickTitleMenu { case Material.BARRIER => clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - player.openInventory(MenuInventoryData.computeRefreshedCombineMenu(player)) + player.openInventory( + MenuInventoryData.computeRefreshedCombineMenu(player, effectPoint) + ) case _ if isSkull && isApplicableAsNextPageButton(current) => clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) @@ -304,7 +315,9 @@ object OnClickTitleMenu { case Material.BARRIER => clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - player.openInventory(MenuInventoryData.computeRefreshedCombineMenu(player)) + player.openInventory( + MenuInventoryData.computeRefreshedCombineMenu(player, effectPoint) + ) case _ if isSkull && isApplicableAsNextPageButton(current) => clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/achievement/AchievementMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/achievement/AchievementMenu.scala index 6bc773881a..bffec21c62 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/achievement/AchievementMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/achievement/AchievementMenu.scala @@ -14,6 +14,7 @@ import com.github.unchama.seichiassist.data.player.NicknameStyle import com.github.unchama.seichiassist.effects.player.CommonSoundEffects import com.github.unchama.seichiassist.menus.stickmenu.FirstPage import com.github.unchama.seichiassist.menus.{ColorScheme, CommonButtons} +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.targetedeffect.player.{FocusedSoundEffect, PlayerEffects} import com.github.unchama.targetedeffect.{SequentialEffect, TargetedEffect} import org.bukkit.ChatColor._ @@ -28,7 +29,8 @@ object AchievementMenu extends Menu { class Environment( implicit val ioCanOpenStickMenu: IO CanOpen FirstPage.type, val ioCanOpenCategoryMenu: IO CanOpen AchievementCategoryMenu, - val ioOnMainThread: OnMinecraftServerThread[IO] + val ioOnMainThread: OnMinecraftServerThread[IO], + val voteAPI: VoteAPI[IO, Player] ) override val frame: MenuFrame = MenuFrame(4.chestRows, s"$DARK_PURPLE${BOLD}実績・二つ名システム") @@ -109,7 +111,12 @@ object AchievementMenu extends Menu { .build(), action.LeftClickButtonEffect( CommonSoundEffects.menuTransitionFenceSound, - PlayerEffects.openInventoryEffect(MenuInventoryData.computeRefreshedCombineMenu(player)) + PlayerEffects.openInventoryEffect( + MenuInventoryData.computeRefreshedCombineMenu( + player, + environment.voteAPI.effectPoints(player).unsafeRunSync() + ) + ) ) ) From 9454769f2440ca4a7049599f654cde821a6700a4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 14:18:12 +0900 Subject: [PATCH 097/482] =?UTF-8?q?[Remove]=E3=82=88=E3=81=8F=E3=82=8F?= =?UTF-8?q?=E3=81=8B=E3=82=89=E3=81=AA=E3=81=84=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=8C=E3=81=A7=E3=81=8D=E3=81=A6=E3=81=84=E3=81=9F?= =?UTF-8?q?=E3=81=AE=E3=81=A7=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1q | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 1q diff --git a/1q b/1q deleted file mode 100644 index 8a57bde6c1..0000000000 --- a/1q +++ /dev/null @@ -1,8 +0,0 @@ -[Fix]fairyConstractSettingToggleボタンが動いていないのを修正 -# Please enter the commit message for your changes. Lines starting -# with '#' will be ignored, and an empty message aborts the commit. -# -# On branch refactorVote -# Changes to be committed: -# modified: src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala -# From 5e6e6ac0f55f2dfdbb745474d0079b4d0b2cdd21 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 14:23:42 +0900 Subject: [PATCH 098/482] =?UTF-8?q?[Fix]=E6=8A=95=E7=A5=A8=E7=89=B9?= =?UTF-8?q?=E5=85=B8=E3=82=92=E5=8F=97=E3=81=91=E5=8F=96=E3=82=8B=E3=81=A8?= =?UTF-8?q?=E3=81=8D=E3=81=AB=E5=8F=97=E3=81=91=E5=8F=96=E3=82=8C=E3=82=8B?= =?UTF-8?q?=E7=89=B9=E5=85=B8=E3=81=8C=E3=81=AA=E3=81=84=E3=81=A8=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=82=92=E5=90=90=E3=81=8F=E3=81=AE=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/BukkitReceiveVoteBenefits.scala | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 9c035a40da..d98fe9434c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -1,7 +1,7 @@ package com.github.unchama.seichiassist.subsystems.vote.bukkit.actions import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps -import cats.effect.{ConcurrentEffect, Sync, SyncEffect} +import cats.effect.{ConcurrentEffect, SyncEffect} import com.github.unchama.generic.ContextCoercion import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.data.{GachaSkullData, ItemData} @@ -32,22 +32,23 @@ object BukkitReceiveVoteBenefits { notReceivedBenefits <- voteAPI.notReceivedVoteBenefits(uuid) // 受け取っていない投票特典数 _ <- voteAPI.increaseVoteBenefits(uuid, notReceivedBenefits) // 受け取ってない分を受け取ったことにする } yield { - if (notReceivedBenefits.value == 0) return Sync[F].pure(()) - - val playerLevel = - ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read.map { - _.levelCorrespondingToExp.level - }).toIO.unsafeRunSync() - - val items = (0 until notReceivedBenefits.value).map { _ => - ContextCoercion(voteAPI.increaseEffectPointsByTen(uuid)).toIO.unsafeRunSync() - Seq.fill(10)(GachaSkullData.gachaForVoting) ++ - Seq( - if (playerLevel < 50) ItemData.getSuperPickaxe(1) else ItemData.getVotingGift(1) - ) + if (notReceivedBenefits.value != 0) { + val playerLevel = + ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read.map { + _.levelCorrespondingToExp.level + }).toIO.unsafeRunSync() + + val items = (0 until notReceivedBenefits.value).map { _ => + ContextCoercion(voteAPI.increaseEffectPointsByTen(uuid)).toIO.unsafeRunSync() + Seq.fill(10)(GachaSkullData.gachaForVoting) ++ + Seq( + if (playerLevel < 50) ItemData.getSuperPickaxe(1) + else ItemData.getVotingGift(1) + ) + } + + grantItemStacksEffect[F](items.flatten: _*) } - - grantItemStacksEffect[F](items.flatten: _*) } } } From 9baf22b42b2c284861d6dc412b031ab161a1d86c Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 14:25:42 +0900 Subject: [PATCH 099/482] =?UTF-8?q?[Remove]=E3=82=88=E3=81=8F=E3=82=8F?= =?UTF-8?q?=E3=81=8B=E3=82=89=E3=81=AA=E3=81=84=E3=82=82=E3=81=AE=E3=81=8C?= =?UTF-8?q?=E6=9B=B8=E3=81=8B=E3=82=8C=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE?= =?UTF-8?q?=E3=81=A7=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/domain/property/FairyLore.scala | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyLore.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyLore.scala index 4354028677..b0d5b0846c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyLore.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyLore.scala @@ -2,7 +2,4 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain. import cats.data.NonEmptyList -case class FairyLore(lore: NonEmptyList[String]) { - - object toIO -} +case class FairyLore(lore: NonEmptyList[String]) From 9aafcec566b2974cb75ce74aa0723f6755f99404 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 14:28:00 +0900 Subject: [PATCH 100/482] =?UTF-8?q?[Chore]=E3=83=89=E3=82=AD=E3=83=A5?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/infrastructure/JdbcFairyPersistence.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index f4b53832c5..83cf77b168 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -37,7 +37,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } /** - * 妖精が有効な時間の状態を更新する + * 妖精を召喚するためのコストを更新する */ override def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] = Sync[F].delay { @@ -64,7 +64,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } /** - * 妖精が召喚されているかを更新します + * 妖精の召喚状態を更新します */ override def updateFairyUsingState(uuid: UUID, fairyUsingState: FairyUsingState): F[Unit] = Sync[F].delay { From cf8046d304234a895b4af7660bce3eb9a6c81e15 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 16:53:06 +0900 Subject: [PATCH 101/482] =?UTF-8?q?[Remove]AntiTypeSafe=E3=82=92=E5=89=8A?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/seichiassist/AntiTypesafe.java | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/AntiTypesafe.java diff --git a/src/main/scala/com/github/unchama/seichiassist/AntiTypesafe.java b/src/main/scala/com/github/unchama/seichiassist/AntiTypesafe.java deleted file mode 100644 index 2bb7fe25d2..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/AntiTypesafe.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.github.unchama.seichiassist; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.METHOD, ElementType.FIELD}) -@Retention(RetentionPolicy.SOURCE) -public @interface AntiTypesafe { -} \ No newline at end of file From 47415fdc76cc863485d9ef4d017bfd611e18d030 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 17:33:47 +0900 Subject: [PATCH 102/482] [Fix]Seq.fill -> lift --- .../fairy/infrastructure/JdbcFairyPersistence.scala | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 83cf77b168..2140e0a274 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -200,10 +200,13 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { if (data._1.nonEmpty) Some(AppleAteByFairyRank(data._1.get, data._2.get, AppleAmount(data._3.get))) else None - ) ++ Seq.fill(3)(None) - /* このSeqは最低一人しか参加していなかった場合に - 2位以降を取り出したときにIndexOutOfBoundsを起こさせないためのやつ */ - AppleAteByFairyRankTopFour(topFour.head.get, topFour(1), topFour(2), topFour(3)) + ) + AppleAteByFairyRankTopFour( + topFour.head.get, + topFour.lift(1).flatten, + topFour.lift(2).flatten, + topFour.lift(3).flatten + ) } } From 8de5f2cbebf77c82db56b2e98aa859f57c209f32 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 20:08:11 +0900 Subject: [PATCH 103/482] =?UTF-8?q?[Fix]=E5=89=AF=E4=BD=9C=E7=94=A8?= =?UTF-8?q?=E3=82=92=E5=90=AB=E3=82=80=E3=83=9C=E3=82=BF=E3=83=B3=E3=82=92?= =?UTF-8?q?IO=E3=81=A7=E3=81=8F=E3=81=8F=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index db40c6b2fd..0fadf317fb 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -63,30 +63,32 @@ object VoteMenu extends Menu { val staticButtons = Map( - ChestSlotRef(0, 0) -> receiveVoteBenefitsButton, - ChestSlotRef(0, 4) -> fairySummonButton, ChestSlotRef(1, 0) -> showVoteURLButton, ChestSlotRef(3, 0) -> CommonButtons.openStickMenu ) val computeButtonsIO = Seq( + ChestSlotRef(0, 0) -> receiveVoteBenefitsButton, + ChestSlotRef(0, 4) -> fairySummonButton, ChestSlotRef(0, 2) -> fairySummonTimeToggleButton, ChestSlotRef(1, 2) -> fairyContractSettingToggle, ChestSlotRef(2, 2) -> fairyPlaySoundToggleButton ).traverse(_.sequence) - val dynamicButtons = - Map(ChestSlotRef(0, 6) -> gachaRingoInformation, ChestSlotRef(1, 4) -> checkTimeButton) + val dynamicButtonsIO = + Seq(ChestSlotRef(0, 6) -> gachaRingoInformation, ChestSlotRef(1, 4) -> checkTimeButton) + .traverse(_.sequence) for { fairyUsingState <- environment.fairyAPI.fairyUsingState(constantButtons.player) computeButtons <- computeButtonsIO + dynamicButtons <- dynamicButtonsIO } yield { val exceptDynamicButtons = staticButtons ++ computeButtons MenuSlotLayout(exceptDynamicButtons).merge( if (fairyUsingState == FairyUsingState.Using) - MenuSlotLayout(dynamicButtons) + MenuSlotLayout(dynamicButtons: _*) else MenuSlotLayout.emptyLayout ) } @@ -106,7 +108,7 @@ object VoteMenu extends Menu { private implicit val ioCE: ConcurrentEffect[IO] = IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) - val receiveVoteBenefitsButton: Button = { + val receiveVoteBenefitsButton: IO[Button] = { val uuid = player.getUniqueId for { benefits <- voteAPI.receivedVoteBenefits(uuid) @@ -139,7 +141,7 @@ object VoteMenu extends Menu { } ) } - }.unsafeRunSync() + } val showVoteURLButton: Button = Button( new IconItemStackBuilder(Material.BOOK_AND_QUILL) @@ -273,7 +275,7 @@ object VoteMenu extends Menu { }) } - val fairySummonButton: Button = { + val fairySummonButton: IO[Button] = IO { val fairySummonState = fairyAPI.fairySummonCost(player).unsafeRunSync() Button( @@ -300,7 +302,7 @@ object VoteMenu extends Menu { ) } - val checkTimeButton: Button = + val checkTimeButton: IO[Button] = IO { Button( new IconItemStackBuilder(Material.COMPASS) .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}マナ妖精に時間を聞く") @@ -316,8 +318,9 @@ object VoteMenu extends Menu { ) } ) + } - val gachaRingoInformation: Button = + val gachaRingoInformation: IO[Button] = IO { Button( new IconItemStackBuilder(Material.GOLDEN_APPLE) .title(s"$YELLOW$UNDERLINE$BOLD㊙ がちゃりんご情報 ㊙") @@ -356,6 +359,7 @@ object VoteMenu extends Menu { .enchanted() .build() ) + } } } From 8d42409f74e8802dac954833731bea351f8b2910 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 21:01:53 +0900 Subject: [PATCH 104/482] =?UTF-8?q?[Remove]=E4=B8=8D=E8=A6=81=E3=81=AAimpo?= =?UTF-8?q?rt=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/data/MenuInventoryData.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java b/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java index 451bca7d8c..32bf628280 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java +++ b/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java @@ -1,12 +1,10 @@ package com.github.unchama.seichiassist.data; -import cats.effect.IO; import com.github.unchama.seichiassist.SeichiAssist; import com.github.unchama.seichiassist.achievement.Nicknames; import com.github.unchama.seichiassist.data.player.AchievementPoint; import com.github.unchama.seichiassist.data.player.PlayerData; import com.github.unchama.seichiassist.data.player.PlayerNickname; -import com.github.unchama.seichiassist.subsystems.vote.VoteAPI; import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint; import com.github.unchama.seichiassist.util.AsyncInventorySetter; import com.github.unchama.seichiassist.util.ItemMetaFactory; @@ -25,7 +23,10 @@ import scala.collection.mutable.HashMap; import scala.collection.mutable.Map; -import java.util.*; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.UUID; import java.util.function.Consumer; public final class MenuInventoryData { From 567e29105bbaa31970bc5cdfa7203c169308c67f Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 29 Jul 2022 21:07:16 +0900 Subject: [PATCH 105/482] =?UTF-8?q?[Remove]=E4=BD=BF=E3=82=8F=E3=82=8C?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84=E3=82=82=E3=81=AE=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/SeichiAssist.scala | 6 +----- .../unchama/seichiassist/data/RankData.java | 21 ------------------- 2 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/data/RankData.java diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index a9f84c3e5a..6cdd941336 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -41,7 +41,7 @@ import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.{ onMainThread } import com.github.unchama.seichiassist.data.player.PlayerData -import com.github.unchama.seichiassist.data.{GachaPrize, MineStackGachaData, RankData} +import com.github.unchama.seichiassist.data.{GachaPrize, MineStackGachaData} import com.github.unchama.seichiassist.database.DatabaseGateway import com.github.unchama.seichiassist.domain.actions.{ GetNetworkConnectionCount, @@ -800,10 +800,6 @@ object SeichiAssist { val gachadatalist: mutable.ArrayBuffer[GachaPrize] = mutable.ArrayBuffer() // Playerdataに依存するデータリスト val playermap: mutable.HashMap[UUID, PlayerData] = mutable.HashMap() - // プレイ時間ランキング表示用データリスト - val ranklist_playtick: mutable.ArrayBuffer[RankData] = mutable.ArrayBuffer() - // 投票ポイント表示用データリスト - val ranklist_p_vote: mutable.ArrayBuffer[RankData] = mutable.ArrayBuffer() var instance: SeichiAssist = _ // デバッグフラグ(デバッグモード使用時はここで変更するのではなくconfig.ymlの設定値を変更すること!) diff --git a/src/main/scala/com/github/unchama/seichiassist/data/RankData.java b/src/main/scala/com/github/unchama/seichiassist/data/RankData.java deleted file mode 100644 index c7a3165ec0..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/data/RankData.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.github.unchama.seichiassist.data; - -public class RankData { - public String name; - /* 整地Lv */ - public final int level; - /* 整地量 */ - public final long totalbreaknum; - /* プレイ時間 (ティック) */ - public int playtick; - /* 投票回数 */ - public int p_vote; - /* ??? */ - public int p_apple; - - public RankData() { - name = ""; - level = 1; - totalbreaknum = 0; - } -} From c48812af6575e6f792b6d86b3e39c01aab582739 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 14:28:41 +0900 Subject: [PATCH 106/482] =?UTF-8?q?[Remove]convertEffectPointToAchivePoint?= =?UTF-8?q?=E3=81=A7=E8=A6=81=E6=B1=82=E3=81=99=E3=82=8BvoteAPI=E3=82=92im?= =?UTF-8?q?plicit=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/data/player/PlayerData.scala | 2 +- .../seichiassist/listener/invlistener/OnClickTitleMenu.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala index ccce951648..f4397a960e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala +++ b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala @@ -299,7 +299,7 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { achievePoint = achievePoint.copy(used = achievePoint.used + amount) } - def convertEffectPointToAchievePoint(voteAPI: VoteAPI[IO, Player]): Unit = { + def convertEffectPointToAchievePoint(implicit voteAPI: VoteAPI[IO, Player]): Unit = { achievePoint = achievePoint.copy(conversionCount = achievePoint.conversionCount + 1) voteAPI.decreaseEffectPoint(uuid, EffectPoint(10)) } diff --git a/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala b/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala index d0d0419a0d..43d6f9ca97 100644 --- a/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala @@ -92,7 +92,7 @@ object OnClickTitleMenu { case Material.EMERALD => clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) if (voteAPI.effectPoints(player).unsafeRunSync().value >= 10) { - pd.convertEffectPointToAchievePoint(voteAPI) + pd.convertEffectPointToAchievePoint } else { player.sendMessage("エフェクトポイントが不足しています。") } From c786e3b07e179df48182e42da2f7c1d3111c158d Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 14:32:02 +0900 Subject: [PATCH 107/482] =?UTF-8?q?[Fix]getFairyValidTime=E3=82=92FairySum?= =?UTF-8?q?monCost=E3=81=AB=E7=B4=90=E3=81=A5=E3=81=91=E3=80=81=E8=A8=88?= =?UTF-8?q?=E7=AE=97=E3=81=95=E3=81=9B=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 13 ++----------- .../fairy/domain/property/FairySummonCost.scala | 9 +++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 0fadf317fb..3321de3fa9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -171,15 +171,6 @@ object VoteMenu extends Menu { } ) - def getFairyValidTime(fairySummonCost: FairySummonCost): String = { - fairySummonCost match { - case FairySummonCost(1) => "30分" - case FairySummonCost(2) => "1時間" - case FairySummonCost(3) => "1時間30分" - case FairySummonCost(4) => "2時間" - } - } - val fairySummonTimeToggleButton: IO[Button] = { RecomputedButton(IO { val fairySummonCost = fairyAPI.fairySummonCost(player).unsafeRunSync() @@ -189,7 +180,7 @@ object VoteMenu extends Menu { .title(s"$AQUA$UNDERLINE${BOLD}マナ妖精 時間設定") .lore( List( - s"$RESET$GREEN$BOLD${getFairyValidTime(fairySummonCost)}", + s"$RESET$GREEN$BOLD${fairySummonCost.finiteDuration}", "", s"$RESET${GRAY}コスト", s"$RESET$RED$BOLD${fairySummonCost.value * 2}投票pt", @@ -285,7 +276,7 @@ object VoteMenu extends Menu { List( s"$RESET$GRAY${fairySummonState.value * 2}投票ptを消費して", s"$RESET${GRAY}マナ妖精を呼びます", - s"$RESET${GRAY}時間: ${getFairyValidTime(fairySummonState)}", + s"$RESET${GRAY}時間: ${fairySummonState.finiteDuration}", s"$RESET${DARK_RED}Lv.10以上で開放" ) ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala index 11b5bc6a5b..f9b07a73ea 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala @@ -24,4 +24,13 @@ case class FairySummonCost(value: Int) { validTime } + def finiteDuration: String = { + value match { + case 1 => "30分" + case 2 => "1時間" + case 3 => "1時間30分" + case 4 => "2時間" + } + } + } From 44fd1e3f105345d313a2c3e21f7a3174bce06804 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 14:40:24 +0900 Subject: [PATCH 108/482] =?UTF-8?q?[Fix]unlockNormalEffect=E3=81=AE?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=81=A7UnfocusedEffect=E3=82=92=E5=88=A9?= =?UTF-8?q?=E7=94=A8=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/skill/ActiveSkillEffectMenu.scala | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/skill/ActiveSkillEffectMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/skill/ActiveSkillEffectMenu.scala index dd38562569..892e961e0f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/skill/ActiveSkillEffectMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/skill/ActiveSkillEffectMenu.scala @@ -66,17 +66,20 @@ object ActiveSkillEffectMenu extends Menu { FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1.0f, 0.5f) ).apply(player) } else { - voteAPI.decreaseEffectPoint(player.getUniqueId, EffectPoint(effect.usePoint)) >> - IO { + voteAPI.decreaseEffectPoint( + player.getUniqueId, + EffectPoint(effect.usePoint) + ) >> SequentialEffect( + UnfocusedEffect { val state = playerData.skillEffectState playerData.skillEffectState = state.copy(obtainedEffects = state.obtainedEffects + effect) - } >> SequentialEffect( - MessageEffect( - s"${LIGHT_PURPLE}エフェクト:${effect.nameOnUI}$RESET$LIGHT_PURPLE${BOLD}を解除しました" - ), - FocusedSoundEffect(Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1.0f, 1.2f) - ).apply(player) + }, + MessageEffect( + s"${LIGHT_PURPLE}エフェクト:${effect.nameOnUI}$RESET$LIGHT_PURPLE${BOLD}を解除しました" + ), + FocusedSoundEffect(Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1.0f, 1.2f) + ).apply(player) } } yield () From ed2313926a4e44aecd07a41fe8a5b0391d0ea02d Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 14:42:21 +0900 Subject: [PATCH 109/482] [Rename]notReceivedVoteBenefits -> restVoteBenefits --- .../github/unchama/seichiassist/subsystems/vote/System.scala | 2 +- .../github/unchama/seichiassist/subsystems/vote/VoteAPI.scala | 2 +- .../vote/bukkit/actions/BukkitReceiveVoteBenefits.scala | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index 4a7ff6fae3..a07166f2ca 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -51,7 +51,7 @@ object System { import cats.implicits._ - override def notReceivedVoteBenefits(uuid: UUID): F[VoteBenefit] = for { + override def restVoteBenefits(uuid: UUID): F[VoteBenefit] = for { voteCounter <- voteCounter(uuid) receivedVote <- receivedVoteBenefits(uuid) } yield VoteBenefit(voteCounter.value - receivedVote.value) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index e0ec94e06d..d395a3f960 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -64,7 +64,7 @@ trait VoteReadAPI[F[_], Player] { /** * 投票特典を受け取っていない回数を返す作用 */ - def notReceivedVoteBenefits(uuid: UUID): F[VoteBenefit] + def restVoteBenefits(uuid: UUID): F[VoteBenefit] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index d98fe9434c..d953af2ef3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -29,7 +29,7 @@ object BukkitReceiveVoteBenefits { ): F[Unit] = { val uuid = player.getUniqueId for { - notReceivedBenefits <- voteAPI.notReceivedVoteBenefits(uuid) // 受け取っていない投票特典数 + notReceivedBenefits <- voteAPI.restVoteBenefits(uuid) // 受け取っていない投票特典数 _ <- voteAPI.increaseVoteBenefits(uuid, notReceivedBenefits) // 受け取ってない分を受け取ったことにする } yield { if (notReceivedBenefits.value != 0) { From 50fedcf676dc5a48d649ca667ab7f8faac719b3a Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 14:46:49 +0900 Subject: [PATCH 110/482] =?UTF-8?q?[Docs]increaseEffectPointsByTen?= =?UTF-8?q?=E3=81=AE=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=92=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/subsystems/vote/VoteAPI.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index d395a3f960..5ab24b6407 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -22,7 +22,7 @@ trait VoteWriteAPI[F[_]] { def decreaseEffectPoint(uuid: UUID, effectPoint: EffectPoint): F[Unit] /** - * effectPointを10増加させる作用 + * effectPointを増加させる作用 */ def increaseEffectPointsByTen(uuid: UUID): F[Unit] From 896b62b34b55dc95ad526b5009bc07c4ad934b70 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 15:30:01 +0900 Subject: [PATCH 111/482] =?UTF-8?q?[Docs]=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92=E6=B6=88=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/bukkit/actions/BukkitReceiveVoteBenefits.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index d953af2ef3..024baa9202 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -29,7 +29,7 @@ object BukkitReceiveVoteBenefits { ): F[Unit] = { val uuid = player.getUniqueId for { - notReceivedBenefits <- voteAPI.restVoteBenefits(uuid) // 受け取っていない投票特典数 + notReceivedBenefits <- voteAPI.restVoteBenefits(uuid) _ <- voteAPI.increaseVoteBenefits(uuid, notReceivedBenefits) // 受け取ってない分を受け取ったことにする } yield { if (notReceivedBenefits.value != 0) { From 0fb08babce8b9320bc01fd8f813a7a5fdd3f0e9b Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 15:39:48 +0900 Subject: [PATCH 112/482] =?UTF-8?q?[Fix]BukkitReceiveVoteBenefits=E3=81=AE?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=81=A7whenA=E3=82=92=E4=BD=BF=E3=81=86?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/BukkitReceiveVoteBenefits.scala | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 024baa9202..370e9f4c8e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -1,5 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.bukkit.actions +import cats.Applicative import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import cats.effect.{ConcurrentEffect, SyncEffect} import com.github.unchama.generic.ContextCoercion @@ -18,10 +19,9 @@ object BukkitReceiveVoteBenefits { /** * 投票特典を配布する */ - def apply[F[_]: OnMinecraftServerThread: ConcurrentEffect, G[_]: SyncEffect: ContextCoercion[ - *[_], - F - ]]: ReceiveVoteBenefits[F, G, Player] = + def apply[F[_]: OnMinecraftServerThread: ConcurrentEffect: Applicative, G[ + _ + ]: SyncEffect: ContextCoercion[*[_], F]]: ReceiveVoteBenefits[F, G, Player] = new ReceiveVoteBenefits[F, G, Player] { override def receive(player: Player)( implicit voteAPI: VoteAPI[F, Player], @@ -31,8 +31,7 @@ object BukkitReceiveVoteBenefits { for { notReceivedBenefits <- voteAPI.restVoteBenefits(uuid) _ <- voteAPI.increaseVoteBenefits(uuid, notReceivedBenefits) // 受け取ってない分を受け取ったことにする - } yield { - if (notReceivedBenefits.value != 0) { + _ <- Applicative[F].whenA(notReceivedBenefits.value != 0) { val playerLevel = ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read.map { _.levelCorrespondingToExp.level @@ -47,9 +46,9 @@ object BukkitReceiveVoteBenefits { ) } - grantItemStacksEffect[F](items.flatten: _*) + grantItemStacksEffect[F](items.flatten: _*).apply(player) } - } + } yield () } } From 8754603b4d369927ad54d9c71c44ded8134b2486 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 15:40:48 +0900 Subject: [PATCH 113/482] =?UTF-8?q?[Add]EffectPoint=E3=81=AERequire?= =?UTF-8?q?=E3=82=92=E6=BA=80=E3=81=9F=E3=81=95=E3=81=AA=E3=81=8B=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E5=A0=B4=E5=90=88=E3=81=AE=E3=83=A1=E3=83=83=E3=82=BB?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1q | 11 +++++++++++ .../subsystems/vote/domain/EffectPoint.scala | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 1q diff --git a/1q b/1q new file mode 100644 index 0000000000..bc71206c15 --- /dev/null +++ b/1q @@ -0,0 +1,11 @@ +[Fix]BukkitReceiveVoteBenefitsの処理でwhenAを使うように +# Please enter the commit message for your changes. Lines starting +# with '#' will be ignored, and an empty message aborts the commit. +# +# On branch refactorVote +# Your branch is ahead of 'rito/refactorVote' by 6 commits. +# (use "git push" to publish your local commits) +# +# Changes to be committed: +# modified: src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +# diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/EffectPoint.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/EffectPoint.scala index e5d3cfa33d..741a797b5a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/EffectPoint.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/EffectPoint.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.domain case class EffectPoint(value: Int) { - require(value >= 0) + require(value >= 0, "EffectPointは非負である必要があります。") } From 2c0b2bfd4481ecdcbc63c2979ada54c0420895c8 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 15:41:19 +0900 Subject: [PATCH 114/482] =?UTF-8?q?[Remove]PlayerName=E5=9E=8B=E3=81=AEreq?= =?UTF-8?q?uire=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/domain/PlayerName.scala | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/PlayerName.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/PlayerName.scala index 70bb1617e3..ccd2b53f16 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/PlayerName.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/PlayerName.scala @@ -1,5 +1,3 @@ package com.github.unchama.seichiassist.subsystems.vote.domain -case class PlayerName(name: String) { - require(name.forall(_.isLower)) -} +case class PlayerName(name: String) From 0da28925d8e6f2a154b829b3cfa10efcf7c4b2c1 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 15:41:47 +0900 Subject: [PATCH 115/482] [Fix]VotePoint -> VoteCounter --- .../seichiassist/subsystems/vote/domain/VoteCounter.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCounter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCounter.scala index 9013d68121..05a280f493 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCounter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCounter.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.domain case class VoteCounter(value: Int) { - require(value >= 0, "votePointは非負である必要があります。") + require(value >= 0, "VoteCounterは非負である必要があります。") } From 010f7021ee7c3441c7c2cb5d2ba9968550db07ea Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 15:42:31 +0900 Subject: [PATCH 116/482] =?UTF-8?q?[Add]VoteBenefit=E3=81=AErequire?= =?UTF-8?q?=E3=82=92=E6=BA=80=E3=81=9F=E3=81=95=E3=81=AA=E3=81=8B=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E5=A0=B4=E5=90=88=E3=81=AE=E6=96=87=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/domain/VoteBenefit.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteBenefit.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteBenefit.scala index 9510fa85e1..ae6c7d4c0f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteBenefit.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteBenefit.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.domain case class VoteBenefit(value: Int) { - require(value >= 0) + require(value >= 0, "VoteBenefitは非負である必要があります。") } From 98498084510dc70645190484fef8d40cf3ad30df Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 15:51:11 +0900 Subject: [PATCH 117/482] =?UTF-8?q?[Docs]=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 5849731ed0..3c6e7b3ef8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -10,7 +10,6 @@ trait FairyWriteAPI[F[_], G[_], Player] { /** * 妖精にあげるりんごの開放状態を変更する - * ※妖精にあげるりんごの数を変更する */ def updateAppleOpenState(uuid: UUID, appleOpenState: AppleOpenState): F[Unit] From e81b7543902fe4c1b06f49a7b5d75ca0804dca70 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 17:19:57 +0900 Subject: [PATCH 118/482] =?UTF-8?q?[Fix]appleAteByFairyRankingTopFour?= =?UTF-8?q?=E3=82=92=E4=B8=80=E8=88=AC=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 10 +++--- .../vote/subsystems/fairy/FairyAPI.scala | 7 ++-- .../vote/subsystems/fairy/System.scala | 9 ++--- .../fairy/domain/FairyPersistence.scala | 5 ++- .../property/AppleAteByFairyRankTopFour.scala | 8 ----- .../infrastructure/JdbcFairyPersistence.scala | 33 +++++++++---------- 6 files changed, 32 insertions(+), 40 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRankTopFour.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 3321de3fa9..0b5ea361c1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -325,17 +325,17 @@ object VoteMenu extends Menu { s"$RESET${DARK_GRAY}召喚されたらラッキーだよ!" ) ++ { // TOP4のランキングロール - val topFour = fairyAPI.appleAteByFairyRankingTopFour(player).unsafeRunSync() - List(Some(topFour.one), topFour.two, topFour.three, topFour.four).flatMap { - rankDataOpt => + val topFour = fairyAPI.appleAteByFairyRanking(player, 4).unsafeRunSync() + List(topFour.headOption, topFour.lift(1), topFour.lift(2), topFour.lift(3)) + .flatMap { rankDataOpt => if (rankDataOpt.nonEmpty) { - val rankData = rankDataOpt.get + val rankData = rankDataOpt.get.get List( s"${GRAY}たくさんくれたニンゲン第${rankData.rank}位!", s"${GRAY}なまえ:${rankData.name} りんご:${rankData.appleAmount.amount}個" ) } else Nil - } + } } ++ { val myRank = fairyAPI.appleAteByFairyMyRanking(player).unsafeRunSync() List( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 3c6e7b3ef8..39888b42ba 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -98,9 +98,12 @@ trait FairyReadAPI[F[_], G[_], Player] { def appleAteByFairyMyRanking(player: Player): F[AppleAteByFairyRank] /** - * 妖精に食べさせたりんごの量の順位上位4件を返す + * 妖精に食べさせたりんごの量の順位上`number`件を返す */ - def appleAteByFairyRankingTopFour(player: Player): F[AppleAteByFairyRankTopFour] + def appleAteByFairyRanking( + player: Player, + number: Int + ): F[Vector[Option[AppleAteByFairyRank]]] /** * 妖精が食べたりんごの合計数を返す diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 6ec1c922a4..9631710dde 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -125,10 +125,11 @@ object System { override def appleAteByFairyMyRanking(player: Player): IO[AppleAteByFairyRank] = persistence.appleAteByFairyMyRanking(player.getUniqueId) - override def appleAteByFairyRankingTopFour( - player: Player - ): IO[AppleAteByFairyRankTopFour] = - persistence.appleAteByFairyRankingTopFour(player.getUniqueId) + override def appleAteByFairyRanking( + player: Player, + number: Int + ): IO[Vector[Option[AppleAteByFairyRank]]] = + persistence.appleAteByFairyRanking(player.getUniqueId, number) override def allEatenAppleAmount: IO[AppleAmount] = persistence.allEatenAppleAmount diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index d1cf78bb6e..d279cbf90b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -3,7 +3,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleAmount, AppleAteByFairyRank, - AppleAteByFairyRankTopFour, AppleOpenState, FairyEndTime, FairyPlaySound, @@ -82,9 +81,9 @@ trait FairyPersistence[F[_]] { def appleAteByFairyMyRanking(uuid: UUID): F[AppleAteByFairyRank] /** - * 妖精に食べさせたりんごの量の順位上位4件を返す + * 妖精に食べさせたりんごの量の順位上位`number`件を返す */ - def appleAteByFairyRankingTopFour(uuid: UUID): F[AppleAteByFairyRankTopFour] + def appleAteByFairyRanking(uuid: UUID, number: Int): F[Vector[Option[AppleAteByFairyRank]]] /** * 妖精が食べたりんごの合計数を返す diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRankTopFour.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRankTopFour.scala deleted file mode 100644 index afce654467..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRankTopFour.scala +++ /dev/null @@ -1,8 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property - -case class AppleAteByFairyRankTopFour( - one: AppleAteByFairyRank, - two: Option[AppleAteByFairyRank], - three: Option[AppleAteByFairyRank], - four: Option[AppleAteByFairyRank] -) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 2140e0a274..be0129e956 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -186,27 +186,24 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } /** - * 妖精に食べさせたりんごの量の順位上位4件を返す + * 妖精に食べさせたりんごの量の順位上位`number`件を返す */ - override def appleAteByFairyRankingTopFour(uuid: UUID): F[AppleAteByFairyRankTopFour] = + override def appleAteByFairyRanking( + uuid: UUID, + number: Int + ): F[Vector[Option[AppleAteByFairyRank]]] = Sync[F].delay { DB.readOnly { implicit session => - val topFour = - sql"SELECT name,p_apple,COUNT(*) AS rank FROM playerdata ORDER BY rank DESC LIMIT 4;" - .map(rs => (rs.stringOpt("name"), rs.intOpt("rank"), rs.intOpt("p_apple"))) - .toList() - .apply() - .map(data => - if (data._1.nonEmpty) - Some(AppleAteByFairyRank(data._1.get, data._2.get, AppleAmount(data._3.get))) - else None - ) - AppleAteByFairyRankTopFour( - topFour.head.get, - topFour.lift(1).flatten, - topFour.lift(2).flatten, - topFour.lift(3).flatten - ) + sql"SELECT name,p_apple,COUNT(*) AS rank FROM playerdata ORDER BY rank DESC LIMIT $number;" + .map(rs => (rs.stringOpt("name"), rs.intOpt("rank"), rs.intOpt("p_apple"))) + .toList() + .apply() + .map(data => + if (data._1.nonEmpty) + Some(AppleAteByFairyRank(data._1.get, data._2.get, AppleAmount(data._3.get))) + else None + ) + .toVector } } From 46ec5317fc77f8c7d746c2a356e1d75085139f94 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 17:25:28 +0900 Subject: [PATCH 119/482] [Rename]context -> repeatingTaskContext --- .../seichiassist/subsystems/vote/subsystems/fairy/System.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 9631710dde..8b0dbb32ff 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -39,7 +39,7 @@ object System { implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], voteAPI: VoteAPI[IO, Player], manaApi: ManaApi[IO, SyncIO, Player], - context: RepeatingTaskContext, + repeatingTaskContext: RepeatingTaskContext, concurrentEffect: ConcurrentEffect[IO] ): SyncIO[System[IO, SyncIO, Player]] = { val persistence = new JdbcFairyPersistence[IO] From 46ccca3623479afcf781917740a151b804d7b1f9 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 17:28:59 +0900 Subject: [PATCH 120/482] =?UTF-8?q?[Fix]summonSpeech=E3=81=A7io=E3=81=AB?= =?UTF-8?q?=E5=88=87=E3=82=8A=E6=9B=BF=E3=81=88=E3=81=AA=E3=81=84=E3=81=A7?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E8=A1=8C=E3=81=86=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/bukkit/FairySpeech.scala | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index 7fbf49460d..3fc979757f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -35,15 +35,15 @@ class FairySpeech[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( else FairyMessageTable.nightMessages(nameCalledByFairy) message <- randomMessage(fairyMessages) - } yield { - val serviceRepository = fairyAPI.fairySpeechServiceRepository(player) - ContextCoercion { - serviceRepository.makeSpeech( - message, - ContextCoercion(fairyAPI.fairySpeechSound(player.getUniqueId)).toIO.unsafeRunSync() - ) - }.toIO.unsafeRunSync() - } + + serviceRepository = fairyAPI.fairySpeechServiceRepository(player) + fairySpeechSound <- ContextCoercion { + fairyAPI.fairySpeechSound(player.getUniqueId) + } + _ <- ContextCoercion { + serviceRepository.makeSpeech(message, fairySpeechSound) + } + } yield () def speechRandomly( player: Player, From 2193a6076eaf62bcbfe84f591d5750b5b6f332be Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 17:35:18 +0900 Subject: [PATCH 121/482] =?UTF-8?q?[Fix]FairySpeech=E3=81=AE=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92io=E3=81=AB=E5=88=87=E3=82=8A=E6=9B=BF?= =?UTF-8?q?=E3=81=88=E3=81=AA=E3=81=84=E3=81=A7=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E3=82=B9=E3=83=AB=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/bukkit/FairySpeech.scala | 51 +++++++------------ 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index 3fc979757f..7f4abeb060 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -1,16 +1,9 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit -import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import cats.effect.{ConcurrentEffect, Sync} import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - FairyManaRecoveryState, - FairyMessage, - FairyMessages, - FairyPlaySound, - NameCalledByFairy -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.FairyMessageTable import org.bukkit.entity.Player @@ -58,55 +51,49 @@ class FairySpeech[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( case FairyManaRecoveryState.notConsumptionApple => FairyMessageTable.notConsumed } - randomMessage(messages(nameCalledByFairy)).map { message => - ContextCoercion { - fairyAPI - .fairySpeechServiceRepository(player) - .makeSpeech( - message, - fairyAPI.fairySpeechSound(player.getUniqueId).toIO.unsafeRunSync() - ) - }.toIO.unsafeRunSync() - } + for { + message <- randomMessage(messages(nameCalledByFairy)) + fairyPlaySound <- fairyAPI.fairySpeechSound(player.getUniqueId) + _ <- ContextCoercion { + fairyAPI.fairySpeechServiceRepository(player).makeSpeech(message, fairyPlaySound) + } + } yield () } def speechEndTime(player: Player): F[Unit] = { for { endTimeOpt <- fairyAPI.fairyEndTime(player) playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) - } yield { - val endTime = endTimeOpt.get.endTimeOpt.get - ContextCoercion { + endTime = endTimeOpt.get.endTimeOpt.get + _ <- ContextCoercion { fairyAPI .fairySpeechServiceRepository(player) .makeSpeech( FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。"), playSound ) - }.toIO.unsafeRunSync() - } + } + } yield () } def welcomeBack(player: Player): F[Unit] = for { playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) - } yield { - ContextCoercion { + _ <- ContextCoercion { fairyAPI .fairySpeechServiceRepository(player) .makeSpeech(FairyMessage(s"おかえり!${player.getName}"), playSound) - }.toIO.unsafeRunSync() - } + } + } yield () def bye(player: Player): F[Unit] = for { playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) - } yield { - val repository = fairyAPI.fairySpeechServiceRepository(player) - (ContextCoercion { + repository = fairyAPI.fairySpeechServiceRepository(player) + _ <- ContextCoercion { repository.makeSpeech(FairyMessage(s"あっ、もうこんな時間だ!"), FairyPlaySound.off) } >> ContextCoercion { repository.makeSpeech(FairyMessage(s"じゃーねー!${player.getName}"), playSound) - }).toIO.unsafeRunSync() - } + } + } yield () private def randomMessage(fairyMessages: FairyMessages): F[FairyMessage] = Sync[F].delay { val messages = fairyMessages.messages From fd38fd0f260653bb309f74c6e6e830fc2e60057e Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 17:36:12 +0900 Subject: [PATCH 122/482] [Fix]ConcurrentEffect -> Sync --- .../subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index 7f4abeb060..6cb47ad590 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit -import cats.effect.{ConcurrentEffect, Sync} +import cats.effect.Sync import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ @@ -10,7 +10,7 @@ import org.bukkit.entity.Player import java.time.LocalTime import scala.util.Random -class FairySpeech[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( +class FairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( implicit fairyAPI: FairyAPI[F, G, Player] ) { From b1d1133d3a5a05818077f5e6425670c8acf6e15a Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 17:58:02 +0900 Subject: [PATCH 123/482] =?UTF-8?q?[Fix]BukkitRecoveryMana=E3=81=AE?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E3=81=A7=E3=81=8D=E3=82=8B=E3=81=A0?= =?UTF-8?q?=E3=81=91for=E3=81=AB=E3=81=A4=E3=81=A3=E3=81=93=E3=82=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/actions/BukkitRecoveryMana.scala | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 8245196cd5..c6576c9229 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -1,5 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions +import cats.Applicative import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import cats.effect.{ConcurrentEffect, Sync} import com.github.unchama.generic.ContextCoercion @@ -29,13 +30,36 @@ object BukkitRecoveryMana { import cats.implicits._ - def apply[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]](player: Player)( + def apply[F[_]: ConcurrentEffect: Applicative, G[_]: ContextCoercion[*[_], F]]( + player: Player + )( implicit breakCountAPI: BreakCountAPI[F, G, Player], fairyAPI: FairyAPI[F, G, Player], voteAPI: VoteAPI[F, Player], manaApi: ManaApi[F, G, Player] ): RecoveryMana[F] = new RecoveryMana[F] { override def recovery: F[Unit] = { + for { + fairyUsingState <- fairyAPI.fairyUsingState(player) + fairyEndTimeOpt <- fairyAPI.fairyEndTime(player) + endTime = fairyEndTimeOpt.get.endTimeOpt.get + isUsing = fairyUsingState == FairyUsingState.Using + _ <- { + new FairySpeech[F, G] + .bye(player) >> fairyAPI.updateFairyUsingState(player, FairyUsingState.NotUsing) + }.whenA( + // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) + isUsing && endTime.isBefore(LocalDateTime.now()) + ) + oldManaAmount <- ContextCoercion { + manaApi.readManaAmount(player) + } + + _ <- { + new FairySpeech[F, G].speechRandomly(player, FairyManaRecoveryState.full) + }.whenA(isUsing && oldManaAmount.isFull) + + } yield () ContextCoercion(manaApi.readManaAmount(player)).map { oldManaAmount => if (fairyAPI.fairyUsingState(player).toIO.unsafeRunSync() == FairyUsingState.Using) { if ( From c96f0dfabd66c7aa8defd1edc912f5d83d7034f8 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 21:16:00 +0900 Subject: [PATCH 124/482] =?UTF-8?q?[Fix]=E3=83=9E=E3=83=8A=E3=81=AE?= =?UTF-8?q?=E5=9B=9E=E5=BE=A9=E9=87=8F=E3=81=AE=E9=99=A4=E7=AE=97=E9=87=8F?= =?UTF-8?q?=E3=81=AE=E3=83=9F=E3=82=B9=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index c6576c9229..4a3559869f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -113,7 +113,7 @@ object BukkitRecoveryMana { // 連続投票を適用した除算量 val chainVoteDivisionAmount = if (chainVoteDayNumber >= 30) 2 - else if (chainVoteDayNumber >= 10) 1.2 + else if (chainVoteDayNumber >= 10) 1.5 else if (chainVoteDayNumber >= 3) 1.25 else 1 From 04411efa2bf14ae25548781c441c0217a618cdf3 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 23:33:28 +0900 Subject: [PATCH 125/482] =?UTF-8?q?[Fix]BukkitRecoveryMana=E3=81=AE?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E5=88=86=E5=89=B2=E3=81=97=E3=81=A6?= =?UTF-8?q?unsafeRunSync=E3=81=97=E3=81=AA=E3=81=84=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/actions/BukkitRecoveryMana.scala | 402 +++++++++--------- .../bukkit/routines/BukkitFairyRoutine.scala | 2 +- 2 files changed, 199 insertions(+), 205 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 4a3559869f..5cba47271b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -1,10 +1,8 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions import cats.Applicative -import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps -import cats.effect.{ConcurrentEffect, Sync} +import cats.effect.{ConcurrentEffect, LiftIO} import com.github.unchama.generic.ContextCoercion -import com.github.unchama.seichiassist.{MineStackObjectList, SeichiAssist} import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.mana.domain.ManaAmount @@ -18,223 +16,219 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p FairyManaRecoveryState, FairyUsingState } -import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} +import com.github.unchama.seichiassist.{MineStackObjectList, SeichiAssist} +import com.github.unchama.targetedeffect.SequentialEffect import com.github.unchama.targetedeffect.commandsender.MessageEffect import org.bukkit.ChatColor._ import org.bukkit.entity.Player import java.time.LocalDateTime +import java.util.UUID import scala.util.Random -object BukkitRecoveryMana { +class BukkitRecoveryMana[F[_]: ConcurrentEffect: Applicative, G[_]: ContextCoercion[*[_], F]]( + player: Player +)( + implicit breakCountAPI: BreakCountAPI[F, G, Player], + fairyAPI: FairyAPI[F, G, Player], + voteAPI: VoteAPI[F, Player], + manaApi: ManaApi[F, G, Player] +) extends RecoveryMana[F] { + + private lazy val uuid: UUID = player.getUniqueId + private lazy val playerdata = SeichiAssist.playermap(uuid) import cats.implicits._ - def apply[F[_]: ConcurrentEffect: Applicative, G[_]: ContextCoercion[*[_], F]]( - player: Player - )( - implicit breakCountAPI: BreakCountAPI[F, G, Player], - fairyAPI: FairyAPI[F, G, Player], - voteAPI: VoteAPI[F, Player], - manaApi: ManaApi[F, G, Player] - ): RecoveryMana[F] = new RecoveryMana[F] { - override def recovery: F[Unit] = { - for { - fairyUsingState <- fairyAPI.fairyUsingState(player) - fairyEndTimeOpt <- fairyAPI.fairyEndTime(player) - endTime = fairyEndTimeOpt.get.endTimeOpt.get - isUsing = fairyUsingState == FairyUsingState.Using - _ <- { - new FairySpeech[F, G] - .bye(player) >> fairyAPI.updateFairyUsingState(player, FairyUsingState.NotUsing) - }.whenA( - // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) - isUsing && endTime.isBefore(LocalDateTime.now()) - ) - oldManaAmount <- ContextCoercion { - manaApi.readManaAmount(player) + override def recovery: F[Unit] = + for { + fairyUsingState <- fairyAPI.fairyUsingState(player) + fairyEndTimeOpt <- fairyAPI.fairyEndTime(player) + endTime = fairyEndTimeOpt.get.endTimeOpt.get + isUsing = fairyUsingState == FairyUsingState.Using + _ <- { + new FairySpeech[F, G] + .bye(player) >> fairyAPI.updateFairyUsingState(player, FairyUsingState.NotUsing) + }.whenA( + // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) + isUsing && endTime.isBefore(LocalDateTime.now()) + ) + oldManaAmount <- ContextCoercion { + manaApi.readManaAmount(player) + } + _ <- { + new FairySpeech[F, G].speechRandomly(player, FairyManaRecoveryState.full) + }.whenA(isUsing && oldManaAmount.isFull) + + finallyAppleConsumptionAmount <- computeFinallyAppleConsumptionAmount + recoveryManaAmount <- computeManaRecoveryAmount + + appleConsumptionAmount <- computeAppleConsumptionAmount + gachaRingoObject <- LiftIO[F].liftIO { + MineStackObjectList.findByName("gachaimo") + } + mineStackedGachaRingoAmount = + playerdata.minestack.getStackedAmountOf(gachaRingoObject.get) + + _ <- LiftIO[F] + .liftIO { + MessageEffect(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。").apply(player) } + .whenA( + isUsing && !oldManaAmount.isFull && appleConsumptionAmount > mineStackedGachaRingoAmount + ) - _ <- { - new FairySpeech[F, G].speechRandomly(player, FairyManaRecoveryState.full) - }.whenA(isUsing && oldManaAmount.isFull) - - } yield () - ContextCoercion(manaApi.readManaAmount(player)).map { oldManaAmount => - if (fairyAPI.fairyUsingState(player).toIO.unsafeRunSync() == FairyUsingState.Using) { - if ( - fairyAPI - .fairyEndTime(player) - .toIO - .unsafeRunSync() - .get - .endTimeOpt - .get - .isBefore(LocalDateTime.now()) - ) { - // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) - (new FairySpeech[F, G].bye(player) >> fairyAPI.updateFairyUsingState( - player, - FairyUsingState.NotUsing - )).toIO.unsafeRunSync() - } else { - // 有効期限内 - if (oldManaAmount.isFull) { - new FairySpeech[F, G] - .speechRandomly(player, FairyManaRecoveryState.full) - .toIO - .unsafeRunSync() - } else { - val uuid = player.getUniqueId - - val eff = for { - seichiAmountData <- ContextCoercion( - breakCountAPI.seichiAmountDataRepository(player).read + _ <- { + fairyAPI.increaseAppleAteByFairy(uuid, AppleAmount(finallyAppleConsumptionAmount)) >> + ContextCoercion( + manaApi.manaAmount(player).restoreAbsolute(ManaAmount(recoveryManaAmount)) + ) >> + new FairySpeech[F, G].speechRandomly( + player, + if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) + FairyManaRecoveryState.notConsumptionApple + else FairyManaRecoveryState.consumptionApple + ) >> LiftIO[F].liftIO { + SequentialEffect( + MessageEffect(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), + if (appleConsumptionAmount != 0) + MessageEffect( + s"$RESET$YELLOW${BOLD}あっ!${appleConsumptionAmount}個のがちゃりんごが食べられてる!" ) - defaultRecoveryManaAmount <- fairyAPI.fairyRecoveryMana(uuid) - chainVoteNumber <- voteAPI.chainVoteDayNumber(uuid) - appleOpenState <- fairyAPI.appleOpenState(uuid) - } yield { - val playerLevel = seichiAmountData.levelCorrespondingToExp - - val playerdata = SeichiAssist.playermap(player.getUniqueId) - val gachaRingoObject = - MineStackObjectList.findByName("gachaimo").unsafeRunSync().get - val mineStackedGachaRingoAmount = - playerdata.minestack.getStackedAmountOf(gachaRingoObject) - - val isAppleOpenStateIsOpenOROpenALittle = - appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open - val isManaExistsSeventyFivePercent = oldManaAmount.ratioToCap.exists(_ >= 0.75) - - val defaultAmount = Math.pow(playerLevel.level / 10, 2) - - val chainVoteDayNumber = chainVoteNumber.value - // 連続投票を適用した除算量 - val chainVoteDivisionAmount = - if (chainVoteDayNumber >= 30) 2 - else if (chainVoteDayNumber >= 10) 1.5 - else if (chainVoteDayNumber >= 3) 1.25 - else 1 - - // りんごの開放状況を適用した除算量 - val appleOpenStateDivisionAmount = - if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 - else 1 - - // りんごの開放状況まで適用したりんごの消費量 (暫定) - val appleOpenStateReflectedAmount = - (defaultAmount / chainVoteDivisionAmount).toInt / appleOpenStateDivisionAmount - - // 妖精がつまみ食いする量 - val amountEatenByKnob = - if (appleOpenStateReflectedAmount >= 10) - new Random().nextInt(appleOpenStateReflectedAmount / 10) - else 0 - - /* - 最終的に算出されたりんごの消費量 - (現時点では持っているりんごの数を - 考慮していないので消費量は確定していない) - */ - val finallyAppleConsumptionAmount = - Math.max(appleOpenStateReflectedAmount + amountEatenByKnob, 1) - - // りんごの消費量 - val appleConsumptionAmount = - if (appleOpenState == AppleOpenState.NotOpen) { - 0 - } else { - if (mineStackedGachaRingoAmount > finallyAppleConsumptionAmount) - finallyAppleConsumptionAmount - else mineStackedGachaRingoAmount - } - - // マナの回復量を算出する - val recoveryManaAmount = { - val appleOpenStateDivision = { - if (isAppleOpenStateIsOpenOROpenALittle && isManaExistsSeventyFivePercent) 2 - else if (appleOpenState == AppleOpenState.NotOpen) 4 - else 1 - } - - val reflectedAppleOpenStateAmount = - defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision - - // minestackに入っているりんごの数を適用したマナの回復量 - val reflectedMineStackedAmount = - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { - if (mineStackedGachaRingoAmount == 0) { - reflectedAppleOpenStateAmount / { - if (appleOpenState == AppleOpenState.Open) 4 - else if (appleOpenState == AppleOpenState.OpenALittle) 4 - else 2 - } - } else { - if ( - (mineStackedGachaRingoAmount / finallyAppleConsumptionAmount) <= 0.5 - ) - (reflectedAppleOpenStateAmount * 0.5).toInt - else - (reflectedAppleOpenStateAmount * mineStackedGachaRingoAmount / finallyAppleConsumptionAmount).toInt - } - } else reflectedAppleOpenStateAmount - - (reflectedMineStackedAmount - reflectedMineStackedAmount / 100) + - (if (reflectedMineStackedAmount >= 50) - Random.nextInt(reflectedMineStackedAmount / 50) - else 0) - } - - // minestackからりんごを消費する - playerdata - .minestack - .subtractStackedAmountOf(gachaRingoObject, appleConsumptionAmount) - - // 消費したりんごの量を保存する - fairyAPI - .increaseAppleAteByFairy(uuid, AppleAmount(appleConsumptionAmount.toInt)) - .toIO - .unsafeRunSync() - - // マナを回復する - ContextCoercion( - manaApi.manaAmount(player).restoreAbsolute(ManaAmount(recoveryManaAmount)) - ).toIO.unsafeRunSync() - - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) { - MessageEffect(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") - .apply(player) - .unsafeRunSync() - } - - SequentialEffect( - UnfocusedEffect { - new FairySpeech[F, G] - .speechRandomly( - player, - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) - FairyManaRecoveryState.notConsumptionApple - else FairyManaRecoveryState.consumptionApple - ) - .toIO - .unsafeRunSync() - }, - MessageEffect(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), - if (appleConsumptionAmount != 0) - MessageEffect( - s"$RESET$YELLOW${BOLD}あっ!${appleConsumptionAmount}個のがちゃりんごが食べられてる!" - ) - else MessageEffect(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") - ).apply(player).unsafeRunSync() - } - eff.toIO.unsafeRunSync() - } + else MessageEffect(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") + ).apply(player) } - } else Sync[F].unit - } + }.whenA(isUsing && !oldManaAmount.isFull) + } yield () + + /** + * MineStackに入っているがちゃりんごの数を考慮していない + * がちゃりんごの消費量を計算します。 + */ + private def computeAppleConsumptionAmount: F[Int] = for { + seichiAmountData <- ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read) + chainVoteNumber <- voteAPI.chainVoteDayNumber(uuid) + appleOpenState <- fairyAPI.appleOpenState(uuid) + oldManaAmount <- ContextCoercion { + manaApi.readManaAmount(player) + } + } yield { + val playerLevel = seichiAmountData.levelCorrespondingToExp + + val isAppleOpenStateIsOpenOrOpenALittle = + appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open + val isManaExistsSeventyFivePercent = oldManaAmount.ratioToCap.exists(_ >= 0.75) + + val defaultAmount = Math.pow(playerLevel.level / 10, 2) + + val chainVoteDayNumber = chainVoteNumber.value + // 連続投票を適用した除算量 + val chainVoteDivisionAmount = + if (chainVoteDayNumber >= 30) 2 + else if (chainVoteDayNumber >= 10) 1.5 + else if (chainVoteDayNumber >= 3) 1.25 + else 1 + + // りんごの開放状況を適用した除算量 + val appleOpenStateDivisionAmount = + if (isAppleOpenStateIsOpenOrOpenALittle && isManaExistsSeventyFivePercent) 2 + else 1 + + // りんごの開放状況まで適用したりんごの消費量 (暫定) + val appleOpenStateReflectedAmount = + (defaultAmount / chainVoteDivisionAmount).toInt / appleOpenStateDivisionAmount + + // 妖精がつまみ食いする量 + val amountEatenByKnob = + if (appleOpenStateReflectedAmount >= 10) + new Random().nextInt(appleOpenStateReflectedAmount / 10) + else 0 + + /* + 最終的に算出されたりんごの消費量 + (現時点では持っているりんごの数を + 考慮していないので消費量は確定していない) + */ + Math.max(appleOpenStateReflectedAmount + amountEatenByKnob, 1) + } + + /** + * MineStackに入っているがちゃりんごの数を考慮した + * がちゃりんごの消費量を計算します。 + */ + private def computeFinallyAppleConsumptionAmount: F[Int] = for { + appleConsumptionAmount <- computeAppleConsumptionAmount + appleOpenState <- fairyAPI.appleOpenState(uuid) + gachaRingoObject <- LiftIO[F].liftIO { + MineStackObjectList.findByName("gachaimo") + } + } yield { + val mineStackedGachaRingoAmount = + playerdata.minestack.getStackedAmountOf(gachaRingoObject.get) + + // りんごの消費量 + if (appleOpenState == AppleOpenState.NotOpen) { + 0 + } else { + if (mineStackedGachaRingoAmount > appleConsumptionAmount) + appleConsumptionAmount + else mineStackedGachaRingoAmount } + } + + /** + * マナの回復量を計算します。 + */ + private def computeManaRecoveryAmount: F[Int] = for { + defaultRecoveryManaAmount <- fairyAPI.fairyRecoveryMana(uuid) + appleOpenState <- fairyAPI.appleOpenState(uuid) + oldManaAmount <- ContextCoercion { + manaApi.readManaAmount(player) + } + gachaRingoObject <- LiftIO[F].liftIO { + MineStackObjectList.findByName("gachaimo") + } + appleConsumptionAmount <- computeAppleConsumptionAmount + } yield { + val isAppleOpenStateIsOpenOrOpenALittle = + appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open + val isManaExistsSeventyFivePercent = oldManaAmount.ratioToCap.exists(_ >= 0.75) + + val mineStackedGachaRingoAmount = + playerdata.minestack.getStackedAmountOf(gachaRingoObject.get) + + // マナの回復量を算出する + + val appleOpenStateDivision = { + if (isAppleOpenStateIsOpenOrOpenALittle && isManaExistsSeventyFivePercent) 2 + else if (appleOpenState == AppleOpenState.NotOpen) 4 + else 1 + } + + val reflectedAppleOpenStateAmount = + defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision + + // minestackに入っているりんごの数を適用したマナの回復量 + val reflectedMineStackedAmount = + if (appleConsumptionAmount > mineStackedGachaRingoAmount) { + if (mineStackedGachaRingoAmount == 0) { + reflectedAppleOpenStateAmount / { + if (appleOpenState == AppleOpenState.Open) 4 + else if (appleOpenState == AppleOpenState.OpenALittle) 4 + else 2 + } + } else { + if ((mineStackedGachaRingoAmount / appleConsumptionAmount) <= 0.5) + (reflectedAppleOpenStateAmount * 0.5).toInt + else + (reflectedAppleOpenStateAmount * mineStackedGachaRingoAmount / appleConsumptionAmount).toInt + } + } else reflectedAppleOpenStateAmount + (reflectedMineStackedAmount - reflectedMineStackedAmount / 100) + + (if (reflectedMineStackedAmount >= 50) + Random.nextInt(reflectedMineStackedAmount / 50) + else 0) } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index d563a1092e..954024bba7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -40,7 +40,7 @@ class BukkitFairyRoutine extends FairyRoutine[IO, SyncIO, Player] { RepeatingRoutine.permanentRoutine( repeatInterval, onMainThread.runAction { - BukkitRecoveryMana[IO, SyncIO](player).recovery.runAsync(_ => IO.unit) + new BukkitRecoveryMana[IO, SyncIO](player).recovery.runAsync(_ => IO.unit) } ) } From efe17bd5e98dabe764294d5807093dfb8aaca5d5 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 23:43:44 +0900 Subject: [PATCH 126/482] =?UTF-8?q?[Fix]BukkitRevoceryMana=E3=81=AE?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/actions/BukkitRecoveryMana.scala | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 5cba47271b..83fafe0585 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -60,10 +60,12 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: Applicative, G[_]: ContextCoerc new FairySpeech[F, G].speechRandomly(player, FairyManaRecoveryState.full) }.whenA(isUsing && oldManaAmount.isFull) - finallyAppleConsumptionAmount <- computeFinallyAppleConsumptionAmount - recoveryManaAmount <- computeManaRecoveryAmount - appleConsumptionAmount <- computeAppleConsumptionAmount + finallyAppleConsumptionAmount <- computeFinallyAppleConsumptionAmount( + appleConsumptionAmount + ) + recoveryManaAmount <- computeManaRecoveryAmount(appleConsumptionAmount) + gachaRingoObject <- LiftIO[F].liftIO { MineStackObjectList.findByName("gachaimo") } @@ -156,8 +158,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: Applicative, G[_]: ContextCoerc * MineStackに入っているがちゃりんごの数を考慮した * がちゃりんごの消費量を計算します。 */ - private def computeFinallyAppleConsumptionAmount: F[Int] = for { - appleConsumptionAmount <- computeAppleConsumptionAmount + private def computeFinallyAppleConsumptionAmount(appleConsumptionAmount: Int): F[Int] = for { appleOpenState <- fairyAPI.appleOpenState(uuid) gachaRingoObject <- LiftIO[F].liftIO { MineStackObjectList.findByName("gachaimo") @@ -179,7 +180,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: Applicative, G[_]: ContextCoerc /** * マナの回復量を計算します。 */ - private def computeManaRecoveryAmount: F[Int] = for { + private def computeManaRecoveryAmount(appleConsumptionAmount: Int): F[Int] = for { defaultRecoveryManaAmount <- fairyAPI.fairyRecoveryMana(uuid) appleOpenState <- fairyAPI.appleOpenState(uuid) oldManaAmount <- ContextCoercion { @@ -188,7 +189,6 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: Applicative, G[_]: ContextCoerc gachaRingoObject <- LiftIO[F].liftIO { MineStackObjectList.findByName("gachaimo") } - appleConsumptionAmount <- computeAppleConsumptionAmount } yield { val isAppleOpenStateIsOpenOrOpenALittle = appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open From 0e76b1c7a82cbb69470f4633bcce62d7cc8d8cb6 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 30 Jul 2022 23:48:53 +0900 Subject: [PATCH 127/482] =?UTF-8?q?[Remove]=E3=82=88=E3=81=8F=E3=82=8F?= =?UTF-8?q?=E3=81=8B=E3=82=89=E3=81=AA=E3=81=84=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=8C=E3=81=A7=E3=81=8D=E3=81=A6=E3=81=84=E3=81=9F?= =?UTF-8?q?=E3=81=AE=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1q | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 1q diff --git a/1q b/1q deleted file mode 100644 index bc71206c15..0000000000 --- a/1q +++ /dev/null @@ -1,11 +0,0 @@ -[Fix]BukkitReceiveVoteBenefitsの処理でwhenAを使うように -# Please enter the commit message for your changes. Lines starting -# with '#' will be ignored, and an empty message aborts the commit. -# -# On branch refactorVote -# Your branch is ahead of 'rito/refactorVote' by 6 commits. -# (use "git push" to publish your local commits) -# -# Changes to be committed: -# modified: src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala -# From 07dc1a47fb62259a438dd123456dc9e3b09c9294 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 12:50:24 +0900 Subject: [PATCH 128/482] [Fix]MessageEffect -> MessageEffectF --- .../bukkit/actions/BukkitRecoveryMana.scala | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 83fafe0585..e714a598c8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -18,7 +18,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p } import com.github.unchama.seichiassist.{MineStackObjectList, SeichiAssist} import com.github.unchama.targetedeffect.SequentialEffect -import com.github.unchama.targetedeffect.commandsender.MessageEffect +import com.github.unchama.targetedeffect.commandsender.MessageEffectF import org.bukkit.ChatColor._ import org.bukkit.entity.Player @@ -72,10 +72,8 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: Applicative, G[_]: ContextCoerc mineStackedGachaRingoAmount = playerdata.minestack.getStackedAmountOf(gachaRingoObject.get) - _ <- LiftIO[F] - .liftIO { - MessageEffect(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。").apply(player) - } + _ <- MessageEffectF(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") + .apply(player) .whenA( isUsing && !oldManaAmount.isFull && appleConsumptionAmount > mineStackedGachaRingoAmount ) @@ -90,16 +88,15 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: Applicative, G[_]: ContextCoerc if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) FairyManaRecoveryState.notConsumptionApple else FairyManaRecoveryState.consumptionApple - ) >> LiftIO[F].liftIO { - SequentialEffect( - MessageEffect(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), - if (appleConsumptionAmount != 0) - MessageEffect( - s"$RESET$YELLOW${BOLD}あっ!${appleConsumptionAmount}個のがちゃりんごが食べられてる!" - ) - else MessageEffect(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") - ).apply(player) - } + ) >> + SequentialEffect( + MessageEffectF(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), + if (appleConsumptionAmount != 0) + MessageEffectF( + s"$RESET$YELLOW${BOLD}あっ!${appleConsumptionAmount}個のがちゃりんごが食べられてる!" + ) + else MessageEffectF(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") + ).apply(player) }.whenA(isUsing && !oldManaAmount.isFull) } yield () From 042b7148d719f713219f7cc6eb64be00c0fb8cfd Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 12:51:19 +0900 Subject: [PATCH 129/482] [rename] reflectedMineStackedAmount -> mineStackBasedRegenValue --- .../fairy/bukkit/actions/BukkitRecoveryMana.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index e714a598c8..cc076931aa 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -206,7 +206,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: Applicative, G[_]: ContextCoerc defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision // minestackに入っているりんごの数を適用したマナの回復量 - val reflectedMineStackedAmount = + val mineStackBasedRegenValue = if (appleConsumptionAmount > mineStackedGachaRingoAmount) { if (mineStackedGachaRingoAmount == 0) { reflectedAppleOpenStateAmount / { @@ -222,9 +222,9 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: Applicative, G[_]: ContextCoerc } } else reflectedAppleOpenStateAmount - (reflectedMineStackedAmount - reflectedMineStackedAmount / 100) + - (if (reflectedMineStackedAmount >= 50) - Random.nextInt(reflectedMineStackedAmount / 50) + (mineStackBasedRegenValue - mineStackBasedRegenValue / 100) + + (if (mineStackBasedRegenValue >= 50) + Random.nextInt(mineStackBasedRegenValue / 50) else 0) } From e913a6d0fe35ef8252ae254a43e29a5f7c1bf336 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 12:52:22 +0900 Subject: [PATCH 130/482] remove: applicative --- .../subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index cc076931aa..20e2459e99 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -1,6 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions -import cats.Applicative import cats.effect.{ConcurrentEffect, LiftIO} import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI @@ -26,7 +25,7 @@ import java.time.LocalDateTime import java.util.UUID import scala.util.Random -class BukkitRecoveryMana[F[_]: ConcurrentEffect: Applicative, G[_]: ContextCoercion[*[_], F]]( +class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( player: Player )( implicit breakCountAPI: BreakCountAPI[F, G, Player], From ec78d03abaff2ad25df0ae30a0c47a20d1d4c466 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 12:54:34 +0900 Subject: [PATCH 131/482] rename: isManaExistsSeventyFivePercent -> isEnoughMana --- .../fairy/bukkit/actions/BukkitRecoveryMana.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 20e2459e99..d69e0872da 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -115,7 +115,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] val isAppleOpenStateIsOpenOrOpenALittle = appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open - val isManaExistsSeventyFivePercent = oldManaAmount.ratioToCap.exists(_ >= 0.75) + val isEnoughMana = oldManaAmount.ratioToCap.exists(_ >= 0.75) val defaultAmount = Math.pow(playerLevel.level / 10, 2) @@ -129,7 +129,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] // りんごの開放状況を適用した除算量 val appleOpenStateDivisionAmount = - if (isAppleOpenStateIsOpenOrOpenALittle && isManaExistsSeventyFivePercent) 2 + if (isAppleOpenStateIsOpenOrOpenALittle && isEnoughMana) 2 else 1 // りんごの開放状況まで適用したりんごの消費量 (暫定) @@ -188,7 +188,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] } yield { val isAppleOpenStateIsOpenOrOpenALittle = appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open - val isManaExistsSeventyFivePercent = oldManaAmount.ratioToCap.exists(_ >= 0.75) + val isEnoughMana = oldManaAmount.ratioToCap.exists(_ >= 0.75) val mineStackedGachaRingoAmount = playerdata.minestack.getStackedAmountOf(gachaRingoObject.get) @@ -196,7 +196,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] // マナの回復量を算出する val appleOpenStateDivision = { - if (isAppleOpenStateIsOpenOrOpenALittle && isManaExistsSeventyFivePercent) 2 + if (isAppleOpenStateIsOpenOrOpenALittle && isEnoughMana) 2 else if (appleOpenState == AppleOpenState.NotOpen) 4 else 1 } From f917459c3af40d712fb908da237701aab3230726 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 12:58:22 +0900 Subject: [PATCH 132/482] remove: lazy --- .../subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index d69e0872da..6d0a31d4cd 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -34,8 +34,8 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] manaApi: ManaApi[F, G, Player] ) extends RecoveryMana[F] { - private lazy val uuid: UUID = player.getUniqueId - private lazy val playerdata = SeichiAssist.playermap(uuid) + private val uuid: UUID = player.getUniqueId + private val playerdata = SeichiAssist.playermap(uuid) import cats.implicits._ From 7799a59fc3da569170ab63482f37efff6214b7e3 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 13:03:27 +0900 Subject: [PATCH 133/482] =?UTF-8?q?refactor:=20bukkitRecoveryMana=E3=81=AE?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/actions/BukkitRecoveryMana.scala | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 6d0a31d4cd..77551f11ad 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -164,13 +164,11 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] playerdata.minestack.getStackedAmountOf(gachaRingoObject.get) // りんごの消費量 - if (appleOpenState == AppleOpenState.NotOpen) { + if (appleOpenState == AppleOpenState.NotOpen) 0 - } else { - if (mineStackedGachaRingoAmount > appleConsumptionAmount) - appleConsumptionAmount - else mineStackedGachaRingoAmount - } + else if (mineStackedGachaRingoAmount > appleConsumptionAmount) + appleConsumptionAmount + else mineStackedGachaRingoAmount } /** @@ -195,11 +193,10 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] // マナの回復量を算出する - val appleOpenStateDivision = { + val appleOpenStateDivision = if (isAppleOpenStateIsOpenOrOpenALittle && isEnoughMana) 2 else if (appleOpenState == AppleOpenState.NotOpen) 4 else 1 - } val reflectedAppleOpenStateAmount = defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision @@ -208,23 +205,23 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] val mineStackBasedRegenValue = if (appleConsumptionAmount > mineStackedGachaRingoAmount) { if (mineStackedGachaRingoAmount == 0) { - reflectedAppleOpenStateAmount / { + reflectedAppleOpenStateAmount / ( if (appleOpenState == AppleOpenState.Open) 4 else if (appleOpenState == AppleOpenState.OpenALittle) 4 else 2 - } - } else { - if ((mineStackedGachaRingoAmount / appleConsumptionAmount) <= 0.5) - (reflectedAppleOpenStateAmount * 0.5).toInt - else - (reflectedAppleOpenStateAmount * mineStackedGachaRingoAmount / appleConsumptionAmount).toInt - } + ) + } else if ((mineStackedGachaRingoAmount / appleConsumptionAmount) <= 0.5) + (reflectedAppleOpenStateAmount * 0.5).toInt + else + (reflectedAppleOpenStateAmount * mineStackedGachaRingoAmount / appleConsumptionAmount).toInt } else reflectedAppleOpenStateAmount - (mineStackBasedRegenValue - mineStackBasedRegenValue / 100) + - (if (mineStackBasedRegenValue >= 50) - Random.nextInt(mineStackBasedRegenValue / 50) - else 0) + val randomizedAdd = + if (mineStackBasedRegenValue >= 50) + Random.nextInt(mineStackBasedRegenValue / 50) + else 0 + + (mineStackBasedRegenValue - mineStackBasedRegenValue / 100) + randomizedAdd } } From b54d376ecc570d9ccf6fa20eb573a1f5ff3b0d79 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 14:33:40 +0900 Subject: [PATCH 134/482] =?UTF-8?q?fix:=20fairySpawnRequest=E3=82=92?= =?UTF-8?q?=E5=91=BC=E3=81=B6=E3=81=93=E3=81=A8=E3=81=A7spawn=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 33 ++++++- .../application/actions/SummonFairy.scala | 9 +- .../bukkit/actions/BukkitSummonFairy.scala | 94 ++++++------------- .../fairy/domain/FairySpawnRequest.scala | 34 ++++--- 4 files changed, 88 insertions(+), 82 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 0b5ea361c1..61e60d9055 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -1,5 +1,6 @@ package com.github.unchama.seichiassist.menus +import cats.data.Kleisli import cats.effect.{ConcurrentEffect, IO, SyncIO} import cats.implicits.toTraverseOps import com.github.unchama.itemstackbuilder.IconItemStackBuilder @@ -17,8 +18,15 @@ import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequest +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestResult.{ + AlreadyFairySpawned, + NotEnoughEffectPoint, + NotEnoughSeichiLevel +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleOpenState, FairyPlaySound, @@ -269,6 +277,8 @@ object VoteMenu extends Menu { val fairySummonButton: IO[Button] = IO { val fairySummonState = fairyAPI.fairySummonCost(player).unsafeRunSync() + implicit val summonFairy: SummonFairy[IO, SyncIO, Player] = + new BukkitSummonFairy[IO, SyncIO]() Button( new IconItemStackBuilder(Material.GHAST_TEAR) .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}マナ妖精 召喚") @@ -284,8 +294,20 @@ object VoteMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - UnfocusedEffect { - BukkitSummonFairy(player).summon.unsafeRunSync() + new FairySpawnRequest().spawnRequest(player).unsafeRunSync() match { + case Left(errorResult) => + errorResult.unsafeRunSync() match { + case NotEnoughSeichiLevel => + spawnFailedEffect(s"${GOLD}プレイヤーレベルが足りません") + case AlreadyFairySpawned => + spawnFailedEffect(s"${GOLD}既に妖精を召喚しています") + case NotEnoughEffectPoint => + spawnFailedEffect(s"${GOLD}投票ptが足りません") + } + case Right(process) => + UnfocusedEffect { + process.unsafeRunSync() + } }, closeInventoryEffect ) @@ -293,6 +315,13 @@ object VoteMenu extends Menu { ) } + private def spawnFailedEffect(message: String): Kleisli[IO, Player, Unit] = { + SequentialEffect( + MessageEffect(message), + FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) + ) + } + val checkTimeButton: IO[Button] = IO { Button( new IconItemStackBuilder(Material.COMPASS) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala index 5242cfdc4d..392a5d98a7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala @@ -1,16 +1,19 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions -trait SummonFairy[F[_]] { +trait SummonFairy[F[_], G[_], Player] { /** * 妖精を召喚する作用 */ - def summon: F[Unit] + def summon(player: Player): F[Unit] } object SummonFairy { - def apply[F[_]](implicit ev: SummonFairy[F]): SummonFairy[F] = ev + def apply[F[_], G[_], Player]( + implicit ev: SummonFairy[F, G, Player] + ): SummonFairy[F, G, Player] = + ev } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 2e058aa424..db0c9c49ab 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -1,6 +1,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions -import cats.effect.{ConcurrentEffect, IO, LiftIO, SyncIO} +import cats.effect.ConcurrentEffect +import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI @@ -8,78 +9,45 @@ import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequest -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestResult._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ FairyRecoveryManaAmount, FairyUsingState } -import com.github.unchama.targetedeffect.commandsender.MessageEffect -import com.github.unchama.targetedeffect.player.FocusedSoundEffect -import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} +import com.github.unchama.targetedeffect.commandsender.MessageEffectF import org.bukkit.ChatColor._ -import org.bukkit.Sound import org.bukkit.entity.Player -object BukkitSummonFairy { +class BukkitSummonFairy[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( + implicit breakCountAPI: BreakCountAPI[F, G, Player], + fairyAPI: FairyAPI[F, G, Player], + voteAPI: VoteAPI[F, Player], + manaApi: ManaApi[F, G, Player] +) extends SummonFairy[F, G, Player] { - def apply(player: Player)( - implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], - fairyAPI: FairyAPI[IO, SyncIO, Player], - voteAPI: VoteAPI[IO, Player], - manaApi: ManaApi[IO, SyncIO, Player], - concurrentEffect: ConcurrentEffect[IO] - ): SummonFairy[IO] = new SummonFairy[IO] { - override def summon: IO[Unit] = { - val failedEffect = spawnFailedEffect(player, _) + import cats.implicits._ - new FairySpawnRequest[IO, SyncIO, Player].spawnRequest(player).unsafeRunSync() match { - case NotEnoughSeichiLevel => - failedEffect(s"${GOLD}プレイヤーレベルが足りません") - case AlreadyFairySpawned => - failedEffect(s"${GOLD}既に妖精を召喚しています") - case NotEnoughEffectPoint => - failedEffect(s"${GOLD}投票ptが足りません") - case Success => - val levelCappedManaAmount = - manaApi.readManaAmount(player).unsafeRunSync().cap.value - - // 回復するマナの量 - val recoveryMana = FairyRecoveryManaAmount.manaAmountAt(levelCappedManaAmount) - - val eff = for { - fairySummonCost <- fairyAPI.fairySummonCost(player) - _ <- fairyAPI.updateFairyUsingState(player, FairyUsingState.Using) - uuid = player.getUniqueId - _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(fairySummonCost.value * 2)) - _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryMana) - _ <- fairyAPI.updateFairyEndTime(player, fairySummonCost.endTime) - } yield () - - LiftIO[IO].liftIO { - SequentialEffect( - UnfocusedEffect { - eff.unsafeRunSync() - new FairySpeech[IO, SyncIO]().summonSpeech(player).unsafeRunSync() - }, - MessageEffect( - List( - s"$RESET$YELLOW${BOLD}妖精を呼び出しました!", - s"$RESET$YELLOW${BOLD}この子は1分間に約${recoveryMana.recoveryMana}マナ", - s"$RESET$YELLOW${BOLD}回復させる力を持っているようです。" - ) - ) - ).apply(player) - } + override def summon(player: Player): F[Unit] = { + for { + _ <- fairyAPI.updateFairyUsingState(player, FairyUsingState.Using) + manaAmount <- ContextCoercion { + manaApi.readManaAmount(player) } - } - } - - private def spawnFailedEffect(player: Player, message: String): IO[Unit] = { - SequentialEffect( - MessageEffect(message), - FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) - ).run(player) + levelCappedManaAmount = manaAmount.cap.value + recoveryManaAmount = FairyRecoveryManaAmount.manaAmountAt(levelCappedManaAmount) + uuid = player.getUniqueId + fairySummonCost <- fairyAPI.fairySummonCost(player) + _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(fairySummonCost.value * 2)) + _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryManaAmount) + _ <- fairyAPI.updateFairyEndTime(player, fairySummonCost.endTime) + _ <- new FairySpeech[F, G].summonSpeech(player) + _ <- MessageEffectF( + List( + s"$RESET$YELLOW${BOLD}妖精を呼び出しました!", + s"$RESET$YELLOW${BOLD}この子は1分間に約${recoveryManaAmount.recoveryMana}マナ", + s"$RESET$YELLOW${BOLD}回復させる力を持っているようです。" + ) + ).apply(player) + } yield () } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala index 141c0bc406..85486f6130 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala @@ -1,40 +1,46 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain -import cats.effect.ConcurrentEffect -import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps +import cats.effect.Sync import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI +import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ FairySpawnRequestResult, FairyUsingState } -class FairySpawnRequest[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F], Player] { +class FairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player] { import cats.implicits._ def spawnRequest(player: Player)( implicit breakCountAPI: BreakCountAPI[F, G, Player], fairyAPI: FairyAPI[F, G, Player], - voteAPI: VoteAPI[F, Player] - ): F[FairySpawnRequestResult] = { - val seichiAmountRepository = ContextCoercion( - breakCountAPI.seichiAmountDataRepository(player).read - ).toIO.unsafeRunSync().levelCorrespondingToExp.level - + voteAPI: VoteAPI[F, Player], + manaApi: ManaApi[F, G, Player], + summonFairy: SummonFairy[F, G, Player] + ): F[Either[F[FairySpawnRequestResult], F[Unit]]] = { for { usingState <- fairyAPI.fairyUsingState(player) effectPoints <- voteAPI.effectPoints(player) fairySummonCost <- fairyAPI.fairySummonCost(player) + seichiAmountRepository <- ContextCoercion( + breakCountAPI.seichiAmountDataRepository(player).read + ) + seichiLevel = seichiAmountRepository.levelCorrespondingToExp.level } yield { - if (seichiAmountRepository < 10) - FairySpawnRequestResult.NotEnoughSeichiLevel - else if (usingState == FairyUsingState.Using) FairySpawnRequestResult.AlreadyFairySpawned + if (seichiLevel < 10) + Left(FairySpawnRequestResult.NotEnoughSeichiLevel) + else if (usingState == FairyUsingState.Using) + Left(FairySpawnRequestResult.AlreadyFairySpawned) else if (effectPoints.value < fairySummonCost.value * 2) - FairySpawnRequestResult.NotEnoughEffectPoint - else FairySpawnRequestResult.Success + Left(FairySpawnRequestResult.NotEnoughEffectPoint) + else { + Right(summonFairy.summon(player)) + } } } From f768647905926a0d626c6f53ed57355c0d5a2ea4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 15:09:02 +0900 Subject: [PATCH 135/482] fix: compile error --- .../unchama/seichiassist/menus/VoteMenu.scala | 8 +++++--- .../bukkit/actions/BukkitRecoveryMana.scala | 2 +- .../fairy/domain/FairySpawnRequest.scala | 19 +++++++++---------- .../property/FairySpawnRequestResult.scala | 2 -- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 61e60d9055..4a3efde393 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -278,7 +278,7 @@ object VoteMenu extends Menu { val fairySummonState = fairyAPI.fairySummonCost(player).unsafeRunSync() implicit val summonFairy: SummonFairy[IO, SyncIO, Player] = - new BukkitSummonFairy[IO, SyncIO]() + new BukkitSummonFairy[IO, SyncIO] Button( new IconItemStackBuilder(Material.GHAST_TEAR) .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}マナ妖精 召喚") @@ -294,9 +294,11 @@ object VoteMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - new FairySpawnRequest().spawnRequest(player).unsafeRunSync() match { + new FairySpawnRequest[IO, SyncIO, Player] + .spawnRequest(player) + .unsafeRunSync() match { case Left(errorResult) => - errorResult.unsafeRunSync() match { + errorResult match { case NotEnoughSeichiLevel => spawnFailedEffect(s"${GOLD}プレイヤーレベルが足りません") case AlreadyFairySpawned => diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 77551f11ad..7621c72309 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -168,7 +168,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] 0 else if (mineStackedGachaRingoAmount > appleConsumptionAmount) appleConsumptionAmount - else mineStackedGachaRingoAmount + else mineStackedGachaRingoAmount.toInt } /** diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala index 85486f6130..fbabe009f2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala @@ -12,17 +12,17 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p FairyUsingState } -class FairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player] { +class FairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player]( + implicit breakCountAPI: BreakCountAPI[F, G, Player], + fairyAPI: FairyAPI[F, G, Player], + voteAPI: VoteAPI[F, Player], + manaApi: ManaApi[F, G, Player], + summonFairy: SummonFairy[F, G, Player] +) { import cats.implicits._ - def spawnRequest(player: Player)( - implicit breakCountAPI: BreakCountAPI[F, G, Player], - fairyAPI: FairyAPI[F, G, Player], - voteAPI: VoteAPI[F, Player], - manaApi: ManaApi[F, G, Player], - summonFairy: SummonFairy[F, G, Player] - ): F[Either[F[FairySpawnRequestResult], F[Unit]]] = { + def spawnRequest(player: Player): F[Either[FairySpawnRequestResult, F[Unit]]] = { for { usingState <- fairyAPI.fairyUsingState(player) effectPoints <- voteAPI.effectPoints(player) @@ -38,9 +38,8 @@ class FairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player] { Left(FairySpawnRequestResult.AlreadyFairySpawned) else if (effectPoints.value < fairySummonCost.value * 2) Left(FairySpawnRequestResult.NotEnoughEffectPoint) - else { + else Right(summonFairy.summon(player)) - } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestResult.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestResult.scala index 1660fe7395..1c2336ab2b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestResult.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestResult.scala @@ -4,8 +4,6 @@ sealed trait FairySpawnRequestResult object FairySpawnRequestResult { - case object Success extends FairySpawnRequestResult - case object NotEnoughSeichiLevel extends FairySpawnRequestResult case object AlreadyFairySpawned extends FairySpawnRequestResult From 298b39553c7e9b9667362fd4055cef2608a09ddc Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 15:25:54 +0900 Subject: [PATCH 136/482] =?UTF-8?q?fix:=20fairyOpenState=E5=91=A8=E3=82=8A?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 10 +++------ .../vote/subsystems/fairy/System.scala | 2 +- .../domain/property/AppleOpenState.scala | 7 +++++- .../property/AppleOpenStateDependency.scala | 10 +++++++++ .../resources/bukkit/FairyLoreTable.scala | 22 +++++++++++++------ .../infrastructure/JdbcFairyPersistence.scala | 6 ++--- 6 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 4a3efde393..13c1cebab4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -28,7 +28,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p NotEnoughSeichiLevel } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - AppleOpenState, + AppleOpenStateDependency, FairyPlaySound, FairySummonCost, FairyUsingState @@ -227,12 +227,8 @@ object VoteMenu extends Menu { fairyAPI .updateAppleOpenState( uuid, - AppleOpenState - .values - .find( - _.amount == fairyAPI.appleOpenState(uuid).unsafeRunSync().amount % 4 + 1 - ) - .get + AppleOpenStateDependency + .dependency(fairyAPI.appleOpenState(uuid).unsafeRunSync()) ) .unsafeRunSync() }, diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 8b0dbb32ff..bd5b03809f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -72,7 +72,7 @@ object System { override def getFairyLore(uuid: UUID): IO[FairyLore] = for { state <- appleOpenState(uuid) - } yield FairyLoreTable.loreTable(state.amount - 1) + } yield FairyLoreTable.loreTable(state) override def updateFairySummonCost( uuid: UUID, diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala index 0725c0fdcd..fa1e8b365a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala @@ -2,7 +2,12 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain. import enumeratum._ -sealed class AppleOpenState(val amount: Int) extends EnumEntry +/** + * がちゃりんごの開放状況を管理するクラス + * @param serializedValue + * 開放状況を永続化する際に必要な番号 + */ +sealed class AppleOpenState(val serializedValue: Int) extends EnumEntry case object AppleOpenState extends Enum[AppleOpenState] { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala new file mode 100644 index 0000000000..aa2de9b56f --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala @@ -0,0 +1,10 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property + +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.AppleOpenState._ + +object AppleOpenStateDependency { + + val dependency: Map[AppleOpenState, AppleOpenState] = + Map(OpenAnyway -> Open, Open -> OpenALittle, OpenALittle -> NotOpen, NotOpen -> OpenAnyway) + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala index 06fc550a83..a05801e7c8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala @@ -1,21 +1,29 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit import cats.data.NonEmptyList -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyLore +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.AppleOpenState.{ + NotOpen, + Open, + OpenALittle, + OpenAnyway +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + AppleOpenState, + FairyLore +} import org.bukkit.ChatColor._ object FairyLoreTable { - val loreTable: List[FairyLore] = List( - property.FairyLore( + val loreTable: Map[AppleOpenState, FairyLore] = Map( + OpenAnyway -> FairyLore( NonEmptyList.of( s"$RED$UNDERLINE${BOLD}ガンガンたべるぞ", s"$RESET${GRAY}とにかく妖精さんにりんごを開放します。", s"$RESET${GRAY}めっちゃ喜ばれます。" ) ), - property.FairyLore( + Open -> FairyLore( NonEmptyList.of( s"$YELLOW$UNDERLINE${BOLD}バッチリたべよう", s"$RESET${GRAY}食べ過ぎないように注意しつつ", @@ -23,14 +31,14 @@ object FairyLoreTable { s"$RESET${GRAY}喜ばれます。" ) ), - property.FairyLore( + OpenALittle -> FairyLore( NonEmptyList.of( s"$GREEN$UNDERLINE${BOLD}リンゴだいじに", s"$RESET${GRAY}少しだけ妖精さんにりんごを開放します。", s"$RESET${GRAY}伝えると大抵落ち込みます。" ) ), - property.FairyLore( + NotOpen -> FairyLore( NonEmptyList.of(s"$BLUE$UNDERLINE${BOLD}リンゴつかうな", s"$RESET${GRAY}絶対にりんごを開放しません。", "") ) ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index be0129e956..094d18fbd5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -15,7 +15,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def changeAppleOpenState(uuid: UUID, openState: AppleOpenState): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET toggleGiveApple = ${openState.amount} WHERE uuid = ${uuid.toString}" + sql"UPDATE playerdata SET toggleGiveApple = ${openState.serializedValue} WHERE uuid = ${uuid.toString}" .execute() .apply() } @@ -26,14 +26,14 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { */ override def appleOpenState(uuid: UUID): F[AppleOpenState] = Sync[F].delay { - val appleAmount = DB.readOnly { implicit session => + val serializedValue = DB.readOnly { implicit session => sql"SELECT toggleGiveApple FROM playerdata WHERE uuid = ${uuid.toString}" .map(_.int("toggleGiveApple")) .single() .apply() .get } - AppleOpenState.values.find(_.amount == appleAmount).get + AppleOpenState.values.find(_.serializedValue == serializedValue).get } /** From ca5cf7c163ef5fda9887c39aac6ecec858395e7a Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 15:28:12 +0900 Subject: [PATCH 137/482] =?UTF-8?q?fix:=20fairymessagetable=E3=81=AE?= =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92=E3=83=89=E3=82=AD?= =?UTF-8?q?=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/resources/FairyMessageTable.scala | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala index 21f95c1924..cc81000dfa 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala @@ -8,7 +8,9 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p object FairyMessageTable { - // 朝に妖精を召喚したときに表示されるメッセージ + /** + * 朝に妖精を召喚したときに表示されるメッセージ + */ val morningMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( FairyMessage(s"おはよ!${name.value}"), @@ -18,7 +20,9 @@ object FairyMessageTable { FairyMessage(s"今日は整地日和だね!${name.value}") ) - // 昼に妖精を召喚したときに表示されるメッセージ + /** + * 昼に妖精を召喚したときに表示されるメッセージ + */ val dayMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( FairyMessage(s"やあ!${name.value}"), @@ -38,7 +42,9 @@ object FairyMessageTable { FairyMessage("こんな時間に呼ぶなんて…りんごははずんでもらうよ?") ) - // マナが満タンだったときに表示されるメッセージ + /** + * マナが満タンだったときに表示されるメッセージ + */ val manaFullMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( FairyMessage("整地しないのー?"), @@ -49,7 +55,9 @@ object FairyMessageTable { FairyMessage("動いてお腹を空かしていっぱい食べるぞー!") ) - // 妖精にりんごが消費されたときに表示されるメッセージ + /** + * 妖精にりんごが消費されたときに表示されるメッセージ + */ val consumed: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( FairyMessage("(´~`)モグモグ…"), @@ -59,7 +67,9 @@ object FairyMessageTable { FairyMessage("いつもりんごをありがとう!") ) - // 妖精がりんごを消費しなかったときに表示されるメッセージ + /** + * 妖精がりんごを消費しなかったときに表示されるメッセージ + */ val notConsumed: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( FairyMessage("お腹空いたなぁー。"), From 7cc195f235d2c25ad0617708ae0f5dfa69a7c79f Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 15:31:42 +0900 Subject: [PATCH 138/482] =?UTF-8?q?rename:=20appleOpenState=E3=81=AEenum?= =?UTF-8?q?=E3=82=92=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/actions/BukkitRecoveryMana.scala | 12 ++++----- .../domain/property/AppleOpenState.scala | 26 ++++++++++++++----- .../property/AppleOpenStateDependency.scala | 7 ++++- .../resources/bukkit/FairyLoreTable.scala | 16 ++++++------ 4 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 7621c72309..1a2ff13a30 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -114,7 +114,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] val playerLevel = seichiAmountData.levelCorrespondingToExp val isAppleOpenStateIsOpenOrOpenALittle = - appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open + appleOpenState == AppleOpenState.LessConsume || appleOpenState == AppleOpenState.Consume val isEnoughMana = oldManaAmount.ratioToCap.exists(_ >= 0.75) val defaultAmount = Math.pow(playerLevel.level / 10, 2) @@ -164,7 +164,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] playerdata.minestack.getStackedAmountOf(gachaRingoObject.get) // りんごの消費量 - if (appleOpenState == AppleOpenState.NotOpen) + if (appleOpenState == AppleOpenState.NoConsume) 0 else if (mineStackedGachaRingoAmount > appleConsumptionAmount) appleConsumptionAmount @@ -185,7 +185,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] } } yield { val isAppleOpenStateIsOpenOrOpenALittle = - appleOpenState == AppleOpenState.OpenALittle || appleOpenState == AppleOpenState.Open + appleOpenState == AppleOpenState.LessConsume || appleOpenState == AppleOpenState.Consume val isEnoughMana = oldManaAmount.ratioToCap.exists(_ >= 0.75) val mineStackedGachaRingoAmount = @@ -195,7 +195,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] val appleOpenStateDivision = if (isAppleOpenStateIsOpenOrOpenALittle && isEnoughMana) 2 - else if (appleOpenState == AppleOpenState.NotOpen) 4 + else if (appleOpenState == AppleOpenState.NoConsume) 4 else 1 val reflectedAppleOpenStateAmount = @@ -206,8 +206,8 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] if (appleConsumptionAmount > mineStackedGachaRingoAmount) { if (mineStackedGachaRingoAmount == 0) { reflectedAppleOpenStateAmount / ( - if (appleOpenState == AppleOpenState.Open) 4 - else if (appleOpenState == AppleOpenState.OpenALittle) 4 + if (appleOpenState == AppleOpenState.Consume) 4 + else if (appleOpenState == AppleOpenState.LessConsume) 4 else 2 ) } else if ((mineStackedGachaRingoAmount / appleConsumptionAmount) <= 0.5) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala index fa1e8b365a..995b27e45b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala @@ -13,12 +13,24 @@ case object AppleOpenState extends Enum[AppleOpenState] { override val values: IndexedSeq[AppleOpenState] = findValues - case object OpenAnyway extends AppleOpenState(1) - - case object Open extends AppleOpenState(2) - - case object OpenALittle extends AppleOpenState(3) - - case object NotOpen extends AppleOpenState(4) + /** + * ガンガン食べるぞ + */ + case object Permissible extends AppleOpenState(1) + + /** + * バッチリたべよう + */ + case object Consume extends AppleOpenState(2) + + /** + * リンゴだいじに + */ + case object LessConsume extends AppleOpenState(3) + + /** + * リンゴつかうな + */ + case object NoConsume extends AppleOpenState(4) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala index aa2de9b56f..379a786545 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala @@ -5,6 +5,11 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p object AppleOpenStateDependency { val dependency: Map[AppleOpenState, AppleOpenState] = - Map(OpenAnyway -> Open, Open -> OpenALittle, OpenALittle -> NotOpen, NotOpen -> OpenAnyway) + Map( + Permissible -> Consume, + Consume -> LessConsume, + LessConsume -> NoConsume, + NoConsume -> Permissible + ) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala index a05801e7c8..6a2bc408f6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala @@ -2,10 +2,10 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain. import cats.data.NonEmptyList import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.AppleOpenState.{ - NotOpen, - Open, - OpenALittle, - OpenAnyway + NoConsume, + Consume, + LessConsume, + Permissible } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleOpenState, @@ -16,14 +16,14 @@ import org.bukkit.ChatColor._ object FairyLoreTable { val loreTable: Map[AppleOpenState, FairyLore] = Map( - OpenAnyway -> FairyLore( + Permissible -> FairyLore( NonEmptyList.of( s"$RED$UNDERLINE${BOLD}ガンガンたべるぞ", s"$RESET${GRAY}とにかく妖精さんにりんごを開放します。", s"$RESET${GRAY}めっちゃ喜ばれます。" ) ), - Open -> FairyLore( + Consume -> FairyLore( NonEmptyList.of( s"$YELLOW$UNDERLINE${BOLD}バッチリたべよう", s"$RESET${GRAY}食べ過ぎないように注意しつつ", @@ -31,14 +31,14 @@ object FairyLoreTable { s"$RESET${GRAY}喜ばれます。" ) ), - OpenALittle -> FairyLore( + LessConsume -> FairyLore( NonEmptyList.of( s"$GREEN$UNDERLINE${BOLD}リンゴだいじに", s"$RESET${GRAY}少しだけ妖精さんにりんごを開放します。", s"$RESET${GRAY}伝えると大抵落ち込みます。" ) ), - NotOpen -> FairyLore( + NoConsume -> FairyLore( NonEmptyList.of(s"$BLUE$UNDERLINE${BOLD}リンゴつかうな", s"$RESET${GRAY}絶対にりんごを開放しません。", "") ) ) From 265d2348af4452bd26fd2963fdec91a559bc54f8 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 15:33:48 +0900 Subject: [PATCH 139/482] rename: appleOpenState -> FairyAppleConsumeStrategy --- .../vote/subsystems/fairy/FairyAPI.scala | 4 +-- .../vote/subsystems/fairy/System.scala | 4 +-- .../bukkit/actions/BukkitRecoveryMana.scala | 14 ++++---- .../fairy/domain/FairyPersistence.scala | 6 ++-- .../domain/property/AppleOpenState.scala | 36 ------------------- .../property/AppleOpenStateDependency.scala | 4 +-- .../property/FairyAppleConsumeStrategy.scala | 36 +++++++++++++++++++ .../resources/bukkit/FairyLoreTable.scala | 6 ++-- .../infrastructure/JdbcFairyPersistence.scala | 6 ++-- 9 files changed, 58 insertions(+), 58 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyAppleConsumeStrategy.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 39888b42ba..8ff39115be 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -11,7 +11,7 @@ trait FairyWriteAPI[F[_], G[_], Player] { /** * 妖精にあげるりんごの開放状態を変更する */ - def updateAppleOpenState(uuid: UUID, appleOpenState: AppleOpenState): F[Unit] + def updateAppleOpenState(uuid: UUID, appleOpenState: FairyAppleConsumeStrategy): F[Unit] /** * 妖精を召喚するためのコストを変更します。 @@ -58,7 +58,7 @@ trait FairyReadAPI[F[_], G[_], Player] { /** * 妖精にあげるりんごの開放状態を取得する */ - def appleOpenState(uuid: UUID): F[AppleOpenState] + def appleOpenState(uuid: UUID): F[FairyAppleConsumeStrategy] /** * 妖精を召喚するためのコストを取得する diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index bd5b03809f..0ddecd6833 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -61,12 +61,12 @@ object System { new System[IO, SyncIO, Player] { override implicit val api: FairyAPI[IO, SyncIO, Player] = new FairyAPI[IO, SyncIO, Player] { - override def appleOpenState(uuid: UUID): IO[AppleOpenState] = + override def appleOpenState(uuid: UUID): IO[FairyAppleConsumeStrategy] = persistence.appleOpenState(uuid) override def updateAppleOpenState( uuid: UUID, - appleOpenState: AppleOpenState + appleOpenState: FairyAppleConsumeStrategy ): IO[Unit] = persistence.changeAppleOpenState(uuid, appleOpenState) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 1a2ff13a30..bb0ef043ba 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -11,7 +11,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applicat import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleAmount, - AppleOpenState, + FairyAppleConsumeStrategy, FairyManaRecoveryState, FairyUsingState } @@ -114,7 +114,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] val playerLevel = seichiAmountData.levelCorrespondingToExp val isAppleOpenStateIsOpenOrOpenALittle = - appleOpenState == AppleOpenState.LessConsume || appleOpenState == AppleOpenState.Consume + appleOpenState == FairyAppleConsumeStrategy.LessConsume || appleOpenState == FairyAppleConsumeStrategy.Consume val isEnoughMana = oldManaAmount.ratioToCap.exists(_ >= 0.75) val defaultAmount = Math.pow(playerLevel.level / 10, 2) @@ -164,7 +164,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] playerdata.minestack.getStackedAmountOf(gachaRingoObject.get) // りんごの消費量 - if (appleOpenState == AppleOpenState.NoConsume) + if (appleOpenState == FairyAppleConsumeStrategy.NoConsume) 0 else if (mineStackedGachaRingoAmount > appleConsumptionAmount) appleConsumptionAmount @@ -185,7 +185,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] } } yield { val isAppleOpenStateIsOpenOrOpenALittle = - appleOpenState == AppleOpenState.LessConsume || appleOpenState == AppleOpenState.Consume + appleOpenState == FairyAppleConsumeStrategy.LessConsume || appleOpenState == FairyAppleConsumeStrategy.Consume val isEnoughMana = oldManaAmount.ratioToCap.exists(_ >= 0.75) val mineStackedGachaRingoAmount = @@ -195,7 +195,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] val appleOpenStateDivision = if (isAppleOpenStateIsOpenOrOpenALittle && isEnoughMana) 2 - else if (appleOpenState == AppleOpenState.NoConsume) 4 + else if (appleOpenState == FairyAppleConsumeStrategy.NoConsume) 4 else 1 val reflectedAppleOpenStateAmount = @@ -206,8 +206,8 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] if (appleConsumptionAmount > mineStackedGachaRingoAmount) { if (mineStackedGachaRingoAmount == 0) { reflectedAppleOpenStateAmount / ( - if (appleOpenState == AppleOpenState.Consume) 4 - else if (appleOpenState == AppleOpenState.LessConsume) 4 + if (appleOpenState == FairyAppleConsumeStrategy.Consume) 4 + else if (appleOpenState == FairyAppleConsumeStrategy.LessConsume) 4 else 2 ) } else if ((mineStackedGachaRingoAmount / appleConsumptionAmount) <= 0.5) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index d279cbf90b..ac6827976e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -3,7 +3,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleAmount, AppleAteByFairyRank, - AppleOpenState, + FairyAppleConsumeStrategy, FairyEndTime, FairyPlaySound, FairyRecoveryMana, @@ -18,12 +18,12 @@ trait FairyPersistence[F[_]] { /** * 妖精に開放するりんごの状態を変更する */ - def changeAppleOpenState(uuid: UUID, openState: AppleOpenState): F[Unit] + def changeAppleOpenState(uuid: UUID, openState: FairyAppleConsumeStrategy): F[Unit] /** * 妖精に開放するりんごの状態を取得する */ - def appleOpenState(uuid: UUID): F[AppleOpenState] + def appleOpenState(uuid: UUID): F[FairyAppleConsumeStrategy] /** * 妖精が召喚するためのコストを変更する diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala deleted file mode 100644 index 995b27e45b..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenState.scala +++ /dev/null @@ -1,36 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property - -import enumeratum._ - -/** - * がちゃりんごの開放状況を管理するクラス - * @param serializedValue - * 開放状況を永続化する際に必要な番号 - */ -sealed class AppleOpenState(val serializedValue: Int) extends EnumEntry - -case object AppleOpenState extends Enum[AppleOpenState] { - - override val values: IndexedSeq[AppleOpenState] = findValues - - /** - * ガンガン食べるぞ - */ - case object Permissible extends AppleOpenState(1) - - /** - * バッチリたべよう - */ - case object Consume extends AppleOpenState(2) - - /** - * リンゴだいじに - */ - case object LessConsume extends AppleOpenState(3) - - /** - * リンゴつかうな - */ - case object NoConsume extends AppleOpenState(4) - -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala index 379a786545..e34d8353db 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala @@ -1,10 +1,10 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.AppleOpenState._ +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyAppleConsumeStrategy._ object AppleOpenStateDependency { - val dependency: Map[AppleOpenState, AppleOpenState] = + val dependency: Map[FairyAppleConsumeStrategy, FairyAppleConsumeStrategy] = Map( Permissible -> Consume, Consume -> LessConsume, diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyAppleConsumeStrategy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyAppleConsumeStrategy.scala new file mode 100644 index 0000000000..4b4408f58b --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyAppleConsumeStrategy.scala @@ -0,0 +1,36 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property + +import enumeratum._ + +/** + * がちゃりんごの消費戦略を管理するクラス + * @param serializedValue + * 消費戦略を永続化する際に必要な番号 + */ +sealed class FairyAppleConsumeStrategy(val serializedValue: Int) extends EnumEntry + +case object FairyAppleConsumeStrategy extends Enum[FairyAppleConsumeStrategy] { + + override val values: IndexedSeq[FairyAppleConsumeStrategy] = findValues + + /** + * ガンガン食べるぞ + */ + case object Permissible extends FairyAppleConsumeStrategy(1) + + /** + * バッチリたべよう + */ + case object Consume extends FairyAppleConsumeStrategy(2) + + /** + * リンゴだいじに + */ + case object LessConsume extends FairyAppleConsumeStrategy(3) + + /** + * リンゴつかうな + */ + case object NoConsume extends FairyAppleConsumeStrategy(4) + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala index 6a2bc408f6..93a680a63a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala @@ -1,21 +1,21 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit import cats.data.NonEmptyList -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.AppleOpenState.{ +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyAppleConsumeStrategy.{ NoConsume, Consume, LessConsume, Permissible } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - AppleOpenState, + FairyAppleConsumeStrategy, FairyLore } import org.bukkit.ChatColor._ object FairyLoreTable { - val loreTable: Map[AppleOpenState, FairyLore] = Map( + val loreTable: Map[FairyAppleConsumeStrategy, FairyLore] = Map( Permissible -> FairyLore( NonEmptyList.of( s"$RED$UNDERLINE${BOLD}ガンガンたべるぞ", diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 094d18fbd5..bc6c9ecf2f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -12,7 +12,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { /** * 妖精に開放するりんごの状態を変更する */ - override def changeAppleOpenState(uuid: UUID, openState: AppleOpenState): F[Unit] = + override def changeAppleOpenState(uuid: UUID, openState: FairyAppleConsumeStrategy): F[Unit] = Sync[F].delay { DB.localTx { implicit session => sql"UPDATE playerdata SET toggleGiveApple = ${openState.serializedValue} WHERE uuid = ${uuid.toString}" @@ -24,7 +24,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { /** * 妖精に開放するりんごの状態を取得する */ - override def appleOpenState(uuid: UUID): F[AppleOpenState] = + override def appleOpenState(uuid: UUID): F[FairyAppleConsumeStrategy] = Sync[F].delay { val serializedValue = DB.readOnly { implicit session => sql"SELECT toggleGiveApple FROM playerdata WHERE uuid = ${uuid.toString}" @@ -33,7 +33,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { .apply() .get } - AppleOpenState.values.find(_.serializedValue == serializedValue).get + FairyAppleConsumeStrategy.values.find(_.serializedValue == serializedValue).get } /** From 63f886d60e7a28b9ab31bdcf96ba65db38f18f38 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 15:36:47 +0900 Subject: [PATCH 140/482] =?UTF-8?q?rename:=20fairyManaRecoveryState?= =?UTF-8?q?=E3=81=AE=E6=9C=80=E5=88=9D=E3=82=92=E5=A4=A7=E6=96=87=E5=AD=97?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/bukkit/FairySpeech.scala | 6 +++--- .../fairy/bukkit/actions/BukkitRecoveryMana.scala | 6 +++--- .../fairy/domain/property/FairyManaRecoveryState.scala | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index 6cb47ad590..cb12886938 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -44,11 +44,11 @@ class FairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( ): F[Unit] = { val nameCalledByFairy = NameCalledByFairy(player.getName) val messages = fairyManaRecoveryState match { - case FairyManaRecoveryState.full => + case FairyManaRecoveryState.Full => FairyMessageTable.manaFullMessages - case FairyManaRecoveryState.consumptionApple => + case FairyManaRecoveryState.ConsumptionApple => FairyMessageTable.consumed - case FairyManaRecoveryState.notConsumptionApple => + case FairyManaRecoveryState.NotConsumptionApple => FairyMessageTable.notConsumed } for { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index bb0ef043ba..e5cbe58cc1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -56,7 +56,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] manaApi.readManaAmount(player) } _ <- { - new FairySpeech[F, G].speechRandomly(player, FairyManaRecoveryState.full) + new FairySpeech[F, G].speechRandomly(player, FairyManaRecoveryState.Full) }.whenA(isUsing && oldManaAmount.isFull) appleConsumptionAmount <- computeAppleConsumptionAmount @@ -85,8 +85,8 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] new FairySpeech[F, G].speechRandomly( player, if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) - FairyManaRecoveryState.notConsumptionApple - else FairyManaRecoveryState.consumptionApple + FairyManaRecoveryState.NotConsumptionApple + else FairyManaRecoveryState.ConsumptionApple ) >> SequentialEffect( MessageEffectF(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyManaRecoveryState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyManaRecoveryState.scala index 0185ab2401..96d25ebae0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyManaRecoveryState.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyManaRecoveryState.scala @@ -4,10 +4,10 @@ sealed trait FairyManaRecoveryState object FairyManaRecoveryState { - case object full extends FairyManaRecoveryState + case object Full extends FairyManaRecoveryState - case object notConsumptionApple extends FairyManaRecoveryState + case object NotConsumptionApple extends FairyManaRecoveryState - case object consumptionApple extends FairyManaRecoveryState + case object ConsumptionApple extends FairyManaRecoveryState } From 11eaa34ecdf494d8782bfc6009dc5fd09f19cc83 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 15:37:47 +0900 Subject: [PATCH 141/482] =?UTF-8?q?rename:=20fairyPlaySound=E3=81=AE?= =?UTF-8?q?=E6=9C=80=E5=88=9D=E3=82=92=E5=A4=A7=E6=96=87=E5=AD=97=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/seichiassist/menus/VoteMenu.scala | 2 +- .../subsystems/vote/subsystems/fairy/System.scala | 6 +++--- .../vote/subsystems/fairy/bukkit/FairySpeech.scala | 2 +- .../subsystems/fairy/domain/property/FairyPlaySound.scala | 4 ++-- .../fairy/infrastructure/JdbcFairyPersistence.scala | 4 ++-- .../vote/subsystems/fairy/service/FairySpeechService.scala | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 13c1cebab4..82a7a37139 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -252,7 +252,7 @@ object VoteMenu extends Menu { if ( fairyAPI .fairySpeechSound(player.getUniqueId) - .unsafeRunSync() == FairyPlaySound.on + .unsafeRunSync() == FairyPlaySound.On ) playSoundOnLore else playSoundOffLore diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 0ddecd6833..5b78b43458 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -140,9 +140,9 @@ object System { override def toggleFairySpeechSound(uuid: UUID): IO[Unit] = persistence.toggleFairySpeechSound( uuid, - if (fairySpeechSound(uuid).unsafeRunSync() == FairyPlaySound.on) - FairyPlaySound.off - else FairyPlaySound.on + if (fairySpeechSound(uuid).unsafeRunSync() == FairyPlaySound.On) + FairyPlaySound.Off + else FairyPlaySound.On ) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index cb12886938..5114cd398b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -89,7 +89,7 @@ class FairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) repository = fairyAPI.fairySpeechServiceRepository(player) _ <- ContextCoercion { - repository.makeSpeech(FairyMessage(s"あっ、もうこんな時間だ!"), FairyPlaySound.off) + repository.makeSpeech(FairyMessage(s"あっ、もうこんな時間だ!"), FairyPlaySound.Off) } >> ContextCoercion { repository.makeSpeech(FairyMessage(s"じゃーねー!${player.getName}"), playSound) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyPlaySound.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyPlaySound.scala index 5373efa25f..6eb9125a18 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyPlaySound.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyPlaySound.scala @@ -4,8 +4,8 @@ sealed trait FairyPlaySound object FairyPlaySound { - case object on extends FairyPlaySound + case object On extends FairyPlaySound - case object off extends FairyPlaySound + case object Off extends FairyPlaySound } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index bc6c9ecf2f..0d780a9996 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -227,7 +227,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def toggleFairySpeechSound(uuid: UUID, fairyPlaySound: FairyPlaySound): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET is_fairy_speech_play_sound = ${fairyPlaySound == FairyPlaySound.on} WHERE uuid = ${uuid.toString}" + sql"UPDATE playerdata SET is_fairy_speech_play_sound = ${fairyPlaySound == FairyPlaySound.On} WHERE uuid = ${uuid.toString}" .execute() .apply() } @@ -245,7 +245,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { .single() .apply() .get - if (isPlaySound) FairyPlaySound.on else FairyPlaySound.off + if (isPlaySound) FairyPlaySound.On else FairyPlaySound.Off } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala index b4e4a87ca3..ec6cf56636 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala @@ -11,7 +11,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p class FairySpeechService[F[_]: Sync](gateway: FairySpeechGateway[F]) { def makeSpeech(fairyMessage: FairyMessage, fairyPlaySound: FairyPlaySound): F[Unit] = { - if (fairyPlaySound == FairyPlaySound.on) + if (fairyPlaySound == FairyPlaySound.On) gateway.sendMessage(fairyMessage) >> gateway.playSpeechSound else gateway.sendMessage(fairyMessage) From 86a04ab959b5938b28bbbf67fe1e5e748823c93f Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 15:44:41 +0900 Subject: [PATCH 142/482] rename: FairySpawnRequestResult -> FairySpawnRequestError --- .../unchama/seichiassist/menus/VoteMenu.scala | 2 +- .../subsystems/fairy/domain/FairySpawnRequest.scala | 10 +++++----- .../domain/property/FairySpawnRequestError.scala | 13 +++++++++++++ .../domain/property/FairySpawnRequestResult.scala | 13 ------------- 4 files changed, 19 insertions(+), 19 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestError.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestResult.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 82a7a37139..dc8b4bcb28 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -22,7 +22,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applicat import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequest -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestResult.{ +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{ AlreadyFairySpawned, NotEnoughEffectPoint, NotEnoughSeichiLevel diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala index fbabe009f2..8bcd29a636 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala @@ -8,7 +8,7 @@ import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - FairySpawnRequestResult, + FairySpawnRequestError, FairyUsingState } @@ -22,7 +22,7 @@ class FairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player]( import cats.implicits._ - def spawnRequest(player: Player): F[Either[FairySpawnRequestResult, F[Unit]]] = { + def spawnRequest(player: Player): F[Either[FairySpawnRequestError, F[Unit]]] = { for { usingState <- fairyAPI.fairyUsingState(player) effectPoints <- voteAPI.effectPoints(player) @@ -33,11 +33,11 @@ class FairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player]( seichiLevel = seichiAmountRepository.levelCorrespondingToExp.level } yield { if (seichiLevel < 10) - Left(FairySpawnRequestResult.NotEnoughSeichiLevel) + Left(FairySpawnRequestError.NotEnoughSeichiLevel) else if (usingState == FairyUsingState.Using) - Left(FairySpawnRequestResult.AlreadyFairySpawned) + Left(FairySpawnRequestError.AlreadyFairySpawned) else if (effectPoints.value < fairySummonCost.value * 2) - Left(FairySpawnRequestResult.NotEnoughEffectPoint) + Left(FairySpawnRequestError.NotEnoughEffectPoint) else Right(summonFairy.summon(player)) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestError.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestError.scala new file mode 100644 index 0000000000..b8a03ee27a --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestError.scala @@ -0,0 +1,13 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property + +sealed trait FairySpawnRequestError + +object FairySpawnRequestError { + + case object NotEnoughSeichiLevel extends FairySpawnRequestError + + case object AlreadyFairySpawned extends FairySpawnRequestError + + case object NotEnoughEffectPoint extends FairySpawnRequestError + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestResult.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestResult.scala deleted file mode 100644 index 1c2336ab2b..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestResult.scala +++ /dev/null @@ -1,13 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property - -sealed trait FairySpawnRequestResult - -object FairySpawnRequestResult { - - case object NotEnoughSeichiLevel extends FairySpawnRequestResult - - case object AlreadyFairySpawned extends FairySpawnRequestResult - - case object NotEnoughEffectPoint extends FairySpawnRequestResult - -} From 8d30b88d2df0a773f6edb9d9139b515191dee21f Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 15:57:19 +0900 Subject: [PATCH 143/482] =?UTF-8?q?refactor:=20makeSpeech=E3=81=AE?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/service/FairySpeechService.scala | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala index ec6cf56636..d6834c040b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala @@ -11,10 +11,9 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p class FairySpeechService[F[_]: Sync](gateway: FairySpeechGateway[F]) { def makeSpeech(fairyMessage: FairyMessage, fairyPlaySound: FairyPlaySound): F[Unit] = { - if (fairyPlaySound == FairyPlaySound.On) - gateway.sendMessage(fairyMessage) >> gateway.playSpeechSound - else - gateway.sendMessage(fairyMessage) + gateway.sendMessage(fairyMessage) >> Sync[F].whenA(fairyPlaySound == FairyPlaySound.On)( + gateway.playSpeechSound + ) } } From b3d8c49d39f67bdaf10a3f718b2196de6d57ef94 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 16:02:01 +0900 Subject: [PATCH 144/482] =?UTF-8?q?fix:=20=E5=BF=85=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E5=9E=8B=E3=82=92Option=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/FairyAPI.scala | 4 +-- .../vote/subsystems/fairy/System.scala | 6 ++-- .../fairy/domain/FairyPersistence.scala | 4 +-- .../infrastructure/JdbcFairyPersistence.scala | 28 +++++++++++-------- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 8ff39115be..e58c33a22d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -83,7 +83,7 @@ trait FairyReadAPI[F[_], G[_], Player] { /** * 妖精が食べたりんごの量を取得する */ - def appleAteByFairy(uuid: UUID): F[AppleAmount] + def appleAteByFairy(uuid: UUID): F[Option[AppleAmount]] val fairySpeechServiceRepository: PlayerDataRepository[FairySpeechService[G]] @@ -95,7 +95,7 @@ trait FairyReadAPI[F[_], G[_], Player] { /** * 自分の妖精に食べさせたりんごの量の順位を返す */ - def appleAteByFairyMyRanking(player: Player): F[AppleAteByFairyRank] + def appleAteByFairyMyRanking(player: Player): F[Option[AppleAteByFairyRank]] /** * 妖精に食べさせたりんごの量の順位上`number`件を返す diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 5b78b43458..3243311899 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -119,10 +119,12 @@ object System { ): IO[Unit] = persistence.increaseAppleAteByFairy(uuid, appleAmount) - override def appleAteByFairy(uuid: UUID): IO[AppleAmount] = + override def appleAteByFairy(uuid: UUID): IO[Option[AppleAmount]] = persistence.appleAteByFairy(uuid) - override def appleAteByFairyMyRanking(player: Player): IO[AppleAteByFairyRank] = + override def appleAteByFairyMyRanking( + player: Player + ): IO[Option[AppleAteByFairyRank]] = persistence.appleAteByFairyMyRanking(player.getUniqueId) override def appleAteByFairyRanking( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index ac6827976e..dde4289ac4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -73,12 +73,12 @@ trait FairyPersistence[F[_]] { /** * 妖精が食べたりんごの量を取得する */ - def appleAteByFairy(uuid: UUID): F[AppleAmount] + def appleAteByFairy(uuid: UUID): F[Option[AppleAmount]] /** * 自分の妖精に食べさせたりんごの量の順位を返す */ - def appleAteByFairyMyRanking(uuid: UUID): F[AppleAteByFairyRank] + def appleAteByFairyMyRanking(uuid: UUID): F[Option[AppleAteByFairyRank]] /** * 妖精に食べさせたりんごの量の順位上位`number`件を返す diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 0d780a9996..83e59436ae 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -160,30 +160,34 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { /** * 妖精が食べたりんごの量を取得する */ - override def appleAteByFairy(uuid: UUID): F[AppleAmount] = Sync[F].delay { + override def appleAteByFairy(uuid: UUID): F[Option[AppleAmount]] = Sync[F].delay { DB.readOnly { implicit session => val appleAmountOpt = sql"SELECT p_apple FROM playerdata WHERE uuid = ${uuid.toString}" .map(_.int("p_apple")) .single() .apply() - AppleAmount(appleAmountOpt.get) + appleAmountOpt.map(AppleAmount) } } /** * 自分の妖精に食べさせたりんごの量の順位を返す */ - override def appleAteByFairyMyRanking(uuid: UUID): F[AppleAteByFairyRank] = Sync[F].delay { - DB.readOnly { implicit session => - sql"SELECT name,p_apple,COUNT(*) AS rank FROM playerdata ORDER BY rank DESC;" - .map(rs => - AppleAteByFairyRank(rs.string("name"), rs.int("rank"), AppleAmount(rs.int("p_apple"))) - ) - .single() - .apply() - .get + override def appleAteByFairyMyRanking(uuid: UUID): F[Option[AppleAteByFairyRank]] = + Sync[F].delay { + DB.readOnly { implicit session => + sql"SELECT name,p_apple,COUNT(*) AS rank FROM playerdata ORDER BY rank DESC;" + .map(rs => + AppleAteByFairyRank( + rs.string("name"), + rs.int("rank"), + AppleAmount(rs.int("p_apple")) + ) + ) + .single() + .apply() + } } - } /** * 妖精に食べさせたりんごの量の順位上位`number`件を返す From 64f60ff4ff5ccc7875e52314abea2b7ca06eccf4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 16:03:42 +0900 Subject: [PATCH 145/482] fix: compile error --- .../scala/com/github/unchama/seichiassist/menus/VoteMenu.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index dc8b4bcb28..d1d13217a3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -364,7 +364,7 @@ object VoteMenu extends Menu { } else Nil } } ++ { - val myRank = fairyAPI.appleAteByFairyMyRanking(player).unsafeRunSync() + val myRank = fairyAPI.appleAteByFairyMyRanking(player).unsafeRunSync().get List( s"${AQUA}ぜーんぶで${fairyAPI.allEatenAppleAmount.unsafeRunSync().amount}個もらえた!", "", From 14622665b565864d6a0662f9e25d3699f9aac822 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 16:19:32 +0900 Subject: [PATCH 146/482] fix: to NonEmptyVector --- .../subsystems/fairy/bukkit/FairySpeech.scala | 2 +- .../fairy/domain/property/FairyMessages.scala | 6 +- .../domain/resources/FairyMessageTable.scala | 75 +++++++++++-------- 3 files changed, 48 insertions(+), 35 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index 5114cd398b..3f2b48fd91 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -96,7 +96,7 @@ class FairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( } yield () private def randomMessage(fairyMessages: FairyMessages): F[FairyMessage] = Sync[F].delay { - val messages = fairyMessages.messages + val messages = fairyMessages.messages.toVector messages(Random.nextInt(messages.size)) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyMessages.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyMessages.scala index aa58a9efa9..af84be0c26 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyMessages.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyMessages.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property -case class FairyMessages(messages: FairyMessage*) { - require(messages.nonEmpty) -} +import cats.data.NonEmptyVector + +case class FairyMessages(messages: NonEmptyVector[FairyMessage]) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala index cc81000dfa..733615e6b6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala @@ -1,5 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources +import cats.data.NonEmptyVector import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ FairyMessage, FairyMessages, @@ -13,11 +14,13 @@ object FairyMessageTable { */ val morningMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( - FairyMessage(s"おはよ!${name.value}"), - FairyMessage(s"ヤッホー${name.value}"), - FairyMessage(s"ふわぁ。。。${name.value}朝は早いね。"), - FairyMessage("うーん、今日も一日頑張ろ!"), - FairyMessage(s"今日は整地日和だね!${name.value}") + NonEmptyVector.of( + FairyMessage(s"おはよ!${name.value}"), + FairyMessage(s"ヤッホー${name.value}"), + FairyMessage(s"ふわぁ。。。${name.value}朝は早いね。"), + FairyMessage("うーん、今日も一日頑張ろ!"), + FairyMessage(s"今日は整地日和だね!${name.value}") + ) ) /** @@ -25,21 +28,25 @@ object FairyMessageTable { */ val dayMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( - FairyMessage(s"やあ!${name.value}"), - FairyMessage(s"ヤッホー${name.value}!"), - FairyMessage(s"あっ、${name.value}じゃん。丁度お腹空いてたんだ!"), - FairyMessage(s"この匂い…${name.value}ってがちゃりんごいっぱい持ってる…?"), - FairyMessage("今日のおやつはがちゃりんごいっぱいだ!") + NonEmptyVector.of( + FairyMessage(s"やあ!${name.value}"), + FairyMessage(s"ヤッホー${name.value}!"), + FairyMessage(s"あっ、${name.value}じゃん。丁度お腹空いてたんだ!"), + FairyMessage(s"この匂い…${name.value}ってがちゃりんごいっぱい持ってる…?"), + FairyMessage("今日のおやつはがちゃりんごいっぱいだ!") + ) ) // 夜に妖精を召喚したときに表示されるメッセージ val nightMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( - FairyMessage(s"やあ!${name.value}"), - FairyMessage(s"ヤッホー${name.value}!"), - FairyMessage(s"ふわぁ。。。${name.value}は夜も元気だね。"), - FairyMessage(s"もう寝ようと思ってたのにー。${name.value}はしょうがないなぁ"), - FairyMessage("こんな時間に呼ぶなんて…りんごははずんでもらうよ?") + NonEmptyVector.of( + FairyMessage(s"やあ!${name.value}"), + FairyMessage(s"ヤッホー${name.value}!"), + FairyMessage(s"ふわぁ。。。${name.value}は夜も元気だね。"), + FairyMessage(s"もう寝ようと思ってたのにー。${name.value}はしょうがないなぁ"), + FairyMessage("こんな時間に呼ぶなんて…りんごははずんでもらうよ?") + ) ) /** @@ -47,12 +54,14 @@ object FairyMessageTable { */ val manaFullMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( - FairyMessage("整地しないのー?"), - FairyMessage("たくさん働いて、たくさんりんごを食べようね!"), - FairyMessage("僕はいつか大きながちゃりんごを食べ尽して見せるっ!"), - FairyMessage("ちょっと食べ疲れちゃった"), - FairyMessage(s"${name.value}はどのりんごが好き?僕はがちゃりんご!"), - FairyMessage("動いてお腹を空かしていっぱい食べるぞー!") + NonEmptyVector.of( + FairyMessage("整地しないのー?"), + FairyMessage("たくさん働いて、たくさんりんごを食べようね!"), + FairyMessage("僕はいつか大きながちゃりんごを食べ尽して見せるっ!"), + FairyMessage("ちょっと食べ疲れちゃった"), + FairyMessage(s"${name.value}はどのりんごが好き?僕はがちゃりんご!"), + FairyMessage("動いてお腹を空かしていっぱい食べるぞー!") + ) ) /** @@ -60,11 +69,13 @@ object FairyMessageTable { */ val consumed: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( - FairyMessage("(´~`)モグモグ…"), - FairyMessage("がちゃりんごって美味しいよね!"), - FairyMessage("あぁ!幸せ!"), - FairyMessage(s"${name.value}のりんごはおいしいなぁ"), - FairyMessage("いつもりんごをありがとう!") + NonEmptyVector.of( + FairyMessage("(´~`)モグモグ…"), + FairyMessage("がちゃりんごって美味しいよね!"), + FairyMessage("あぁ!幸せ!"), + FairyMessage(s"${name.value}のりんごはおいしいなぁ"), + FairyMessage("いつもりんごをありがとう!") + ) ) /** @@ -72,11 +83,13 @@ object FairyMessageTable { */ val notConsumed: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => FairyMessages( - FairyMessage("お腹空いたなぁー。"), - FairyMessage("がちゃりんごがっ!食べたいっ!"), - FairyMessage("(´;ω;`)ウゥゥ ヒモジイ..."), - FairyMessage(s"@うんちゃま ${name.value}が意地悪するんだっ!"), - FairyMessage("うわーん!お腹空いたよー!") + NonEmptyVector.of( + FairyMessage("お腹空いたなぁー。"), + FairyMessage("がちゃりんごがっ!食べたいっ!"), + FairyMessage("(´;ω;`)ウゥゥ ヒモジイ..."), + FairyMessage(s"@うんちゃま ${name.value}が意地悪するんだっ!"), + FairyMessage("うわーん!お腹空いたよー!") + ) ) } From 18251e2225d687e217f533b4a90505f2b7926a27 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 17:13:17 +0900 Subject: [PATCH 147/482] =?UTF-8?q?replace:=20fairyPlaySound=E5=89=8A?= =?UTF-8?q?=E9=99=A4=E3=81=97Boolean=E3=81=AB=E7=BD=AE=E3=81=8D=E6=8F=9B?= =?UTF-8?q?=E3=81=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 11 ++--------- .../vote/subsystems/fairy/FairyAPI.scala | 2 +- .../vote/subsystems/fairy/System.scala | 9 ++------- .../subsystems/fairy/bukkit/FairySpeech.scala | 2 +- .../fairy/domain/FairyPersistence.scala | 5 ++--- .../fairy/domain/property/FairyPlaySound.scala | 11 ----------- .../infrastructure/JdbcFairyPersistence.scala | 18 ++++++++---------- .../fairy/service/FairySpeechService.scala | 11 +++-------- 8 files changed, 19 insertions(+), 50 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyPlaySound.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index d1d13217a3..2247920179 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -9,7 +9,6 @@ import com.github.unchama.menuinventory.slot.button.action.LeftClickButtonEffect import com.github.unchama.menuinventory.slot.button.{Button, RecomputedButton} import com.github.unchama.menuinventory.syntax.IntInventorySizeOps import com.github.unchama.menuinventory.{ChestSlotRef, Menu, MenuFrame, MenuSlotLayout} -import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMainThread import com.github.unchama.seichiassist.menus.stickmenu.FirstPage @@ -29,7 +28,6 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleOpenStateDependency, - FairyPlaySound, FairySummonCost, FairyUsingState } @@ -48,8 +46,7 @@ object VoteMenu extends Menu { val fairyAPI: FairyAPI[IO, SyncIO, Player], val breakCountAPI: BreakCountAPI[IO, SyncIO, Player], val manaApi: ManaApi[IO, SyncIO, Player], - val ioCanOpenFirstPage: IO CanOpen FirstPage.type, - onMainThread: OnMinecraftServerThread[IO] + val ioCanOpenFirstPage: IO CanOpen FirstPage.type ) /** @@ -249,11 +246,7 @@ object VoteMenu extends Menu { new IconItemStackBuilder(Material.JUKEBOX) .title(s"$GOLD$UNDERLINE${BOLD}マナ妖精の音トグル") .lore( - if ( - fairyAPI - .fairySpeechSound(player.getUniqueId) - .unsafeRunSync() == FairyPlaySound.On - ) + if (fairyAPI.fairySpeechSound(player.getUniqueId).unsafeRunSync()) playSoundOnLore else playSoundOffLore ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index e58c33a22d..cd43572736 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -113,7 +113,7 @@ trait FairyReadAPI[F[_], G[_], Player] { /** * 妖精が喋ったときに音を再生するか取得する */ - def fairySpeechSound(uuid: UUID): F[FairyPlaySound] + def fairySpeechSound(uuid: UUID): F[Boolean] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 3243311899..c828ce71a3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -136,16 +136,11 @@ object System { override def allEatenAppleAmount: IO[AppleAmount] = persistence.allEatenAppleAmount - override def fairySpeechSound(uuid: UUID): IO[FairyPlaySound] = + override def fairySpeechSound(uuid: UUID): IO[Boolean] = persistence.fairySpeechSound(uuid) override def toggleFairySpeechSound(uuid: UUID): IO[Unit] = - persistence.toggleFairySpeechSound( - uuid, - if (fairySpeechSound(uuid).unsafeRunSync() == FairyPlaySound.On) - FairyPlaySound.Off - else FairyPlaySound.On - ) + persistence.toggleFairySpeechSound(uuid, !fairySpeechSound(uuid).unsafeRunSync()) } override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala index 3f2b48fd91..2a985f1db6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala @@ -89,7 +89,7 @@ class FairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) repository = fairyAPI.fairySpeechServiceRepository(player) _ <- ContextCoercion { - repository.makeSpeech(FairyMessage(s"あっ、もうこんな時間だ!"), FairyPlaySound.Off) + repository.makeSpeech(FairyMessage(s"あっ、もうこんな時間だ!"), fairyPlaySound = false) } >> ContextCoercion { repository.makeSpeech(FairyMessage(s"じゃーねー!${player.getName}"), playSound) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index dde4289ac4..fb6743136e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -5,7 +5,6 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p AppleAteByFairyRank, FairyAppleConsumeStrategy, FairyEndTime, - FairyPlaySound, FairyRecoveryMana, FairySummonCost, FairyUsingState @@ -93,11 +92,11 @@ trait FairyPersistence[F[_]] { /** * 妖精が喋るときに音をだすかをトグルする */ - def toggleFairySpeechSound(uuid: UUID, fairyPlaySound: FairyPlaySound): F[Unit] + def toggleFairySpeechSound(uuid: UUID, fairyPlaySound: Boolean): F[Unit] /** * 妖精が喋ったときに音を再生するか取得する */ - def fairySpeechSound(uuid: UUID): F[FairyPlaySound] + def fairySpeechSound(uuid: UUID): F[Boolean] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyPlaySound.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyPlaySound.scala deleted file mode 100644 index 6eb9125a18..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyPlaySound.scala +++ /dev/null @@ -1,11 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property - -sealed trait FairyPlaySound - -object FairyPlaySound { - - case object On extends FairyPlaySound - - case object Off extends FairyPlaySound - -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 83e59436ae..fcc0ca4ee4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -228,10 +228,10 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { /** * 妖精が喋るときに音をだすかをトグルする */ - override def toggleFairySpeechSound(uuid: UUID, fairyPlaySound: FairyPlaySound): F[Unit] = + override def toggleFairySpeechSound(uuid: UUID, fairyPlaySound: Boolean): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET is_fairy_speech_play_sound = ${fairyPlaySound == FairyPlaySound.On} WHERE uuid = ${uuid.toString}" + sql"UPDATE playerdata SET is_fairy_speech_play_sound = $fairyPlaySound WHERE uuid = ${uuid.toString}" .execute() .apply() } @@ -240,16 +240,14 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { /** * 妖精が喋ったときに音を再生するか取得する */ - override def fairySpeechSound(uuid: UUID): F[FairyPlaySound] = + override def fairySpeechSound(uuid: UUID): F[Boolean] = Sync[F].delay { DB.readOnly { implicit session => - val isPlaySound = - sql"SELECT is_fairy_speech_play_sound FROM playerdata WHERE uuid=${uuid.toString}" - .map(_.boolean("is_fairy_speech_play_sound")) - .single() - .apply() - .get - if (isPlaySound) FairyPlaySound.On else FairyPlaySound.Off + sql"SELECT is_fairy_speech_play_sound FROM playerdata WHERE uuid=${uuid.toString}" + .map(_.boolean("is_fairy_speech_play_sound")) + .single() + .apply() + .get } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala index d6834c040b..0bf7cd7121 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala @@ -3,17 +3,12 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service import cats.effect.Sync import cats.implicits.catsSyntaxFlatMapOps import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - FairyMessage, - FairyPlaySound -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage class FairySpeechService[F[_]: Sync](gateway: FairySpeechGateway[F]) { - def makeSpeech(fairyMessage: FairyMessage, fairyPlaySound: FairyPlaySound): F[Unit] = { - gateway.sendMessage(fairyMessage) >> Sync[F].whenA(fairyPlaySound == FairyPlaySound.On)( - gateway.playSpeechSound - ) + def makeSpeech(fairyMessage: FairyMessage, fairyPlaySound: Boolean): F[Unit] = { + gateway.sendMessage(fairyMessage) >> Sync[F].whenA(fairyPlaySound)(gateway.playSpeechSound) } } From df1d4bc79e17b6f9c9cc2a1b46b78469000de5bf Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 17:19:21 +0900 Subject: [PATCH 148/482] =?UTF-8?q?replace:=20fairyUsingState=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=81=97Boolean=E3=81=AB=E7=BD=AE=E3=81=8D?= =?UTF-8?q?=E6=8F=9B=E3=81=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 5 ++--- .../vote/subsystems/fairy/FairyAPI.scala | 4 ++-- .../subsystems/vote/subsystems/fairy/System.scala | 4 ++-- .../fairy/bukkit/actions/BukkitRecoveryMana.scala | 15 ++++++--------- .../fairy/bukkit/actions/BukkitSummonFairy.scala | 11 +++-------- .../bukkit/listeners/FairyPlayerJoinGreeter.scala | 5 ++--- .../fairy/domain/FairyPersistence.scala | 7 +++---- .../fairy/domain/FairySpawnRequest.scala | 9 ++------- .../fairy/domain/property/FairyUsingState.scala | 11 ----------- .../infrastructure/JdbcFairyPersistence.scala | 10 ++++------ 10 files changed, 26 insertions(+), 55 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyUsingState.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 2247920179..e45a46abec 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -28,8 +28,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleOpenStateDependency, - FairySummonCost, - FairyUsingState + FairySummonCost } import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect @@ -92,7 +91,7 @@ object VoteMenu extends Menu { } yield { val exceptDynamicButtons = staticButtons ++ computeButtons MenuSlotLayout(exceptDynamicButtons).merge( - if (fairyUsingState == FairyUsingState.Using) + if (fairyUsingState) MenuSlotLayout(dynamicButtons: _*) else MenuSlotLayout.emptyLayout ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index cd43572736..c325d2f14e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -21,7 +21,7 @@ trait FairyWriteAPI[F[_], G[_], Player] { /** * 妖精を使っているかどうかを切り替える */ - def updateFairyUsingState(player: Player, fairyUsingState: FairyUsingState): F[Unit] + def updateFairyUsingState(player: Player, fairyUsingState: Boolean): F[Unit] /** * 妖精が回復するマナの量を変更する @@ -73,7 +73,7 @@ trait FairyReadAPI[F[_], G[_], Player] { /** * 妖精を使っているかを取得する */ - def fairyUsingState(player: Player): F[FairyUsingState] + def fairyUsingState(player: Player): F[Boolean] /** * 妖精が回復するマナの量を取得する diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index c828ce71a3..04ad12292e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -92,12 +92,12 @@ object System { ): IO[Unit] = persistence.updateFairyEndTime(player.getUniqueId, fairyEndTime) - override def fairyUsingState(player: Player): IO[FairyUsingState] = + override def fairyUsingState(player: Player): IO[Boolean] = persistence.fairyUsingState(player.getUniqueId) override def updateFairyUsingState( player: Player, - fairyUsingState: FairyUsingState + fairyUsingState: Boolean ): IO[Unit] = persistence.updateFairyUsingState(player.getUniqueId, fairyUsingState) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index e5cbe58cc1..e76a1b190e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -12,8 +12,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.F import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleAmount, FairyAppleConsumeStrategy, - FairyManaRecoveryState, - FairyUsingState + FairyManaRecoveryState } import com.github.unchama.seichiassist.{MineStackObjectList, SeichiAssist} import com.github.unchama.targetedeffect.SequentialEffect @@ -44,20 +43,18 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] fairyUsingState <- fairyAPI.fairyUsingState(player) fairyEndTimeOpt <- fairyAPI.fairyEndTime(player) endTime = fairyEndTimeOpt.get.endTimeOpt.get - isUsing = fairyUsingState == FairyUsingState.Using _ <- { - new FairySpeech[F, G] - .bye(player) >> fairyAPI.updateFairyUsingState(player, FairyUsingState.NotUsing) + new FairySpeech[F, G].bye(player) >> fairyAPI.updateFairyUsingState(player, false) }.whenA( // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) - isUsing && endTime.isBefore(LocalDateTime.now()) + fairyUsingState && endTime.isBefore(LocalDateTime.now()) ) oldManaAmount <- ContextCoercion { manaApi.readManaAmount(player) } _ <- { new FairySpeech[F, G].speechRandomly(player, FairyManaRecoveryState.Full) - }.whenA(isUsing && oldManaAmount.isFull) + }.whenA(fairyUsingState && oldManaAmount.isFull) appleConsumptionAmount <- computeAppleConsumptionAmount finallyAppleConsumptionAmount <- computeFinallyAppleConsumptionAmount( @@ -74,7 +71,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] _ <- MessageEffectF(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") .apply(player) .whenA( - isUsing && !oldManaAmount.isFull && appleConsumptionAmount > mineStackedGachaRingoAmount + fairyUsingState && !oldManaAmount.isFull && appleConsumptionAmount > mineStackedGachaRingoAmount ) _ <- { @@ -96,7 +93,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] ) else MessageEffectF(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") ).apply(player) - }.whenA(isUsing && !oldManaAmount.isFull) + }.whenA(fairyUsingState && !oldManaAmount.isFull) } yield () /** diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index db0c9c49ab..e7f84d42b7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -2,24 +2,19 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit. import cats.effect.ConcurrentEffect import com.github.unchama.generic.ContextCoercion -import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - FairyRecoveryManaAmount, - FairyUsingState -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyRecoveryManaAmount import com.github.unchama.targetedeffect.commandsender.MessageEffectF import org.bukkit.ChatColor._ import org.bukkit.entity.Player class BukkitSummonFairy[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( - implicit breakCountAPI: BreakCountAPI[F, G, Player], - fairyAPI: FairyAPI[F, G, Player], + implicit fairyAPI: FairyAPI[F, G, Player], voteAPI: VoteAPI[F, Player], manaApi: ManaApi[F, G, Player] ) extends SummonFairy[F, G, Player] { @@ -28,7 +23,7 @@ class BukkitSummonFairy[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( override def summon(player: Player): F[Unit] = { for { - _ <- fairyAPI.updateFairyUsingState(player, FairyUsingState.Using) + _ <- fairyAPI.updateFairyUsingState(player, fairyUsingState = true) manaAmount <- ContextCoercion { manaApi.readManaAmount(player) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index 8e917d09bf..700e30bb40 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -4,7 +4,6 @@ import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyUsingState import org.bukkit.entity.Player import org.bukkit.event.player.PlayerJoinEvent import org.bukkit.event.{EventHandler, Listener} @@ -21,11 +20,11 @@ class FairyPlayerJoinGreeter(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]) ex usingState <- fairyAPI.fairyUsingState(player) endTime <- fairyAPI.fairyEndTime(player) } yield { - if (usingState == FairyUsingState.Using) { + if (usingState) { if (endTime.get.endTimeOpt.get.isBefore(LocalDateTime.now())) { // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) player.sendMessage(s"$LIGHT_PURPLE${BOLD}妖精は何処かへ行ってしまったようだ...") - fairyAPI.updateFairyUsingState(player, FairyUsingState.NotUsing).unsafeRunSync() + fairyAPI.updateFairyUsingState(player, false).unsafeRunSync() } else { // まだ終了時間ではない(つまり有効時間内) implicit val ioCE: ConcurrentEffect[IO] = diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index fb6743136e..1049a173d8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -6,8 +6,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p FairyAppleConsumeStrategy, FairyEndTime, FairyRecoveryMana, - FairySummonCost, - FairyUsingState + FairySummonCost } import java.util.UUID @@ -37,12 +36,12 @@ trait FairyPersistence[F[_]] { /** * 妖精が召喚されているかを更新する */ - def updateFairyUsingState(uuid: UUID, fairyUsingState: FairyUsingState): F[Unit] + def updateFairyUsingState(uuid: UUID, fairyUsingState: Boolean): F[Unit] /** * 妖精が召喚されているかを取得する */ - def fairyUsingState(uuid: UUID): F[FairyUsingState] + def fairyUsingState(uuid: UUID): F[Boolean] /** * 妖精が回復するマナの量を変更する diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala index 8bcd29a636..335da2c0c0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala @@ -3,20 +3,15 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain import cats.effect.Sync import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI -import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - FairySpawnRequestError, - FairyUsingState -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError class FairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player]( implicit breakCountAPI: BreakCountAPI[F, G, Player], fairyAPI: FairyAPI[F, G, Player], voteAPI: VoteAPI[F, Player], - manaApi: ManaApi[F, G, Player], summonFairy: SummonFairy[F, G, Player] ) { @@ -34,7 +29,7 @@ class FairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player]( } yield { if (seichiLevel < 10) Left(FairySpawnRequestError.NotEnoughSeichiLevel) - else if (usingState == FairyUsingState.Using) + else if (usingState) Left(FairySpawnRequestError.AlreadyFairySpawned) else if (effectPoints.value < fairySummonCost.value * 2) Left(FairySpawnRequestError.NotEnoughEffectPoint) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyUsingState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyUsingState.scala deleted file mode 100644 index 245a4c78b6..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyUsingState.scala +++ /dev/null @@ -1,11 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property - -sealed trait FairyUsingState - -object FairyUsingState { - - case object Using extends FairyUsingState - - case object NotUsing extends FairyUsingState - -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index fcc0ca4ee4..63969a03cc 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -66,11 +66,11 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { /** * 妖精の召喚状態を更新します */ - override def updateFairyUsingState(uuid: UUID, fairyUsingState: FairyUsingState): F[Unit] = + override def updateFairyUsingState(uuid: UUID, fairyUsingState: Boolean): F[Unit] = Sync[F].delay { DB.localTx { implicit session => sql"""UPDATE playerdata - | SET canVotingFairyUse = ${fairyUsingState == FairyUsingState.Using} WHERE uuid = ${uuid.toString}""" + | SET canVotingFairyUse = ${fairyUsingState} WHERE uuid = ${uuid.toString}""" .stripMargin .execute() .apply() @@ -80,15 +80,13 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { /** * 妖精が召喚されているかを取得します */ - override def fairyUsingState(uuid: UUID): F[FairyUsingState] = Sync[F].delay { - val isFairyUsing = DB.readOnly { implicit session => + override def fairyUsingState(uuid: UUID): F[Boolean] = Sync[F].delay { + DB.readOnly { implicit session => sql"SELECT canVotingFairyUse FROM playerdata WHERE uuid = ${uuid.toString}" .map(_.boolean("canVotingFairyUse")) .single() .apply() }.get - if (isFairyUsing) FairyUsingState.Using - else FairyUsingState.NotUsing } /** From 1143114b284b87b980be9ccb2bfb38b11d4068df Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 17:22:17 +0900 Subject: [PATCH 149/482] rename: fairyUsingState -> isFairyUsing --- .../unchama/seichiassist/menus/VoteMenu.scala | 4 ++-- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 4 ++-- .../subsystems/vote/subsystems/fairy/System.scala | 11 ++++------- .../fairy/bukkit/actions/BukkitRecoveryMana.scala | 13 +++++++------ .../fairy/bukkit/actions/BukkitSummonFairy.scala | 2 +- .../bukkit/listeners/FairyPlayerJoinGreeter.scala | 4 ++-- .../subsystems/fairy/domain/FairyPersistence.scala | 4 ++-- .../subsystems/fairy/domain/FairySpawnRequest.scala | 2 +- .../fairy/infrastructure/JdbcFairyPersistence.scala | 6 +++--- 9 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index e45a46abec..ed673ad067 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -85,13 +85,13 @@ object VoteMenu extends Menu { .traverse(_.sequence) for { - fairyUsingState <- environment.fairyAPI.fairyUsingState(constantButtons.player) + isFairyUsing <- environment.fairyAPI.isFairyUsing(constantButtons.player) computeButtons <- computeButtonsIO dynamicButtons <- dynamicButtonsIO } yield { val exceptDynamicButtons = staticButtons ++ computeButtons MenuSlotLayout(exceptDynamicButtons).merge( - if (fairyUsingState) + if (isFairyUsing) MenuSlotLayout(dynamicButtons: _*) else MenuSlotLayout.emptyLayout ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index c325d2f14e..ab98894357 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -21,7 +21,7 @@ trait FairyWriteAPI[F[_], G[_], Player] { /** * 妖精を使っているかどうかを切り替える */ - def updateFairyUsingState(player: Player, fairyUsingState: Boolean): F[Unit] + def updateIsFairyUsing(player: Player, isFairyUsing: Boolean): F[Unit] /** * 妖精が回復するマナの量を変更する @@ -73,7 +73,7 @@ trait FairyReadAPI[F[_], G[_], Player] { /** * 妖精を使っているかを取得する */ - def fairyUsingState(player: Player): F[Boolean] + def isFairyUsing(player: Player): F[Boolean] /** * 妖精が回復するマナの量を取得する diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 04ad12292e..8e9dfc0e8e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -92,14 +92,11 @@ object System { ): IO[Unit] = persistence.updateFairyEndTime(player.getUniqueId, fairyEndTime) - override def fairyUsingState(player: Player): IO[Boolean] = - persistence.fairyUsingState(player.getUniqueId) + override def isFairyUsing(player: Player): IO[Boolean] = + persistence.isFairyUsing(player.getUniqueId) - override def updateFairyUsingState( - player: Player, - fairyUsingState: Boolean - ): IO[Unit] = - persistence.updateFairyUsingState(player.getUniqueId, fairyUsingState) + override def updateIsFairyUsing(player: Player, isFairyUsing: Boolean): IO[Unit] = + persistence.updateIsFairyUsing(player.getUniqueId, isFairyUsing) override def fairyRecoveryMana(uuid: UUID): IO[FairyRecoveryMana] = persistence.fairyRecoveryMana(uuid) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index e76a1b190e..7591c862ee 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -40,21 +40,22 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] override def recovery: F[Unit] = for { - fairyUsingState <- fairyAPI.fairyUsingState(player) + isFairyUsing <- fairyAPI.isFairyUsing(player) fairyEndTimeOpt <- fairyAPI.fairyEndTime(player) endTime = fairyEndTimeOpt.get.endTimeOpt.get _ <- { - new FairySpeech[F, G].bye(player) >> fairyAPI.updateFairyUsingState(player, false) + new FairySpeech[F, G] + .bye(player) >> fairyAPI.updateIsFairyUsing(player, isFairyUsing = false) }.whenA( // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) - fairyUsingState && endTime.isBefore(LocalDateTime.now()) + isFairyUsing && endTime.isBefore(LocalDateTime.now()) ) oldManaAmount <- ContextCoercion { manaApi.readManaAmount(player) } _ <- { new FairySpeech[F, G].speechRandomly(player, FairyManaRecoveryState.Full) - }.whenA(fairyUsingState && oldManaAmount.isFull) + }.whenA(isFairyUsing && oldManaAmount.isFull) appleConsumptionAmount <- computeAppleConsumptionAmount finallyAppleConsumptionAmount <- computeFinallyAppleConsumptionAmount( @@ -71,7 +72,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] _ <- MessageEffectF(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") .apply(player) .whenA( - fairyUsingState && !oldManaAmount.isFull && appleConsumptionAmount > mineStackedGachaRingoAmount + isFairyUsing && !oldManaAmount.isFull && appleConsumptionAmount > mineStackedGachaRingoAmount ) _ <- { @@ -93,7 +94,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] ) else MessageEffectF(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") ).apply(player) - }.whenA(fairyUsingState && !oldManaAmount.isFull) + }.whenA(isFairyUsing && !oldManaAmount.isFull) } yield () /** diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index e7f84d42b7..934dd49ce2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -23,7 +23,7 @@ class BukkitSummonFairy[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( override def summon(player: Player): F[Unit] = { for { - _ <- fairyAPI.updateFairyUsingState(player, fairyUsingState = true) + _ <- fairyAPI.updateIsFairyUsing(player, isFairyUsing = true) manaAmount <- ContextCoercion { manaApi.readManaAmount(player) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index 700e30bb40..d0f08f6fa4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -17,14 +17,14 @@ class FairyPlayerJoinGreeter(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]) ex def onJoin(e: PlayerJoinEvent): Unit = { val player = e.getPlayer val eff = for { - usingState <- fairyAPI.fairyUsingState(player) + usingState <- fairyAPI.isFairyUsing(player) endTime <- fairyAPI.fairyEndTime(player) } yield { if (usingState) { if (endTime.get.endTimeOpt.get.isBefore(LocalDateTime.now())) { // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) player.sendMessage(s"$LIGHT_PURPLE${BOLD}妖精は何処かへ行ってしまったようだ...") - fairyAPI.updateFairyUsingState(player, false).unsafeRunSync() + fairyAPI.updateIsFairyUsing(player, false).unsafeRunSync() } else { // まだ終了時間ではない(つまり有効時間内) implicit val ioCE: ConcurrentEffect[IO] = diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index 1049a173d8..58a7736605 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -36,12 +36,12 @@ trait FairyPersistence[F[_]] { /** * 妖精が召喚されているかを更新する */ - def updateFairyUsingState(uuid: UUID, fairyUsingState: Boolean): F[Unit] + def updateIsFairyUsing(uuid: UUID, isFairyUsing: Boolean): F[Unit] /** * 妖精が召喚されているかを取得する */ - def fairyUsingState(uuid: UUID): F[Boolean] + def isFairyUsing(uuid: UUID): F[Boolean] /** * 妖精が回復するマナの量を変更する diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala index 335da2c0c0..8e04d4aebb 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala @@ -19,7 +19,7 @@ class FairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player]( def spawnRequest(player: Player): F[Either[FairySpawnRequestError, F[Unit]]] = { for { - usingState <- fairyAPI.fairyUsingState(player) + usingState <- fairyAPI.isFairyUsing(player) effectPoints <- voteAPI.effectPoints(player) fairySummonCost <- fairyAPI.fairySummonCost(player) seichiAmountRepository <- ContextCoercion( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 63969a03cc..f6e06530fd 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -66,11 +66,11 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { /** * 妖精の召喚状態を更新します */ - override def updateFairyUsingState(uuid: UUID, fairyUsingState: Boolean): F[Unit] = + override def updateIsFairyUsing(uuid: UUID, isFairyUsing: Boolean): F[Unit] = Sync[F].delay { DB.localTx { implicit session => sql"""UPDATE playerdata - | SET canVotingFairyUse = ${fairyUsingState} WHERE uuid = ${uuid.toString}""" + | SET canVotingFairyUse = ${isFairyUsing} WHERE uuid = ${uuid.toString}""" .stripMargin .execute() .apply() @@ -80,7 +80,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { /** * 妖精が召喚されているかを取得します */ - override def fairyUsingState(uuid: UUID): F[Boolean] = Sync[F].delay { + override def isFairyUsing(uuid: UUID): F[Boolean] = Sync[F].delay { DB.readOnly { implicit session => sql"SELECT canVotingFairyUse FROM playerdata WHERE uuid = ${uuid.toString}" .map(_.boolean("canVotingFairyUse")) From efdda61e6119ce42a2cff6052d90f7c39faf055a Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 17:28:36 +0900 Subject: [PATCH 150/482] =?UTF-8?q?move:=20speechAPI=E3=82=92=E5=88=86?= =?UTF-8?q?=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/FairyAPI.scala | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index ab98894357..05324d4a9d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -38,11 +38,6 @@ trait FairyWriteAPI[F[_], G[_], Player] { */ def increaseAppleAteByFairy(uuid: UUID, appleAmount: AppleAmount): F[Unit] - /** - * 妖精が喋るときに音をだすかをトグルする - */ - def toggleFairySpeechSound(uuid: UUID): F[Unit] - } object FairyWriteAPI { @@ -110,6 +105,23 @@ trait FairyReadAPI[F[_], G[_], Player] { */ def allEatenAppleAmount: F[AppleAmount] +} + +object FairyReadAPI { + + def apply[F[_], G[_], Player]( + implicit ev: FairyReadAPI[F, G, Player] + ): FairyReadAPI[F, G, Player] = ev + +} + +trait FairySpeechAPI[F[_]] { + + /** + * 妖精が喋るときに音をだすかをトグルする + */ + def toggleFairySpeechSound(uuid: UUID): F[Unit] + /** * 妖精が喋ったときに音を再生するか取得する */ @@ -117,14 +129,13 @@ trait FairyReadAPI[F[_], G[_], Player] { } -object FairyReadAPI { +object FairySpeechAPI { - def apply[F[_], G[_], Player]( - implicit ev: FairyReadAPI[F, G, Player] - ): FairyReadAPI[F, G, Player] = ev + def apply[F[_]](implicit ev: FairySpeechAPI[F]): FairySpeechAPI[F] = ev } trait FairyAPI[F[_], G[_], Player] extends FairyReadAPI[F, G, Player] with FairyWriteAPI[F, G, Player] + with FairySpeechAPI[F] From 57968442e23e3bbc35280c5a506b41beea5936c9 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 17:33:33 +0900 Subject: [PATCH 151/482] =?UTF-8?q?fix:=20bukkitFairySpeechGateway?= =?UTF-8?q?=E3=81=A7G=E3=81=A8IO=E3=82=92=E5=BE=80=E5=BE=A9=E3=81=97?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gateway/BukkitFairySpeechGateway.scala | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala index 3d746b7ef1..52d6ee927b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala @@ -1,22 +1,23 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway -import cats.effect.Sync +import cats.effect.{LiftIO, Sync} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage -import com.github.unchama.targetedeffect.commandsender.MessageEffect +import com.github.unchama.targetedeffect.commandsender.MessageEffectF import com.github.unchama.targetedeffect.player.FocusedSoundEffect import org.bukkit.ChatColor.{AQUA, BOLD, RESET} import org.bukkit.Sound import org.bukkit.entity.Player -class BukkitFairySpeechGateway[G[_]: Sync](player: Player) extends FairySpeechGateway[G] { +class BukkitFairySpeechGateway[G[_]: Sync: LiftIO](player: Player) + extends FairySpeechGateway[G] { - override def sendMessage(fairyMessage: FairyMessage): G[Unit] = Sync[G].delay { - MessageEffect(s"$AQUA$BOLD<マナ妖精>$RESET${fairyMessage.message}").run(player).unsafeRunSync() - } + override def sendMessage(fairyMessage: FairyMessage): G[Unit] = + MessageEffectF[G](s"$AQUA$BOLD<マナ妖精>$RESET${fairyMessage.message}").run(player) - override def playSpeechSound: G[Unit] = Sync[G].delay { - FocusedSoundEffect(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f).run(player).unsafeRunSync() - } + override def playSpeechSound: G[Unit] = + LiftIO[G].liftIO { + FocusedSoundEffect(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f).run(player) + } } From 8eb08658331c5b2c0f2c6dbceb6db6146821e6f3 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 17:41:01 +0900 Subject: [PATCH 152/482] rename: usingState -> isUsing --- .../fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index d0f08f6fa4..c8dcfed55d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -1,5 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners +import cats.Applicative import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI @@ -17,14 +18,14 @@ class FairyPlayerJoinGreeter(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]) ex def onJoin(e: PlayerJoinEvent): Unit = { val player = e.getPlayer val eff = for { - usingState <- fairyAPI.isFairyUsing(player) + isUsing <- fairyAPI.isFairyUsing(player) endTime <- fairyAPI.fairyEndTime(player) } yield { - if (usingState) { + if (isUsing) { if (endTime.get.endTimeOpt.get.isBefore(LocalDateTime.now())) { // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) player.sendMessage(s"$LIGHT_PURPLE${BOLD}妖精は何処かへ行ってしまったようだ...") - fairyAPI.updateIsFairyUsing(player, false).unsafeRunSync() + fairyAPI.updateIsFairyUsing(player, isFairyUsing = false).unsafeRunSync() } else { // まだ終了時間ではない(つまり有効時間内) implicit val ioCE: ConcurrentEffect[IO] = From 7a5cae3313d40ce017085944d6439b9f67e50a14 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 31 Jul 2022 18:02:36 +0900 Subject: [PATCH 153/482] fix: compile error --- .../subsystems/vote/subsystems/fairy/System.scala | 2 +- .../bukkit/gateway/BukkitFairySpeechGateway.scala | 12 +++++------- .../bukkit/listeners/FairyPlayerJoinGreeter.scala | 3 +-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 8e9dfc0e8e..9368d0f67e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -19,9 +19,9 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applicat import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala index 52d6ee927b..a697addbd8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway -import cats.effect.{LiftIO, Sync} +import cats.effect.Sync import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage import com.github.unchama.targetedeffect.commandsender.MessageEffectF @@ -9,15 +9,13 @@ import org.bukkit.ChatColor.{AQUA, BOLD, RESET} import org.bukkit.Sound import org.bukkit.entity.Player -class BukkitFairySpeechGateway[G[_]: Sync: LiftIO](player: Player) - extends FairySpeechGateway[G] { +class BukkitFairySpeechGateway[G[_]: Sync](player: Player) extends FairySpeechGateway[G] { override def sendMessage(fairyMessage: FairyMessage): G[Unit] = MessageEffectF[G](s"$AQUA$BOLD<マナ妖精>$RESET${fairyMessage.message}").run(player) - override def playSpeechSound: G[Unit] = - LiftIO[G].liftIO { - FocusedSoundEffect(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f).run(player) - } + override def playSpeechSound: G[Unit] = Sync[G].delay { + FocusedSoundEffect(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f).run(player).unsafeRunSync() + } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index c8dcfed55d..3972cfff2d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -1,14 +1,13 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners -import cats.Applicative import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech +import org.bukkit.ChatColor._ import org.bukkit.entity.Player import org.bukkit.event.player.PlayerJoinEvent import org.bukkit.event.{EventHandler, Listener} -import org.bukkit.ChatColor._ import java.time.LocalDateTime From 1741245f7dffc1fd0e85b341816c5560562fc4ac Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 11:35:29 +0900 Subject: [PATCH 154/482] =?UTF-8?q?add:=20migration=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=82=A4=E3=83=AB=20V2.0.2=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V2.0.2__Move_vote_column.sql | 22 +++++++++++++++++++ .../seichiassist/data/player/VoteStatus.scala | 5 ----- 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/db/migration/V2.0.2__Move_vote_column.sql delete mode 100644 src/main/scala/com/github/unchama/seichiassist/data/player/VoteStatus.scala diff --git a/src/main/resources/db/migration/V2.0.2__Move_vote_column.sql b/src/main/resources/db/migration/V2.0.2__Move_vote_column.sql new file mode 100644 index 0000000000..47ae417d84 --- /dev/null +++ b/src/main/resources/db/migration/V2.0.2__Move_vote_column.sql @@ -0,0 +1,22 @@ +use seichiassist; + +CREATE TABLE vote( + uuid CHAR(36) PRIMARY KEY, + vote_number INT, + chain_vote_number INT, + effect_point INT, + given_effect_point INT, + last_vote DATETIME +); + +INSERT INTO vote( + uuid, + vote_number, + chain_vote_number, + effect_point, + given_effect_point, + last_vote +) +SELECT uuid,p_vote,chainvote,effectpoint,p_givenvote,lastvote FROM playerdata; + +ALTER TABLE playerdata DROP p_vote,chainvote,effectpoint,p_givenvote,lastvote; diff --git a/src/main/scala/com/github/unchama/seichiassist/data/player/VoteStatus.scala b/src/main/scala/com/github/unchama/seichiassist/data/player/VoteStatus.scala deleted file mode 100644 index cfef5de615..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/data/player/VoteStatus.scala +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.unchama.seichiassist.data.player - -import java.time.LocalDateTime - -case class VoteStatus(lastVote: LocalDateTime, chainLength: Int = 0, totalVote: Int = 0) From 2da36539d21d43d6bac3aa96b8578b172e461b9a Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 11:50:07 +0900 Subject: [PATCH 155/482] =?UTF-8?q?fix:=20lastvote=E3=82=92=E5=8F=96?= =?UTF-8?q?=E5=BE=97=E3=81=99=E3=82=8B=E3=81=A8=E3=81=8D=E3=81=ABCONVERT?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/db/migration/V2.0.2__Move_vote_column.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/db/migration/V2.0.2__Move_vote_column.sql b/src/main/resources/db/migration/V2.0.2__Move_vote_column.sql index 47ae417d84..d49df14b90 100644 --- a/src/main/resources/db/migration/V2.0.2__Move_vote_column.sql +++ b/src/main/resources/db/migration/V2.0.2__Move_vote_column.sql @@ -17,6 +17,6 @@ INSERT INTO vote( given_effect_point, last_vote ) -SELECT uuid,p_vote,chainvote,effectpoint,p_givenvote,lastvote FROM playerdata; +SELECT uuid,p_vote,chainvote,effectpoint,p_givenvote,CONVERT(lastvote, DATE) FROM playerdata; ALTER TABLE playerdata DROP p_vote,chainvote,effectpoint,p_givenvote,lastvote; From 45f87cfc35212caba0c143e720879cae05b99a3a Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 13:36:05 +0900 Subject: [PATCH 156/482] format: V2.0.2 --- .../db/migration/V2.0.2__Move_vote_column.sql | 48 ++++++++++++------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/main/resources/db/migration/V2.0.2__Move_vote_column.sql b/src/main/resources/db/migration/V2.0.2__Move_vote_column.sql index d49df14b90..8e15a731de 100644 --- a/src/main/resources/db/migration/V2.0.2__Move_vote_column.sql +++ b/src/main/resources/db/migration/V2.0.2__Move_vote_column.sql @@ -1,22 +1,36 @@ -use seichiassist; +USE seichiassist; CREATE TABLE vote( - uuid CHAR(36) PRIMARY KEY, - vote_number INT, - chain_vote_number INT, - effect_point INT, - given_effect_point INT, - last_vote DATETIME + uuid CHAR(36) PRIMARY KEY, + vote_number INT, + chain_vote_number INT, + effect_point INT, + given_effect_point INT, + last_vote DATETIME ); -INSERT INTO vote( - uuid, - vote_number, - chain_vote_number, - effect_point, - given_effect_point, - last_vote -) -SELECT uuid,p_vote,chainvote,effectpoint,p_givenvote,CONVERT(lastvote, DATE) FROM playerdata; +INSERT INTO + vote( + uuid, + vote_number, + chain_vote_number, + effect_point, + given_effect_point, + last_vote + ) +SELECT + uuid, + p_vote, + chainvote, + effectpoint, + p_givenvote, + CONVERT(lastvote, DATE) +FROM + playerdata; -ALTER TABLE playerdata DROP p_vote,chainvote,effectpoint,p_givenvote,lastvote; +ALTER TABLE + playerdata DROP p_vote, + DROP chainvote, + DROP effectpoint, + DROP p_givenvote, + DROP lastvote; \ No newline at end of file From 9c422088a7d4babfadff498defb5086b9869856b Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 13:49:23 +0900 Subject: [PATCH 157/482] fix: RankingQuery --- .../infrastructure/JdbcVoteRankingRecordPersistence.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/ranking/infrastructure/JdbcVoteRankingRecordPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/ranking/infrastructure/JdbcVoteRankingRecordPersistence.scala index 3012680e3c..55ab6f3794 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/ranking/infrastructure/JdbcVoteRankingRecordPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/ranking/infrastructure/JdbcVoteRankingRecordPersistence.scala @@ -12,7 +12,7 @@ class JdbcVoteRankingRecordPersistence[F[_]: Sync] extends RankingRecordPersistence[F, VoteCount] { override def getAllRankingRecords: F[Vector[RankingRecord[VoteCount]]] = Sync[F].delay { DB.readOnly { implicit session => - sql"SELECT name,p_vote from playerdata" + sql"SELECT playerdata.name,vote_number FROM vote INNER JOIN playerdata ON vote.uuid = playerdata.uuid" .map { rs => RankingRecord(rs.string("name"), VoteCount(rs.int("p_vote"))) } .list() .apply() From 4368c608c36ac07211174b884c4336594c3cfc43 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 14:09:27 +0900 Subject: [PATCH 158/482] =?UTF-8?q?fix:=20JdbcVotePersistence=E3=81=AE?= =?UTF-8?q?=E3=82=AF=E3=82=A8=E3=83=AA=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/JdbcVotePersistence.scala | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index b9f252a1b5..27540aed67 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -16,9 +16,13 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { */ override def voteCounterIncrement(playerName: PlayerName): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET p_vote = p_vote + 1 WHERE name = ${playerName.name}" - .execute() - .apply() + sql"""INSERT INTO vote + | (uuid,vote_number,chain_vote_number,effect_point,given_effect_point,last_vote) + | VALUES + | ((SELECT uuid FROM playerdata WHERE name = ${playerName.name}),1,0,0,0,NULL) + | ON DUPLICATE KEY UPDATE + | vote_number = vote_number + 1 + """.stripMargin.execute().apply() } } @@ -27,7 +31,7 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { */ override def voteCounter(uuid: UUID): F[VoteCounter] = Sync[F].delay { DB.readOnly { implicit session => - val votePoint = sql"SELECT p_vote FROM playerdata WHERE uuid = ${uuid.toString}" + val votePoint = sql"SELECT vote_number FROM vote WHERE uuid = ${uuid.toString}" .map(_.int("p_vote")) .single() .apply() @@ -45,12 +49,16 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { NOTE: 最終投票日時より(連続投票許容幅 - 1)した日時よりも 小さかった場合に連続投票を0に戻します。 */ - sql"""UPDATE playerdata SET chainvote = + sql"""UPDATE vote SET chain_vote_number = | CASE WHEN DATEDIFF(last_vote, NOW()) <= ${-chainVoteAllowableWidth - 1} | THEN 0 - | ELSE chainvote + 1 - | END - | WHERE name = ${playerName.name}""".stripMargin.execute().apply() + | ELSE chain_vote_number + 1 + | END, + | last_vote = NOW() + | WHERE uuid = (SELECT uuid FROM playerdata WHERE name = ${playerName.name})""" + .stripMargin + .execute() + .apply() } } @@ -59,8 +67,8 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { */ override def chainVoteDays(uuid: UUID): F[ChainVoteDayNumber] = Sync[F].delay { DB.readOnly { implicit session => - val chainVoteDays = sql"SELECT chainvote FROM playerdata WHERE uuid = ${uuid.toString}" - .map(_.int("chainvote")) + val chainVoteDays = sql"SELECT chain_vote_number FROM vote WHERE uuid = ${uuid.toString}" + .map(_.int("chain_vote_number")) .single() .apply() .get @@ -73,7 +81,7 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { */ override def increaseEffectPointsByTen(uuid: UUID): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET effectpoint = effectpoint + 10 WHERE uuid = ${uuid.toString}" + sql"UPDATE vote SET effect_point = effect_point + 10 WHERE uuid = ${uuid.toString}" .execute() .apply() } @@ -85,7 +93,7 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { override def decreaseEffectPoints(uuid: UUID, effectPoint: EffectPoint): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET effectpoint = effectpoint - ${effectPoint.value} WHERE uuid = ${uuid.toString}" + sql"UPDATE vote SET effect_point = effect_point - ${effectPoint.value} WHERE uuid = ${uuid.toString}" .execute() .apply() } @@ -96,8 +104,8 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { */ override def effectPoints(uuid: UUID): F[EffectPoint] = Sync[F].delay { DB.readOnly { implicit session => - val effectPoints = sql"SELECT effectpoint FROM playerdata WHERE uuid = ${uuid.toString}" - .map(_.int("effectpoint")) + val effectPoints = sql"SELECT effect_point FROM vote WHERE uuid = ${uuid.toString}" + .map(_.int("effect_point")) .single() .apply() .get @@ -110,7 +118,7 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { */ override def increaseVoteBenefits(uuid: UUID, benefit: VoteBenefit): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET p_givenvote = p_givenvote + ${benefit.value} WHERE uuid = ${uuid.toString}" + sql"UPDATE vote SET given_effect_point = given_effect_point + ${benefit.value} WHERE uuid = ${uuid.toString}" .execute() .apply() } @@ -121,8 +129,8 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { */ override def receivedVoteBenefits(uuid: UUID): F[VoteBenefit] = Sync[F].delay { DB.readOnly { implicit session => - val benefits = sql"SELECT p_givenvote FROM playerdata WHERE uuid = ${uuid.toString}" - .map(_.int("p_givenvote")) + val benefits = sql"SELECT given_effect_point FROM vote WHERE uuid = ${uuid.toString}" + .map(_.int("given_effect_point")) .single() .apply() .get From 9d0d278361a027f84f1e8a63abd89cb069fc41c6 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 14:55:26 +0900 Subject: [PATCH 159/482] =?UTF-8?q?add:=20createPlayerData=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/domain/VotePersistence.scala | 5 ++++ .../infrastructure/JdbcVotePersistence.scala | 23 +++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala index a8eab457c8..fdb32959e0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala @@ -4,6 +4,11 @@ import java.util.UUID trait VotePersistence[F[_]] { + /** + * プレイヤーデータを作成する作用 + */ + def createPlayerData(uuid: UUID): F[Unit] + /** * 投票回数をインクリメントする作用 */ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index 27540aed67..c44b471e61 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -11,18 +11,27 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { // NOTE: 連続投票許容幅を変更する場合はここを変更してください。 private val chainVoteAllowableWidth = 4 + /** + * プレイヤーデータを作成する作用 + */ + def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { + DB.localTx { implicit session => + sql"""INSERT INTO vote + | (uuid, vote_number, chain_vote_number, effect_point, given_effect_point, last_vote) + | VALUES + | (${uuid.toString}, 0, 0, 0, 0, NULL) + | WHERE NOT EXISTS (SELECT uuid FROM vote WHERE uuid = ${uuid.toString})""" + .execute() + .apply() + } + } + /** * 投票回数をインクリメントする作用 */ override def voteCounterIncrement(playerName: PlayerName): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"""INSERT INTO vote - | (uuid,vote_number,chain_vote_number,effect_point,given_effect_point,last_vote) - | VALUES - | ((SELECT uuid FROM playerdata WHERE name = ${playerName.name}),1,0,0,0,NULL) - | ON DUPLICATE KEY UPDATE - | vote_number = vote_number + 1 - """.stripMargin.execute().apply() + sql"UPDATE vote SET vote_number = vote_number + 1".execute().apply() } } From 1eba202ad964281fb12694c241f006413459baed Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 15:01:06 +0900 Subject: [PATCH 160/482] =?UTF-8?q?add:=20voteDataCreator=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/System.scala | 6 +++++- .../bukkit/listeners/PlayerDataCreator.scala | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/listeners/PlayerDataCreator.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index a07166f2ca..b69c0ef378 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -4,10 +4,12 @@ import cats.effect.ConcurrentEffect import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.vote.bukkit.command.VoteCommand +import com.github.unchama.seichiassist.subsystems.vote.bukkit.listeners.PlayerDataCreator import com.github.unchama.seichiassist.subsystems.vote.domain._ import com.github.unchama.seichiassist.subsystems.vote.infrastructure.JdbcVotePersistence import org.bukkit.command.TabExecutor import org.bukkit.entity.Player +import org.bukkit.event.Listener import java.util.UUID @@ -18,7 +20,7 @@ trait System[F[_], Player] extends Subsystem[F] { object System { def wired[F[_]: ConcurrentEffect: OnMinecraftServerThread]: System[F, Player] = { - val votePersistence = new JdbcVotePersistence[F] + implicit val votePersistence: VotePersistence[F] = new JdbcVotePersistence[F] new System[F, Player] { override implicit val api: VoteAPI[F, Player] = new VoteAPI[F, Player] { @@ -60,6 +62,8 @@ object System { override val commands: Map[String, TabExecutor] = Map( "vote" -> new VoteCommand[F].executor ) + + override val listeners: Seq[Listener] = Seq(new PlayerDataCreator[F]) } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/listeners/PlayerDataCreator.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/listeners/PlayerDataCreator.scala new file mode 100644 index 0000000000..0755e987b9 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/listeners/PlayerDataCreator.scala @@ -0,0 +1,17 @@ +package com.github.unchama.seichiassist.subsystems.vote.bukkit.listeners + +import cats.effect.ConcurrentEffect +import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps +import com.github.unchama.seichiassist.subsystems.vote.domain.VotePersistence +import org.bukkit.event.player.PlayerJoinEvent +import org.bukkit.event.{EventHandler, Listener} + +class PlayerDataCreator[F[_]: ConcurrentEffect](implicit votePersistence: VotePersistence[F]) + extends Listener { + + @EventHandler + def onJoin(e: PlayerJoinEvent): Unit = { + votePersistence.createPlayerData(e.getPlayer.getUniqueId).toIO.unsafeRunSync() + } + +} From 7a08f138bc34a0dbf253abb9e3bd62e96a97112b Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 15:01:55 +0900 Subject: [PATCH 161/482] add: stripMergin --- .../vote/infrastructure/JdbcVotePersistence.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index c44b471e61..25d0730caf 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -17,10 +17,11 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { DB.localTx { implicit session => sql"""INSERT INTO vote - | (uuid, vote_number, chain_vote_number, effect_point, given_effect_point, last_vote) - | VALUES - | (${uuid.toString}, 0, 0, 0, 0, NULL) - | WHERE NOT EXISTS (SELECT uuid FROM vote WHERE uuid = ${uuid.toString})""" + | (uuid, vote_number, chain_vote_number, effect_point, given_effect_point, last_vote) + | VALUES + | (${uuid.toString}, 0, 0, 0, 0, NULL) + | WHERE NOT EXISTS (SELECT uuid FROM vote WHERE uuid = ${uuid.toString})""" + .stripMargin .execute() .apply() } From 4278fb2a02d4ffbfd5916d053a2d4784c11b23db Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 15:26:22 +0900 Subject: [PATCH 162/482] fix: INSERT INTO -> INSERT IGNORE INTO --- .../vote/infrastructure/JdbcVotePersistence.scala | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index 25d0730caf..93b5fae4ee 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -16,14 +16,10 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { */ def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"""INSERT INTO vote + sql"""INSERT IGNORE INTO vote | (uuid, vote_number, chain_vote_number, effect_point, given_effect_point, last_vote) | VALUES - | (${uuid.toString}, 0, 0, 0, 0, NULL) - | WHERE NOT EXISTS (SELECT uuid FROM vote WHERE uuid = ${uuid.toString})""" - .stripMargin - .execute() - .apply() + | (${uuid.toString}, 0, 0, 0, 0, NULL)""".stripMargin.execute().apply() } } @@ -32,7 +28,9 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { */ override def voteCounterIncrement(playerName: PlayerName): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE vote SET vote_number = vote_number + 1".execute().apply() + sql"UPDATE vote SET vote_number = vote_number + 1 WHERE uuid = (SELECT uuid FROM playerdata WHERE name = ${playerName.name})" + .execute() + .apply() } } From 72a5cf6d4e17aa27ff85f2b3bc515ad9d53e563b Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 15:27:12 +0900 Subject: [PATCH 163/482] fix: p_vote -> vote_number --- .../infrastructure/JdbcVoteRankingRecordPersistence.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/ranking/infrastructure/JdbcVoteRankingRecordPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/ranking/infrastructure/JdbcVoteRankingRecordPersistence.scala index 55ab6f3794..2a06e54cc6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/ranking/infrastructure/JdbcVoteRankingRecordPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/ranking/infrastructure/JdbcVoteRankingRecordPersistence.scala @@ -13,7 +13,7 @@ class JdbcVoteRankingRecordPersistence[F[_]: Sync] override def getAllRankingRecords: F[Vector[RankingRecord[VoteCount]]] = Sync[F].delay { DB.readOnly { implicit session => sql"SELECT playerdata.name,vote_number FROM vote INNER JOIN playerdata ON vote.uuid = playerdata.uuid" - .map { rs => RankingRecord(rs.string("name"), VoteCount(rs.int("p_vote"))) } + .map { rs => RankingRecord(rs.string("name"), VoteCount(rs.int("vote_number"))) } .list() .apply() .toVector From 4f037ecf7393d660dd739197d7003de29c5ac28a Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 15:30:23 +0900 Subject: [PATCH 164/482] fix: p_vote -> voteNumber --- .../subsystems/vote/infrastructure/JdbcVotePersistence.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index 93b5fae4ee..4fb0304736 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -40,7 +40,7 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { override def voteCounter(uuid: UUID): F[VoteCounter] = Sync[F].delay { DB.readOnly { implicit session => val votePoint = sql"SELECT vote_number FROM vote WHERE uuid = ${uuid.toString}" - .map(_.int("p_vote")) + .map(_.int("vote_number")) .single() .apply() .get From b5a941bee4a29b789a8dee58a0a45fdb9d882cef Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 15:34:54 +0900 Subject: [PATCH 165/482] =?UTF-8?q?fix:=20record=E3=82=B3=E3=83=9E?= =?UTF-8?q?=E3=83=B3=E3=83=89=E3=81=8C=E5=8B=95=E3=81=8B=E3=81=AA=E3=81=84?= =?UTF-8?q?=E4=B8=8D=E5=85=B7=E5=90=88=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/bukkit/command/VoteCommand.scala | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala index cb019ee07a..1fc43db938 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala @@ -1,6 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.bukkit.command -import cats.Monad import cats.effect.ConcurrentEffect import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import com.github.unchama.contextualexecutor.builder.ContextualExecutorBuilder @@ -22,8 +21,6 @@ class VoteCommand[F[_]: ConcurrentEffect](implicit voteAPI: VoteAPI[F, Player]) import cats.implicits._ private val recordExecutor = { - implicit val F: Monad[F] = Monad[F] - ContextualExecutorBuilder .beginConfiguration() .executionCSEffect { context => @@ -37,7 +34,7 @@ class VoteCommand[F[_]: ConcurrentEffect](implicit voteAPI: VoteAPI[F, Player]) _ <- voteAPI.voteCounterIncrement(playerName) _ <- voteAPI.updateChainVote(playerName) } yield () - eff.toIO + eff.toIO.unsafeRunSync() } ) } From cd28970bf498681efefa7543db7b3743c0658117 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 16:06:01 +0900 Subject: [PATCH 166/482] add: V2.0.3 migrationfile --- .../V2.0.3__Move_vote_fairy_column.sql | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql diff --git a/src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql b/src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql new file mode 100644 index 0000000000..ebafb8b6ec --- /dev/null +++ b/src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql @@ -0,0 +1,39 @@ +USE seichiassist; + +CREATE TABLE vote_fairy( + uuid CHAR(36) PRIMARY KEY, + apple_open_state INT, + is_fairy_using BOOLEAN, + fairy_recovery_mana_value INT, + fairy_end_time DATETIME, + given_apple_amount BIGINT, + is_play_fairy_speech_sound BOOLEAN +) +INSERT INTO + vote_fairy( + uuid, + apple_open_state, + is_fairy_using, + fairy_recovery_mana_value, + fairy_end_time, + given_apple_amount, + is_play_fairy_speech_sound + ) +SELECT + uuid, + toggleGiveApple, + canVotingFairyUse, + VotingFairyRecoveryValue, + newVotingFairyTime, + p_apple, + is_fairy_speech_play_sound +FROM + playerdata; + +ALTER TABLE + playerdata DROP toggleGiveApple, + DROP canVotingFairyUse, + DROP VotingFairyRecoveryValue, + DROP newVotingFairyTime, + DROP p_apple, + DROP is_fairy_speech_play_sound \ No newline at end of file From 6d033d692c76c3303cf9c52575fa6e58f307861f Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 16:14:10 +0900 Subject: [PATCH 167/482] =?UTF-8?q?fix:=20jdbcFairyPersistence=E3=82=92?= =?UTF-8?q?=E6=96=B0=E3=81=97=E3=81=84=E3=83=86=E3=83=BC=E3=83=96=E3=83=AB?= =?UTF-8?q?=E8=A1=8C=E5=8B=95z=E3=81=AB=E5=90=88=E3=82=8F=E3=81=9B?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../V2.0.3__Move_vote_fairy_column.sql | 4 ++ .../infrastructure/JdbcFairyPersistence.scala | 59 ++++++++++--------- 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql b/src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql index ebafb8b6ec..ccfdd3fee9 100644 --- a/src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql +++ b/src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql @@ -3,6 +3,7 @@ USE seichiassist; CREATE TABLE vote_fairy( uuid CHAR(36) PRIMARY KEY, apple_open_state INT, + fairy_summon_cost INT, is_fairy_using BOOLEAN, fairy_recovery_mana_value INT, fairy_end_time DATETIME, @@ -13,6 +14,7 @@ INSERT INTO vote_fairy( uuid, apple_open_state, + fairy_summon_cost, is_fairy_using, fairy_recovery_mana_value, fairy_end_time, @@ -22,6 +24,7 @@ INSERT INTO SELECT uuid, toggleGiveApple, + toggleVotingFairy, canVotingFairyUse, VotingFairyRecoveryValue, newVotingFairyTime, @@ -32,6 +35,7 @@ FROM ALTER TABLE playerdata DROP toggleGiveApple, + DROP toggleVotingFairy, DROP canVotingFairyUse, DROP VotingFairyRecoveryValue, DROP newVotingFairyTime, diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index f6e06530fd..a6ee58d5a3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -15,7 +15,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def changeAppleOpenState(uuid: UUID, openState: FairyAppleConsumeStrategy): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET toggleGiveApple = ${openState.serializedValue} WHERE uuid = ${uuid.toString}" + sql"UPDATE vote_fairy SET apple_open_state = ${openState.serializedValue} WHERE uuid = ${uuid.toString}" .execute() .apply() } @@ -27,8 +27,8 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def appleOpenState(uuid: UUID): F[FairyAppleConsumeStrategy] = Sync[F].delay { val serializedValue = DB.readOnly { implicit session => - sql"SELECT toggleGiveApple FROM playerdata WHERE uuid = ${uuid.toString}" - .map(_.int("toggleGiveApple")) + sql"SELECT apple_open_state FROM vote_fairy WHERE uuid = ${uuid.toString}" + .map(_.int("apple_open_state")) .single() .apply() .get @@ -42,7 +42,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET toggleVotingFairy = ${fairySummonCost.value} WHERE uuid = ${uuid.toString}" + sql"UPDATE vote_fairy SET fairy_summon_cost = ${fairySummonCost.value} WHERE uuid = ${uuid.toString}" .execute() .apply() } @@ -54,8 +54,8 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def fairySummonCost(uuid: UUID): F[FairySummonCost] = Sync[F].delay { DB.readOnly { implicit session => val fairySummonCost = - sql"SELECT toggleVotingFairy FROM playerdata WHERE uuid = ${uuid.toString}" - .map(_.int("toggleVotingFairy")) + sql"SELECT fairy_summon_cost FROM vote_fairy WHERE uuid = ${uuid.toString}" + .map(_.int("fairy_summon_cost")) .single() .apply() .get @@ -69,8 +69,8 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def updateIsFairyUsing(uuid: UUID, isFairyUsing: Boolean): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"""UPDATE playerdata - | SET canVotingFairyUse = ${isFairyUsing} WHERE uuid = ${uuid.toString}""" + sql"""UPDATE vote_fairy + | SET is_fairy_using = $isFairyUsing WHERE uuid = ${uuid.toString}""" .stripMargin .execute() .apply() @@ -82,8 +82,8 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { */ override def isFairyUsing(uuid: UUID): F[Boolean] = Sync[F].delay { DB.readOnly { implicit session => - sql"SELECT canVotingFairyUse FROM playerdata WHERE uuid = ${uuid.toString}" - .map(_.boolean("canVotingFairyUse")) + sql"SELECT is_fairy_using FROM vote_fairy WHERE uuid = ${uuid.toString}" + .map(_.boolean("is_fairy_using")) .single() .apply() }.get @@ -97,7 +97,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { fairyRecoveryMana: FairyRecoveryMana ): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET VotingFairyRecoveryValue = ${fairyRecoveryMana.recoveryMana} WHERE uuid = ${uuid.toString}" + sql"UPDATE vote_fairy SET fairy_recovery_mana_value = ${fairyRecoveryMana.recoveryMana} WHERE uuid = ${uuid.toString}" .execute() .apply() } @@ -109,8 +109,8 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] = Sync[F].delay { DB.readOnly { implicit session => val recoveryMana = - sql"SELECT VotingFairyRecoveryValue FROM playerdata WHERE uuid = ${uuid.toString}" - .map(_.int("VotingFairyRecoveryValue")) + sql"SELECT fairy_recovery_mana_value FROM vote_fairy WHERE uuid = ${uuid.toString}" + .map(_.int("fairy_recovery_mana_value")) .single() .apply() .get @@ -124,7 +124,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def updateFairyEndTime(uuid: UUID, fairyEndTime: FairyEndTime): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET newVotingFairyTime = ${fairyEndTime.endTimeOpt.get} WHERE uuid = ${uuid.toString}" + sql"UPDATE vote_fairy SET fairy_end_time = ${fairyEndTime.endTimeOpt.get} WHERE uuid = ${uuid.toString}" .execute() .apply() } @@ -135,8 +135,8 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { */ override def fairyEndTime(uuid: UUID): F[Option[FairyEndTime]] = Sync[F].delay { DB.readOnly { implicit session => - val dateOpt = sql"SELECT newVotingFairyTime FROM playerdata WHERE uuid = ${uuid.toString}" - .map(_.localDateTime("newVotingFairyTime")) + val dateOpt = sql"SELECT fairy_end_time FROM vote_fairy WHERE uuid = ${uuid.toString}" + .map(_.localDateTime("fairy_end_time")) .single() .apply() dateOpt.map { date => FairyEndTime(Some(date)) } @@ -149,7 +149,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def increaseAppleAteByFairy(uuid: UUID, appleAmount: AppleAmount): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET p_apple = p_apple + ${appleAmount.amount} WHERE uuid = ${uuid.toString}" + sql"UPDATE vote_fairy SET given_apple_amount = given_apple_amount + ${appleAmount.amount} WHERE uuid = ${uuid.toString}" .execute() .apply() } @@ -160,10 +160,11 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { */ override def appleAteByFairy(uuid: UUID): F[Option[AppleAmount]] = Sync[F].delay { DB.readOnly { implicit session => - val appleAmountOpt = sql"SELECT p_apple FROM playerdata WHERE uuid = ${uuid.toString}" - .map(_.int("p_apple")) - .single() - .apply() + val appleAmountOpt = + sql"SELECT given_apple_amount FROM vote_fairy WHERE uuid = ${uuid.toString}" + .map(_.int("given_apple_amount")) + .single() + .apply() appleAmountOpt.map(AppleAmount) } } @@ -174,12 +175,12 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def appleAteByFairyMyRanking(uuid: UUID): F[Option[AppleAteByFairyRank]] = Sync[F].delay { DB.readOnly { implicit session => - sql"SELECT name,p_apple,COUNT(*) AS rank FROM playerdata ORDER BY rank DESC;" + sql"SELECT name,given_apple_amount,COUNT(*) AS rank FROM vote_fairy ORDER BY rank DESC;" .map(rs => AppleAteByFairyRank( rs.string("name"), rs.int("rank"), - AppleAmount(rs.int("p_apple")) + AppleAmount(rs.int("given_apple_amount")) ) ) .single() @@ -196,8 +197,8 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { ): F[Vector[Option[AppleAteByFairyRank]]] = Sync[F].delay { DB.readOnly { implicit session => - sql"SELECT name,p_apple,COUNT(*) AS rank FROM playerdata ORDER BY rank DESC LIMIT $number;" - .map(rs => (rs.stringOpt("name"), rs.intOpt("rank"), rs.intOpt("p_apple"))) + sql"SELECT name,given_apple_amount,COUNT(*) AS rank FROM vote_fairy ORDER BY rank DESC LIMIT $number;" + .map(rs => (rs.stringOpt("name"), rs.intOpt("rank"), rs.intOpt("given_apple_amount"))) .toList() .apply() .map(data => @@ -214,7 +215,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { */ override def allEatenAppleAmount: F[AppleAmount] = Sync[F].delay { DB.readOnly { implicit session => - val amount = sql"SELECT SUM(p_apple) AS allAppleAmount FROM playerdata;" + val amount = sql"SELECT SUM(given_apple_amount) AS allAppleAmount FROM vote_fairy;" .map(_.int("allAppleAmount")) .single() .apply() @@ -229,7 +230,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def toggleFairySpeechSound(uuid: UUID, fairyPlaySound: Boolean): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE playerdata SET is_fairy_speech_play_sound = $fairyPlaySound WHERE uuid = ${uuid.toString}" + sql"UPDATE vote_fairy SET is_play_fairy_speech_sound = $fairyPlaySound WHERE uuid = ${uuid.toString}" .execute() .apply() } @@ -241,8 +242,8 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def fairySpeechSound(uuid: UUID): F[Boolean] = Sync[F].delay { DB.readOnly { implicit session => - sql"SELECT is_fairy_speech_play_sound FROM playerdata WHERE uuid=${uuid.toString}" - .map(_.boolean("is_fairy_speech_play_sound")) + sql"SELECT is_play_fairy_speech_sound FROM vote_fairy WHERE uuid=${uuid.toString}" + .map(_.boolean("is_play_fairy_speech_sound")) .single() .apply() .get From 1dd5cd3662f4f8877c9f20e15acaec0893f22470 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 16:26:42 +0900 Subject: [PATCH 168/482] =?UTF-8?q?fix:=20jdbcFairyPersistence=E3=82=92?= =?UTF-8?q?=E6=96=B0=E3=83=86=E3=83=BC=E3=83=96=E3=83=AB=E6=A7=8B=E9=80=A0?= =?UTF-8?q?=E3=81=AB=E5=90=88=E3=82=8F=E3=81=9B=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/menus/VoteMenu.scala | 2 +- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 5 +---- .../subsystems/vote/subsystems/fairy/System.scala | 3 +-- .../subsystems/fairy/domain/FairyPersistence.scala | 2 +- .../fairy/infrastructure/JdbcFairyPersistence.scala | 10 +++++++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index ed673ad067..246f028f86 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -344,7 +344,7 @@ object VoteMenu extends Menu { s"$RESET${DARK_GRAY}召喚されたらラッキーだよ!" ) ++ { // TOP4のランキングロール - val topFour = fairyAPI.appleAteByFairyRanking(player, 4).unsafeRunSync() + val topFour = fairyAPI.appleAteByFairyRanking(4).unsafeRunSync() List(topFour.headOption, topFour.lift(1), topFour.lift(2), topFour.lift(3)) .flatMap { rankDataOpt => if (rankDataOpt.nonEmpty) { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 05324d4a9d..2fae691a91 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -95,10 +95,7 @@ trait FairyReadAPI[F[_], G[_], Player] { /** * 妖精に食べさせたりんごの量の順位上`number`件を返す */ - def appleAteByFairyRanking( - player: Player, - number: Int - ): F[Vector[Option[AppleAteByFairyRank]]] + def appleAteByFairyRanking(number: Int): F[Vector[Option[AppleAteByFairyRank]]] /** * 妖精が食べたりんごの合計数を返す diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 9368d0f67e..d9d922cdf9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -125,10 +125,9 @@ object System { persistence.appleAteByFairyMyRanking(player.getUniqueId) override def appleAteByFairyRanking( - player: Player, number: Int ): IO[Vector[Option[AppleAteByFairyRank]]] = - persistence.appleAteByFairyRanking(player.getUniqueId, number) + persistence.appleAteByFairyRanking(number) override def allEatenAppleAmount: IO[AppleAmount] = persistence.allEatenAppleAmount diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index 58a7736605..ab3fe51b64 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -81,7 +81,7 @@ trait FairyPersistence[F[_]] { /** * 妖精に食べさせたりんごの量の順位上位`number`件を返す */ - def appleAteByFairyRanking(uuid: UUID, number: Int): F[Vector[Option[AppleAteByFairyRank]]] + def appleAteByFairyRanking(number: Int): F[Vector[Option[AppleAteByFairyRank]]] /** * 妖精が食べたりんごの合計数を返す diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index a6ee58d5a3..d3590fae93 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -175,7 +175,9 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def appleAteByFairyMyRanking(uuid: UUID): F[Option[AppleAteByFairyRank]] = Sync[F].delay { DB.readOnly { implicit session => - sql"SELECT name,given_apple_amount,COUNT(*) AS rank FROM vote_fairy ORDER BY rank DESC;" + sql"""SELECT (SELECT name FROM playerdata WHERE uuid = ${uuid.toString}),given_apple_amount,COUNT(*) AS rank + | FROM vote_fairy ORDER BY rank DESC WHERE uuid = ${uuid.toString};""" + .stripMargin .map(rs => AppleAteByFairyRank( rs.string("name"), @@ -192,12 +194,14 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { * 妖精に食べさせたりんごの量の順位上位`number`件を返す */ override def appleAteByFairyRanking( - uuid: UUID, number: Int ): F[Vector[Option[AppleAteByFairyRank]]] = Sync[F].delay { DB.readOnly { implicit session => - sql"SELECT name,given_apple_amount,COUNT(*) AS rank FROM vote_fairy ORDER BY rank DESC LIMIT $number;" + sql"""SELECT name,given_apple_amount,COUNT(*) AS rank FROM vote_fairy + | INNER JOIN playerdata ON (vote_fairy.uuid = playerdata.uuid) + | ORDER BY rank DESC LIMIT $number;""" + .stripMargin .map(rs => (rs.stringOpt("name"), rs.intOpt("rank"), rs.intOpt("given_apple_amount"))) .toList() .apply() From 11d4c66ea4f9b26820d2533a67f37ca4db3875d3 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 16:49:22 +0900 Subject: [PATCH 169/482] =?UTF-8?q?add:=20=E3=83=97=E3=83=AC=E3=82=A4?= =?UTF-8?q?=E3=83=A4=E3=83=BC=E5=8F=82=E5=8A=A0=E6=99=82=E3=81=AB=E3=83=87?= =?UTF-8?q?=E3=83=BC=E3=82=BF=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration/V2.0.3__Move_vote_fairy_column.sql | 14 +++++++------- .../vote/subsystems/fairy/FairyAPI.scala | 5 +++++ .../subsystems/vote/subsystems/fairy/System.scala | 6 ++++++ .../bukkit/listeners/FairyPlayerJoinGreeter.scala | 1 + .../subsystems/fairy/domain/FairyPersistence.scala | 5 +++++ .../infrastructure/JdbcFairyPersistence.scala | 13 ++++++++++--- 6 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql b/src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql index ccfdd3fee9..80263ed37f 100644 --- a/src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql +++ b/src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql @@ -2,13 +2,13 @@ USE seichiassist; CREATE TABLE vote_fairy( uuid CHAR(36) PRIMARY KEY, - apple_open_state INT, - fairy_summon_cost INT, - is_fairy_using BOOLEAN, - fairy_recovery_mana_value INT, - fairy_end_time DATETIME, - given_apple_amount BIGINT, - is_play_fairy_speech_sound BOOLEAN + apple_open_state INT DEFAULT 1, + fairy_summon_cost INT DEFAULT 1, + is_fairy_using BOOLEAN DEFAULT false, + fairy_recovery_mana_value INT DEFAULT 0, + fairy_end_time DATETIME DEFAULT NULL, + given_apple_amount BIGINT DEFAULT 0, + is_play_fairy_speech_sound BOOLEAN DEFAULT true ) INSERT INTO vote_fairy( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 2fae691a91..5a42dbe533 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -8,6 +8,11 @@ import java.util.UUID trait FairyWriteAPI[F[_], G[_], Player] { + /** + * プレイヤーデータを作成する + */ + def createPlayerData(uuid: UUID): F[Unit] + /** * 妖精にあげるりんごの開放状態を変更する */ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index d9d922cdf9..88ca8bd664 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -137,6 +137,12 @@ object System { override def toggleFairySpeechSound(uuid: UUID): IO[Unit] = persistence.toggleFairySpeechSound(uuid, !fairySpeechSound(uuid).unsafeRunSync()) + + /** + * プレイヤーデータを作成する + */ + override def createPlayerData(uuid: UUID): IO[Unit] = + persistence.createPlayerData(uuid) } override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index 3972cfff2d..456ecbfbb3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -17,6 +17,7 @@ class FairyPlayerJoinGreeter(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]) ex def onJoin(e: PlayerJoinEvent): Unit = { val player = e.getPlayer val eff = for { + _ <- fairyAPI.createPlayerData(player.getUniqueId) isUsing <- fairyAPI.isFairyUsing(player) endTime <- fairyAPI.fairyEndTime(player) } yield { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index ab3fe51b64..3a50814ca3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -13,6 +13,11 @@ import java.util.UUID trait FairyPersistence[F[_]] { + /** + * プレイヤーデータを作成する + */ + def createPlayerData(uuid: UUID): F[Unit] + /** * 妖精に開放するりんごの状態を変更する */ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index d3590fae93..65ccad1d8d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -9,6 +9,15 @@ import java.util.UUID class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { + /** + * プレイヤーデータを作成する + */ + def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { + DB.localTx { implicit session => + sql"INSERT IGNORE INTO vote_fairy uuid VALUES $uuid".execute().apply() + } + } + /** * 妖精に開放するりんごの状態を変更する */ @@ -193,9 +202,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { /** * 妖精に食べさせたりんごの量の順位上位`number`件を返す */ - override def appleAteByFairyRanking( - number: Int - ): F[Vector[Option[AppleAteByFairyRank]]] = + override def appleAteByFairyRanking(number: Int): F[Vector[Option[AppleAteByFairyRank]]] = Sync[F].delay { DB.readOnly { implicit session => sql"""SELECT name,given_apple_amount,COUNT(*) AS rank FROM vote_fairy From 2218d069a55b19688a8cc4c57b9a240fe7228618 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 16:55:34 +0900 Subject: [PATCH 170/482] =?UTF-8?q?fix:=20V2.0.3=E3=81=AE=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=83=9F=E3=82=B9=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/db/migration/V2.0.3__Move_vote_fairy_column.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql b/src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql index 80263ed37f..b9d6b3fc50 100644 --- a/src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql +++ b/src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql @@ -9,7 +9,8 @@ CREATE TABLE vote_fairy( fairy_end_time DATETIME DEFAULT NULL, given_apple_amount BIGINT DEFAULT 0, is_play_fairy_speech_sound BOOLEAN DEFAULT true -) +); + INSERT INTO vote_fairy( uuid, From 54ce4432538d29d16a8a64ec7b90122b520d268d Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 16:56:11 +0900 Subject: [PATCH 171/482] =?UTF-8?q?fix:=20createPlayerData=E3=81=AEuuid?= =?UTF-8?q?=E3=82=92String=E3=81=AB=E3=81=97=E3=81=A6=E3=81=84=E3=81=AA?= =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=9F=E3=81=AE=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/infrastructure/JdbcFairyPersistence.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 65ccad1d8d..8934fecb3d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -14,7 +14,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { */ def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"INSERT IGNORE INTO vote_fairy uuid VALUES $uuid".execute().apply() + sql"INSERT IGNORE INTO vote_fairy uuid VALUES ${uuid.toString}".execute().apply() } } From dc56f7ae6ddf055e8bae8f1da8861a32b024cb20 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 4 Aug 2022 18:10:10 +0900 Subject: [PATCH 172/482] fix: sql --- .../infrastructure/JdbcFairyPersistence.scala | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 8934fecb3d..b4567b212d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -14,7 +14,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { */ def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"INSERT IGNORE INTO vote_fairy uuid VALUES ${uuid.toString}".execute().apply() + sql"INSERT IGNORE INTO vote_fairy (uuid) VALUES (${uuid.toString})".execute().apply() } } @@ -184,18 +184,23 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def appleAteByFairyMyRanking(uuid: UUID): F[Option[AppleAteByFairyRank]] = Sync[F].delay { DB.readOnly { implicit session => - sql"""SELECT (SELECT name FROM playerdata WHERE uuid = ${uuid.toString}),given_apple_amount,COUNT(*) AS rank - | FROM vote_fairy ORDER BY rank DESC WHERE uuid = ${uuid.toString};""" + sql"""SELECT vote_fairy.uuid AS uuid,name,given_apple_amount,COUNT(*) AS rank + | FROM vote_fairy + | INNER JOIN playerdata + | ON (playerdata.uuid = vote_fairy.uuid) + | ORDER BY rank DESC;""" .stripMargin .map(rs => - AppleAteByFairyRank( + rs.string("uuid") -> AppleAteByFairyRank( rs.string("name"), rs.int("rank"), AppleAmount(rs.int("given_apple_amount")) ) ) - .single() + .toList() .apply() + .find(_._1 == uuid.toString) + .map(_._2) } } From ed6babc5c7f18595163e7cf6401bb85b0eb8853f Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 20 Aug 2022 21:40:51 +0900 Subject: [PATCH 173/482] =?UTF-8?q?fix:=20=E3=83=9E=E3=82=A4=E3=82=B0?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E3=81=AE=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E8=A1=A8=E8=A8=98=E3=82=92=E6=B2=BB=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...airy_time_type.sql => V1.11.0__Change_new_fairy_time_type.sql} | 0 ....0.1__Add_fairy_columns.sql => V1.11.1__Add_fairy_columns.sql} | 0 ...V2.0.2__Move_vote_column.sql => V1.11.2__Move_vote_column.sql} | 0 ..._vote_fairy_column.sql => V1.11.3__Move_vote_fairy_column.sql} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V2.0.0__Change_new_fairy_time_type.sql => V1.11.0__Change_new_fairy_time_type.sql} (100%) rename src/main/resources/db/migration/{V2.0.1__Add_fairy_columns.sql => V1.11.1__Add_fairy_columns.sql} (100%) rename src/main/resources/db/migration/{V2.0.2__Move_vote_column.sql => V1.11.2__Move_vote_column.sql} (100%) rename src/main/resources/db/migration/{V2.0.3__Move_vote_fairy_column.sql => V1.11.3__Move_vote_fairy_column.sql} (100%) diff --git a/src/main/resources/db/migration/V2.0.0__Change_new_fairy_time_type.sql b/src/main/resources/db/migration/V1.11.0__Change_new_fairy_time_type.sql similarity index 100% rename from src/main/resources/db/migration/V2.0.0__Change_new_fairy_time_type.sql rename to src/main/resources/db/migration/V1.11.0__Change_new_fairy_time_type.sql diff --git a/src/main/resources/db/migration/V2.0.1__Add_fairy_columns.sql b/src/main/resources/db/migration/V1.11.1__Add_fairy_columns.sql similarity index 100% rename from src/main/resources/db/migration/V2.0.1__Add_fairy_columns.sql rename to src/main/resources/db/migration/V1.11.1__Add_fairy_columns.sql diff --git a/src/main/resources/db/migration/V2.0.2__Move_vote_column.sql b/src/main/resources/db/migration/V1.11.2__Move_vote_column.sql similarity index 100% rename from src/main/resources/db/migration/V2.0.2__Move_vote_column.sql rename to src/main/resources/db/migration/V1.11.2__Move_vote_column.sql diff --git a/src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql b/src/main/resources/db/migration/V1.11.3__Move_vote_fairy_column.sql similarity index 100% rename from src/main/resources/db/migration/V2.0.3__Move_vote_fairy_column.sql rename to src/main/resources/db/migration/V1.11.3__Move_vote_fairy_column.sql From 278c8ac2aceb9d5499453b96642dd61ccb59ff97 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 20 Aug 2022 21:43:57 +0900 Subject: [PATCH 174/482] =?UTF-8?q?refactor:=20ReceiveVoteBenefits?= =?UTF-8?q?=E3=81=AEimplicit=E5=BC=95=E6=95=B0=E3=82=92=E6=8E=92=E9=99=A4?= =?UTF-8?q?=E3=81=97=E3=80=81=E5=AE=9F=E8=A3=85=E5=81=B4=E3=81=AB=E8=AD=B2?= =?UTF-8?q?=E6=B8=A1=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 13 +---- .../actions/ReceiveVoteBenefits.scala | 7 +-- .../actions/BukkitReceiveVoteBenefits.scala | 57 +++++++++---------- 3 files changed, 31 insertions(+), 46 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 246f028f86..3aab1a2d56 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -21,15 +21,8 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applicat import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequest -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{ - AlreadyFairySpawned, - NotEnoughEffectPoint, - NotEnoughSeichiLevel -} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - AppleOpenStateDependency, - FairySummonCost -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{AlreadyFairySpawned, NotEnoughEffectPoint, NotEnoughSeichiLevel} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{AppleOpenStateDependency, FairySummonCost} import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.player.PlayerEffects.closeInventoryEffect @@ -136,7 +129,7 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( TargetedEffect.delay { player => - BukkitReceiveVoteBenefits[IO, SyncIO].receive(player).unsafeRunSync() + new BukkitReceiveVoteBenefits[IO, SyncIO].receive(player).unsafeRunSync() }, MessageEffect( s"${GOLD}投票特典$WHITE(${voteCounter.value - benefits.value}票分)を受け取りました" diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala index fba8d39447..262be00bd5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala @@ -1,13 +1,8 @@ package com.github.unchama.seichiassist.subsystems.vote.application.actions -import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI -import com.github.unchama.seichiassist.subsystems.vote.VoteAPI - trait ReceiveVoteBenefits[F[_], G[_], Player] { - def receive( - player: Player - )(implicit voteAPI: VoteAPI[F, Player], breakCountAPI: BreakCountAPI[F, G, Player]): F[Unit] + def receive(player: Player): F[Unit] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 370e9f4c8e..2d7690a537 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -12,44 +12,41 @@ import com.github.unchama.seichiassist.subsystems.vote.application.actions.Recei import com.github.unchama.seichiassist.util.InventoryOperations.grantItemStacksEffect import org.bukkit.entity.Player -object BukkitReceiveVoteBenefits { +class BukkitReceiveVoteBenefits[F[_]: OnMinecraftServerThread: ConcurrentEffect: Applicative, G[ + _ +]: SyncEffect: ContextCoercion[*[_], F]]( + implicit voteAPI: VoteAPI[F, Player], + breakCountAPI: BreakCountAPI[F, G, Player] +) extends ReceiveVoteBenefits[F, G, Player] { import cats.implicits._ /** * 投票特典を配布する */ - def apply[F[_]: OnMinecraftServerThread: ConcurrentEffect: Applicative, G[ - _ - ]: SyncEffect: ContextCoercion[*[_], F]]: ReceiveVoteBenefits[F, G, Player] = - new ReceiveVoteBenefits[F, G, Player] { - override def receive(player: Player)( - implicit voteAPI: VoteAPI[F, Player], - breakCountAPI: BreakCountAPI[F, G, Player] - ): F[Unit] = { - val uuid = player.getUniqueId - for { - notReceivedBenefits <- voteAPI.restVoteBenefits(uuid) - _ <- voteAPI.increaseVoteBenefits(uuid, notReceivedBenefits) // 受け取ってない分を受け取ったことにする - _ <- Applicative[F].whenA(notReceivedBenefits.value != 0) { - val playerLevel = - ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read.map { - _.levelCorrespondingToExp.level - }).toIO.unsafeRunSync() + override def receive(player: Player): F[Unit] = { + val uuid = player.getUniqueId + for { + notReceivedBenefits <- voteAPI.restVoteBenefits(uuid) + _ <- voteAPI.increaseVoteBenefits(uuid, notReceivedBenefits) // 受け取ってない分を受け取ったことにする + _ <- Applicative[F].whenA(notReceivedBenefits.value != 0) { + val playerLevel = + ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read.map { + _.levelCorrespondingToExp.level + }).toIO.unsafeRunSync() - val items = (0 until notReceivedBenefits.value).map { _ => - ContextCoercion(voteAPI.increaseEffectPointsByTen(uuid)).toIO.unsafeRunSync() - Seq.fill(10)(GachaSkullData.gachaForVoting) ++ - Seq( - if (playerLevel < 50) ItemData.getSuperPickaxe(1) - else ItemData.getVotingGift(1) - ) - } + val items = (0 until notReceivedBenefits.value).map { _ => + ContextCoercion(voteAPI.increaseEffectPointsByTen(uuid)).toIO.unsafeRunSync() + Seq.fill(10)(GachaSkullData.gachaForVoting) ++ + Seq( + if (playerLevel < 50) ItemData.getSuperPickaxe(1) + else ItemData.getVotingGift(1) + ) + } - grantItemStacksEffect[F](items.flatten: _*).apply(player) - } - } yield () + grantItemStacksEffect[F](items.flatten: _*).apply(player) } - } + } yield () + } } From 2cf5cb8f8f02fb8131557c807dd4c98153a38cf2 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 20 Aug 2022 21:50:27 +0900 Subject: [PATCH 175/482] =?UTF-8?q?refactor:=20FairyRoutine=E3=81=AEimplic?= =?UTF-8?q?it=E5=BC=95=E6=95=B0=E3=82=92=E5=AE=9F=E8=A3=85=E5=81=B4?= =?UTF-8?q?=E3=81=AB=E8=AD=B2=E6=B8=A1=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 5 +++-- .../application/actions/FairyRoutine.scala | 14 +------------- .../bukkit/routines/BukkitFairyRoutine.scala | 17 +++++++++-------- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 88ca8bd664..88e6be63c8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -45,8 +45,6 @@ object System { val persistence = new JdbcFairyPersistence[IO] implicit val fairySpeechGatewayProvider: Player => FairySpeechGateway[SyncIO] = new BukkitFairySpeechGateway[SyncIO](_) - implicit val fairyRoutine: FairyRoutine[IO, SyncIO, Player] = - new BukkitFairyRoutine for { speechServiceRepositoryControls <- BukkitRepositoryControls.createHandles( @@ -145,6 +143,9 @@ object System { persistence.createPlayerData(uuid) } + implicit val fairyRoutine: FairyRoutine[IO, SyncIO, Player] = + new BukkitFairyRoutine + override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = { BukkitRepositoryControls .createHandles( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala index cfb945920a..5854f9b20f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala @@ -1,19 +1,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions -import com.github.unchama.concurrent.RepeatingTaskContext -import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI -import com.github.unchama.seichiassist.subsystems.mana.ManaApi -import com.github.unchama.seichiassist.subsystems.vote.VoteAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI - trait FairyRoutine[F[_], G[_], Player] { - def start(player: Player)( - implicit breakCountAPI: BreakCountAPI[F, G, Player], - fairyAPI: FairyAPI[F, G, Player], - voteAPI: VoteAPI[F, Player], - manaApi: ManaApi[F, G, Player], - context: RepeatingTaskContext - ): F[Nothing] + def start(player: Player): F[Nothing] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index 954024bba7..543be0288a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -14,14 +14,15 @@ import org.bukkit.entity.Player import scala.concurrent.duration.FiniteDuration -class BukkitFairyRoutine extends FairyRoutine[IO, SyncIO, Player] { - override def start(player: Player)( - implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], - fairyAPI: FairyAPI[IO, SyncIO, Player], - voteAPI: VoteAPI[IO, Player], - manaApi: ManaApi[IO, SyncIO, Player], - context: RepeatingTaskContext - ): IO[Nothing] = { +class BukkitFairyRoutine( + implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], + fairyAPI: FairyAPI[IO, SyncIO, Player], + voteAPI: VoteAPI[IO, Player], + manaApi: ManaApi[IO, SyncIO, Player], + context: RepeatingTaskContext +) extends FairyRoutine[IO, SyncIO, Player] { + + override def start(player: Player): IO[Nothing] = { val repeatInterval: IO[FiniteDuration] = IO { import scala.concurrent.duration._ From 2601a90cef5f8f59330977690dfcbab5c71f7753 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 20 Aug 2022 22:18:48 +0900 Subject: [PATCH 176/482] =?UTF-8?q?refactor:=20BukkitReceiveVoteBenefits?= =?UTF-8?q?=E3=81=AE=E5=87=A6=E7=90=86=E3=82=92=E7=B0=A1=E7=95=A5=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/BukkitReceiveVoteBenefits.scala | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 2d7690a537..34041b4998 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -1,7 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.bukkit.actions import cats.Applicative -import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import cats.effect.{ConcurrentEffect, SyncEffect} import com.github.unchama.generic.ContextCoercion import com.github.unchama.minecraft.actions.OnMinecraftServerThread @@ -29,23 +28,20 @@ class BukkitReceiveVoteBenefits[F[_]: OnMinecraftServerThread: ConcurrentEffect: for { notReceivedBenefits <- voteAPI.restVoteBenefits(uuid) _ <- voteAPI.increaseVoteBenefits(uuid, notReceivedBenefits) // 受け取ってない分を受け取ったことにする - _ <- Applicative[F].whenA(notReceivedBenefits.value != 0) { - val playerLevel = - ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read.map { - _.levelCorrespondingToExp.level - }).toIO.unsafeRunSync() - - val items = (0 until notReceivedBenefits.value).map { _ => - ContextCoercion(voteAPI.increaseEffectPointsByTen(uuid)).toIO.unsafeRunSync() - Seq.fill(10)(GachaSkullData.gachaForVoting) ++ - Seq( - if (playerLevel < 50) ItemData.getSuperPickaxe(1) - else ItemData.getVotingGift(1) - ) - } - - grantItemStacksEffect[F](items.flatten: _*).apply(player) - } + playerLevel <- ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read.map { + _.levelCorrespondingToExp.level + }) + items = + Seq.fill(10 * notReceivedBenefits.value)(GachaSkullData.gachaForVoting) ++ + Seq.fill(notReceivedBenefits.value)( + if (playerLevel < 50) ItemData.getSuperPickaxe(1) + else ItemData.getVotingGift(1) + ) + _ <- { + ContextCoercion(voteAPI.increaseEffectPointsByTen(uuid)) + .replicateA(notReceivedBenefits.value) >> + grantItemStacksEffect[F](items: _*).apply(player) + }.whenA(notReceivedBenefits.value != 0) } yield () } From c049ee7c3e968f6070d2af1ba06a4ebaa501bad3 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 20 Aug 2022 22:32:49 +0900 Subject: [PATCH 177/482] =?UTF-8?q?refactor:=20=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E5=9E=8B=E3=83=91=E3=83=A9=E3=83=A1=E3=83=BC=E3=82=BF=E3=81=AE?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/bukkit/actions/BukkitReceiveVoteBenefits.scala | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 34041b4998..93d03d253f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -1,7 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.bukkit.actions -import cats.Applicative -import cats.effect.{ConcurrentEffect, SyncEffect} +import cats.effect.{Sync, SyncEffect} import com.github.unchama.generic.ContextCoercion import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.data.{GachaSkullData, ItemData} @@ -11,7 +10,7 @@ import com.github.unchama.seichiassist.subsystems.vote.application.actions.Recei import com.github.unchama.seichiassist.util.InventoryOperations.grantItemStacksEffect import org.bukkit.entity.Player -class BukkitReceiveVoteBenefits[F[_]: OnMinecraftServerThread: ConcurrentEffect: Applicative, G[ +class BukkitReceiveVoteBenefits[F[_]: OnMinecraftServerThread: Sync, G[ _ ]: SyncEffect: ContextCoercion[*[_], F]]( implicit voteAPI: VoteAPI[F, Player], From 588390f914f0c6b42e6f949f924e2eb202d3c34e Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 20 Aug 2022 22:38:17 +0900 Subject: [PATCH 178/482] refactor: Scalafmt --- .../github/unchama/seichiassist/menus/VoteMenu.scala | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 3aab1a2d56..30f9f6186a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -21,8 +21,15 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applicat import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequest -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{AlreadyFairySpawned, NotEnoughEffectPoint, NotEnoughSeichiLevel} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{AppleOpenStateDependency, FairySummonCost} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{ + AlreadyFairySpawned, + NotEnoughEffectPoint, + NotEnoughSeichiLevel +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + AppleOpenStateDependency, + FairySummonCost +} import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.player.PlayerEffects.closeInventoryEffect From 2cb4802770c4ecc232ab18ab12a3f4290af3dfb4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 17 Oct 2022 22:32:44 +0900 Subject: [PATCH 179/482] =?UTF-8?q?refactor:=20=E6=B6=88=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84=E8=AA=AD=E3=81=BF=E8=BE=BC?= =?UTF-8?q?=E3=81=BF(p=5Fvote)=E3=82=92=E5=89=8A=E9=99=A4=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/seichiassist/task/PlayerDataLoading.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala b/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala index 33a5413297..4839a83c8c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala +++ b/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala @@ -226,7 +226,6 @@ object PlayerDataLoading { playerData.totalexp = rs.getInt("totalexp") // 実績、二つ名の情報 - playerData.p_vote_forT = rs.getInt("p_vote") playerData.giveachvNo = rs.getInt("giveachvNo") playerData.achievePoint = AchievementPoint( rs.getInt("achvPointMAX"), From efe0bcbbbc8877068be2b7c89310aa894faf47bd Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 17 Oct 2022 22:39:29 +0900 Subject: [PATCH 180/482] =?UTF-8?q?docs:=20voteSystem=E3=82=92public?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=81=A6TODO=E3=82=B3=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=82=92=E6=AE=8B=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scala/com/github/unchama/seichiassist/SeichiAssist.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 8a805a9711..d70e5dae1d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -385,7 +385,8 @@ class SeichiAssist extends JavaPlugin() { private lazy val sharedInventorySystem: subsystems.sharedinventory.System[IO] = subsystems.sharedinventory.System.wired[IO] - private lazy val voteSystem: subsystems.vote.System[IO, Player] = + // TODO: これはprivateであるべきだが、Achievementシステムが再実装されるまでやむを得ずpublicにする + lazy val voteSystem: subsystems.vote.System[IO, Player] = subsystems.vote.System.wired[IO] private lazy val fairySystem: subsystems.vote.subsystems.fairy.System[IO, SyncIO, Player] = { From a857f6dd5b7b0a27a5f9bf198ae40f5b410127f5 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 17 Oct 2022 22:45:38 +0900 Subject: [PATCH 181/482] =?UTF-8?q?docs:=20p=5Fvote=5Ffor=5FT=E3=81=ABTODO?= =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92=E6=AE=8B=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/data/player/PlayerData.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala index f4397a960e..6ef25f03f9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala +++ b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala @@ -105,7 +105,8 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { var TitleFlags: mutable.BitSet = new mutable.BitSet(10001) // 二つ名関連用にp_vote(投票数)を引っ張る。(予期せぬエラー回避のため名前を複雑化) - var p_vote_forT = 0 + // TODO: Achievementシステムが再実装させたら速攻でこれを消すべき + var p_vote_forT = SeichiAssist.instance.voteSystem.api.voteCounter(uuid).unsafeRunSync().value // 二つ名配布予約NOの保存 var giveachvNo = 0 // 実績ポイント用 From 8fb8e7bce4d92aabb1c8f05742ac0b8842a14cd0 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 17 Oct 2022 22:48:23 +0900 Subject: [PATCH 182/482] =?UTF-8?q?style:=20=E5=9E=8B=E3=82=92=E6=98=8E?= =?UTF-8?q?=E8=A8=98=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/data/player/PlayerData.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala index 6ef25f03f9..32dc3acd2c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala +++ b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala @@ -106,7 +106,7 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { // 二つ名関連用にp_vote(投票数)を引っ張る。(予期せぬエラー回避のため名前を複雑化) // TODO: Achievementシステムが再実装させたら速攻でこれを消すべき - var p_vote_forT = SeichiAssist.instance.voteSystem.api.voteCounter(uuid).unsafeRunSync().value + var p_vote_forT: Int = SeichiAssist.instance.voteSystem.api.voteCounter(uuid).unsafeRunSync().value // 二つ名配布予約NOの保存 var giveachvNo = 0 // 実績ポイント用 From 286ea1c828d0b1ec57d2cff795849c0dcb624c7e Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 21 Oct 2022 23:25:50 +0900 Subject: [PATCH 183/482] =?UTF-8?q?fix:=20convertEffectPointToAchivePoint?= =?UTF-8?q?=E3=81=AEF=E3=82=92=E6=8D=A8=E3=81=A6=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=81=9F=E3=81=AE=E3=81=A7=E4=BD=BF=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/data/player/PlayerData.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala index 0ff94482bb..6ce7ca0a1d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala +++ b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala @@ -303,7 +303,7 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { def convertEffectPointToAchievePoint(implicit voteAPI: VoteAPI[IO, Player]): Unit = { achievePoint = achievePoint.copy(conversionCount = achievePoint.conversionCount + 1) - voteAPI.decreaseEffectPoint(uuid, EffectPoint(10)) + voteAPI.decreaseEffectPoint(uuid, EffectPoint(10)).unsafeRunAsyncAndForget() } // パッシブスキルの獲得量表示 From 76cc282161c42e1c01eadb58d72bdf4d8399cc65 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 21 Oct 2022 23:27:35 +0900 Subject: [PATCH 184/482] docs: typo --- .../github/unchama/seichiassist/data/player/PlayerData.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala index 6ce7ca0a1d..6387dedbec 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala +++ b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala @@ -105,7 +105,7 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { var TitleFlags: mutable.BitSet = new mutable.BitSet(10001) // 二つ名関連用にp_vote(投票数)を引っ張る。(予期せぬエラー回避のため名前を複雑化) - // TODO: Achievementシステムが再実装させたら速攻でこれを消すべき + // TODO: Achievementシステムが再実装されたら速攻でこれを消すべき var p_vote_forT: Int = SeichiAssist.instance.voteSystem.api.voteCounter(uuid).unsafeRunSync().value // 二つ名配布予約NOの保存 From 2d85241f4aa5c72c44907645779672e6d9c8398b Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 21:43:05 +0900 Subject: [PATCH 185/482] =?UTF-8?q?style:=20=E3=83=9E=E3=82=A4=E3=82=B0?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E3=81=AE=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=82=92=E6=9B=B4=E6=96=B0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...airy_time_type.sql => V1.13.0__Change_new_fairy_time_type.sql} | 0 ...11.1__Add_fairy_columns.sql => V1.13.1__Add_fairy_columns.sql} | 0 ...1.11.2__Move_vote_column.sql => V1.13.2__Move_vote_column.sql} | 0 ..._vote_fairy_column.sql => V1.13.3__Move_vote_fairy_column.sql} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V1.11.0__Change_new_fairy_time_type.sql => V1.13.0__Change_new_fairy_time_type.sql} (100%) rename src/main/resources/db/migration/{V1.11.1__Add_fairy_columns.sql => V1.13.1__Add_fairy_columns.sql} (100%) rename src/main/resources/db/migration/{V1.11.2__Move_vote_column.sql => V1.13.2__Move_vote_column.sql} (100%) rename src/main/resources/db/migration/{V1.11.3__Move_vote_fairy_column.sql => V1.13.3__Move_vote_fairy_column.sql} (100%) diff --git a/src/main/resources/db/migration/V1.11.0__Change_new_fairy_time_type.sql b/src/main/resources/db/migration/V1.13.0__Change_new_fairy_time_type.sql similarity index 100% rename from src/main/resources/db/migration/V1.11.0__Change_new_fairy_time_type.sql rename to src/main/resources/db/migration/V1.13.0__Change_new_fairy_time_type.sql diff --git a/src/main/resources/db/migration/V1.11.1__Add_fairy_columns.sql b/src/main/resources/db/migration/V1.13.1__Add_fairy_columns.sql similarity index 100% rename from src/main/resources/db/migration/V1.11.1__Add_fairy_columns.sql rename to src/main/resources/db/migration/V1.13.1__Add_fairy_columns.sql diff --git a/src/main/resources/db/migration/V1.11.2__Move_vote_column.sql b/src/main/resources/db/migration/V1.13.2__Move_vote_column.sql similarity index 100% rename from src/main/resources/db/migration/V1.11.2__Move_vote_column.sql rename to src/main/resources/db/migration/V1.13.2__Move_vote_column.sql diff --git a/src/main/resources/db/migration/V1.11.3__Move_vote_fairy_column.sql b/src/main/resources/db/migration/V1.13.3__Move_vote_fairy_column.sql similarity index 100% rename from src/main/resources/db/migration/V1.11.3__Move_vote_fairy_column.sql rename to src/main/resources/db/migration/V1.13.3__Move_vote_fairy_column.sql From cbb7bc8fbfc8c3866da5d430e4b3b8a245cd8a8f Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 21:44:55 +0900 Subject: [PATCH 186/482] =?UTF-8?q?style:=20V1.13.1=E3=81=AE=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E8=A6=8F=E5=89=87=E3=81=AB?= =?UTF-8?q?=E3=81=9D=E3=82=8F=E3=81=9B=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/db/migration/V1.13.1__Add_fairy_columns.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/db/migration/V1.13.1__Add_fairy_columns.sql b/src/main/resources/db/migration/V1.13.1__Add_fairy_columns.sql index df8a9c7128..a069af9e8b 100644 --- a/src/main/resources/db/migration/V1.13.1__Add_fairy_columns.sql +++ b/src/main/resources/db/migration/V1.13.1__Add_fairy_columns.sql @@ -1,3 +1,3 @@ -use seichiassist; +USE seichiassist; -ALTER TABLE playerdata ADD is_fairy_speech_play_sound BOOLEAN DEFAULT TRUE AFTER toggleVotingFairy ; +ALTER TABLE playerdata ADD is_fairy_speech_play_sound BOOLEAN DEFAULT TRUE AFTER toggleVotingFairy; From dd0fc1ea2d8819c4140dd0503c552f2e09375c63 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 21:46:09 +0900 Subject: [PATCH 187/482] =?UTF-8?q?style:=20V.1.13.0=E3=81=AE=E3=83=9E?= =?UTF-8?q?=E3=82=A4=E3=82=B0=E3=83=AC=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E8=A6=8F=E5=89=87?= =?UTF-8?q?=E3=81=AB=E3=81=9D=E3=82=8F=E3=81=9B=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V1.13.0__Change_new_fairy_time_type.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/db/migration/V1.13.0__Change_new_fairy_time_type.sql b/src/main/resources/db/migration/V1.13.0__Change_new_fairy_time_type.sql index 6644ab7048..27f32025fc 100644 --- a/src/main/resources/db/migration/V1.13.0__Change_new_fairy_time_type.sql +++ b/src/main/resources/db/migration/V1.13.0__Change_new_fairy_time_type.sql @@ -1,4 +1,4 @@ -use seichiassist; +USE seichiassist; -- 型を変えるので一度内容をリセットする UPDATE playerdata SET newVotingFairyTime = NULL; From e8e8b468bb4a414d2630a2bbd71ddd9bbe91ef5b Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 21:49:09 +0900 Subject: [PATCH 188/482] =?UTF-8?q?refactor:=20VoteMenu=E3=81=AEUnit?= =?UTF-8?q?=E3=82=92=E8=BF=94=E3=81=99=E3=82=82=E3=81=AE=E3=81=A7unsafeRun?= =?UTF-8?q?AsyncAndForget=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/menus/VoteMenu.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 30f9f6186a..572bc48293 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -136,7 +136,7 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( TargetedEffect.delay { player => - new BukkitReceiveVoteBenefits[IO, SyncIO].receive(player).unsafeRunSync() + new BukkitReceiveVoteBenefits[IO, SyncIO].receive(player).unsafeRunAsyncAndForget() }, MessageEffect( s"${GOLD}投票特典$WHITE(${voteCounter.value - benefits.value}票分)を受け取りました" @@ -202,7 +202,7 @@ object VoteMenu extends Menu { player.getUniqueId, FairySummonCost(fairySummonCost.value % 4 + 1) ) - .unsafeRunSync() + .unsafeRunAsyncAndForget() ) ) } @@ -226,7 +226,7 @@ object VoteMenu extends Menu { AppleOpenStateDependency .dependency(fairyAPI.appleOpenState(uuid).unsafeRunSync()) ) - .unsafeRunSync() + .unsafeRunAsyncAndForget() }, FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) ) @@ -254,7 +254,7 @@ object VoteMenu extends Menu { SequentialEffect( FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), UnfocusedEffect { - fairyAPI.toggleFairySpeechSound(player.getUniqueId).unsafeRunSync() + fairyAPI.toggleFairySpeechSound(player.getUniqueId).unsafeRunAsyncAndForget() } ) } @@ -296,7 +296,7 @@ object VoteMenu extends Menu { } case Right(process) => UnfocusedEffect { - process.unsafeRunSync() + process.unsafeRunAsyncAndForget() } }, closeInventoryEffect @@ -322,7 +322,7 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( UnfocusedEffect { - new FairySpeech[IO, SyncIO]().speechEndTime(player).unsafeRunSync() + new FairySpeech[IO, SyncIO]().speechEndTime(player).unsafeRunAsyncAndForget() }, closeInventoryEffect ) From 2779a1b84c0cb57611ddb7e62820cd05b9dc0e87 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 22:00:08 +0900 Subject: [PATCH 189/482] style: FairySpeech -> BukkitFairySpeech --- .../com/github/unchama/seichiassist/menus/VoteMenu.scala | 4 ++-- .../bukkit/{FairySpeech.scala => BukkitFairySpeech.scala} | 2 +- .../fairy/bukkit/actions/BukkitRecoveryMana.scala | 8 ++++---- .../fairy/bukkit/actions/BukkitSummonFairy.scala | 4 ++-- .../fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/{FairySpeech.scala => BukkitFairySpeech.scala} (98%) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 572bc48293..ddf77b5784 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -18,7 +18,7 @@ import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequest import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{ @@ -322,7 +322,7 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( UnfocusedEffect { - new FairySpeech[IO, SyncIO]().speechEndTime(player).unsafeRunAsyncAndForget() + new BukkitFairySpeech[IO, SyncIO]().speechEndTime(player).unsafeRunAsyncAndForget() }, closeInventoryEffect ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala similarity index 98% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index 2a985f1db6..64dc65f532 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -10,7 +10,7 @@ import org.bukkit.entity.Player import java.time.LocalTime import scala.util.Random -class FairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( +class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( implicit fairyAPI: FairyAPI[F, G, Player] ) { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 7591c862ee..47f624d7a1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -8,7 +8,7 @@ import com.github.unchama.seichiassist.subsystems.mana.domain.ManaAmount import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.RecoveryMana -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleAmount, FairyAppleConsumeStrategy, @@ -44,7 +44,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] fairyEndTimeOpt <- fairyAPI.fairyEndTime(player) endTime = fairyEndTimeOpt.get.endTimeOpt.get _ <- { - new FairySpeech[F, G] + new BukkitFairySpeech[F, G] .bye(player) >> fairyAPI.updateIsFairyUsing(player, isFairyUsing = false) }.whenA( // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) @@ -54,7 +54,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] manaApi.readManaAmount(player) } _ <- { - new FairySpeech[F, G].speechRandomly(player, FairyManaRecoveryState.Full) + new BukkitFairySpeech[F, G].speechRandomly(player, FairyManaRecoveryState.Full) }.whenA(isFairyUsing && oldManaAmount.isFull) appleConsumptionAmount <- computeAppleConsumptionAmount @@ -80,7 +80,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] ContextCoercion( manaApi.manaAmount(player).restoreAbsolute(ManaAmount(recoveryManaAmount)) ) >> - new FairySpeech[F, G].speechRandomly( + new BukkitFairySpeech[F, G].speechRandomly( player, if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) FairyManaRecoveryState.NotConsumptionApple diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 934dd49ce2..5acfc4d124 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -7,7 +7,7 @@ import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyRecoveryManaAmount import com.github.unchama.targetedeffect.commandsender.MessageEffectF import org.bukkit.ChatColor._ @@ -34,7 +34,7 @@ class BukkitSummonFairy[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(fairySummonCost.value * 2)) _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryManaAmount) _ <- fairyAPI.updateFairyEndTime(player, fairySummonCost.endTime) - _ <- new FairySpeech[F, G].summonSpeech(player) + _ <- new BukkitFairySpeech[F, G].summonSpeech(player) _ <- MessageEffectF( List( s"$RESET$YELLOW${BOLD}妖精を呼び出しました!", diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index 456ecbfbb3..03ff89c317 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -3,7 +3,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit. import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySpeech import org.bukkit.ChatColor._ import org.bukkit.entity.Player import org.bukkit.event.player.PlayerJoinEvent @@ -31,7 +31,7 @@ class FairyPlayerJoinGreeter(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]) ex implicit val ioCE: ConcurrentEffect[IO] = IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) - new FairySpeech[IO, SyncIO]().welcomeBack(player).unsafeRunSync() + new BukkitFairySpeech[IO, SyncIO]().welcomeBack(player).unsafeRunSync() } } else SyncIO.unit } From dac46dfc2f620181d9ee8f6aacdc388643458ee6 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 22:06:56 +0900 Subject: [PATCH 190/482] =?UTF-8?q?feat:=20FairySpeech=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/domain/FairySpeech.scala | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeech.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeech.scala new file mode 100644 index 0000000000..e627fa09c9 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeech.scala @@ -0,0 +1,30 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +trait FairySpeech[F[_], Player] { + + /** + * @return 妖精が召喚された際のメッセージを[[Player]]に送信する作用 + */ + def summonSpeech(player: Player): F[Unit] + + /** + * @return 妖精のメッセージをランダムに[[Player]]へ送信する作用 + */ + def speechRandomly(player: Player): F[Unit] + + /** + * @return 妖精がいつ帰るのかを[[Player]]へ送信する作用 + */ + def speechEndTime(player: Player): F[Unit] + + /** + * @return 妖精召喚中に[[Player]]が再ログインした際のメッセージを[[Player]]に送信する作用 + */ + def welcomeBack(player: Player): F[Unit] + + /** + * @return 妖精が帰るときのメッセージを[[Player]]に送信する作用 + */ + def bye(player: Player): F[Unit] + +} From 55c86fe286b2be88d4e587f717093bbf56c2c460 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 22:09:49 +0900 Subject: [PATCH 191/482] =?UTF-8?q?fix:=20speechRandomly=E9=96=A2=E6=95=B0?= =?UTF-8?q?=E3=81=AE=E5=BC=95=E6=95=B0=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/bukkit/BukkitFairySpeech.scala | 13 +++++++------ .../vote/subsystems/fairy/domain/FairySpeech.scala | 7 +++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index 64dc65f532..cc6d9fc058 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -3,6 +3,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit import cats.effect.Sync import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.FairyMessageTable import org.bukkit.entity.Player @@ -12,11 +13,11 @@ import scala.util.Random class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( implicit fairyAPI: FairyAPI[F, G, Player] -) { +) extends FairySpeech[F, Player] { import cats.implicits._ - def summonSpeech(player: Player): F[Unit] = + override def summonSpeech(player: Player): F[Unit] = for { startHour <- Sync[F].delay(LocalTime.now().getHour) nameCalledByFairy = NameCalledByFairy(player.getName) @@ -38,7 +39,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( } } yield () - def speechRandomly( + override def speechRandomly( player: Player, fairyManaRecoveryState: FairyManaRecoveryState ): F[Unit] = { @@ -60,7 +61,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( } yield () } - def speechEndTime(player: Player): F[Unit] = { + override def speechEndTime(player: Player): F[Unit] = { for { endTimeOpt <- fairyAPI.fairyEndTime(player) playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) @@ -76,7 +77,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( } yield () } - def welcomeBack(player: Player): F[Unit] = for { + override def welcomeBack(player: Player): F[Unit] = for { playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) _ <- ContextCoercion { fairyAPI @@ -85,7 +86,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( } } yield () - def bye(player: Player): F[Unit] = for { + override def bye(player: Player): F[Unit] = for { playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) repository = fairyAPI.fairySpeechServiceRepository(player) _ <- ContextCoercion { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeech.scala index e627fa09c9..5dab825718 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeech.scala @@ -1,5 +1,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyManaRecoveryState + trait FairySpeech[F[_], Player] { /** @@ -8,9 +10,10 @@ trait FairySpeech[F[_], Player] { def summonSpeech(player: Player): F[Unit] /** - * @return 妖精のメッセージをランダムに[[Player]]へ送信する作用 + * @return [[FairyManaRecoveryState]]に応じた + * 妖精のメッセージをランダムに[[Player]]へ送信する作用 */ - def speechRandomly(player: Player): F[Unit] + def speechRandomly(player: Player, fairyManaRecoveryState: FairyManaRecoveryState): F[Unit] /** * @return 妖精がいつ帰るのかを[[Player]]へ送信する作用 From 3b7f1f19846f28866558fa1a5409171bf1bc63d7 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 22:13:21 +0900 Subject: [PATCH 192/482] =?UTF-8?q?feat:=20FairySpeechAPI=E3=81=ABspeechEn?= =?UTF-8?q?dTime=E3=82=92=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 5a42dbe533..14baf113eb 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -117,7 +117,7 @@ object FairyReadAPI { } -trait FairySpeechAPI[F[_]] { +trait FairySpeechAPI[F[_], Player] { /** * 妖精が喋るときに音をだすかをトグルする @@ -129,15 +129,21 @@ trait FairySpeechAPI[F[_]] { */ def fairySpeechSound(uuid: UUID): F[Boolean] + /** + * @return 妖精がいつ帰るのかを[[Player]]に送信する作用 + */ + def speechEndTime(player: Player): F[Unit] + } object FairySpeechAPI { - def apply[F[_]](implicit ev: FairySpeechAPI[F]): FairySpeechAPI[F] = ev + def apply[F[_], Player](implicit ev: FairySpeechAPI[F, Player]): FairySpeechAPI[F, Player] = + ev } trait FairyAPI[F[_], G[_], Player] extends FairyReadAPI[F, G, Player] with FairyWriteAPI[F, G, Player] - with FairySpeechAPI[F] + with FairySpeechAPI[F, Player] From dc565b6db95d72d4bb878f402389ce2b4d211c1a Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 22:13:57 +0900 Subject: [PATCH 193/482] =?UTF-8?q?docs:=20=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AE?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/subsystems/fairy/System.scala | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 88e6be63c8..7466fb2990 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -136,9 +136,6 @@ object System { override def toggleFairySpeechSound(uuid: UUID): IO[Unit] = persistence.toggleFairySpeechSound(uuid, !fairySpeechSound(uuid).unsafeRunSync()) - /** - * プレイヤーデータを作成する - */ override def createPlayerData(uuid: UUID): IO[Unit] = persistence.createPlayerData(uuid) } From fe990dd45a0e0654bf2f0ea1c469b70fcd9ba375 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 22:27:59 +0900 Subject: [PATCH 194/482] =?UTF-8?q?refactor:=20fairySpeechServiceRepositor?= =?UTF-8?q?y=E3=82=92=E5=AE=9F=E8=A3=85=E5=81=B4=E3=81=AB=E5=88=87?= =?UTF-8?q?=E3=82=8A=E5=87=BA=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/FairyAPI.scala | 4 ---- .../vote/subsystems/fairy/System.scala | 22 ++++++++----------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 14baf113eb..e7f3aa364e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -1,8 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy -import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import java.util.UUID @@ -85,8 +83,6 @@ trait FairyReadAPI[F[_], G[_], Player] { */ def appleAteByFairy(uuid: UUID): F[Option[AppleAmount]] - val fairySpeechServiceRepository: PlayerDataRepository[FairySpeechService[G]] - /** * 妖精が有効な時間を返す */ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 7466fb2990..79310160e9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -2,24 +2,19 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.concurrent.RepeatingTaskContext -import com.github.unchama.datarepository.bukkit.player.{ - BukkitRepositoryControls, - PlayerDataRepository -} +import com.github.unchama.datarepository.bukkit.player.{BukkitRepositoryControls, PlayerDataRepository} import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{ - FairyManaRecoveryRoutineFiberRepositoryDefinition, - SpeechServiceRepositoryDefinitions -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{FairyManaRecoveryRoutineFiberRepositoryDefinition, SpeechServiceRepositoryDefinitions} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairySpeech, FairySpeechGateway} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence @@ -46,6 +41,8 @@ object System { implicit val fairySpeechGatewayProvider: Player => FairySpeechGateway[SyncIO] = new BukkitFairySpeechGateway[SyncIO](_) + val fairySpeech: FairySpeech[IO, Player] = new BukkitFairySpeech[IO, IO] + for { speechServiceRepositoryControls <- BukkitRepositoryControls.createHandles( RepositoryDefinition @@ -55,6 +52,7 @@ object System { SpeechServiceRepositoryDefinitions.finalization[SyncIO, Player] ) ) + fairySpeechServiceRepository = speechServiceRepositoryControls.repository } yield { new System[IO, SyncIO, Player] { override implicit val api: FairyAPI[IO, SyncIO, Player] = @@ -104,10 +102,6 @@ object System { fairyRecoveryMana: FairyRecoveryMana ): IO[Unit] = persistence.updateFairyRecoveryMana(uuid, fairyRecoveryMana) - override val fairySpeechServiceRepository - : PlayerDataRepository[FairySpeechService[SyncIO]] = - speechServiceRepositoryControls.repository - override def increaseAppleAteByFairy( uuid: UUID, appleAmount: AppleAmount @@ -138,6 +132,8 @@ object System { override def createPlayerData(uuid: UUID): IO[Unit] = persistence.createPlayerData(uuid) + + override def speechEndTime(player: Player): IO[Unit] = } implicit val fairyRoutine: FairyRoutine[IO, SyncIO, Player] = From d06dbd87b7d54bec08905f1cbd19ffa95b16df1a Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 22:32:36 +0900 Subject: [PATCH 195/482] =?UTF-8?q?refactor:=20speechRepository=E3=81=AE?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E5=BC=95=E6=95=B0=E3=82=92=E5=8F=97?= =?UTF-8?q?=E3=81=91=E5=8F=96=E3=81=A3=E3=81=A6=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 2 -- .../fairy/bukkit/BukkitFairySpeech.scala | 24 +++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 79310160e9..f6a90cc3c1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -41,8 +41,6 @@ object System { implicit val fairySpeechGatewayProvider: Player => FairySpeechGateway[SyncIO] = new BukkitFairySpeechGateway[SyncIO](_) - val fairySpeech: FairySpeech[IO, Player] = new BukkitFairySpeech[IO, IO] - for { speechServiceRepositoryControls <- BukkitRepositoryControls.createHandles( RepositoryDefinition diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index cc6d9fc058..93011acc1c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -1,18 +1,21 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit import cats.effect.Sync +import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.FairyMessageTable +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player import java.time.LocalTime import scala.util.Random class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( - implicit fairyAPI: FairyAPI[F, G, Player] + implicit fairyAPI: FairyAPI[F, G, Player], + fairySpeechServiceRepository: PlayerDataRepository[FairySpeechService[G]] ) extends FairySpeech[F, Player] { import cats.implicits._ @@ -30,7 +33,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( FairyMessageTable.nightMessages(nameCalledByFairy) message <- randomMessage(fairyMessages) - serviceRepository = fairyAPI.fairySpeechServiceRepository(player) + serviceRepository = fairySpeechServiceRepository(player) fairySpeechSound <- ContextCoercion { fairyAPI.fairySpeechSound(player.getUniqueId) } @@ -56,7 +59,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( message <- randomMessage(messages(nameCalledByFairy)) fairyPlaySound <- fairyAPI.fairySpeechSound(player.getUniqueId) _ <- ContextCoercion { - fairyAPI.fairySpeechServiceRepository(player).makeSpeech(message, fairyPlaySound) + fairySpeechServiceRepository(player).makeSpeech(message, fairyPlaySound) } } yield () } @@ -67,12 +70,10 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) endTime = endTimeOpt.get.endTimeOpt.get _ <- ContextCoercion { - fairyAPI - .fairySpeechServiceRepository(player) - .makeSpeech( - FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。"), - playSound - ) + fairySpeechServiceRepository(player).makeSpeech( + FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。"), + playSound + ) } } yield () } @@ -80,15 +81,14 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( override def welcomeBack(player: Player): F[Unit] = for { playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) _ <- ContextCoercion { - fairyAPI - .fairySpeechServiceRepository(player) + fairySpeechServiceRepository(player) .makeSpeech(FairyMessage(s"おかえり!${player.getName}"), playSound) } } yield () override def bye(player: Player): F[Unit] = for { playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) - repository = fairyAPI.fairySpeechServiceRepository(player) + repository = fairySpeechServiceRepository(player) _ <- ContextCoercion { repository.makeSpeech(FairyMessage(s"あっ、もうこんな時間だ!"), fairyPlaySound = false) } >> ContextCoercion { From 41fd77de0ef7889212abe6a45073ce06e5a68484 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 22:36:35 +0900 Subject: [PATCH 196/482] =?UTF-8?q?refactor:=20BukkitFairySpeech=E3=81=A7A?= =?UTF-8?q?PI=E3=82=92=E5=8F=97=E3=81=91=E5=8F=96=E3=82=89=E3=81=9Apersist?= =?UTF-8?q?ence=E3=82=92=E5=8F=97=E3=81=91=E5=8F=96=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/BukkitFairySpeech.scala | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index 93011acc1c..27924eb798 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -3,10 +3,9 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit import cats.effect.Sync import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository import com.github.unchama.generic.ContextCoercion -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.FairyMessageTable +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpeech} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player @@ -14,8 +13,8 @@ import java.time.LocalTime import scala.util.Random class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( - implicit fairyAPI: FairyAPI[F, G, Player], - fairySpeechServiceRepository: PlayerDataRepository[FairySpeechService[G]] + implicit fairySpeechServiceRepository: PlayerDataRepository[FairySpeechService[G]], + fairyPersistence: FairyPersistence[F] ) extends FairySpeech[F, Player] { import cats.implicits._ @@ -35,7 +34,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( serviceRepository = fairySpeechServiceRepository(player) fairySpeechSound <- ContextCoercion { - fairyAPI.fairySpeechSound(player.getUniqueId) + fairyPersistence.fairySpeechSound(player.getUniqueId) } _ <- ContextCoercion { serviceRepository.makeSpeech(message, fairySpeechSound) @@ -57,7 +56,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( } for { message <- randomMessage(messages(nameCalledByFairy)) - fairyPlaySound <- fairyAPI.fairySpeechSound(player.getUniqueId) + fairyPlaySound <- fairyPersistence.fairySpeechSound(player.getUniqueId) _ <- ContextCoercion { fairySpeechServiceRepository(player).makeSpeech(message, fairyPlaySound) } @@ -66,8 +65,8 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( override def speechEndTime(player: Player): F[Unit] = { for { - endTimeOpt <- fairyAPI.fairyEndTime(player) - playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) + endTimeOpt <- fairyPersistence.fairyEndTime(player.getUniqueId) + playSound <- fairyPersistence.fairySpeechSound(player.getUniqueId) endTime = endTimeOpt.get.endTimeOpt.get _ <- ContextCoercion { fairySpeechServiceRepository(player).makeSpeech( @@ -79,7 +78,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( } override def welcomeBack(player: Player): F[Unit] = for { - playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) + playSound <- fairyPersistence.fairySpeechSound(player.getUniqueId) _ <- ContextCoercion { fairySpeechServiceRepository(player) .makeSpeech(FairyMessage(s"おかえり!${player.getName}"), playSound) @@ -87,7 +86,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( } yield () override def bye(player: Player): F[Unit] = for { - playSound <- fairyAPI.fairySpeechSound(player.getUniqueId) + playSound <- fairyPersistence.fairySpeechSound(player.getUniqueId) repository = fairySpeechServiceRepository(player) _ <- ContextCoercion { repository.makeSpeech(FairyMessage(s"あっ、もうこんな時間だ!"), fairyPlaySound = false) From ee4a0d84676f09ddf9e051bd0179099b90d77b57 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 22:40:06 +0900 Subject: [PATCH 197/482] =?UTF-8?q?feat:=20speechEndTime=E3=82=92API?= =?UTF-8?q?=E3=81=AB=E5=AE=9F=E8=A3=85=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index f6a90cc3c1..e80cf4369e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -2,21 +2,30 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.concurrent.RepeatingTaskContext -import com.github.unchama.datarepository.bukkit.player.{BukkitRepositoryControls, PlayerDataRepository} +import com.github.unchama.datarepository.bukkit.player.{ + BukkitRepositoryControls, + PlayerDataRepository +} import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{FairyManaRecoveryRoutineFiberRepositoryDefinition, SpeechServiceRepositoryDefinitions} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{ + FairyManaRecoveryRoutineFiberRepositoryDefinition, + SpeechServiceRepositoryDefinitions +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairySpeech, FairySpeechGateway} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + FairyPersistence, + FairySpeechGateway +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player @@ -37,7 +46,7 @@ object System { repeatingTaskContext: RepeatingTaskContext, concurrentEffect: ConcurrentEffect[IO] ): SyncIO[System[IO, SyncIO, Player]] = { - val persistence = new JdbcFairyPersistence[IO] + implicit val persistence: FairyPersistence[IO] = new JdbcFairyPersistence[IO] implicit val fairySpeechGatewayProvider: Player => FairySpeechGateway[SyncIO] = new BukkitFairySpeechGateway[SyncIO](_) @@ -50,11 +59,15 @@ object System { SpeechServiceRepositoryDefinitions.finalization[SyncIO, Player] ) ) - fairySpeechServiceRepository = speechServiceRepositoryControls.repository } yield { new System[IO, SyncIO, Player] { override implicit val api: FairyAPI[IO, SyncIO, Player] = new FairyAPI[IO, SyncIO, Player] { + implicit val fairySpeechServiceRepository + : PlayerDataRepository[FairySpeechService[SyncIO]] = + speechServiceRepositoryControls.repository + val fairySpeech = new BukkitFairySpeech[IO, SyncIO] + override def appleOpenState(uuid: UUID): IO[FairyAppleConsumeStrategy] = persistence.appleOpenState(uuid) @@ -132,6 +145,7 @@ object System { persistence.createPlayerData(uuid) override def speechEndTime(player: Player): IO[Unit] = + fairySpeech.speechEndTime(player) } implicit val fairyRoutine: FairyRoutine[IO, SyncIO, Player] = From 4ee1acd42c7a67080f57a113c9286cb50901be99 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 22:41:31 +0900 Subject: [PATCH 198/482] =?UTF-8?q?refactor:=20VoteMenu=E3=81=AEspeechEndT?= =?UTF-8?q?ime=E3=82=92API=E3=81=8B=E3=82=89=E6=8C=81=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=81=8F=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index ddf77b5784..1b0a408298 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -18,18 +18,10 @@ import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequest -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{ - AlreadyFairySpawned, - NotEnoughEffectPoint, - NotEnoughSeichiLevel -} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - AppleOpenStateDependency, - FairySummonCost -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{AlreadyFairySpawned, NotEnoughEffectPoint, NotEnoughSeichiLevel} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{AppleOpenStateDependency, FairySummonCost} import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.player.PlayerEffects.closeInventoryEffect @@ -136,7 +128,9 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( TargetedEffect.delay { player => - new BukkitReceiveVoteBenefits[IO, SyncIO].receive(player).unsafeRunAsyncAndForget() + new BukkitReceiveVoteBenefits[IO, SyncIO] + .receive(player) + .unsafeRunAsyncAndForget() }, MessageEffect( s"${GOLD}投票特典$WHITE(${voteCounter.value - benefits.value}票分)を受け取りました" @@ -322,7 +316,7 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( UnfocusedEffect { - new BukkitFairySpeech[IO, SyncIO]().speechEndTime(player).unsafeRunAsyncAndForget() + fairyAPI.speechEndTime(player).unsafeRunAsyncAndForget() }, closeInventoryEffect ) From babe8cc55ca0c2341b512d82675587b6b7535b05 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 22:45:10 +0900 Subject: [PATCH 199/482] =?UTF-8?q?refactor:=20BukkitRevoceryMana=E3=81=A7?= =?UTF-8?q?fairySpeech=E3=82=92=E7=9B=B4=E6=8E=A5=E5=8F=97=E3=81=91?= =?UTF-8?q?=E5=8F=96=E3=81=A3=E3=81=A6=E5=87=A6=E7=90=86=E3=82=92=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/actions/BukkitRecoveryMana.scala | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 47f624d7a1..0f59dc7617 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -8,12 +8,8 @@ import com.github.unchama.seichiassist.subsystems.mana.domain.ManaAmount import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.RecoveryMana -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySpeech -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - AppleAmount, - FairyAppleConsumeStrategy, - FairyManaRecoveryState -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{AppleAmount, FairyAppleConsumeStrategy, FairyManaRecoveryState} import com.github.unchama.seichiassist.{MineStackObjectList, SeichiAssist} import com.github.unchama.targetedeffect.SequentialEffect import com.github.unchama.targetedeffect.commandsender.MessageEffectF @@ -30,7 +26,8 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] implicit breakCountAPI: BreakCountAPI[F, G, Player], fairyAPI: FairyAPI[F, G, Player], voteAPI: VoteAPI[F, Player], - manaApi: ManaApi[F, G, Player] + manaApi: ManaApi[F, G, Player], + fairySpeech: FairySpeech[F, Player] ) extends RecoveryMana[F] { private val uuid: UUID = player.getUniqueId @@ -44,8 +41,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] fairyEndTimeOpt <- fairyAPI.fairyEndTime(player) endTime = fairyEndTimeOpt.get.endTimeOpt.get _ <- { - new BukkitFairySpeech[F, G] - .bye(player) >> fairyAPI.updateIsFairyUsing(player, isFairyUsing = false) + fairySpeech.bye(player) >> fairyAPI.updateIsFairyUsing(player, isFairyUsing = false) }.whenA( // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) isFairyUsing && endTime.isBefore(LocalDateTime.now()) @@ -54,7 +50,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] manaApi.readManaAmount(player) } _ <- { - new BukkitFairySpeech[F, G].speechRandomly(player, FairyManaRecoveryState.Full) + fairySpeech.speechRandomly(player, FairyManaRecoveryState.Full) }.whenA(isFairyUsing && oldManaAmount.isFull) appleConsumptionAmount <- computeAppleConsumptionAmount @@ -80,7 +76,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] ContextCoercion( manaApi.manaAmount(player).restoreAbsolute(ManaAmount(recoveryManaAmount)) ) >> - new BukkitFairySpeech[F, G].speechRandomly( + fairySpeech.speechRandomly( player, if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) FairyManaRecoveryState.NotConsumptionApple From a1ce91ea8c492da5e3afebf7a20fd02ed1c388cd Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 22:51:48 +0900 Subject: [PATCH 200/482] =?UTF-8?q?refactor:=20BukkitFairyRoutine=E3=81=AB?= =?UTF-8?q?fairySpeech=E3=82=92=E6=B8=A1=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/System.scala | 14 +++++++++----- .../fairy/bukkit/BukkitFairySpeech.scala | 7 +++++-- .../fairy/bukkit/routines/BukkitFairyRoutine.scala | 4 +++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index e80cf4369e..116ea9f937 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -24,6 +24,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ FairyPersistence, + FairySpeech, FairySpeechGateway } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence @@ -49,6 +50,9 @@ object System { implicit val persistence: FairyPersistence[IO] = new JdbcFairyPersistence[IO] implicit val fairySpeechGatewayProvider: Player => FairySpeechGateway[SyncIO] = new BukkitFairySpeechGateway[SyncIO](_) + val fairySpeechProvider + : PlayerDataRepository[FairySpeechService[SyncIO]] => FairySpeech[IO, Player] = + fairySpeechService => new BukkitFairySpeech[IO, SyncIO](fairySpeechService, persistence) for { speechServiceRepositoryControls <- BukkitRepositoryControls.createHandles( @@ -61,13 +65,13 @@ object System { ) } yield { new System[IO, SyncIO, Player] { + implicit val fairySpeechServiceRepository + : PlayerDataRepository[FairySpeechService[SyncIO]] = + speechServiceRepositoryControls.repository + implicit val fairySpeech: FairySpeech[IO, Player] = fairySpeechProvider(fairySpeechServiceRepository) + override implicit val api: FairyAPI[IO, SyncIO, Player] = new FairyAPI[IO, SyncIO, Player] { - implicit val fairySpeechServiceRepository - : PlayerDataRepository[FairySpeechService[SyncIO]] = - speechServiceRepositoryControls.repository - val fairySpeech = new BukkitFairySpeech[IO, SyncIO] - override def appleOpenState(uuid: UUID): IO[FairyAppleConsumeStrategy] = persistence.appleOpenState(uuid) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index 27924eb798..d19c4cac94 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -5,7 +5,10 @@ import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.FairyMessageTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpeech} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + FairyPersistence, + FairySpeech +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player @@ -13,7 +16,7 @@ import java.time.LocalTime import scala.util.Random class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( - implicit fairySpeechServiceRepository: PlayerDataRepository[FairySpeechService[G]], + fairySpeechServiceRepository: PlayerDataRepository[FairySpeechService[G]], fairyPersistence: FairyPersistence[F] ) extends FairySpeech[F, Player] { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index 543be0288a..146ffdfeec 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -10,6 +10,7 @@ import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitRecoveryMana +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeech import org.bukkit.entity.Player import scala.concurrent.duration.FiniteDuration @@ -19,7 +20,8 @@ class BukkitFairyRoutine( fairyAPI: FairyAPI[IO, SyncIO, Player], voteAPI: VoteAPI[IO, Player], manaApi: ManaApi[IO, SyncIO, Player], - context: RepeatingTaskContext + context: RepeatingTaskContext, + fairySpeech: FairySpeech[IO, Player] ) extends FairyRoutine[IO, SyncIO, Player] { override def start(player: Player): IO[Nothing] = { From 6f5b44b95a41f5d24b0631e53433ca7381b5ceba Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 23:02:03 +0900 Subject: [PATCH 201/482] =?UTF-8?q?refactor:=20BukkitFairyRoutine=E3=81=A7?= =?UTF-8?q?Persistence=E3=82=92=E5=8F=97=E3=81=91=E5=8F=96=E3=81=A3?= =?UTF-8?q?=E3=81=A6=E5=87=A6=E7=90=86=E3=82=92=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/actions/BukkitRecoveryMana.scala | 23 +++++++++---------- .../bukkit/routines/BukkitFairyRoutine.scala | 7 +++--- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 0f59dc7617..79c5bff135 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -6,10 +6,9 @@ import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.mana.domain.ManaAmount import com.github.unchama.seichiassist.subsystems.vote.VoteAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.RecoveryMana -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{AppleAmount, FairyAppleConsumeStrategy, FairyManaRecoveryState} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpeech} import com.github.unchama.seichiassist.{MineStackObjectList, SeichiAssist} import com.github.unchama.targetedeffect.SequentialEffect import com.github.unchama.targetedeffect.commandsender.MessageEffectF @@ -24,10 +23,10 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] player: Player )( implicit breakCountAPI: BreakCountAPI[F, G, Player], - fairyAPI: FairyAPI[F, G, Player], voteAPI: VoteAPI[F, Player], manaApi: ManaApi[F, G, Player], - fairySpeech: FairySpeech[F, Player] + fairySpeech: FairySpeech[F, Player], + fairyPersistence: FairyPersistence[F] ) extends RecoveryMana[F] { private val uuid: UUID = player.getUniqueId @@ -37,11 +36,11 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] override def recovery: F[Unit] = for { - isFairyUsing <- fairyAPI.isFairyUsing(player) - fairyEndTimeOpt <- fairyAPI.fairyEndTime(player) + isFairyUsing <- fairyPersistence.isFairyUsing(uuid) + fairyEndTimeOpt <- fairyPersistence.fairyEndTime(uuid) endTime = fairyEndTimeOpt.get.endTimeOpt.get _ <- { - fairySpeech.bye(player) >> fairyAPI.updateIsFairyUsing(player, isFairyUsing = false) + fairySpeech.bye(player) >> fairyPersistence.updateIsFairyUsing(uuid, isFairyUsing = false) }.whenA( // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) isFairyUsing && endTime.isBefore(LocalDateTime.now()) @@ -72,7 +71,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] ) _ <- { - fairyAPI.increaseAppleAteByFairy(uuid, AppleAmount(finallyAppleConsumptionAmount)) >> + fairyPersistence.increaseAppleAteByFairy(uuid, AppleAmount(finallyAppleConsumptionAmount)) >> ContextCoercion( manaApi.manaAmount(player).restoreAbsolute(ManaAmount(recoveryManaAmount)) ) >> @@ -100,7 +99,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] private def computeAppleConsumptionAmount: F[Int] = for { seichiAmountData <- ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read) chainVoteNumber <- voteAPI.chainVoteDayNumber(uuid) - appleOpenState <- fairyAPI.appleOpenState(uuid) + appleOpenState <- fairyPersistence.appleOpenState(uuid) oldManaAmount <- ContextCoercion { manaApi.readManaAmount(player) } @@ -149,7 +148,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] * がちゃりんごの消費量を計算します。 */ private def computeFinallyAppleConsumptionAmount(appleConsumptionAmount: Int): F[Int] = for { - appleOpenState <- fairyAPI.appleOpenState(uuid) + appleOpenState <- fairyPersistence.appleOpenState(uuid) gachaRingoObject <- LiftIO[F].liftIO { MineStackObjectList.findByName("gachaimo") } @@ -169,8 +168,8 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] * マナの回復量を計算します。 */ private def computeManaRecoveryAmount(appleConsumptionAmount: Int): F[Int] = for { - defaultRecoveryManaAmount <- fairyAPI.fairyRecoveryMana(uuid) - appleOpenState <- fairyAPI.appleOpenState(uuid) + defaultRecoveryManaAmount <- fairyPersistence.fairyRecoveryMana(uuid) + appleOpenState <- fairyPersistence.appleOpenState(uuid) oldManaAmount <- ContextCoercion { manaApi.readManaAmount(player) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index 146ffdfeec..8841689037 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -7,21 +7,20 @@ import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitRecoveryMana -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpeech} import org.bukkit.entity.Player import scala.concurrent.duration.FiniteDuration class BukkitFairyRoutine( implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], - fairyAPI: FairyAPI[IO, SyncIO, Player], voteAPI: VoteAPI[IO, Player], manaApi: ManaApi[IO, SyncIO, Player], context: RepeatingTaskContext, - fairySpeech: FairySpeech[IO, Player] + fairySpeech: FairySpeech[IO, Player], + fairyPersistence: FairyPersistence[IO] ) extends FairyRoutine[IO, SyncIO, Player] { override def start(player: Player): IO[Nothing] = { From 2b576d51c3539c44e0f21f17a6b7bc669077ea99 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 23:10:48 +0900 Subject: [PATCH 202/482] =?UTF-8?q?refactor:=20System=E3=81=AE=E5=AE=9F?= =?UTF-8?q?=E8=A3=85=E3=82=92=E3=81=BE=E3=81=A8=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 44 +++++++++---------- ...veryRoutineFiberRepositoryDefinition.scala | 7 +-- .../bukkit/routines/BukkitFairyRoutine.scala | 3 +- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 116ea9f937..6051e1ea3e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -11,7 +11,6 @@ import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{ FairyManaRecoveryRoutineFiberRepositoryDefinition, SpeechServiceRepositoryDefinitions @@ -63,12 +62,25 @@ object System { SpeechServiceRepositoryDefinitions.finalization[SyncIO, Player] ) ) + _fairyRoutine = new BukkitFairyRoutine( + fairySpeechProvider(speechServiceRepositoryControls.repository) + ) + fairyRecoveryRoutineFiberRepositoryControls <- BukkitRepositoryControls.createHandles( + RepositoryDefinition + .Phased + .TwoPhased( + FairyManaRecoveryRoutineFiberRepositoryDefinition + .initialization[Player](_fairyRoutine), + FairyManaRecoveryRoutineFiberRepositoryDefinition.finalization[SyncIO, Player] + ) + ) } yield { new System[IO, SyncIO, Player] { - implicit val fairySpeechServiceRepository - : PlayerDataRepository[FairySpeechService[SyncIO]] = + val fairySpeechServiceRepository: PlayerDataRepository[FairySpeechService[SyncIO]] = speechServiceRepositoryControls.repository - implicit val fairySpeech: FairySpeech[IO, Player] = fairySpeechProvider(fairySpeechServiceRepository) + val fairySpeech: FairySpeech[IO, Player] = fairySpeechProvider( + fairySpeechServiceRepository + ) override implicit val api: FairyAPI[IO, SyncIO, Player] = new FairyAPI[IO, SyncIO, Player] { @@ -152,25 +164,11 @@ object System { fairySpeech.speechEndTime(player) } - implicit val fairyRoutine: FairyRoutine[IO, SyncIO, Player] = - new BukkitFairyRoutine - - override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = { - BukkitRepositoryControls - .createHandles( - RepositoryDefinition - .Phased - .TwoPhased( - FairyManaRecoveryRoutineFiberRepositoryDefinition.initialization[Player], - FairyManaRecoveryRoutineFiberRepositoryDefinition.finalization[SyncIO, Player] - ) - ) - .map { fairyRecoveryRoutineFiberRepositoryControls => - Seq(speechServiceRepositoryControls, fairyRecoveryRoutineFiberRepositoryControls) - .map(_.coerceFinalizationContextTo[IO]) - } - .unsafeRunSync() - } + override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = + Seq(speechServiceRepositoryControls, fairyRecoveryRoutineFiberRepositoryControls).map( + _.coerceFinalizationContextTo[IO] + ) + override val listeners: Seq[Listener] = Seq(new FairyPlayerJoinGreeter) } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala index 6455ee9b32..a71a4b9a5c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala @@ -10,7 +10,6 @@ import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine object FairyManaRecoveryRoutineFiberRepositoryDefinition { @@ -18,10 +17,8 @@ object FairyManaRecoveryRoutineFiberRepositoryDefinition { implicit val ioCE: ConcurrentEffect[IO] = IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) - def initialization[Player]( - implicit fairyRoutine: FairyRoutine[IO, SyncIO, Player], - fairyAPI: FairyAPI[IO, SyncIO, Player], - breakCountAPI: BreakCountAPI[IO, SyncIO, Player], + def initialization[Player](fairyRoutine: FairyRoutine[IO, SyncIO, Player])( + implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], voteAPI: VoteAPI[IO, Player], manaApi: ManaApi[IO, SyncIO, Player], context: RepeatingTaskContext diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index 8841689037..109501bb5a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -14,12 +14,11 @@ import org.bukkit.entity.Player import scala.concurrent.duration.FiniteDuration -class BukkitFairyRoutine( +class BukkitFairyRoutine(fairySpeech: FairySpeech[IO, Player])( implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], voteAPI: VoteAPI[IO, Player], manaApi: ManaApi[IO, SyncIO, Player], context: RepeatingTaskContext, - fairySpeech: FairySpeech[IO, Player], fairyPersistence: FairyPersistence[IO] ) extends FairyRoutine[IO, SyncIO, Player] { From bc82566f13bbebd8552c4769d57b260fab120b66 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 23:32:42 +0900 Subject: [PATCH 203/482] =?UTF-8?q?refactor:=20FairyManaRecoveryRoutineFib?= =?UTF-8?q?erRepositoryDefinition=E3=81=AE=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E5=BC=95=E6=95=B0=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...airyManaRecoveryRoutineFiberRepositoryDefinition.scala | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala index a71a4b9a5c..1382782257 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala @@ -7,9 +7,6 @@ import com.github.unchama.datarepository.template.finalization.RepositoryFinaliz import com.github.unchama.datarepository.template.initialization.TwoPhasedRepositoryInitialization import com.github.unchama.generic.effect.EffectExtra import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts -import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI -import com.github.unchama.seichiassist.subsystems.mana.ManaApi -import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine object FairyManaRecoveryRoutineFiberRepositoryDefinition { @@ -18,10 +15,7 @@ object FairyManaRecoveryRoutineFiberRepositoryDefinition { IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) def initialization[Player](fairyRoutine: FairyRoutine[IO, SyncIO, Player])( - implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], - voteAPI: VoteAPI[IO, Player], - manaApi: ManaApi[IO, SyncIO, Player], - context: RepeatingTaskContext + implicit context: RepeatingTaskContext ): TwoPhasedRepositoryInitialization[SyncIO, Player, Deferred[IO, Fiber[IO, Nothing]]] = TwoPhasedRepositoryInitialization .withoutPrefetching[SyncIO, Player, Deferred[IO, Fiber[IO, Nothing]]] { player => From e064558879f7ac3906c405a1eb16a00d54cb418b Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 23:37:25 +0900 Subject: [PATCH 204/482] =?UTF-8?q?fix:=20BukkitRecoveryMana=E3=81=AB?= =?UTF-8?q?=E6=AD=A3=E3=81=97=E3=81=8F=E5=BC=95=E6=95=B0=E3=82=92=E6=B8=A1?= =?UTF-8?q?=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/actions/BukkitRecoveryMana.scala | 23 ++++++++++++++----- .../bukkit/routines/BukkitFairyRoutine.scala | 7 ++++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 79c5bff135..33c7ca00a7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -7,8 +7,15 @@ import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.mana.domain.ManaAmount import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.RecoveryMana -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{AppleAmount, FairyAppleConsumeStrategy, FairyManaRecoveryState} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpeech} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + AppleAmount, + FairyAppleConsumeStrategy, + FairyManaRecoveryState +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + FairyPersistence, + FairySpeech +} import com.github.unchama.seichiassist.{MineStackObjectList, SeichiAssist} import com.github.unchama.targetedeffect.SequentialEffect import com.github.unchama.targetedeffect.commandsender.MessageEffectF @@ -20,12 +27,12 @@ import java.util.UUID import scala.util.Random class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( - player: Player + player: Player, + fairySpeech: FairySpeech[F, Player] )( implicit breakCountAPI: BreakCountAPI[F, G, Player], voteAPI: VoteAPI[F, Player], manaApi: ManaApi[F, G, Player], - fairySpeech: FairySpeech[F, Player], fairyPersistence: FairyPersistence[F] ) extends RecoveryMana[F] { @@ -40,7 +47,8 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] fairyEndTimeOpt <- fairyPersistence.fairyEndTime(uuid) endTime = fairyEndTimeOpt.get.endTimeOpt.get _ <- { - fairySpeech.bye(player) >> fairyPersistence.updateIsFairyUsing(uuid, isFairyUsing = false) + fairySpeech + .bye(player) >> fairyPersistence.updateIsFairyUsing(uuid, isFairyUsing = false) }.whenA( // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) isFairyUsing && endTime.isBefore(LocalDateTime.now()) @@ -71,7 +79,10 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] ) _ <- { - fairyPersistence.increaseAppleAteByFairy(uuid, AppleAmount(finallyAppleConsumptionAmount)) >> + fairyPersistence.increaseAppleAteByFairy( + uuid, + AppleAmount(finallyAppleConsumptionAmount) + ) >> ContextCoercion( manaApi.manaAmount(player).restoreAbsolute(ManaAmount(recoveryManaAmount)) ) >> diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index 109501bb5a..1d7f4768aa 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -9,7 +9,10 @@ import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitRecoveryMana -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpeech} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + FairyPersistence, + FairySpeech +} import org.bukkit.entity.Player import scala.concurrent.duration.FiniteDuration @@ -41,7 +44,7 @@ class BukkitFairyRoutine(fairySpeech: FairySpeech[IO, Player])( RepeatingRoutine.permanentRoutine( repeatInterval, onMainThread.runAction { - new BukkitRecoveryMana[IO, SyncIO](player).recovery.runAsync(_ => IO.unit) + new BukkitRecoveryMana[IO, SyncIO](player, fairySpeech).recovery.runAsync(_ => IO.unit) } ) } From 47212bbca33a2bf066f750cc08d04446033b0ef2 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 23:42:13 +0900 Subject: [PATCH 205/482] =?UTF-8?q?feat:=20summonSpeech=E3=82=92FairyAPI?= =?UTF-8?q?=E3=81=AB=E5=AE=9A=E7=BE=A9=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index e7f3aa364e..1f0b677857 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -130,6 +130,11 @@ trait FairySpeechAPI[F[_], Player] { */ def speechEndTime(player: Player): F[Unit] + /** + * @return 妖精が召喚された際のメッセージを[[Player]]に送信する作用 + */ + def summonSpeech(player: Player): F[Unit] + } object FairySpeechAPI { From d24e730cfca56613e58d2cfa7f4b1f0f65f154ff Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 23:44:15 +0900 Subject: [PATCH 206/482] =?UTF-8?q?feat:=20summonSpeech=E3=82=92API?= =?UTF-8?q?=E3=81=AB=E5=AE=9F=E8=A3=85=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/subsystems/fairy/System.scala | 3 +++ .../subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 6051e1ea3e..4c2ae394e9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -162,6 +162,9 @@ object System { override def speechEndTime(player: Player): IO[Unit] = fairySpeech.speechEndTime(player) + + override def summonSpeech(player: Player): IO[Unit] = + fairySpeech.summonSpeech(player) } override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 5acfc4d124..007d0c464e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -34,7 +34,7 @@ class BukkitSummonFairy[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(fairySummonCost.value * 2)) _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryManaAmount) _ <- fairyAPI.updateFairyEndTime(player, fairySummonCost.endTime) - _ <- new BukkitFairySpeech[F, G].summonSpeech(player) + _ <- fairyAPI.summonSpeech(player) _ <- MessageEffectF( List( s"$RESET$YELLOW${BOLD}妖精を呼び出しました!", From 7a74b89f37fbc0ce5173a830ed6f85ec7ab93d3e Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 23:44:43 +0900 Subject: [PATCH 207/482] =?UTF-8?q?refactor:=20BukkitSummonFairy=E3=81=A7s?= =?UTF-8?q?ummonSpeech=E3=82=92API=E3=81=8B=E3=82=89=E5=91=BC=E3=81=B3?= =?UTF-8?q?=E5=87=BA=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 007d0c464e..06a2b17ea9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -7,7 +7,6 @@ import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyRecoveryManaAmount import com.github.unchama.targetedeffect.commandsender.MessageEffectF import org.bukkit.ChatColor._ From eef53398af4264ec62ade1c8a507b7a4842ac7a7 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 23:47:25 +0900 Subject: [PATCH 208/482] =?UTF-8?q?feat:=20fairyAPI=E3=81=ABwelcomeback?= =?UTF-8?q?=E9=96=A2=E6=95=B0=E3=82=92=E5=AE=9A=E7=BE=A9=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 1f0b677857..bae6726ad3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -135,6 +135,11 @@ trait FairySpeechAPI[F[_], Player] { */ def summonSpeech(player: Player): F[Unit] + /** + * @return 妖精召喚中に[[Player]]が再ログインした際のメッセージを[[Player]]に送信する作用 + */ + def welcomeBack(player: Player): F[Unit] + } object FairySpeechAPI { From 0a32265ad3ecec977eec3412e6667db4136d1326 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 23:48:19 +0900 Subject: [PATCH 209/482] =?UTF-8?q?feat:=20welcomeBack=E9=96=A2=E6=95=B0?= =?UTF-8?q?=E3=82=92FairyAPI=E3=81=AB=E5=AE=9F=E8=A3=85=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/subsystems/fairy/System.scala | 3 +++ .../fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 4c2ae394e9..8b2ae96c9a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -165,6 +165,9 @@ object System { override def summonSpeech(player: Player): IO[Unit] = fairySpeech.summonSpeech(player) + + override def welcomeBack(player: Player): IO[Unit] = + fairySpeech.welcomeBack(player) } override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index 03ff89c317..35dc9a8a68 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -31,7 +31,7 @@ class FairyPlayerJoinGreeter(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]) ex implicit val ioCE: ConcurrentEffect[IO] = IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) - new BukkitFairySpeech[IO, SyncIO]().welcomeBack(player).unsafeRunSync() + fairyAPI.welcomeBack(player).unsafeRunSync() } } else SyncIO.unit } From b9837568a6fb9f3e2a7bf0f10ba9aac2e380a5f5 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 23:50:48 +0900 Subject: [PATCH 210/482] =?UTF-8?q?style:=20Scalafmt=E7=AD=89=E3=82=92?= =?UTF-8?q?=E5=AE=9F=E8=A1=8C=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/menus/VoteMenu.scala | 11 +++++++++-- .../bukkit/listeners/FairyPlayerJoinGreeter.scala | 1 - 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 1b0a408298..7e0da633a4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -20,8 +20,15 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequest -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{AlreadyFairySpawned, NotEnoughEffectPoint, NotEnoughSeichiLevel} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{AppleOpenStateDependency, FairySummonCost} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{ + AlreadyFairySpawned, + NotEnoughEffectPoint, + NotEnoughSeichiLevel +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + AppleOpenStateDependency, + FairySummonCost +} import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.player.PlayerEffects.closeInventoryEffect diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index 35dc9a8a68..d92e955bfc 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -3,7 +3,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit. import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySpeech import org.bukkit.ChatColor._ import org.bukkit.entity.Player import org.bukkit.event.player.PlayerJoinEvent From 37f61e555224611e5b8048b408f830134bfca883 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Oct 2022 23:58:17 +0900 Subject: [PATCH 211/482] =?UTF-8?q?feat:=20getSummonMessagesByStartHour?= =?UTF-8?q?=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/BukkitFairySpeech.scala | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index d19c4cac94..5762bfae36 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -22,17 +22,26 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( import cats.implicits._ + /** + * @return 時間から妖精の召喚メッセージを返す + */ + private def getSummonMessagesByStartHour( + startHour: Int, + nameCalledByFairy: NameCalledByFairy + ): FairyMessages = { + if (4 <= startHour && startHour < 10) + FairyMessageTable.morningMessages(nameCalledByFairy) + else if (10 <= startHour && startHour < 18) + FairyMessageTable.dayMessages(nameCalledByFairy) + else + FairyMessageTable.nightMessages(nameCalledByFairy) + } + override def summonSpeech(player: Player): F[Unit] = for { startHour <- Sync[F].delay(LocalTime.now().getHour) nameCalledByFairy = NameCalledByFairy(player.getName) - fairyMessages = - if (4 <= startHour && startHour < 10) - FairyMessageTable.morningMessages(nameCalledByFairy) - else if (10 <= startHour && startHour < 18) - FairyMessageTable.dayMessages(nameCalledByFairy) - else - FairyMessageTable.nightMessages(nameCalledByFairy) + fairyMessages = getSummonMessagesByStartHour(startHour, nameCalledByFairy) message <- randomMessage(fairyMessages) serviceRepository = fairySpeechServiceRepository(player) From b20c4b2119e8427dc1b6f5264942bf60ceb8a5bd Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 00:06:05 +0900 Subject: [PATCH 212/482] =?UTF-8?q?feat:=20FairySummonAPI=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/FairyAPI.scala | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index bae6726ad3..7310bbfc86 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -149,7 +149,24 @@ object FairySpeechAPI { } +trait FairySummonAPI[F[_], Player] { + + /** + * @return 妖精を召喚する作用 + */ + def fairySummon(player: Player): F[Unit] + +} + +object FairySummonAPI { + + def apply[F[_], Player](implicit ev: FairySummonAPI[F, Player]): FairySummonAPI[F, Player] = + ev + +} + trait FairyAPI[F[_], G[_], Player] extends FairyReadAPI[F, G, Player] with FairyWriteAPI[F, G, Player] with FairySpeechAPI[F, Player] + with FairySummonAPI[F, Player] From 9c6791239a594f7b49c6a1a5bdcc4ca5a82736db Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 13:48:22 +0900 Subject: [PATCH 213/482] =?UTF-8?q?refactor:=20BukkitSummonFairy=E3=81=AE?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=81=A7fairyAPI=E3=82=92=E4=BD=BF=E3=82=8F?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=81=A7=E5=87=A6=E7=90=86=E3=82=92=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 22 ++++++++---------- .../bukkit/actions/BukkitSummonFairy.scala | 23 +++++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 8b2ae96c9a..b75b00bcf8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -2,30 +2,22 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.concurrent.RepeatingTaskContext -import com.github.unchama.datarepository.bukkit.player.{ - BukkitRepositoryControls, - PlayerDataRepository -} +import com.github.unchama.datarepository.bukkit.player.{BukkitRepositoryControls, PlayerDataRepository} import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{ - FairyManaRecoveryRoutineFiberRepositoryDefinition, - SpeechServiceRepositoryDefinitions -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{FairyManaRecoveryRoutineFiberRepositoryDefinition, SpeechServiceRepositoryDefinitions} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - FairyPersistence, - FairySpeech, - FairySpeechGateway -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpeech, FairySpeechGateway} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player @@ -52,6 +44,7 @@ object System { val fairySpeechProvider : PlayerDataRepository[FairySpeechService[SyncIO]] => FairySpeech[IO, Player] = fairySpeechService => new BukkitFairySpeech[IO, SyncIO](fairySpeechService, persistence) + val summonFairy: SummonFairy[IO, SyncIO, Player] = new BukkitSummonFairy[IO, SyncIO]() for { speechServiceRepositoryControls <- BukkitRepositoryControls.createHandles( @@ -168,6 +161,9 @@ object System { override def welcomeBack(player: Player): IO[Unit] = fairySpeech.welcomeBack(player) + + override def fairySummon(player: Player): IO[Unit] = + } override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 06a2b17ea9..f742ec9f11 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -5,35 +5,40 @@ import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyRecoveryManaAmount +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + FairyPersistence, + FairySpeech +} import com.github.unchama.targetedeffect.commandsender.MessageEffectF import org.bukkit.ChatColor._ import org.bukkit.entity.Player class BukkitSummonFairy[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( - implicit fairyAPI: FairyAPI[F, G, Player], - voteAPI: VoteAPI[F, Player], - manaApi: ManaApi[F, G, Player] + implicit voteAPI: VoteAPI[F, Player], + manaApi: ManaApi[F, G, Player], + fairyPersistence: FairyPersistence[F], + fairySpeech: FairySpeech[F, Player] ) extends SummonFairy[F, G, Player] { import cats.implicits._ override def summon(player: Player): F[Unit] = { + val uuid = player.getUniqueId for { - _ <- fairyAPI.updateIsFairyUsing(player, isFairyUsing = true) + _ <- fairyPersistence.updateIsFairyUsing(uuid, isFairyUsing = true) manaAmount <- ContextCoercion { manaApi.readManaAmount(player) } levelCappedManaAmount = manaAmount.cap.value recoveryManaAmount = FairyRecoveryManaAmount.manaAmountAt(levelCappedManaAmount) uuid = player.getUniqueId - fairySummonCost <- fairyAPI.fairySummonCost(player) + fairySummonCost <- fairyPersistence.fairySummonCost(uuid) _ <- voteAPI.decreaseEffectPoint(uuid, EffectPoint(fairySummonCost.value * 2)) - _ <- fairyAPI.updateFairyRecoveryManaAmount(uuid, recoveryManaAmount) - _ <- fairyAPI.updateFairyEndTime(player, fairySummonCost.endTime) - _ <- fairyAPI.summonSpeech(player) + _ <- fairyPersistence.updateFairyRecoveryMana(uuid, recoveryManaAmount) + _ <- fairyPersistence.updateFairyEndTime(uuid, fairySummonCost.endTime) + _ <- fairySpeech.summonSpeech(player) _ <- MessageEffectF( List( s"$RESET$YELLOW${BOLD}妖精を呼び出しました!", From 79f0df0ec1bc7c5a9bbe94d174799e6914649464 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 13:50:00 +0900 Subject: [PATCH 214/482] =?UTF-8?q?feat:=20FairyAPI=E3=81=ABfairySummon?= =?UTF-8?q?=E3=82=92=E5=AE=9F=E8=A3=85=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index b75b00bcf8..287c148d5d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -2,14 +2,20 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.concurrent.RepeatingTaskContext -import com.github.unchama.datarepository.bukkit.player.{BukkitRepositoryControls, PlayerDataRepository} +import com.github.unchama.datarepository.bukkit.player.{ + BukkitRepositoryControls, + PlayerDataRepository +} import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{FairyManaRecoveryRoutineFiberRepositoryDefinition, SpeechServiceRepositoryDefinitions} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{ + FairyManaRecoveryRoutineFiberRepositoryDefinition, + SpeechServiceRepositoryDefinitions +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway @@ -17,7 +23,11 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.l import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpeech, FairySpeechGateway} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + FairyPersistence, + FairySpeech, + FairySpeechGateway +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player @@ -44,7 +54,6 @@ object System { val fairySpeechProvider : PlayerDataRepository[FairySpeechService[SyncIO]] => FairySpeech[IO, Player] = fairySpeechService => new BukkitFairySpeech[IO, SyncIO](fairySpeechService, persistence) - val summonFairy: SummonFairy[IO, SyncIO, Player] = new BukkitSummonFairy[IO, SyncIO]() for { speechServiceRepositoryControls <- BukkitRepositoryControls.createHandles( @@ -71,9 +80,10 @@ object System { new System[IO, SyncIO, Player] { val fairySpeechServiceRepository: PlayerDataRepository[FairySpeechService[SyncIO]] = speechServiceRepositoryControls.repository - val fairySpeech: FairySpeech[IO, Player] = fairySpeechProvider( + implicit val fairySpeech: FairySpeech[IO, Player] = fairySpeechProvider( fairySpeechServiceRepository ) + val summonFairy: SummonFairy[IO, SyncIO, Player] = new BukkitSummonFairy[IO, SyncIO] override implicit val api: FairyAPI[IO, SyncIO, Player] = new FairyAPI[IO, SyncIO, Player] { @@ -163,6 +173,7 @@ object System { fairySpeech.welcomeBack(player) override def fairySummon(player: Player): IO[Unit] = + summonFairy.summon(player) } From a90d070f385f0851d322f1b095d932df511e9b9f Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 14:13:24 +0900 Subject: [PATCH 215/482] =?UTF-8?q?refactor:=20fairySummonRequest=E3=81=AE?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=81=A7summon=E3=82=92API=E3=81=8B=E3=82=89?= =?UTF-8?q?=E8=A1=8C=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 15 ++------------- .../fairy/domain/FairySpawnRequest.scala | 6 ++---- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 7e0da633a4..dbe1314263 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -17,18 +17,9 @@ import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequest -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{ - AlreadyFairySpawned, - NotEnoughEffectPoint, - NotEnoughSeichiLevel -} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - AppleOpenStateDependency, - FairySummonCost -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{AlreadyFairySpawned, NotEnoughEffectPoint, NotEnoughSeichiLevel} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{AppleOpenStateDependency, FairySummonCost} import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.player.PlayerEffects.closeInventoryEffect @@ -266,8 +257,6 @@ object VoteMenu extends Menu { val fairySummonButton: IO[Button] = IO { val fairySummonState = fairyAPI.fairySummonCost(player).unsafeRunSync() - implicit val summonFairy: SummonFairy[IO, SyncIO, Player] = - new BukkitSummonFairy[IO, SyncIO] Button( new IconItemStackBuilder(Material.GHAST_TEAR) .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}マナ妖精 召喚") diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala index 8e04d4aebb..24556219d0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala @@ -5,14 +5,12 @@ import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError class FairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player]( implicit breakCountAPI: BreakCountAPI[F, G, Player], fairyAPI: FairyAPI[F, G, Player], - voteAPI: VoteAPI[F, Player], - summonFairy: SummonFairy[F, G, Player] + voteAPI: VoteAPI[F, Player] ) { import cats.implicits._ @@ -34,7 +32,7 @@ class FairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player]( else if (effectPoints.value < fairySummonCost.value * 2) Left(FairySpawnRequestError.NotEnoughEffectPoint) else - Right(summonFairy.summon(player)) + Right(fairyAPI.fairySummon(player)) } } From 409c462c09ab7073c9b95f50e55cfb36f849ca3d Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 14:20:08 +0900 Subject: [PATCH 216/482] refactor: FairySpawnRequest -> BukkitFairySpawnRequest --- .../com/github/unchama/seichiassist/menus/VoteMenu.scala | 4 ++-- ...{FairySpawnRequest.scala => BukkitFairySpawnRequest.scala} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{FairySpawnRequest.scala => BukkitFairySpawnRequest.scala} (94%) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index dbe1314263..b97ce40530 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -17,7 +17,7 @@ import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequest +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.BukkitFairySpawnRequest import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{AlreadyFairySpawned, NotEnoughEffectPoint, NotEnoughSeichiLevel} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{AppleOpenStateDependency, FairySummonCost} import com.github.unchama.targetedeffect.commandsender.MessageEffect @@ -272,7 +272,7 @@ object VoteMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - new FairySpawnRequest[IO, SyncIO, Player] + new BukkitFairySpawnRequest[IO, SyncIO, Player] .spawnRequest(player) .unsafeRunSync() match { case Left(errorResult) => diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/BukkitFairySpawnRequest.scala similarity index 94% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/BukkitFairySpawnRequest.scala index 24556219d0..c41faf0429 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/BukkitFairySpawnRequest.scala @@ -7,7 +7,7 @@ import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError -class FairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player]( +class BukkitFairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player]( implicit breakCountAPI: BreakCountAPI[F, G, Player], fairyAPI: FairyAPI[F, G, Player], voteAPI: VoteAPI[F, Player] From d0e30bdfb3e189c6e1f4bcbcd6c180331b0c8a32 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 14:22:42 +0900 Subject: [PATCH 217/482] =?UTF-8?q?style:=20BukkitFairySpawnRequest?= =?UTF-8?q?=E3=82=92Bukkit=E3=83=91=E3=83=83=E3=82=B1=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=81=AB=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scala/com/github/unchama/seichiassist/menus/VoteMenu.scala | 2 +- .../fairy/{domain => bukkit}/BukkitFairySpawnRequest.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/{domain => bukkit}/BukkitFairySpawnRequest.scala (98%) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index b97ce40530..bb3c5e7f93 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -17,7 +17,7 @@ import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.BukkitFairySpawnRequest +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySpawnRequest import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{AlreadyFairySpawned, NotEnoughEffectPoint, NotEnoughSeichiLevel} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{AppleOpenStateDependency, FairySummonCost} import com.github.unchama.targetedeffect.commandsender.MessageEffect diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/BukkitFairySpawnRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpawnRequest.scala similarity index 98% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/BukkitFairySpawnRequest.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpawnRequest.scala index c41faf0429..fbe5eedfca 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/BukkitFairySpawnRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpawnRequest.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit import cats.effect.Sync import com.github.unchama.generic.ContextCoercion From 33ddb02673bb9908c19e6db323c0659b7fc0d1e4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 14:29:44 +0900 Subject: [PATCH 218/482] =?UTF-8?q?style:=20FairySpawnRequestErrorOrSpawn?= =?UTF-8?q?=E3=82=92=E5=AE=9A=E7=BE=A9=E3=81=97=E3=81=A6=E6=97=A2=E5=AD=98?= =?UTF-8?q?=E3=81=AE=E3=82=82=E3=81=AE=E3=82=92=E7=BD=AE=E3=81=8D=E6=8F=9B?= =?UTF-8?q?=E3=81=88=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/BukkitFairySpawnRequest.scala | 3 ++- .../vote/subsystems/fairy/domain/package.scala | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/package.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpawnRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpawnRequest.scala index fbe5eedfca..09ebe675cb 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpawnRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpawnRequest.scala @@ -5,6 +5,7 @@ import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequestErrorOrSpawn import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError class BukkitFairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player]( @@ -15,7 +16,7 @@ class BukkitFairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player import cats.implicits._ - def spawnRequest(player: Player): F[Either[FairySpawnRequestError, F[Unit]]] = { + def spawnRequest(player: Player): F[FairySpawnRequestErrorOrSpawn[F]] = { for { usingState <- fairyAPI.isFairyUsing(player) effectPoints <- voteAPI.effectPoints(player) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/package.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/package.scala new file mode 100644 index 0000000000..d36050f7a8 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/package.scala @@ -0,0 +1,9 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy + +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError + +package object domain { + + type FairySpawnRequestErrorOrSpawn[F[_]] = Either[FairySpawnRequestError, F[Unit]] + +} From 2d91a1aadb36b4ca512fccb4d36a43f9577f355b Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 14:33:19 +0900 Subject: [PATCH 219/482] =?UTF-8?q?style:=20speech=E3=83=91=E3=83=83?= =?UTF-8?q?=E3=82=B1=E3=83=BC=E3=82=B8=E3=81=AB=E3=82=AF=E3=83=A9=E3=82=B9?= =?UTF-8?q?=E3=82=92=E3=81=BE=E3=81=A8=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/System.scala | 7 ++----- .../repository/SpeechServiceRepositoryDefinitions.scala | 2 +- .../vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala | 6 ++---- .../fairy/bukkit/actions/BukkitRecoveryMana.scala | 6 ++---- .../fairy/bukkit/actions/BukkitSummonFairy.scala | 6 ++---- .../fairy/bukkit/gateway/BukkitFairySpeechGateway.scala | 2 +- .../fairy/bukkit/routines/BukkitFairyRoutine.scala | 6 ++---- .../subsystems/fairy/domain/{ => speech}/FairySpeech.scala | 2 +- .../fairy/domain/{ => speech}/FairySpeechGateway.scala | 2 +- .../vote/subsystems/fairy/service/FairySpeechService.scala | 2 +- 10 files changed, 15 insertions(+), 26 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{ => speech}/FairySpeech.scala (97%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{ => speech}/FairySpeechGateway.scala (92%) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 287c148d5d..6403fd14b1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -23,11 +23,8 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.l import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - FairyPersistence, - FairySpeech, - FairySpeechGateway -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{FairySpeech, FairySpeechGateway} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala index ee8fa36fab..9570c83256 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala @@ -4,7 +4,7 @@ import cats.Applicative import cats.effect.Sync import com.github.unchama.datarepository.template.finalization.RepositoryFinalization import com.github.unchama.datarepository.template.initialization.TwoPhasedRepositoryInitialization -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService object SpeechServiceRepositoryDefinitions { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index 5762bfae36..21908e7451 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -5,10 +5,8 @@ import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.FairyMessageTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - FairyPersistence, - FairySpeech -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 33c7ca00a7..0d5ab53947 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -12,10 +12,8 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p FairyAppleConsumeStrategy, FairyManaRecoveryState } -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - FairyPersistence, - FairySpeech -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import com.github.unchama.seichiassist.{MineStackObjectList, SeichiAssist} import com.github.unchama.targetedeffect.SequentialEffect import com.github.unchama.targetedeffect.commandsender.MessageEffectF diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index f742ec9f11..2c49f8f30d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -7,10 +7,8 @@ import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyRecoveryManaAmount -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - FairyPersistence, - FairySpeech -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import com.github.unchama.targetedeffect.commandsender.MessageEffectF import org.bukkit.ChatColor._ import org.bukkit.entity.Player diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala index a697addbd8..33c0d52b33 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala @@ -1,8 +1,8 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway import cats.effect.Sync -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeechGateway import com.github.unchama.targetedeffect.commandsender.MessageEffectF import com.github.unchama.targetedeffect.player.FocusedSoundEffect import org.bukkit.ChatColor.{AQUA, BOLD, RESET} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index 1d7f4768aa..e551aaf095 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -9,10 +9,8 @@ import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitRecoveryMana -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - FairyPersistence, - FairySpeech -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import org.bukkit.entity.Player import scala.concurrent.duration.FiniteDuration diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeech.scala similarity index 97% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeech.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeech.scala index 5dab825718..5bca92a165 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeech.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyManaRecoveryState diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeechGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeechGateway.scala similarity index 92% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeechGateway.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeechGateway.scala index fcb12dd557..22d15a0614 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpeechGateway.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeechGateway.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala index 0bf7cd7121..a00d7e4aa1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala @@ -2,8 +2,8 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service import cats.effect.Sync import cats.implicits.catsSyntaxFlatMapOps -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeechGateway class FairySpeechService[F[_]: Sync](gateway: FairySpeechGateway[F]) { From 12e888daf9abbfed31acdbf318733fdd952775f5 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 14:54:17 +0900 Subject: [PATCH 220/482] =?UTF-8?q?feat:=20FairySpawnRequest=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/domain/FairySpawnRequest.scala | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala new file mode 100644 index 0000000000..c9ff035283 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala @@ -0,0 +1,12 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain + +trait FairySpawnRequest[F[_], Player] { + + /** + * 妖精の召喚をリクエストする + * 召喚に失敗した場合はエラーを返す + * 成功した場合は召喚する作用を返す + */ + def spawnRequest(player: Player): F[FairySpawnRequestErrorOrSpawn[F]] + +} From 202077bfd257706e53e71389ee150c7f1b262d10 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 15:45:17 +0900 Subject: [PATCH 221/482] =?UTF-8?q?feat:=20fairySpawnRequest=E3=82=92fairy?= =?UTF-8?q?API=E3=81=AB=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 7 +++++++ .../fairy/bukkit/BukkitFairySpawnRequest.scala | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 7310bbfc86..3127388813 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -1,5 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequestErrorOrSpawn import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import java.util.UUID @@ -156,6 +157,12 @@ trait FairySummonAPI[F[_], Player] { */ def fairySummon(player: Player): F[Unit] + /** + * 妖精の召喚をリクエストする + * 召喚に失敗した場合はエラーを返す + * 成功した場合は召喚する作用を返す + */ + def fairySpawnRequest(player: Player): F[FairySpawnRequestErrorOrSpawn[F]] } object FairySummonAPI { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpawnRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpawnRequest.scala index 09ebe675cb..690f479070 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpawnRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpawnRequest.scala @@ -5,18 +5,21 @@ import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequestErrorOrSpawn +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + FairySpawnRequest, + FairySpawnRequestErrorOrSpawn +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError class BukkitFairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player]( implicit breakCountAPI: BreakCountAPI[F, G, Player], fairyAPI: FairyAPI[F, G, Player], voteAPI: VoteAPI[F, Player] -) { +) extends FairySpawnRequest[F, Player] { import cats.implicits._ - def spawnRequest(player: Player): F[FairySpawnRequestErrorOrSpawn[F]] = { + override def spawnRequest(player: Player): F[FairySpawnRequestErrorOrSpawn[F]] = { for { usingState <- fairyAPI.isFairyUsing(player) effectPoints <- voteAPI.effectPoints(player) From 07654671f9ef500ecb6e666713e5716e9f173166 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 16:08:33 +0900 Subject: [PATCH 222/482] =?UTF-8?q?feat:=20fairySpawnRequest=E3=82=92?= =?UTF-8?q?=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 6403fd14b1..3a3c418fe8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -2,21 +2,15 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.concurrent.RepeatingTaskContext -import com.github.unchama.datarepository.bukkit.player.{ - BukkitRepositoryControls, - PlayerDataRepository -} +import com.github.unchama.datarepository.bukkit.player.{BukkitRepositoryControls, PlayerDataRepository} import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{ - FairyManaRecoveryRoutineFiberRepositoryDefinition, - SpeechServiceRepositoryDefinitions -} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{FairyManaRecoveryRoutineFiberRepositoryDefinition, SpeechServiceRepositoryDefinitions} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{BukkitFairySpawnRequest, BukkitFairySpeech} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter @@ -24,7 +18,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.r import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{FairySpeech, FairySpeechGateway} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpawnRequest, FairySpawnRequestErrorOrSpawn} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player @@ -81,6 +75,7 @@ object System { fairySpeechServiceRepository ) val summonFairy: SummonFairy[IO, SyncIO, Player] = new BukkitSummonFairy[IO, SyncIO] + val summonRequest: FairySpawnRequest[IO, Player] = new BukkitFairySpawnRequest[IO,SyncIO, Player] override implicit val api: FairyAPI[IO, SyncIO, Player] = new FairyAPI[IO, SyncIO, Player] { @@ -172,6 +167,9 @@ object System { override def fairySummon(player: Player): IO[Unit] = summonFairy.summon(player) + override def fairySpawnRequest(player: Player): IO[FairySpawnRequestErrorOrSpawn[IO]] = + summonRequest.spawnRequest(player) + } override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = From d8b892fb7957cd1d5ba4022a9cd015e969237d24 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 16:10:48 +0900 Subject: [PATCH 223/482] =?UTF-8?q?refactor:=20fairySummonRequest=E3=82=92?= =?UTF-8?q?API=E3=81=8B=E3=82=89=E5=91=BC=E3=81=B3=E5=87=BA=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/menus/VoteMenu.scala | 5 +---- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 2 +- .../subsystems/vote/subsystems/fairy/System.scala | 10 +++++----- ...awnRequest.scala => BukkitFairySummonRequest.scala} | 8 ++++---- ...airySpawnRequest.scala => FairySummonRequest.scala} | 4 ++-- 5 files changed, 13 insertions(+), 16 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/{BukkitFairySpawnRequest.scala => BukkitFairySummonRequest.scala} (86%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/{FairySpawnRequest.scala => FairySummonRequest.scala} (68%) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index bb3c5e7f93..67c971b5b3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -17,7 +17,6 @@ import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySpawnRequest import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{AlreadyFairySpawned, NotEnoughEffectPoint, NotEnoughSeichiLevel} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{AppleOpenStateDependency, FairySummonCost} import com.github.unchama.targetedeffect.commandsender.MessageEffect @@ -272,9 +271,7 @@ object VoteMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - new BukkitFairySpawnRequest[IO, SyncIO, Player] - .spawnRequest(player) - .unsafeRunSync() match { + fairyAPI.fairySummonRequest(player).unsafeRunSync() match { case Left(errorResult) => errorResult match { case NotEnoughSeichiLevel => diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 3127388813..20b0bdf3ad 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -162,7 +162,7 @@ trait FairySummonAPI[F[_], Player] { * 召喚に失敗した場合はエラーを返す * 成功した場合は召喚する作用を返す */ - def fairySpawnRequest(player: Player): F[FairySpawnRequestErrorOrSpawn[F]] + def fairySummonRequest(player: Player): F[FairySpawnRequestErrorOrSpawn[F]] } object FairySummonAPI { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 3a3c418fe8..7941587f41 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -10,7 +10,7 @@ import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{FairyManaRecoveryRoutineFiberRepositoryDefinition, SpeechServiceRepositoryDefinitions} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{BukkitFairySpawnRequest, BukkitFairySpeech} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{BukkitFairySummonRequest, BukkitFairySpeech} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter @@ -18,7 +18,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.r import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{FairySpeech, FairySpeechGateway} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpawnRequest, FairySpawnRequestErrorOrSpawn} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySummonRequest, FairySpawnRequestErrorOrSpawn} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player @@ -75,7 +75,7 @@ object System { fairySpeechServiceRepository ) val summonFairy: SummonFairy[IO, SyncIO, Player] = new BukkitSummonFairy[IO, SyncIO] - val summonRequest: FairySpawnRequest[IO, Player] = new BukkitFairySpawnRequest[IO,SyncIO, Player] + val summonRequest: FairySummonRequest[IO, Player] = new BukkitFairySummonRequest[IO,SyncIO, Player] override implicit val api: FairyAPI[IO, SyncIO, Player] = new FairyAPI[IO, SyncIO, Player] { @@ -167,8 +167,8 @@ object System { override def fairySummon(player: Player): IO[Unit] = summonFairy.summon(player) - override def fairySpawnRequest(player: Player): IO[FairySpawnRequestErrorOrSpawn[IO]] = - summonRequest.spawnRequest(player) + override def fairySummonRequest(player: Player): IO[FairySpawnRequestErrorOrSpawn[IO]] = + summonRequest.summonRequest(player) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpawnRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala similarity index 86% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpawnRequest.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala index 690f479070..8a82ea55f3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpawnRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala @@ -6,20 +6,20 @@ import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - FairySpawnRequest, + FairySummonRequest, FairySpawnRequestErrorOrSpawn } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError -class BukkitFairySpawnRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player]( +class BukkitFairySummonRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player]( implicit breakCountAPI: BreakCountAPI[F, G, Player], fairyAPI: FairyAPI[F, G, Player], voteAPI: VoteAPI[F, Player] -) extends FairySpawnRequest[F, Player] { +) extends FairySummonRequest[F, Player] { import cats.implicits._ - override def spawnRequest(player: Player): F[FairySpawnRequestErrorOrSpawn[F]] = { + override def summonRequest(player: Player): F[FairySpawnRequestErrorOrSpawn[F]] = { for { usingState <- fairyAPI.isFairyUsing(player) effectPoints <- voteAPI.effectPoints(player) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonRequest.scala similarity index 68% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonRequest.scala index c9ff035283..1c66ca63d6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySpawnRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonRequest.scala @@ -1,12 +1,12 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain -trait FairySpawnRequest[F[_], Player] { +trait FairySummonRequest[F[_], Player] { /** * 妖精の召喚をリクエストする * 召喚に失敗した場合はエラーを返す * 成功した場合は召喚する作用を返す */ - def spawnRequest(player: Player): F[FairySpawnRequestErrorOrSpawn[F]] + def summonRequest(player: Player): F[FairySpawnRequestErrorOrSpawn[F]] } From f81312bd33fc2c8e0ff39d117c4859a5f9873a76 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:18:41 +0900 Subject: [PATCH 224/482] =?UTF-8?q?refactor:=20BukkitFairySummonRequest?= =?UTF-8?q?=E3=81=A7FairyAPI=E3=82=92=E5=88=A9=E7=94=A8=E3=81=97=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=81=A7=E5=87=A6=E7=90=86=E3=82=92=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 2 +- .../bukkit/BukkitFairySummonRequest.scala | 22 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 7941587f41..95fe3ca4ad 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -75,7 +75,7 @@ object System { fairySpeechServiceRepository ) val summonFairy: SummonFairy[IO, SyncIO, Player] = new BukkitSummonFairy[IO, SyncIO] - val summonRequest: FairySummonRequest[IO, Player] = new BukkitFairySummonRequest[IO,SyncIO, Player] + val summonRequest: FairySummonRequest[IO, Player] = new BukkitFairySummonRequest[IO,SyncIO] override implicit val api: FairyAPI[IO, SyncIO, Player] = new FairyAPI[IO, SyncIO, Player] { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala index 8a82ea55f3..1773652195 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala @@ -4,26 +4,26 @@ import cats.effect.Sync import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - FairySummonRequest, - FairySpawnRequestErrorOrSpawn -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpawnRequestErrorOrSpawn, FairySummonRequest} +import org.bukkit.entity.Player -class BukkitFairySummonRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Player]( +class BukkitFairySummonRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( implicit breakCountAPI: BreakCountAPI[F, G, Player], - fairyAPI: FairyAPI[F, G, Player], - voteAPI: VoteAPI[F, Player] + voteAPI: VoteAPI[F, Player], + fairyPersistence: FairyPersistence[F], + summonFairy: SummonFairy[F, G, Player] ) extends FairySummonRequest[F, Player] { import cats.implicits._ override def summonRequest(player: Player): F[FairySpawnRequestErrorOrSpawn[F]] = { + val uuid = player.getUniqueId for { - usingState <- fairyAPI.isFairyUsing(player) + usingState <- fairyPersistence.isFairyUsing(uuid) effectPoints <- voteAPI.effectPoints(player) - fairySummonCost <- fairyAPI.fairySummonCost(player) + fairySummonCost <- fairyPersistence.fairySummonCost(uuid) seichiAmountRepository <- ContextCoercion( breakCountAPI.seichiAmountDataRepository(player).read ) @@ -36,7 +36,7 @@ class BukkitFairySummonRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F], Playe else if (effectPoints.value < fairySummonCost.value * 2) Left(FairySpawnRequestError.NotEnoughEffectPoint) else - Right(fairyAPI.fairySummon(player)) + Right(summonFairy.summon(player)) } } From aa37d9e57dd65b8599bf8a664b1c9ee3e9195cf2 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:21:25 +0900 Subject: [PATCH 225/482] fix: compile error --- .../unchama/seichiassist/menus/VoteMenu.scala | 11 ++++-- .../vote/subsystems/fairy/System.scala | 36 ++++++++++++++----- .../bukkit/BukkitFairySummonRequest.scala | 6 +++- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 67c971b5b3..ba399c6186 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -17,8 +17,15 @@ import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{AlreadyFairySpawned, NotEnoughEffectPoint, NotEnoughSeichiLevel} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{AppleOpenStateDependency, FairySummonCost} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{ + AlreadyFairySpawned, + NotEnoughEffectPoint, + NotEnoughSeichiLevel +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + AppleOpenStateDependency, + FairySummonCost +} import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.player.PlayerEffects.closeInventoryEffect diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 95fe3ca4ad..05fc33210b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -2,23 +2,39 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.concurrent.RepeatingTaskContext -import com.github.unchama.datarepository.bukkit.player.{BukkitRepositoryControls, PlayerDataRepository} +import com.github.unchama.datarepository.bukkit.player.{ + BukkitRepositoryControls, + PlayerDataRepository +} import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{FairyManaRecoveryRoutineFiberRepositoryDefinition, SpeechServiceRepositoryDefinitions} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{BukkitFairySummonRequest, BukkitFairySpeech} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{ + FairyManaRecoveryRoutineFiberRepositoryDefinition, + SpeechServiceRepositoryDefinitions +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{ + BukkitFairySummonRequest, + BukkitFairySpeech +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{FairySpeech, FairySpeechGateway} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySummonRequest, FairySpawnRequestErrorOrSpawn} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{ + FairySpeech, + FairySpeechGateway +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + FairyPersistence, + FairySummonRequest, + FairySpawnRequestErrorOrSpawn +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player @@ -74,8 +90,10 @@ object System { implicit val fairySpeech: FairySpeech[IO, Player] = fairySpeechProvider( fairySpeechServiceRepository ) - val summonFairy: SummonFairy[IO, SyncIO, Player] = new BukkitSummonFairy[IO, SyncIO] - val summonRequest: FairySummonRequest[IO, Player] = new BukkitFairySummonRequest[IO,SyncIO] + implicit val summonFairy: SummonFairy[IO, SyncIO, Player] = + new BukkitSummonFairy[IO, SyncIO] + val summonRequest: FairySummonRequest[IO, Player] = + new BukkitFairySummonRequest[IO, SyncIO] override implicit val api: FairyAPI[IO, SyncIO, Player] = new FairyAPI[IO, SyncIO, Player] { @@ -167,7 +185,9 @@ object System { override def fairySummon(player: Player): IO[Unit] = summonFairy.summon(player) - override def fairySummonRequest(player: Player): IO[FairySpawnRequestErrorOrSpawn[IO]] = + override def fairySummonRequest( + player: Player + ): IO[FairySpawnRequestErrorOrSpawn[IO]] = summonRequest.summonRequest(player) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala index 1773652195..7a2bec3250 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala @@ -6,7 +6,11 @@ import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpawnRequestErrorOrSpawn, FairySummonRequest} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + FairyPersistence, + FairySpawnRequestErrorOrSpawn, + FairySummonRequest +} import org.bukkit.entity.Player class BukkitFairySummonRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( From a4ecfd96a7153434ad056f1724409597c54f82ca Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:22:00 +0900 Subject: [PATCH 226/482] =?UTF-8?q?refactor:=20summonFairy=E3=82=92API?= =?UTF-8?q?=E3=81=8B=E3=82=89=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 5 ----- .../subsystems/vote/subsystems/fairy/System.scala | 3 --- 2 files changed, 8 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 20b0bdf3ad..004e7d3df0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -152,11 +152,6 @@ object FairySpeechAPI { trait FairySummonAPI[F[_], Player] { - /** - * @return 妖精を召喚する作用 - */ - def fairySummon(player: Player): F[Unit] - /** * 妖精の召喚をリクエストする * 召喚に失敗した場合はエラーを返す diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 05fc33210b..f34d143bb4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -182,9 +182,6 @@ object System { override def welcomeBack(player: Player): IO[Unit] = fairySpeech.welcomeBack(player) - override def fairySummon(player: Player): IO[Unit] = - summonFairy.summon(player) - override def fairySummonRequest( player: Player ): IO[FairySpawnRequestErrorOrSpawn[IO]] = From 177fffdcea45ced0c5a6116738439ccbdf21dc46 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:24:33 +0900 Subject: [PATCH 227/482] =?UTF-8?q?refactor:=20FairyPlayerJoinGreeter?= =?UTF-8?q?=E3=81=AE=E5=87=A6=E7=90=86=E3=81=A7API=E3=82=92=E5=88=A9?= =?UTF-8?q?=E7=94=A8=E3=81=97=E3=81=AA=E3=81=84=E3=81=A7=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listeners/FairyPlayerJoinGreeter.scala | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index d92e955bfc..546900fd52 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -2,7 +2,8 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit. import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import org.bukkit.ChatColor._ import org.bukkit.entity.Player import org.bukkit.event.player.PlayerJoinEvent @@ -10,27 +11,31 @@ import org.bukkit.event.{EventHandler, Listener} import java.time.LocalDateTime -class FairyPlayerJoinGreeter(implicit fairyAPI: FairyAPI[IO, SyncIO, Player]) extends Listener { +class FairyPlayerJoinGreeter( + implicit fairyPersistence: FairyPersistence[IO], + fairySpeech: FairySpeech[IO, Player] +) extends Listener { @EventHandler def onJoin(e: PlayerJoinEvent): Unit = { val player = e.getPlayer + val uuid = player.getUniqueId val eff = for { - _ <- fairyAPI.createPlayerData(player.getUniqueId) - isUsing <- fairyAPI.isFairyUsing(player) - endTime <- fairyAPI.fairyEndTime(player) + _ <- fairyPersistence.createPlayerData(uuid) + isUsing <- fairyPersistence.isFairyUsing(uuid) + endTime <- fairyPersistence.fairyEndTime(uuid) } yield { if (isUsing) { if (endTime.get.endTimeOpt.get.isBefore(LocalDateTime.now())) { // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) player.sendMessage(s"$LIGHT_PURPLE${BOLD}妖精は何処かへ行ってしまったようだ...") - fairyAPI.updateIsFairyUsing(player, isFairyUsing = false).unsafeRunSync() + fairyPersistence.updateIsFairyUsing(uuid, isFairyUsing = false).unsafeRunSync() } else { // まだ終了時間ではない(つまり有効時間内) implicit val ioCE: ConcurrentEffect[IO] = IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) - fairyAPI.welcomeBack(player).unsafeRunSync() + fairySpeech.welcomeBack(player).unsafeRunSync() } } else SyncIO.unit } From b141f6ba70f4c2191c6215922aebff7943032d5b Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:27:49 +0900 Subject: [PATCH 228/482] =?UTF-8?q?refactor:=20=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?API=E3=81=AE=E5=AE=9A=E7=BE=A9=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/FairyAPI.scala | 50 ------------------- 1 file changed, 50 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 004e7d3df0..1a4d9166a4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -7,11 +7,6 @@ import java.util.UUID trait FairyWriteAPI[F[_], G[_], Player] { - /** - * プレイヤーデータを作成する - */ - def createPlayerData(uuid: UUID): F[Unit] - /** * 妖精にあげるりんごの開放状態を変更する */ @@ -22,26 +17,6 @@ trait FairyWriteAPI[F[_], G[_], Player] { */ def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] - /** - * 妖精を使っているかどうかを切り替える - */ - def updateIsFairyUsing(player: Player, isFairyUsing: Boolean): F[Unit] - - /** - * 妖精が回復するマナの量を変更する - */ - def updateFairyRecoveryManaAmount(uuid: UUID, fairyRecoveryMana: FairyRecoveryMana): F[Unit] - - /** - * 妖精の効果が終了する時間を変更する - */ - def updateFairyEndTime(player: Player, fairyEndTime: FairyEndTime): F[Unit] - - /** - * 妖精が食べたりんごの数を増加させる - */ - def increaseAppleAteByFairy(uuid: UUID, appleAmount: AppleAmount): F[Unit] - } object FairyWriteAPI { @@ -74,21 +49,6 @@ trait FairyReadAPI[F[_], G[_], Player] { */ def isFairyUsing(player: Player): F[Boolean] - /** - * 妖精が回復するマナの量を取得する - */ - def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] - - /** - * 妖精が食べたりんごの量を取得する - */ - def appleAteByFairy(uuid: UUID): F[Option[AppleAmount]] - - /** - * 妖精が有効な時間を返す - */ - def fairyEndTime(player: Player): F[Option[FairyEndTime]] - /** * 自分の妖精に食べさせたりんごの量の順位を返す */ @@ -131,16 +91,6 @@ trait FairySpeechAPI[F[_], Player] { */ def speechEndTime(player: Player): F[Unit] - /** - * @return 妖精が召喚された際のメッセージを[[Player]]に送信する作用 - */ - def summonSpeech(player: Player): F[Unit] - - /** - * @return 妖精召喚中に[[Player]]が再ログインした際のメッセージを[[Player]]に送信する作用 - */ - def welcomeBack(player: Player): F[Unit] - } object FairySpeechAPI { From 398260660f45748b72176b11333aa4933a846336 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:28:56 +0900 Subject: [PATCH 229/482] =?UTF-8?q?refactor:=20=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?API=E3=81=AE=E5=AE=9F=E8=A3=85=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 38 ------------------- 1 file changed, 38 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index f34d143bb4..5b30b593fb 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -119,38 +119,9 @@ object System { override def fairySummonCost(player: Player): IO[FairySummonCost] = persistence.fairySummonCost(player.getUniqueId) - override def fairyEndTime(player: Player): IO[Option[FairyEndTime]] = - persistence.fairyEndTime(player.getUniqueId) - - override def updateFairyEndTime( - player: Player, - fairyEndTime: FairyEndTime - ): IO[Unit] = - persistence.updateFairyEndTime(player.getUniqueId, fairyEndTime) - override def isFairyUsing(player: Player): IO[Boolean] = persistence.isFairyUsing(player.getUniqueId) - override def updateIsFairyUsing(player: Player, isFairyUsing: Boolean): IO[Unit] = - persistence.updateIsFairyUsing(player.getUniqueId, isFairyUsing) - - override def fairyRecoveryMana(uuid: UUID): IO[FairyRecoveryMana] = - persistence.fairyRecoveryMana(uuid) - - override def updateFairyRecoveryManaAmount( - uuid: UUID, - fairyRecoveryMana: FairyRecoveryMana - ): IO[Unit] = persistence.updateFairyRecoveryMana(uuid, fairyRecoveryMana) - - override def increaseAppleAteByFairy( - uuid: UUID, - appleAmount: AppleAmount - ): IO[Unit] = - persistence.increaseAppleAteByFairy(uuid, appleAmount) - - override def appleAteByFairy(uuid: UUID): IO[Option[AppleAmount]] = - persistence.appleAteByFairy(uuid) - override def appleAteByFairyMyRanking( player: Player ): IO[Option[AppleAteByFairyRank]] = @@ -170,18 +141,9 @@ object System { override def toggleFairySpeechSound(uuid: UUID): IO[Unit] = persistence.toggleFairySpeechSound(uuid, !fairySpeechSound(uuid).unsafeRunSync()) - override def createPlayerData(uuid: UUID): IO[Unit] = - persistence.createPlayerData(uuid) - override def speechEndTime(player: Player): IO[Unit] = fairySpeech.speechEndTime(player) - override def summonSpeech(player: Player): IO[Unit] = - fairySpeech.summonSpeech(player) - - override def welcomeBack(player: Player): IO[Unit] = - fairySpeech.welcomeBack(player) - override def fairySummonRequest( player: Player ): IO[FairySpawnRequestErrorOrSpawn[IO]] = From 60fc2226efdedabe9c66a803d42879d13bd04548 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:32:07 +0900 Subject: [PATCH 230/482] =?UTF-8?q?style:=20APIObject=E3=81=AE=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=81=A7=E7=9B=B4=E6=8E=A5implicit=E3=82=92=E8=BF=94?= =?UTF-8?q?=E3=81=99=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/subsystems/vote/VoteAPI.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index 5ab24b6407..c8cb3dae58 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -35,7 +35,7 @@ trait VoteWriteAPI[F[_]] { object VoteWriteAPI { - def apply[F[_]](implicit voteWriteAPI: VoteWriteAPI[F]): VoteWriteAPI[F] = implicitly + def apply[F[_]](implicit ev: VoteWriteAPI[F]): VoteWriteAPI[F] = ev } @@ -70,9 +70,7 @@ trait VoteReadAPI[F[_], Player] { object VoteReadAPI { - def apply[F[_], Player]( - implicit voteReadAPI: VoteReadAPI[F, Player] - ): VoteReadAPI[F, Player] = implicitly + def apply[F[_], Player](implicit ev: VoteReadAPI[F, Player]): VoteReadAPI[F, Player] = ev } From 01cc148fe3f690efbc8050dc07aacbf151984de7 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:36:19 +0900 Subject: [PATCH 231/482] =?UTF-8?q?refactor:=20VoteCommand=E3=81=A7API?= =?UTF-8?q?=E3=82=92=E5=88=A9=E7=94=A8=E3=81=97=E3=81=AA=E3=81=84=E3=81=A7?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/bukkit/command/VoteCommand.scala | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala index 1fc43db938..3c7ca3301b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala @@ -4,15 +4,13 @@ import cats.effect.ConcurrentEffect import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import com.github.unchama.contextualexecutor.builder.ContextualExecutorBuilder import com.github.unchama.contextualexecutor.executors.{BranchedExecutor, EchoExecutor} -import com.github.unchama.seichiassist.subsystems.vote.VoteAPI -import com.github.unchama.seichiassist.subsystems.vote.domain.PlayerName +import com.github.unchama.seichiassist.subsystems.vote.domain.{PlayerName, VotePersistence} import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} import org.bukkit.ChatColor._ import org.bukkit.command.TabExecutor -import org.bukkit.entity.Player -class VoteCommand[F[_]: ConcurrentEffect](implicit voteAPI: VoteAPI[F, Player]) { +class VoteCommand[F[_]: ConcurrentEffect](implicit votePersistence: VotePersistence[F]) { private val usageEchoExecutor: EchoExecutor = EchoExecutor( MessageEffect(List(s"$RED/vote record <プレイヤー名>", "投票特典配布用コマンドです")) @@ -31,8 +29,8 @@ class VoteCommand[F[_]: ConcurrentEffect](implicit voteAPI: VoteAPI[F, Player]) UnfocusedEffect { val playerName = PlayerName(lowerCasePlayerName) val eff = for { - _ <- voteAPI.voteCounterIncrement(playerName) - _ <- voteAPI.updateChainVote(playerName) + _ <- votePersistence.voteCounterIncrement(playerName) + _ <- votePersistence.updateChainVote(playerName) } yield () eff.toIO.unsafeRunSync() } From 8bcfb38d158ae28bacfbed6e16e5b115670d4dab Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:37:14 +0900 Subject: [PATCH 232/482] =?UTF-8?q?refactor:=20VoteAPI=E3=81=8B=E3=82=89?= =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E5=AE=9A=E7=BE=A9=E3=82=92=E5=89=8A?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/subsystems/vote/VoteAPI.scala | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index c8cb3dae58..bb4468ab89 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -6,16 +6,6 @@ import java.util.UUID trait VoteWriteAPI[F[_]] { - /** - * 投票ポイントをインクリメントする作用 - */ - def voteCounterIncrement(playerName: PlayerName): F[Unit] - - /** - * 連続投票を更新する作用 - */ - def updateChainVote(playerName: PlayerName): F[Unit] - /** * effectPointを減少させる作用 */ From 418192a33002b9ad99da46d58850607bcb95dd78 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:37:39 +0900 Subject: [PATCH 233/482] =?UTF-8?q?refactor:=20=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?API=E5=AE=9F=E8=A3=85=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/subsystems/vote/System.scala | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index b69c0ef378..e05deccea1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -24,12 +24,6 @@ object System { new System[F, Player] { override implicit val api: VoteAPI[F, Player] = new VoteAPI[F, Player] { - override def voteCounterIncrement(playerName: PlayerName): F[Unit] = - votePersistence.voteCounterIncrement(playerName) - - override def updateChainVote(playerName: PlayerName): F[Unit] = - votePersistence.updateChainVote(playerName) - override def voteCounter(uuid: UUID): F[VoteCounter] = votePersistence.voteCounter(uuid) From 5fa0bb85bc66651fe25b5267b30c9f4fafd5aeb8 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:41:22 +0900 Subject: [PATCH 234/482] =?UTF-8?q?refactor:=20BukkitReceiveVoteBenefits?= =?UTF-8?q?=E3=81=AE=E5=87=A6=E7=90=86=E3=81=A7API=E3=82=92=E5=88=A9?= =?UTF-8?q?=E7=94=A8=E3=81=97=E3=81=AA=E3=81=84=E3=81=A7=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/BukkitReceiveVoteBenefits.scala | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 039a7d996c..085a643db6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -6,15 +6,15 @@ import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.data.ItemData import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.gacha.bukkit.factories.BukkitGachaSkullData -import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.application.actions.ReceiveVoteBenefits +import com.github.unchama.seichiassist.subsystems.vote.domain.{VoteBenefit, VotePersistence} import com.github.unchama.seichiassist.util.InventoryOperations.grantItemStacksEffect import org.bukkit.entity.Player class BukkitReceiveVoteBenefits[F[_]: OnMinecraftServerThread: Sync, G[ _ ]: SyncEffect: ContextCoercion[*[_], F]]( - implicit voteAPI: VoteAPI[F, Player], + implicit votePersistence: VotePersistence[F], breakCountAPI: BreakCountAPI[F, G, Player] ) extends ReceiveVoteBenefits[F, G, Player] { @@ -26,8 +26,13 @@ class BukkitReceiveVoteBenefits[F[_]: OnMinecraftServerThread: Sync, G[ override def receive(player: Player): F[Unit] = { val uuid = player.getUniqueId for { - notReceivedBenefits <- voteAPI.restVoteBenefits(uuid) - _ <- voteAPI.increaseVoteBenefits(uuid, notReceivedBenefits) // 受け取ってない分を受け取ったことにする + voteCounter <- votePersistence.voteCounter(uuid) + receivedVote <- votePersistence.receivedVoteBenefits(uuid) + notReceivedBenefits = VoteBenefit(voteCounter.value - receivedVote.value) + _ <- votePersistence.increaseVoteBenefits( + uuid, + notReceivedBenefits + ) // 受け取ってない分を受け取ったことにする playerLevel <- ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read.map { _.levelCorrespondingToExp.level }) @@ -38,7 +43,7 @@ class BukkitReceiveVoteBenefits[F[_]: OnMinecraftServerThread: Sync, G[ else ItemData.getVotingGift(1) ) _ <- { - ContextCoercion(voteAPI.increaseEffectPointsByTen(uuid)) + ContextCoercion(votePersistence.increaseEffectPointsByTen(uuid)) .replicateA(notReceivedBenefits.value) >> grantItemStacksEffect[F](items: _*).apply(player) }.whenA(notReceivedBenefits.value != 0) From 1fd6690fbf47ac99a345c2f314d3346636e93d3f Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:42:46 +0900 Subject: [PATCH 235/482] =?UTF-8?q?docs:=20receive=E9=96=A2=E6=95=B0?= =?UTF-8?q?=E3=81=AE=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=81=8C=E9=96=93=E9=81=95=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F?= =?UTF-8?q?=E3=81=AE=E3=81=A7=E7=9B=B4=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/application/actions/ReceiveVoteBenefits.scala | 3 +++ .../vote/bukkit/actions/BukkitReceiveVoteBenefits.scala | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala index 262be00bd5..2005087eed 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala @@ -2,6 +2,9 @@ package com.github.unchama.seichiassist.subsystems.vote.application.actions trait ReceiveVoteBenefits[F[_], G[_], Player] { + /** + * @return 投票特典を受け取る作用 + */ def receive(player: Player): F[Unit] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 085a643db6..dd2f8f10bf 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -20,9 +20,6 @@ class BukkitReceiveVoteBenefits[F[_]: OnMinecraftServerThread: Sync, G[ import cats.implicits._ - /** - * 投票特典を配布する - */ override def receive(player: Player): F[Unit] = { val uuid = player.getUniqueId for { From 45dacc249ae0e52779235eb7995150e9725d494c Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:45:54 +0900 Subject: [PATCH 236/482] =?UTF-8?q?feat:=20VoteReceiveAPI=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/VoteAPI.scala | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index bb4468ab89..c8b2fa3c79 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -64,4 +64,23 @@ object VoteReadAPI { } -trait VoteAPI[F[_], Player] extends VoteReadAPI[F, Player] with VoteWriteAPI[F] +trait VoteReceiveAPI[F[_], Player] { + + /** + * @return 投票特典を受け取る作用 + */ + def receiveVotePrivilege(player: Player): F[Unit] + +} + +object VoteReceiveAPI { + + def apply[F[_], Player](implicit ev: VoteReceiveAPI[F, Player]): VoteReceiveAPI[F, Player] = + ev + +} + +trait VoteAPI[F[_], Player] + extends VoteReadAPI[F, Player] + with VoteWriteAPI[F] + with VoteReceiveAPI[F, Player] From a50a71809b449f6e1533823f8b9b7d4144de79a2 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:49:41 +0900 Subject: [PATCH 237/482] =?UTF-8?q?feat:=20receiveVotePrivilege=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/System.scala | 14 ++++++++++++-- .../application/actions/ReceiveVoteBenefits.scala | 8 ++++---- .../bukkit/actions/BukkitReceiveVoteBenefits.scala | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index e05deccea1..b59a2b5540 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -1,8 +1,11 @@ package com.github.unchama.seichiassist.subsystems.vote -import cats.effect.ConcurrentEffect +import cats.effect.{ConcurrentEffect, SyncEffect} import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem +import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI +import com.github.unchama.seichiassist.subsystems.vote.application.actions.ReceiveVoteBenefits +import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits import com.github.unchama.seichiassist.subsystems.vote.bukkit.command.VoteCommand import com.github.unchama.seichiassist.subsystems.vote.bukkit.listeners.PlayerDataCreator import com.github.unchama.seichiassist.subsystems.vote.domain._ @@ -19,8 +22,12 @@ trait System[F[_], Player] extends Subsystem[F] { object System { - def wired[F[_]: ConcurrentEffect: OnMinecraftServerThread]: System[F, Player] = { + def wired[F[_]: ConcurrentEffect: OnMinecraftServerThread, G[_]: SyncEffect]( + implicit breakCountAPI: BreakCountAPI[F, G, Player] + ): System[F, Player] = { implicit val votePersistence: VotePersistence[F] = new JdbcVotePersistence[F] + val receiveVoteBenefits: ReceiveVoteBenefits[F, Player] = + new BukkitReceiveVoteBenefits[F, G]() new System[F, Player] { override implicit val api: VoteAPI[F, Player] = new VoteAPI[F, Player] { @@ -51,6 +58,9 @@ object System { voteCounter <- voteCounter(uuid) receivedVote <- receivedVoteBenefits(uuid) } yield VoteBenefit(voteCounter.value - receivedVote.value) + + override def receiveVotePrivilege(player: Player): F[Unit] = + receiveVoteBenefits.receive(player) } override val commands: Map[String, TabExecutor] = Map( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala index 2005087eed..2ffd4c25f4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/application/actions/ReceiveVoteBenefits.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.application.actions -trait ReceiveVoteBenefits[F[_], G[_], Player] { +trait ReceiveVoteBenefits[F[_], Player] { /** * @return 投票特典を受け取る作用 @@ -11,8 +11,8 @@ trait ReceiveVoteBenefits[F[_], G[_], Player] { object ReceiveVoteBenefits { - def apply[F[_], G[_], Player]( - implicit ev: ReceiveVoteBenefits[F, G, Player] - ): ReceiveVoteBenefits[F, G, Player] = ev + def apply[F[_], Player]( + implicit ev: ReceiveVoteBenefits[F, Player] + ): ReceiveVoteBenefits[F, Player] = ev } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index dd2f8f10bf..b46eccafa0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -16,7 +16,7 @@ class BukkitReceiveVoteBenefits[F[_]: OnMinecraftServerThread: Sync, G[ ]: SyncEffect: ContextCoercion[*[_], F]]( implicit votePersistence: VotePersistence[F], breakCountAPI: BreakCountAPI[F, G, Player] -) extends ReceiveVoteBenefits[F, G, Player] { +) extends ReceiveVoteBenefits[F, Player] { import cats.implicits._ From 71e824843d3e34abd1de2241dbaad7603679ed21 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:50:10 +0900 Subject: [PATCH 238/482] =?UTF-8?q?style:=20receiveVoteBenefits=E3=81=AB?= =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/subsystems/vote/System.scala | 2 +- .../github/unchama/seichiassist/subsystems/vote/VoteAPI.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index b59a2b5540..76f16b3f55 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -59,7 +59,7 @@ object System { receivedVote <- receivedVoteBenefits(uuid) } yield VoteBenefit(voteCounter.value - receivedVote.value) - override def receiveVotePrivilege(player: Player): F[Unit] = + override def receiveVoteBenefits(player: Player): F[Unit] = receiveVoteBenefits.receive(player) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index c8b2fa3c79..1ba1092e49 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -69,7 +69,7 @@ trait VoteReceiveAPI[F[_], Player] { /** * @return 投票特典を受け取る作用 */ - def receiveVotePrivilege(player: Player): F[Unit] + def receiveVoteBenefits(player: Player): F[Unit] } From 7c6b7077a1689bd32ee54f8c58db70c9567e537f Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:51:03 +0900 Subject: [PATCH 239/482] =?UTF-8?q?refactor:=20receiveVoteBenefits?= =?UTF-8?q?=E3=81=AE=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/System.scala | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index 76f16b3f55..9978931b0f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -25,32 +25,32 @@ object System { def wired[F[_]: ConcurrentEffect: OnMinecraftServerThread, G[_]: SyncEffect]( implicit breakCountAPI: BreakCountAPI[F, G, Player] ): System[F, Player] = { - implicit val votePersistence: VotePersistence[F] = new JdbcVotePersistence[F] - val receiveVoteBenefits: ReceiveVoteBenefits[F, Player] = + implicit val _votePersistence: VotePersistence[F] = new JdbcVotePersistence[F] + val _receiveVoteBenefits: ReceiveVoteBenefits[F, Player] = new BukkitReceiveVoteBenefits[F, G]() new System[F, Player] { override implicit val api: VoteAPI[F, Player] = new VoteAPI[F, Player] { override def voteCounter(uuid: UUID): F[VoteCounter] = - votePersistence.voteCounter(uuid) + _votePersistence.voteCounter(uuid) override def chainVoteDayNumber(uuid: UUID): F[ChainVoteDayNumber] = - votePersistence.chainVoteDays(uuid) + _votePersistence.chainVoteDays(uuid) override def decreaseEffectPoint(uuid: UUID, effectPoint: EffectPoint): F[Unit] = - votePersistence.decreaseEffectPoints(uuid, effectPoint) + _votePersistence.decreaseEffectPoints(uuid, effectPoint) override def increaseEffectPointsByTen(uuid: UUID): F[Unit] = - votePersistence.increaseEffectPointsByTen(uuid) + _votePersistence.increaseEffectPointsByTen(uuid) override def effectPoints(player: Player): F[EffectPoint] = - votePersistence.effectPoints(player.getUniqueId) + _votePersistence.effectPoints(player.getUniqueId) override def increaseVoteBenefits(uuid: UUID, benefit: VoteBenefit): F[Unit] = - votePersistence.increaseVoteBenefits(uuid, benefit) + _votePersistence.increaseVoteBenefits(uuid, benefit) override def receivedVoteBenefits(uuid: UUID): F[VoteBenefit] = - votePersistence.receivedVoteBenefits(uuid) + _votePersistence.receivedVoteBenefits(uuid) import cats.implicits._ @@ -60,7 +60,7 @@ object System { } yield VoteBenefit(voteCounter.value - receivedVote.value) override def receiveVoteBenefits(player: Player): F[Unit] = - receiveVoteBenefits.receive(player) + _receiveVoteBenefits.receive(player) } override val commands: Map[String, TabExecutor] = Map( From 894bc0ade601b0279b90a4f9fa32fe45bd54a1bd Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:52:19 +0900 Subject: [PATCH 240/482] =?UTF-8?q?fix:=20voteSystem=E3=81=AE=E5=91=BC?= =?UTF-8?q?=E3=81=B3=E5=87=BA=E3=81=97=E5=87=A6=E7=90=86=E3=81=AE=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/seichiassist/SeichiAssist.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index a3f9f67bec..d458794981 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -408,8 +408,11 @@ class SeichiAssist extends JavaPlugin() { subsystems.sharedinventory.System.wired[IO] // TODO: これはprivateであるべきだが、Achievementシステムが再実装されるまでやむを得ずpublicにする - lazy val voteSystem: subsystems.vote.System[IO, Player] = - subsystems.vote.System.wired[IO] + lazy val voteSystem: subsystems.vote.System[IO, Player] = { + implicit val breakCountAPI: BreakCountAPI[IO, SyncIO, Player] = breakCountSystem.api + + subsystems.vote.System.wired[IO, SyncIO] + } private lazy val fairySystem: subsystems.vote.subsystems.fairy.System[IO, SyncIO, Player] = { import PluginExecutionContexts.{asyncShift, sleepAndRoutineContext} From 32b1573bfb4a3e625d53a4c0fcf65c1419b12e0c Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:53:19 +0900 Subject: [PATCH 241/482] =?UTF-8?q?refactor:=20receiveVoteBenefits?= =?UTF-8?q?=E3=82=92API=E3=81=8B=E3=82=89=E5=91=BC=E3=81=B3=E5=87=BA?= =?UTF-8?q?=E3=81=99=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/seichiassist/menus/VoteMenu.scala | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index ba399c6186..0b77a8b6c3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -132,9 +132,7 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( TargetedEffect.delay { player => - new BukkitReceiveVoteBenefits[IO, SyncIO] - .receive(player) - .unsafeRunAsyncAndForget() + voteAPI.receiveVoteBenefits(player).unsafeRunAsyncAndForget() }, MessageEffect( s"${GOLD}投票特典$WHITE(${voteCounter.value - benefits.value}票分)を受け取りました" From 08486bf71041c25627d6bd2041e4037ff4ac986c Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:54:50 +0900 Subject: [PATCH 242/482] =?UTF-8?q?refactor:=20=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?API=E3=81=AE=E5=AE=9A=E7=BE=A9=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/VoteAPI.scala | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index 1ba1092e49..bed527a3c4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -11,16 +11,6 @@ trait VoteWriteAPI[F[_]] { */ def decreaseEffectPoint(uuid: UUID, effectPoint: EffectPoint): F[Unit] - /** - * effectPointを増加させる作用 - */ - def increaseEffectPointsByTen(uuid: UUID): F[Unit] - - /** - * 投票特典を受け取った回数を増加させる作用 - */ - def increaseVoteBenefits(uuid: UUID, benefit: VoteBenefit): F[Unit] - } object VoteWriteAPI { @@ -51,11 +41,6 @@ trait VoteReadAPI[F[_], Player] { */ def receivedVoteBenefits(uuid: UUID): F[VoteBenefit] - /** - * 投票特典を受け取っていない回数を返す作用 - */ - def restVoteBenefits(uuid: UUID): F[VoteBenefit] - } object VoteReadAPI { From dc757b7ee852a373566a592908203ab8b0ff3f0e Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:55:17 +0900 Subject: [PATCH 243/482] =?UTF-8?q?refactor:=20API=E3=81=AE=E4=B8=8D?= =?UTF-8?q?=E8=A6=81=E3=81=AA=E5=AE=9F=E8=A3=85=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/System.scala | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index 9978931b0f..573bbb40fc 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -40,25 +40,12 @@ object System { override def decreaseEffectPoint(uuid: UUID, effectPoint: EffectPoint): F[Unit] = _votePersistence.decreaseEffectPoints(uuid, effectPoint) - override def increaseEffectPointsByTen(uuid: UUID): F[Unit] = - _votePersistence.increaseEffectPointsByTen(uuid) - override def effectPoints(player: Player): F[EffectPoint] = _votePersistence.effectPoints(player.getUniqueId) - override def increaseVoteBenefits(uuid: UUID, benefit: VoteBenefit): F[Unit] = - _votePersistence.increaseVoteBenefits(uuid, benefit) - override def receivedVoteBenefits(uuid: UUID): F[VoteBenefit] = _votePersistence.receivedVoteBenefits(uuid) - import cats.implicits._ - - override def restVoteBenefits(uuid: UUID): F[VoteBenefit] = for { - voteCounter <- voteCounter(uuid) - receivedVote <- receivedVoteBenefits(uuid) - } yield VoteBenefit(voteCounter.value - receivedVote.value) - override def receiveVoteBenefits(player: Player): F[Unit] = _receiveVoteBenefits.receive(player) } From f56e547d3a7efff0b52d9fe4646cc1dabf5ee224 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 17:57:42 +0900 Subject: [PATCH 244/482] =?UTF-8?q?refactor:=20=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?implicit=20=E5=BC=95=E6=95=B0=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listener/PlayerInventoryListener.scala | 8 ++------ .../unchama/seichiassist/menus/VoteMenu.scala | 20 +++---------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala b/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala index 346355985b..088e1ad79c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala +++ b/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala @@ -1,16 +1,14 @@ package com.github.unchama.seichiassist.listener -import cats.effect.{IO, SyncIO} +import cats.effect.IO import com.github.unchama.generic.effect.unsafe.EffectEnvironment import com.github.unchama.menuinventory.router.CanOpen import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist._ -import com.github.unchama.seichiassist.data.player.GiganticBerserk import com.github.unchama.seichiassist.data.MenuInventoryData +import com.github.unchama.seichiassist.data.player.GiganticBerserk import com.github.unchama.seichiassist.listener.invlistener.OnClickTitleMenu import com.github.unchama.seichiassist.menus.achievement.AchievementMenu -import com.github.unchama.seichiassist.menus.stickmenu.FirstPage -import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.util.InventoryOperations import com.github.unchama.targetedeffect.commandsender.MessageEffect @@ -25,9 +23,7 @@ import org.bukkit.{Bukkit, Material, Sound} class PlayerInventoryListener( implicit effectEnvironment: EffectEnvironment, - manaApi: ManaApi[IO, SyncIO, Player], voteAPI: VoteAPI[IO, Player], - ioCanOpenFirstPage: IO CanOpen FirstPage.type, ioCanOpenAchievementMenu: IO CanOpen AchievementMenu.type, ioOnMainThread: OnMinecraftServerThread[IO] ) extends Listener { diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 0b77a8b6c3..8f8024a03e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -12,20 +12,10 @@ import com.github.unchama.menuinventory.{ChestSlotRef, Menu, MenuFrame, MenuSlot import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMainThread import com.github.unchama.seichiassist.menus.stickmenu.FirstPage -import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI -import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI -import com.github.unchama.seichiassist.subsystems.vote.bukkit.actions.BukkitReceiveVoteBenefits import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{ - AlreadyFairySpawned, - NotEnoughEffectPoint, - NotEnoughSeichiLevel -} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - AppleOpenStateDependency, - FairySummonCost -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{AlreadyFairySpawned, NotEnoughEffectPoint, NotEnoughSeichiLevel} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{AppleOpenStateDependency, FairySummonCost} import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.player.PlayerEffects.closeInventoryEffect @@ -39,8 +29,6 @@ object VoteMenu extends Menu { class Environment( implicit val voteAPI: VoteAPI[IO, Player], val fairyAPI: FairyAPI[IO, SyncIO, Player], - val breakCountAPI: BreakCountAPI[IO, SyncIO, Player], - val manaApi: ManaApi[IO, SyncIO, Player], val ioCanOpenFirstPage: IO CanOpen FirstPage.type ) @@ -96,9 +84,7 @@ object VoteMenu extends Menu { private case class ConstantButtons(player: Player)( implicit voteAPI: VoteAPI[IO, Player], - fairyAPI: FairyAPI[IO, SyncIO, Player], - breakCountAPI: BreakCountAPI[IO, SyncIO, Player], - manaApi: ManaApi[IO, SyncIO, Player] + fairyAPI: FairyAPI[IO, SyncIO, Player] ) { import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.layoutPreparationContext From c36db29e03e353e76bc2aa10434089dc68819d22 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 18:11:12 +0900 Subject: [PATCH 245/482] =?UTF-8?q?refactor:=20gachaRingoInformation?= =?UTF-8?q?=E3=83=AD=E3=83=BC=E3=83=AB=E3=81=AEList=E3=82=92=E5=A4=89?= =?UTF-8?q?=E6=95=B0=E3=81=AB=E5=88=87=E3=82=8A=E5=87=BA=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 73 ++++++++++--------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 8f8024a03e..b0588f2071 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -14,8 +14,15 @@ import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMain import com.github.unchama.seichiassist.menus.stickmenu.FirstPage import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{AlreadyFairySpawned, NotEnoughEffectPoint, NotEnoughSeichiLevel} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{AppleOpenStateDependency, FairySummonCost} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{ + AlreadyFairySpawned, + NotEnoughEffectPoint, + NotEnoughSeichiLevel +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + AppleOpenStateDependency, + FairySummonCost +} import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.player.PlayerEffects.closeInventoryEffect @@ -309,41 +316,39 @@ object VoteMenu extends Menu { } val gachaRingoInformation: IO[Button] = IO { + val staticLore = List( + s"$RESET$RED$BOLD※ニンゲンに見られないように気を付けること!", + s"$RESET$RED$BOLD 毎日大妖精からデータを更新すること!", + "", + s"$RESET$GOLD${BOLD}昨日までにがちゃりんごを", + s"$RESET$GOLD${BOLD}たくさんくれたニンゲンたち", + s"$RESET${DARK_GRAY}召喚されたらラッキーだよ!" + ) + val topFour = fairyAPI.appleAteByFairyRanking(4).unsafeRunSync() + val topFourRankingLore = + List(topFour.headOption, topFour.lift(1), topFour.lift(2), topFour.lift(3)).flatMap { + rankDataOpt => + if (rankDataOpt.nonEmpty) { + val rankData = rankDataOpt.get.get + List( + s"${GRAY}たくさんくれたニンゲン第${rankData.rank}位!", + s"${GRAY}なまえ:${rankData.name} りんご:${rankData.appleAmount.amount}個" + ) + } else Nil + } + val myRank = fairyAPI.appleAteByFairyMyRanking(player).unsafeRunSync().get + val statistics = List( + s"${AQUA}ぜーんぶで${fairyAPI.allEatenAppleAmount.unsafeRunSync().amount}個もらえた!", + "", + s"$GREEN↓呼び出したニンゲンの情報↓", + s"${GREEN}今までに${myRank.appleAmount.amount}個もらった", + s"${GREEN}ニンゲンの中では${myRank.rank}番目にたくさんくれる!" + ) + Button( new IconItemStackBuilder(Material.GOLDEN_APPLE) .title(s"$YELLOW$UNDERLINE$BOLD㊙ がちゃりんご情報 ㊙") - .lore( - List( - s"$RESET$RED$BOLD※ニンゲンに見られないように気を付けること!", - s"$RESET$RED$BOLD 毎日大妖精からデータを更新すること!", - "", - s"$RESET$GOLD${BOLD}昨日までにがちゃりんごを", - s"$RESET$GOLD${BOLD}たくさんくれたニンゲンたち", - s"$RESET${DARK_GRAY}召喚されたらラッキーだよ!" - ) ++ { - // TOP4のランキングロール - val topFour = fairyAPI.appleAteByFairyRanking(4).unsafeRunSync() - List(topFour.headOption, topFour.lift(1), topFour.lift(2), topFour.lift(3)) - .flatMap { rankDataOpt => - if (rankDataOpt.nonEmpty) { - val rankData = rankDataOpt.get.get - List( - s"${GRAY}たくさんくれたニンゲン第${rankData.rank}位!", - s"${GRAY}なまえ:${rankData.name} りんご:${rankData.appleAmount.amount}個" - ) - } else Nil - } - } ++ { - val myRank = fairyAPI.appleAteByFairyMyRanking(player).unsafeRunSync().get - List( - s"${AQUA}ぜーんぶで${fairyAPI.allEatenAppleAmount.unsafeRunSync().amount}個もらえた!", - "", - s"$GREEN↓呼び出したニンゲンの情報↓", - s"${GREEN}今までに${myRank.appleAmount.amount}個もらった", - s"${GREEN}ニンゲンの中では${myRank.rank}番目にたくさんくれる!" - ) - } - ) + .lore(staticLore ++ topFourRankingLore ++ statistics) .enchanted() .build() ) From 2f657f41f7ff8fde2d235e85963029008b757ea6 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 18:16:10 +0900 Subject: [PATCH 246/482] =?UTF-8?q?refactor:=20=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E5=9E=8B=E3=83=91=E3=83=A9=E3=83=A1=E3=83=BC=E3=82=BF=E3=83=BC?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/application/actions/FairyRoutine.scala | 2 +- .../fairy/application/actions/SummonFairy.scala | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala index 5854f9b20f..2bf138b817 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions -trait FairyRoutine[F[_], G[_], Player] { +trait FairyRoutine[F[_], Player] { def start(player: Player): F[Nothing] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala index 392a5d98a7..79a4a0d9c8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions -trait SummonFairy[F[_], G[_], Player] { +trait SummonFairy[F[_], Player] { /** * 妖精を召喚する作用 @@ -11,9 +11,9 @@ trait SummonFairy[F[_], G[_], Player] { object SummonFairy { - def apply[F[_], G[_], Player]( - implicit ev: SummonFairy[F, G, Player] - ): SummonFairy[F, G, Player] = + def apply[F[_], Player]( + implicit ev: SummonFairy[F, Player] + ): SummonFairy[F, Player] = ev } From a3b976bd1bcba74094d779750177b8f98a96e986 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 18:19:51 +0900 Subject: [PATCH 247/482] fix: compile error --- .../seichiassist/subsystems/vote/subsystems/fairy/System.scala | 2 +- .../FairyManaRecoveryRoutineFiberRepositoryDefinition.scala | 2 +- .../vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala | 2 +- .../subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala | 2 +- .../subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 5b30b593fb..9105e04514 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -90,7 +90,7 @@ object System { implicit val fairySpeech: FairySpeech[IO, Player] = fairySpeechProvider( fairySpeechServiceRepository ) - implicit val summonFairy: SummonFairy[IO, SyncIO, Player] = + implicit val summonFairy: SummonFairy[IO, Player] = new BukkitSummonFairy[IO, SyncIO] val summonRequest: FairySummonRequest[IO, Player] = new BukkitFairySummonRequest[IO, SyncIO] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala index 1382782257..5ee4d8f45b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala @@ -14,7 +14,7 @@ object FairyManaRecoveryRoutineFiberRepositoryDefinition { implicit val ioCE: ConcurrentEffect[IO] = IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) - def initialization[Player](fairyRoutine: FairyRoutine[IO, SyncIO, Player])( + def initialization[Player](fairyRoutine: FairyRoutine[IO, Player])( implicit context: RepeatingTaskContext ): TwoPhasedRepositoryInitialization[SyncIO, Player, Deferred[IO, Fiber[IO, Nothing]]] = TwoPhasedRepositoryInitialization diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala index 7a2bec3250..91a5c6b01b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala @@ -17,7 +17,7 @@ class BukkitFairySummonRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( implicit breakCountAPI: BreakCountAPI[F, G, Player], voteAPI: VoteAPI[F, Player], fairyPersistence: FairyPersistence[F], - summonFairy: SummonFairy[F, G, Player] + summonFairy: SummonFairy[F, Player] ) extends FairySummonRequest[F, Player] { import cats.implicits._ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 2c49f8f30d..0d574e090e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -18,7 +18,7 @@ class BukkitSummonFairy[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( manaApi: ManaApi[F, G, Player], fairyPersistence: FairyPersistence[F], fairySpeech: FairySpeech[F, Player] -) extends SummonFairy[F, G, Player] { +) extends SummonFairy[F, Player] { import cats.implicits._ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index e551aaf095..1a4903f645 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -21,7 +21,7 @@ class BukkitFairyRoutine(fairySpeech: FairySpeech[IO, Player])( manaApi: ManaApi[IO, SyncIO, Player], context: RepeatingTaskContext, fairyPersistence: FairyPersistence[IO] -) extends FairyRoutine[IO, SyncIO, Player] { +) extends FairyRoutine[IO, Player] { override def start(player: Player): IO[Nothing] = { From 43ad6a371ba12312f6e6c2107306415303a22e5f Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 18:22:00 +0900 Subject: [PATCH 248/482] =?UTF-8?q?feat:=20AppleAmount=E3=81=AErequire?= =?UTF-8?q?=E3=81=AB=E3=82=A8=E3=83=A9=E3=83=BC=E3=83=A1=E3=83=83=E3=82=BB?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/domain/property/AppleAmount.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAmount.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAmount.scala index 5bf4fd31d5..e584b4bc27 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAmount.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAmount.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property case class AppleAmount(amount: Int) { - require(amount >= 0) + require(amount >= 0, "amountは非負の値で指定してください。") } From 1c94a51297e4a8aa6f536d6f5eebba3a7d222241 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 18:22:40 +0900 Subject: [PATCH 249/482] =?UTF-8?q?feat:=20AppleAteByFairyRank=E3=81=AEreq?= =?UTF-8?q?uire=E3=81=AB=E3=82=A8=E3=83=A9=E3=83=BC=E3=83=A1=E3=83=83?= =?UTF-8?q?=E3=82=BB=E3=83=BC=E3=82=B8=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/domain/property/AppleAteByFairyRank.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRank.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRank.scala index 020ae93301..3d5286f405 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRank.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRank.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property case class AppleAteByFairyRank(name: String, rank: Int, appleAmount: AppleAmount) { - require(rank >= 1) + require(rank >= 1, "rankは1以上の値で指定してください。") } From a6d949f7f1919eea73932aa4c9305ad0f5f88c87 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 18:24:20 +0900 Subject: [PATCH 250/482] =?UTF-8?q?docs:=20createPlayerData=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E3=81=A7IGNORE=E3=81=99=E3=82=8B=E7=90=86=E7=94=B1?= =?UTF-8?q?=E3=82=92=E6=9B=B8=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/infrastructure/JdbcFairyPersistence.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index b4567b212d..57b5aeba76 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -14,6 +14,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { */ def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { DB.localTx { implicit session => + // ここでIGNOREするのは、作成するデータが既に存在していた場合に発生するエラーを無視するため sql"INSERT IGNORE INTO vote_fairy (uuid) VALUES (${uuid.toString})".execute().apply() } } From cd58b65c1e1979659473af158675a770a6d4082b Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 18:26:46 +0900 Subject: [PATCH 251/482] =?UTF-8?q?refactor:=20FairyPlayerJoinGreeter?= =?UTF-8?q?=E3=81=AEConcurrentEffect=E3=82=92=E5=BC=95=E6=95=B0=E3=81=A7?= =?UTF-8?q?=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index 546900fd52..22020291af 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -13,7 +13,8 @@ import java.time.LocalDateTime class FairyPlayerJoinGreeter( implicit fairyPersistence: FairyPersistence[IO], - fairySpeech: FairySpeech[IO, Player] + fairySpeech: FairySpeech[IO, Player], + concurrentEffect: ConcurrentEffect[IO] ) extends Listener { @EventHandler @@ -32,9 +33,6 @@ class FairyPlayerJoinGreeter( fairyPersistence.updateIsFairyUsing(uuid, isFairyUsing = false).unsafeRunSync() } else { // まだ終了時間ではない(つまり有効時間内) - implicit val ioCE: ConcurrentEffect[IO] = - IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) - fairySpeech.welcomeBack(player).unsafeRunSync() } } else SyncIO.unit From a57c3b767cc88eb2157bab3d6bb17c17225d2155 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 18:27:52 +0900 Subject: [PATCH 252/482] =?UTF-8?q?refactor:=20BukkitFairyRoutine=E3=81=A7?= =?UTF-8?q?concurrentEffect=E3=82=92=E5=BC=95=E6=95=B0=E3=81=A7=E5=8F=96?= =?UTF-8?q?=E5=BE=97=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/routines/BukkitFairyRoutine.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index 1a4903f645..27507c70c9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -20,7 +20,8 @@ class BukkitFairyRoutine(fairySpeech: FairySpeech[IO, Player])( voteAPI: VoteAPI[IO, Player], manaApi: ManaApi[IO, SyncIO, Player], context: RepeatingTaskContext, - fairyPersistence: FairyPersistence[IO] + fairyPersistence: FairyPersistence[IO], + concurrentEffect: ConcurrentEffect[IO] ) extends FairyRoutine[IO, Player] { override def start(player: Player): IO[Nothing] = { @@ -36,9 +37,6 @@ class BukkitFairyRoutine(fairySpeech: FairySpeech[IO, Player])( implicit val onMainThread: OnMinecraftServerThread[IO] = PluginExecutionContexts.onMainThread - implicit val ioCE: ConcurrentEffect[IO] = - IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) - RepeatingRoutine.permanentRoutine( repeatInterval, onMainThread.runAction { From 0cb8c65ecde4e9dd21b7eb23be9d42c9683c71ba Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 18:29:38 +0900 Subject: [PATCH 253/482] =?UTF-8?q?refactor:=20BukkitFairyRoutine=E3=81=AE?= =?UTF-8?q?onMainThread=E3=82=92=E5=BC=95=E6=95=B0=E3=81=8B=E3=82=89?= =?UTF-8?q?=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 30 +++++-------------- .../listeners/FairyPlayerJoinGreeter.scala | 1 - .../bukkit/routines/BukkitFairyRoutine.scala | 9 ++---- 3 files changed, 11 insertions(+), 29 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 9105e04514..11f661500c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -2,39 +2,24 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.concurrent.RepeatingTaskContext -import com.github.unchama.datarepository.bukkit.player.{ - BukkitRepositoryControls, - PlayerDataRepository -} +import com.github.unchama.datarepository.bukkit.player.{BukkitRepositoryControls, PlayerDataRepository} import com.github.unchama.datarepository.template.RepositoryDefinition +import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{ - FairyManaRecoveryRoutineFiberRepositoryDefinition, - SpeechServiceRepositoryDefinitions -} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{ - BukkitFairySummonRequest, - BukkitFairySpeech -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{FairyManaRecoveryRoutineFiberRepositoryDefinition, SpeechServiceRepositoryDefinitions} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{BukkitFairySpeech, BukkitFairySummonRequest} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{ - FairySpeech, - FairySpeechGateway -} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - FairyPersistence, - FairySummonRequest, - FairySpawnRequestErrorOrSpawn -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{FairySpeech, FairySpeechGateway} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpawnRequestErrorOrSpawn, FairySummonRequest} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player @@ -53,7 +38,8 @@ object System { voteAPI: VoteAPI[IO, Player], manaApi: ManaApi[IO, SyncIO, Player], repeatingTaskContext: RepeatingTaskContext, - concurrentEffect: ConcurrentEffect[IO] + concurrentEffect: ConcurrentEffect[IO], + minecraftServerThread: OnMinecraftServerThread[IO] ): SyncIO[System[IO, SyncIO, Player]] = { implicit val persistence: FairyPersistence[IO] = new JdbcFairyPersistence[IO] implicit val fairySpeechGatewayProvider: Player => FairySpeechGateway[SyncIO] = diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index 22020291af..48612d3d54 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -1,7 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners import cats.effect.{ConcurrentEffect, IO, SyncIO} -import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import org.bukkit.ChatColor._ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index 27507c70c9..e179dadb14 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -3,7 +3,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit. import cats.effect.{ConcurrentEffect, IO, SyncIO, Timer} import com.github.unchama.concurrent.{RepeatingRoutine, RepeatingTaskContext} import com.github.unchama.minecraft.actions.OnMinecraftServerThread -import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI @@ -21,7 +20,8 @@ class BukkitFairyRoutine(fairySpeech: FairySpeech[IO, Player])( manaApi: ManaApi[IO, SyncIO, Player], context: RepeatingTaskContext, fairyPersistence: FairyPersistence[IO], - concurrentEffect: ConcurrentEffect[IO] + concurrentEffect: ConcurrentEffect[IO], + minecraftServerThread: OnMinecraftServerThread[IO] ) extends FairyRoutine[IO, Player] { override def start(player: Player): IO[Nothing] = { @@ -34,12 +34,9 @@ class BukkitFairyRoutine(fairySpeech: FairySpeech[IO, Player])( implicit val timer: Timer[IO] = IO.timer(context) - implicit val onMainThread: OnMinecraftServerThread[IO] = - PluginExecutionContexts.onMainThread - RepeatingRoutine.permanentRoutine( repeatInterval, - onMainThread.runAction { + minecraftServerThread.runAction { new BukkitRecoveryMana[IO, SyncIO](player, fairySpeech).recovery.runAsync(_ => IO.unit) } ) From 59d0929f7bd1b61d8d974b2d9223285cb328cf49 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 19:00:48 +0900 Subject: [PATCH 254/482] =?UTF-8?q?style:=20appleConsumeStrategy=E3=81=AB?= =?UTF-8?q?=E3=83=AA=E3=83=8D=E3=83=BC=E3=83=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 2 +- .../subsystems/vote/subsystems/fairy/System.scala | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 1a4d9166a4..4d8df1e1b9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -10,7 +10,7 @@ trait FairyWriteAPI[F[_], G[_], Player] { /** * 妖精にあげるりんごの開放状態を変更する */ - def updateAppleOpenState(uuid: UUID, appleOpenState: FairyAppleConsumeStrategy): F[Unit] + def updateAppleOpenState(uuid: UUID, appleConsumeStrategy: FairyAppleConsumeStrategy): F[Unit] /** * 妖精を召喚するためのコストを変更します。 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 11f661500c..7c5807a582 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -87,10 +87,10 @@ object System { persistence.appleOpenState(uuid) override def updateAppleOpenState( - uuid: UUID, - appleOpenState: FairyAppleConsumeStrategy + uuid: UUID, + appleConsumeStrategy: FairyAppleConsumeStrategy ): IO[Unit] = - persistence.changeAppleOpenState(uuid, appleOpenState) + persistence.changeAppleOpenState(uuid, appleConsumeStrategy) override def getFairyLore(uuid: UUID): IO[FairyLore] = for { state <- appleOpenState(uuid) From 1bcd60a88da9960c4591239954b973dac19fc7c7 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 19:09:23 +0900 Subject: [PATCH 255/482] =?UTF-8?q?refactor:=20effectPoints=E3=82=92?= =?UTF-8?q?=E5=85=88=E3=81=AB=E5=B1=95=E9=96=8B=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/menus/skill/ActiveSkillEffectMenu.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/skill/ActiveSkillEffectMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/skill/ActiveSkillEffectMenu.scala index 892e961e0f..839bfdf3c7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/skill/ActiveSkillEffectMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/skill/ActiveSkillEffectMenu.scala @@ -190,6 +190,7 @@ object ActiveSkillEffectMenu extends Menu { .databaseGateway .donateDataManipulator .currentPremiumPointFor(player) + effectPoints <- voteAPI.effectPoints(player) button <- IO { val playerData = SeichiAssist.playermap(getUniqueId) @@ -201,7 +202,7 @@ object ActiveSkillEffectMenu extends Menu { .lore( List( s"$RESET${GREEN}現在選択しているエフェクト:${playerData.skillEffectState.selection.nameOnUI}", - s"$RESET${YELLOW}使えるエフェクトポイント:${voteAPI.effectPoints(player).unsafeRunSync().value}", + s"$RESET${YELLOW}使えるエフェクトポイント:${effectPoints.value}", s"$RESET$DARK_GRAY※投票すると獲得できます", s"$RESET${LIGHT_PURPLE}使えるプレミアムポイント$premiumEffectPoint", s"$RESET$DARK_GRAY※寄付をすると獲得できます" From 86a3332011269cde349ca6bab10c556d182d813e Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 19:13:38 +0900 Subject: [PATCH 256/482] =?UTF-8?q?refactor:=20=E4=BB=98=E4=B8=8E=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=A2=E3=82=A4=E3=83=86=E3=83=A0=E3=82=92=E5=A4=89?= =?UTF-8?q?=E6=95=B0=E3=81=AB=E5=88=87=E3=82=8A=E5=87=BA=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/BukkitReceiveVoteBenefits.scala | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index b46eccafa0..0767bb47ec 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -33,16 +33,18 @@ class BukkitReceiveVoteBenefits[F[_]: OnMinecraftServerThread: Sync, G[ playerLevel <- ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read.map { _.levelCorrespondingToExp.level }) - items = - Seq.fill(10 * notReceivedBenefits.value)(BukkitGachaSkullData.gachaForVoting) ++ - Seq.fill(notReceivedBenefits.value)( - if (playerLevel < 50) ItemData.getSuperPickaxe(1) - else ItemData.getVotingGift(1) - ) + gachaSkulls = Seq.fill(10 * notReceivedBenefits.value)( + BukkitGachaSkullData.gachaForVoting + ) + elseVoteBenefits = Seq.fill(notReceivedBenefits.value)( + if (playerLevel < 50) ItemData.getSuperPickaxe(1) + else ItemData.getVotingGift(1) + ) + grantItems = gachaSkulls ++ elseVoteBenefits _ <- { ContextCoercion(votePersistence.increaseEffectPointsByTen(uuid)) .replicateA(notReceivedBenefits.value) >> - grantItemStacksEffect[F](items: _*).apply(player) + grantItemStacksEffect[F](grantItems: _*).apply(player) }.whenA(notReceivedBenefits.value != 0) } yield () } From 76ec33229d07636f1e1435dc685d08a37e6f7d1b Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 21:22:42 +0900 Subject: [PATCH 257/482] =?UTF-8?q?refactor:=20playSpeechSound=E3=81=A7uns?= =?UTF-8?q?afeRunSync=E3=82=92=E5=91=BC=E3=81=B0=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/gateway/BukkitFairySpeechGateway.scala | 13 ++++++------- .../com/github/unchama/targetedeffect/package.scala | 1 + .../targetedeffect/player/FocusedSoundEffect.scala | 11 ++++++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala index 33c0d52b33..d3ac2e8fb4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala @@ -4,18 +4,17 @@ import cats.effect.Sync import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeechGateway import com.github.unchama.targetedeffect.commandsender.MessageEffectF -import com.github.unchama.targetedeffect.player.FocusedSoundEffect +import com.github.unchama.targetedeffect.player.FocusedSoundEffectF import org.bukkit.ChatColor.{AQUA, BOLD, RESET} import org.bukkit.Sound import org.bukkit.entity.Player -class BukkitFairySpeechGateway[G[_]: Sync](player: Player) extends FairySpeechGateway[G] { +class BukkitFairySpeechGateway[F[_]: Sync](player: Player) extends FairySpeechGateway[F] { - override def sendMessage(fairyMessage: FairyMessage): G[Unit] = - MessageEffectF[G](s"$AQUA$BOLD<マナ妖精>$RESET${fairyMessage.message}").run(player) + override def sendMessage(fairyMessage: FairyMessage): F[Unit] = + MessageEffectF[F](s"$AQUA$BOLD<マナ妖精>$RESET${fairyMessage.message}").run(player) - override def playSpeechSound: G[Unit] = Sync[G].delay { - FocusedSoundEffect(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f).run(player).unsafeRunSync() - } + override def playSpeechSound: F[Unit] = + FocusedSoundEffectF(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f).run(player) } diff --git a/src/main/scala/com/github/unchama/targetedeffect/package.scala b/src/main/scala/com/github/unchama/targetedeffect/package.scala index 34acaf4784..4fbcbc00e0 100644 --- a/src/main/scala/com/github/unchama/targetedeffect/package.scala +++ b/src/main/scala/com/github/unchama/targetedeffect/package.scala @@ -6,5 +6,6 @@ import cats.effect.IO package object targetedeffect { type TargetedEffect[-T] = Kleisli[IO, T, Unit] + type TargetedEffectF[F[_], -T] = Kleisli[F, T, Unit] } diff --git a/src/main/scala/com/github/unchama/targetedeffect/player/FocusedSoundEffect.scala b/src/main/scala/com/github/unchama/targetedeffect/player/FocusedSoundEffect.scala index 6cd25c03b6..5a09b43faa 100644 --- a/src/main/scala/com/github/unchama/targetedeffect/player/FocusedSoundEffect.scala +++ b/src/main/scala/com/github/unchama/targetedeffect/player/FocusedSoundEffect.scala @@ -1,6 +1,7 @@ package com.github.unchama.targetedeffect.player -import com.github.unchama.targetedeffect.TargetedEffect +import cats.effect.Sync +import com.github.unchama.targetedeffect.{TargetedEffect, TargetedEffectF} import org.bukkit.Sound import org.bukkit.entity.Player @@ -14,3 +15,11 @@ object FocusedSoundEffect { player.playSound(player.getLocation, sound, volume, pitch) } } + +object FocusedSoundEffectF { + def apply[F[_]: Sync](sound: Sound, volume: Float, pitch: Float): TargetedEffectF[F, Player] = + TargetedEffect.delay[F, Player] { player => + // 音を鳴らすのは非同期スレッドでも問題ない(Spigot 1.12.2) + player.playSound(player.getLocation, sound, volume, pitch) + } +} From 8a1cfe4fb2a58bf1d5a006581dff439f3784f8c2 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 21:33:20 +0900 Subject: [PATCH 258/482] =?UTF-8?q?refactor:=20FairyPlayerJoinGreeter?= =?UTF-8?q?=E3=81=AE=E5=87=A6=E7=90=86=E3=81=A7unsafeRunSync=E3=82=92?= =?UTF-8?q?=E3=81=BE=E3=81=A8=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listeners/FairyPlayerJoinGreeter.scala | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index 48612d3d54..e8ce6bc8cf 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners -import cats.effect.{ConcurrentEffect, IO, SyncIO} +import cats.effect.{ConcurrentEffect, IO} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import org.bukkit.ChatColor._ @@ -16,6 +16,8 @@ class FairyPlayerJoinGreeter( concurrentEffect: ConcurrentEffect[IO] ) extends Listener { + import cats.implicits._ + @EventHandler def onJoin(e: PlayerJoinEvent): Unit = { val player = e.getPlayer @@ -24,18 +26,15 @@ class FairyPlayerJoinGreeter( _ <- fairyPersistence.createPlayerData(uuid) isUsing <- fairyPersistence.isFairyUsing(uuid) endTime <- fairyPersistence.fairyEndTime(uuid) - } yield { - if (isUsing) { - if (endTime.get.endTimeOpt.get.isBefore(LocalDateTime.now())) { - // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) + isEnd = endTime.get.endTimeOpt.get.isBefore(LocalDateTime.now()) + _ <- { + fairyPersistence.updateIsFairyUsing(uuid, isFairyUsing = false) >> IO( player.sendMessage(s"$LIGHT_PURPLE${BOLD}妖精は何処かへ行ってしまったようだ...") - fairyPersistence.updateIsFairyUsing(uuid, isFairyUsing = false).unsafeRunSync() - } else { - // まだ終了時間ではない(つまり有効時間内) - fairySpeech.welcomeBack(player).unsafeRunSync() - } - } else SyncIO.unit - } + ) + // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) + }.whenA(isUsing && isEnd) + _ <- fairySpeech.welcomeBack(player).whenA(isUsing && !isEnd) + } yield () eff.unsafeRunSync() } From 5bc6f32a86b93ab11427ba048555f83263a10ddf Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 21:35:11 +0900 Subject: [PATCH 259/482] =?UTF-8?q?style:=20Scalafmt=E7=AD=89=E5=AE=9F?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 30 ++++++++++++++----- .../application/actions/SummonFairy.scala | 4 +-- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 7c5807a582..63460ed054 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -2,7 +2,10 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.concurrent.RepeatingTaskContext -import com.github.unchama.datarepository.bukkit.player.{BukkitRepositoryControls, PlayerDataRepository} +import com.github.unchama.datarepository.bukkit.player.{ + BukkitRepositoryControls, + PlayerDataRepository +} import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem @@ -10,16 +13,29 @@ import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{FairyManaRecoveryRoutineFiberRepositoryDefinition, SpeechServiceRepositoryDefinitions} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{BukkitFairySpeech, BukkitFairySummonRequest} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{ + FairyManaRecoveryRoutineFiberRepositoryDefinition, + SpeechServiceRepositoryDefinitions +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{ + BukkitFairySpeech, + BukkitFairySummonRequest +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{FairySpeech, FairySpeechGateway} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpawnRequestErrorOrSpawn, FairySummonRequest} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{ + FairySpeech, + FairySpeechGateway +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + FairyPersistence, + FairySpawnRequestErrorOrSpawn, + FairySummonRequest +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player @@ -87,8 +103,8 @@ object System { persistence.appleOpenState(uuid) override def updateAppleOpenState( - uuid: UUID, - appleConsumeStrategy: FairyAppleConsumeStrategy + uuid: UUID, + appleConsumeStrategy: FairyAppleConsumeStrategy ): IO[Unit] = persistence.changeAppleOpenState(uuid, appleConsumeStrategy) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala index 79a4a0d9c8..37b0cac8c1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala @@ -11,9 +11,7 @@ trait SummonFairy[F[_], Player] { object SummonFairy { - def apply[F[_], Player]( - implicit ev: SummonFairy[F, Player] - ): SummonFairy[F, Player] = + def apply[F[_], Player](implicit ev: SummonFairy[F, Player]): SummonFairy[F, Player] = ev } From 7538e28cb0c2152e7460b8c99d4a6edfc235e168 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 21:55:22 +0900 Subject: [PATCH 260/482] =?UTF-8?q?style:=20FairySummonCost=E3=81=AE?= =?UTF-8?q?=E6=96=87=E5=AD=97=E5=88=97=E7=BD=AE=E3=81=8D=E6=8F=9B=E3=81=88?= =?UTF-8?q?=E3=82=92Menu=E5=81=B4=E3=81=AB=E6=8A=BC=E3=81=97=E4=BB=98?= =?UTF-8?q?=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 13 +++++++++++-- .../fairy/domain/property/FairySummonCost.scala | 9 --------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index b0588f2071..14fda279d3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -173,7 +173,7 @@ object VoteMenu extends Menu { .title(s"$AQUA$UNDERLINE${BOLD}マナ妖精 時間設定") .lore( List( - s"$RESET$GREEN$BOLD${fairySummonCost.finiteDuration}", + s"$RESET$GREEN$BOLD${fairySummonCostToString(fairySummonCost)}", "", s"$RESET${GRAY}コスト", s"$RESET$RED$BOLD${fairySummonCost.value * 2}投票pt", @@ -261,7 +261,7 @@ object VoteMenu extends Menu { List( s"$RESET$GRAY${fairySummonState.value * 2}投票ptを消費して", s"$RESET${GRAY}マナ妖精を呼びます", - s"$RESET${GRAY}時間: ${fairySummonState.finiteDuration}", + s"$RESET${GRAY}時間: ${fairySummonCostToString(fairySummonState)}", s"$RESET${DARK_RED}Lv.10以上で開放" ) ) @@ -290,6 +290,15 @@ object VoteMenu extends Menu { ) } + private def fairySummonCostToString(fairySummonCost: FairySummonCost): String = { + fairySummonCost.value match { + case 1 => "30分" + case 2 => "1時間" + case 3 => "1時間30分" + case 4 => "2時間" + } + } + private def spawnFailedEffect(message: String): Kleisli[IO, Player, Unit] = { SequentialEffect( MessageEffect(message), diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala index f9b07a73ea..11b5bc6a5b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala @@ -24,13 +24,4 @@ case class FairySummonCost(value: Int) { validTime } - def finiteDuration: String = { - value match { - case 1 => "30分" - case 2 => "1時間" - case 3 => "1時間30分" - case 4 => "2時間" - } - } - } From f95b4ebdf539b07988a8a5966fe505998eee3e70 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 21:56:22 +0900 Subject: [PATCH 261/482] style: Spawn -> Summon --- .../unchama/seichiassist/menus/VoteMenu.scala | 2 +- .../fairy/bukkit/BukkitFairySummonRequest.scala | 8 ++++---- .../vote/subsystems/fairy/domain/package.scala | 4 ++-- .../domain/property/FairySpawnRequestError.scala | 13 ------------- .../domain/property/FairySummonRequestError.scala | 13 +++++++++++++ 5 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestError.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonRequestError.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 14fda279d3..c5ef24e7df 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -14,7 +14,7 @@ import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMain import com.github.unchama.seichiassist.menus.stickmenu.FirstPage import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError.{ +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySummonRequestError.{ AlreadyFairySpawned, NotEnoughEffectPoint, NotEnoughSeichiLevel diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala index 91a5c6b01b..58dea7f5f8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala @@ -5,7 +5,7 @@ import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySummonRequestError import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ FairyPersistence, FairySpawnRequestErrorOrSpawn, @@ -34,11 +34,11 @@ class BukkitFairySummonRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( seichiLevel = seichiAmountRepository.levelCorrespondingToExp.level } yield { if (seichiLevel < 10) - Left(FairySpawnRequestError.NotEnoughSeichiLevel) + Left(FairySummonRequestError.NotEnoughSeichiLevel) else if (usingState) - Left(FairySpawnRequestError.AlreadyFairySpawned) + Left(FairySummonRequestError.AlreadyFairySpawned) else if (effectPoints.value < fairySummonCost.value * 2) - Left(FairySpawnRequestError.NotEnoughEffectPoint) + Left(FairySummonRequestError.NotEnoughEffectPoint) else Right(summonFairy.summon(player)) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/package.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/package.scala index d36050f7a8..0720e763aa 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/package.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/package.scala @@ -1,9 +1,9 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySpawnRequestError +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySummonRequestError package object domain { - type FairySpawnRequestErrorOrSpawn[F[_]] = Either[FairySpawnRequestError, F[Unit]] + type FairySpawnRequestErrorOrSpawn[F[_]] = Either[FairySummonRequestError, F[Unit]] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestError.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestError.scala deleted file mode 100644 index b8a03ee27a..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySpawnRequestError.scala +++ /dev/null @@ -1,13 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property - -sealed trait FairySpawnRequestError - -object FairySpawnRequestError { - - case object NotEnoughSeichiLevel extends FairySpawnRequestError - - case object AlreadyFairySpawned extends FairySpawnRequestError - - case object NotEnoughEffectPoint extends FairySpawnRequestError - -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonRequestError.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonRequestError.scala new file mode 100644 index 0000000000..ddf38e9bd2 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonRequestError.scala @@ -0,0 +1,13 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property + +sealed trait FairySummonRequestError + +object FairySummonRequestError { + + case object NotEnoughSeichiLevel extends FairySummonRequestError + + case object AlreadyFairySpawned extends FairySummonRequestError + + case object NotEnoughEffectPoint extends FairySummonRequestError + +} From 9f80d675ed64c1383827c327c0754558cb5a320a Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 21:58:09 +0900 Subject: [PATCH 262/482] =?UTF-8?q?docs:=20FairySummonRequestError?= =?UTF-8?q?=E3=81=AB=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=92=E6=9B=B8=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/property/FairySummonRequestError.scala | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonRequestError.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonRequestError.scala index ddf38e9bd2..6207350172 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonRequestError.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonRequestError.scala @@ -2,12 +2,24 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain. sealed trait FairySummonRequestError +/** + * 妖精の召喚をする際に発生する可能性がある一覧を定義したobject + */ object FairySummonRequestError { + /** + * 整地レベルが足りなかった + */ case object NotEnoughSeichiLevel extends FairySummonRequestError + /** + * 妖精がすでに召喚されている + */ case object AlreadyFairySpawned extends FairySummonRequestError + /** + * 妖精の召喚ポイントが足りなかった + */ case object NotEnoughEffectPoint extends FairySummonRequestError } From 54cb0ce1e01845b270764a97901231608977c260 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 21:59:23 +0900 Subject: [PATCH 263/482] =?UTF-8?q?docs:=20FairySpawnRequest=E3=81=AE?= =?UTF-8?q?=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/domain/FairySummonRequest.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonRequest.scala index 1c66ca63d6..3a73010f61 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonRequest.scala @@ -4,7 +4,7 @@ trait FairySummonRequest[F[_], Player] { /** * 妖精の召喚をリクエストする - * 召喚に失敗した場合はエラーを返す + * 召喚に失敗した場合は[[FairySpawnRequestError]]を返す * 成功した場合は召喚する作用を返す */ def summonRequest(player: Player): F[FairySpawnRequestErrorOrSpawn[F]] From e97126c3204e1f4f9cde012cc9a186c5f2948804 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:00:46 +0900 Subject: [PATCH 264/482] =?UTF-8?q?docs:=20AppleOpenStateDependency?= =?UTF-8?q?=E3=81=AB=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/domain/property/AppleOpenStateDependency.scala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala index e34d8353db..284b67ed6a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala @@ -2,6 +2,9 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain. import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyAppleConsumeStrategy._ +/** + * 妖精に開放するりんごの状態の順番を定義したオブジェクト + */ object AppleOpenStateDependency { val dependency: Map[FairyAppleConsumeStrategy, FairyAppleConsumeStrategy] = From 839fa87617f0166b67f7503dbc20187ed0660e42 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:02:43 +0900 Subject: [PATCH 265/482] =?UTF-8?q?docs:=20FairySpeechGateway=E3=81=AB?= =?UTF-8?q?=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/domain/speech/FairySpeechGateway.scala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeechGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeechGateway.scala index 22d15a0614..d4ab9b77fe 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeechGateway.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeechGateway.scala @@ -4,8 +4,14 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p trait FairySpeechGateway[F[_]] { + /** + * @return 妖精からメッセージを送信する作用 + */ def sendMessage(fairyMessage: FairyMessage): F[Unit] + /** + * @return 妖精がメッセージを送信した時の音を再生する作用 + */ def playSpeechSound: F[Unit] } From 17a390c46d5457db45a4c9c1e50f27b2f0947ebb Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:05:19 +0900 Subject: [PATCH 266/482] =?UTF-8?q?docs:=20FairyManaRecoveryState=E3=81=AB?= =?UTF-8?q?=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/property/FairyManaRecoveryState.scala | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyManaRecoveryState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyManaRecoveryState.scala index 96d25ebae0..8ece677f03 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyManaRecoveryState.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyManaRecoveryState.scala @@ -2,12 +2,24 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain. sealed trait FairyManaRecoveryState +/** + * 妖精がマナを回復する際に考えられるステータスを定義したオブジェクト + */ object FairyManaRecoveryState { + /** + * マナが完全に回復している + */ case object Full extends FairyManaRecoveryState + /** + * マナを回復したがりんごを消費しなかった + */ case object NotConsumptionApple extends FairyManaRecoveryState + /** + * りんごを消費してマナを回復した + */ case object ConsumptionApple extends FairyManaRecoveryState } From 1628c609c780267bd0c886540266f89cc028699a Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:08:34 +0900 Subject: [PATCH 267/482] refactor: increaseEffectPointsByTen -> increaseEffectPoints --- .../actions/BukkitReceiveVoteBenefits.scala | 2 +- .../vote/domain/VotePersistence.scala | 8 ++-- .../infrastructure/JdbcVotePersistence.scala | 43 +++---------------- 3 files changed, 12 insertions(+), 41 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 0767bb47ec..3ee48394aa 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -42,7 +42,7 @@ class BukkitReceiveVoteBenefits[F[_]: OnMinecraftServerThread: Sync, G[ ) grantItems = gachaSkulls ++ elseVoteBenefits _ <- { - ContextCoercion(votePersistence.increaseEffectPointsByTen(uuid)) + ContextCoercion(votePersistence.increaseEffectPoints(uuid)) .replicateA(notReceivedBenefits.value) >> grantItemStacksEffect[F](grantItems: _*).apply(player) }.whenA(notReceivedBenefits.value != 0) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala index fdb32959e0..ba91636f63 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala @@ -30,17 +30,17 @@ trait VotePersistence[F[_]] { def chainVoteDays(uuid: UUID): F[ChainVoteDayNumber] /** - * effectPointを10増加させる作用 + * [[EffectPoint]]を指定分だけ増加させる作用 */ - def increaseEffectPointsByTen(uuid: UUID): F[Unit] + def increaseEffectPoints(uuid: UUID, effectPoint: EffectPoint): F[Unit] /** - * effectPointを減少させる作用 + * [[EffectPoint]]を減少させる作用 */ def decreaseEffectPoints(uuid: UUID, effectPoint: EffectPoint): F[Unit] /** - * effectPointを返す作用 + * 指定プレイヤーの[[EffectPoint]]を返す作用 */ def effectPoints(uuid: UUID): F[EffectPoint] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index 4fb0304736..52874a2c88 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -11,9 +11,6 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { // NOTE: 連続投票許容幅を変更する場合はここを変更してください。 private val chainVoteAllowableWidth = 4 - /** - * プレイヤーデータを作成する作用 - */ def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { DB.localTx { implicit session => sql"""INSERT IGNORE INTO vote @@ -23,9 +20,6 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { } } - /** - * 投票回数をインクリメントする作用 - */ override def voteCounterIncrement(playerName: PlayerName): F[Unit] = Sync[F].delay { DB.localTx { implicit session => sql"UPDATE vote SET vote_number = vote_number + 1 WHERE uuid = (SELECT uuid FROM playerdata WHERE name = ${playerName.name})" @@ -34,9 +28,6 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { } } - /** - * 投票回数を返す作用 - */ override def voteCounter(uuid: UUID): F[VoteCounter] = Sync[F].delay { DB.readOnly { implicit session => val votePoint = sql"SELECT vote_number FROM vote WHERE uuid = ${uuid.toString}" @@ -48,9 +39,6 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { } } - /** - * 連続投票回数を更新する作用 - */ override def updateChainVote(playerName: PlayerName): F[Unit] = Sync[F].delay { DB.localTx { implicit session => /* @@ -70,9 +58,6 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { } } - /** - * 連続投票日数を返す作用 - */ override def chainVoteDays(uuid: UUID): F[ChainVoteDayNumber] = Sync[F].delay { DB.readOnly { implicit session => val chainVoteDays = sql"SELECT chain_vote_number FROM vote WHERE uuid = ${uuid.toString}" @@ -84,20 +69,15 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { } } - /** - * effectPointを10増加させる作用 - */ - override def increaseEffectPointsByTen(uuid: UUID): F[Unit] = Sync[F].delay { - DB.localTx { implicit session => - sql"UPDATE vote SET effect_point = effect_point + 10 WHERE uuid = ${uuid.toString}" - .execute() - .apply() + override def increaseEffectPoints(uuid: UUID, effectPoint: EffectPoint): F[Unit] = + Sync[F].delay { + DB.localTx { implicit session => + sql"UPDATE vote SET effect_point = effect_point + ${effectPoint.value} WHERE uuid = ${uuid.toString}" + .execute() + .apply() + } } - } - /** - * effectPointを減少させる作用 - */ override def decreaseEffectPoints(uuid: UUID, effectPoint: EffectPoint): F[Unit] = Sync[F].delay { DB.localTx { implicit session => @@ -107,9 +87,6 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { } } - /** - * effectPointを返す作用 - */ override def effectPoints(uuid: UUID): F[EffectPoint] = Sync[F].delay { DB.readOnly { implicit session => val effectPoints = sql"SELECT effect_point FROM vote WHERE uuid = ${uuid.toString}" @@ -121,9 +98,6 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { } } - /** - * 投票特典を受け取った回数を増加させる作用 - */ override def increaseVoteBenefits(uuid: UUID, benefit: VoteBenefit): F[Unit] = Sync[F].delay { DB.localTx { implicit session => sql"UPDATE vote SET given_effect_point = given_effect_point + ${benefit.value} WHERE uuid = ${uuid.toString}" @@ -132,9 +106,6 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { } } - /** - * 投票特典を受け取った回数を返す作用 - */ override def receivedVoteBenefits(uuid: UUID): F[VoteBenefit] = Sync[F].delay { DB.readOnly { implicit session => val benefits = sql"SELECT given_effect_point FROM vote WHERE uuid = ${uuid.toString}" From 5ba5295f54cb1dc7870510ed444f8c3a68eba93d Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:09:17 +0900 Subject: [PATCH 268/482] =?UTF-8?q?fix:=20increaseEffectPoints=E3=82=92?= =?UTF-8?q?=E5=91=BC=E3=81=B6=E9=9A=9B=E3=81=AE=E5=BC=95=E6=95=B0=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/bukkit/actions/BukkitReceiveVoteBenefits.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 3ee48394aa..65d9cc769d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -7,7 +7,11 @@ import com.github.unchama.seichiassist.data.ItemData import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.gacha.bukkit.factories.BukkitGachaSkullData import com.github.unchama.seichiassist.subsystems.vote.application.actions.ReceiveVoteBenefits -import com.github.unchama.seichiassist.subsystems.vote.domain.{VoteBenefit, VotePersistence} +import com.github.unchama.seichiassist.subsystems.vote.domain.{ + EffectPoint, + VoteBenefit, + VotePersistence +} import com.github.unchama.seichiassist.util.InventoryOperations.grantItemStacksEffect import org.bukkit.entity.Player @@ -42,7 +46,7 @@ class BukkitReceiveVoteBenefits[F[_]: OnMinecraftServerThread: Sync, G[ ) grantItems = gachaSkulls ++ elseVoteBenefits _ <- { - ContextCoercion(votePersistence.increaseEffectPoints(uuid)) + ContextCoercion(votePersistence.increaseEffectPoints(uuid, EffectPoint(10))) .replicateA(notReceivedBenefits.value) >> grantItemStacksEffect[F](grantItems: _*).apply(player) }.whenA(notReceivedBenefits.value != 0) From 83361553b9007845945444bdffcf69cda76710f8 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:19:08 +0900 Subject: [PATCH 269/482] =?UTF-8?q?docs:=20=E3=83=87=E3=83=83=E3=83=88?= =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AB=E3=81=AA=E3=82=8A?= =?UTF-8?q?=E3=82=84=E3=81=99=E3=81=84=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/JdbcFairyPersistence.scala | 54 ------------------- 1 file changed, 54 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 57b5aeba76..49a815d238 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -9,9 +9,6 @@ import java.util.UUID class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { - /** - * プレイヤーデータを作成する - */ def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { DB.localTx { implicit session => // ここでIGNOREするのは、作成するデータが既に存在していた場合に発生するエラーを無視するため @@ -19,9 +16,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - /** - * 妖精に開放するりんごの状態を変更する - */ override def changeAppleOpenState(uuid: UUID, openState: FairyAppleConsumeStrategy): F[Unit] = Sync[F].delay { DB.localTx { implicit session => @@ -31,9 +25,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - /** - * 妖精に開放するりんごの状態を取得する - */ override def appleOpenState(uuid: UUID): F[FairyAppleConsumeStrategy] = Sync[F].delay { val serializedValue = DB.readOnly { implicit session => @@ -46,9 +37,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { FairyAppleConsumeStrategy.values.find(_.serializedValue == serializedValue).get } - /** - * 妖精を召喚するためのコストを更新する - */ override def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] = Sync[F].delay { DB.localTx { implicit session => @@ -58,9 +46,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - /** - * 妖精を召喚するためのコストを取得する - */ override def fairySummonCost(uuid: UUID): F[FairySummonCost] = Sync[F].delay { DB.readOnly { implicit session => val fairySummonCost = @@ -73,9 +58,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - /** - * 妖精の召喚状態を更新します - */ override def updateIsFairyUsing(uuid: UUID, isFairyUsing: Boolean): F[Unit] = Sync[F].delay { DB.localTx { implicit session => @@ -87,9 +69,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - /** - * 妖精が召喚されているかを取得します - */ override def isFairyUsing(uuid: UUID): F[Boolean] = Sync[F].delay { DB.readOnly { implicit session => sql"SELECT is_fairy_using FROM vote_fairy WHERE uuid = ${uuid.toString}" @@ -99,9 +78,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { }.get } - /** - * 妖精が回復するマナの量を変更する - */ override def updateFairyRecoveryMana( uuid: UUID, fairyRecoveryMana: FairyRecoveryMana @@ -113,9 +89,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - /** - * 妖精が回復するマナの量を取得する - */ override def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] = Sync[F].delay { DB.readOnly { implicit session => val recoveryMana = @@ -128,9 +101,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - /** - * 妖精の効果が終了する時刻を変更する - */ override def updateFairyEndTime(uuid: UUID, fairyEndTime: FairyEndTime): F[Unit] = Sync[F].delay { DB.localTx { implicit session => @@ -140,9 +110,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - /** - * 妖精の効果が終了する時刻を取得する - */ override def fairyEndTime(uuid: UUID): F[Option[FairyEndTime]] = Sync[F].delay { DB.readOnly { implicit session => val dateOpt = sql"SELECT fairy_end_time FROM vote_fairy WHERE uuid = ${uuid.toString}" @@ -153,9 +120,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - /** - * 妖精が食べたりんごの量を増加させる - */ override def increaseAppleAteByFairy(uuid: UUID, appleAmount: AppleAmount): F[Unit] = Sync[F].delay { DB.localTx { implicit session => @@ -165,9 +129,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - /** - * 妖精が食べたりんごの量を取得する - */ override def appleAteByFairy(uuid: UUID): F[Option[AppleAmount]] = Sync[F].delay { DB.readOnly { implicit session => val appleAmountOpt = @@ -179,9 +140,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - /** - * 自分の妖精に食べさせたりんごの量の順位を返す - */ override def appleAteByFairyMyRanking(uuid: UUID): F[Option[AppleAteByFairyRank]] = Sync[F].delay { DB.readOnly { implicit session => @@ -205,9 +163,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - /** - * 妖精に食べさせたりんごの量の順位上位`number`件を返す - */ override def appleAteByFairyRanking(number: Int): F[Vector[Option[AppleAteByFairyRank]]] = Sync[F].delay { DB.readOnly { implicit session => @@ -227,9 +182,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - /** - * 妖精が食べたりんごの合計数を返す - */ override def allEatenAppleAmount: F[AppleAmount] = Sync[F].delay { DB.readOnly { implicit session => val amount = sql"SELECT SUM(given_apple_amount) AS allAppleAmount FROM vote_fairy;" @@ -241,9 +193,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - /** - * 妖精が喋るときに音をだすかをトグルする - */ override def toggleFairySpeechSound(uuid: UUID, fairyPlaySound: Boolean): F[Unit] = Sync[F].delay { DB.localTx { implicit session => @@ -253,9 +202,6 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - /** - * 妖精が喋ったときに音を再生するか取得する - */ override def fairySpeechSound(uuid: UUID): F[Boolean] = Sync[F].delay { DB.readOnly { implicit session => From 97af4fc9197f2e154e4b5c0086cff9bc77dff2d7 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:22:38 +0900 Subject: [PATCH 270/482] =?UTF-8?q?refactor:=20BukkitSummonFairy=E3=81=AE?= =?UTF-8?q?=E3=83=91=E3=83=A9=E3=83=A1=E3=83=BC=E3=82=BF=E3=82=92Sync?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 0d574e090e..24ae552371 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -1,19 +1,19 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions -import cats.effect.ConcurrentEffect +import cats.effect.Sync import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyRecoveryManaAmount import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyRecoveryManaAmount import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import com.github.unchama.targetedeffect.commandsender.MessageEffectF import org.bukkit.ChatColor._ import org.bukkit.entity.Player -class BukkitSummonFairy[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( +class BukkitSummonFairy[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( implicit voteAPI: VoteAPI[F, Player], manaApi: ManaApi[F, G, Player], fairyPersistence: FairyPersistence[F], From 9aedff7541f2cafd4346c0039a012abf301c336c Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:25:07 +0900 Subject: [PATCH 271/482] =?UTF-8?q?refactor:=20initialization=E3=81=AE?= =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AAApplicative=E3=82=92=E5=89=8A?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/SpeechServiceRepositoryDefinitions.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala index 9570c83256..98cd7dc886 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala @@ -9,7 +9,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service. object SpeechServiceRepositoryDefinitions { - def initialization[F[_]: Applicative: Sync, Player]( + def initialization[F[_]: Sync, Player]( implicit gatewayProvider: Player => FairySpeechGateway[F] ): TwoPhasedRepositoryInitialization[F, Player, FairySpeechService[F]] = TwoPhasedRepositoryInitialization.withoutPrefetching[F, Player, FairySpeechService[F]] { From b46de11903d6e0fc7f14f96e25ceafa2f051c6c1 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:26:01 +0900 Subject: [PATCH 272/482] =?UTF-8?q?refactor:=20concurrentEffect=E3=82=92?= =?UTF-8?q?=E5=BC=95=E6=95=B0=E3=81=8B=E3=82=89=E6=8C=81=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=81=8F=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...FairyManaRecoveryRoutineFiberRepositoryDefinition.scala | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala index 5ee4d8f45b..0da923c3b9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala @@ -6,16 +6,13 @@ import com.github.unchama.concurrent.RepeatingTaskContext import com.github.unchama.datarepository.template.finalization.RepositoryFinalization import com.github.unchama.datarepository.template.initialization.TwoPhasedRepositoryInitialization import com.github.unchama.generic.effect.EffectExtra -import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine object FairyManaRecoveryRoutineFiberRepositoryDefinition { - implicit val ioCE: ConcurrentEffect[IO] = - IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) - def initialization[Player](fairyRoutine: FairyRoutine[IO, Player])( - implicit context: RepeatingTaskContext + implicit context: RepeatingTaskContext, + concurrentEffect: ConcurrentEffect[IO] ): TwoPhasedRepositoryInitialization[SyncIO, Player, Deferred[IO, Fiber[IO, Nothing]]] = TwoPhasedRepositoryInitialization .withoutPrefetching[SyncIO, Player, Deferred[IO, Fiber[IO, Nothing]]] { player => From 42a3c5e47f6410c221e09314a962d65e2e2d2039 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:27:07 +0900 Subject: [PATCH 273/482] =?UTF-8?q?refactor:=20=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E5=9E=8B=E3=83=91=E3=83=A9=E3=83=A1=E3=83=BC=E3=82=BF=E3=83=BC?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/System.scala | 2 +- .../FairyManaRecoveryRoutineFiberRepositoryDefinition.scala | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 63460ed054..7cf3329b5d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -82,7 +82,7 @@ object System { .TwoPhased( FairyManaRecoveryRoutineFiberRepositoryDefinition .initialization[Player](_fairyRoutine), - FairyManaRecoveryRoutineFiberRepositoryDefinition.finalization[SyncIO, Player] + FairyManaRecoveryRoutineFiberRepositoryDefinition.finalization[Player] ) ) } yield { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala index 0da923c3b9..62e38c7a19 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/FairyManaRecoveryRoutineFiberRepositoryDefinition.scala @@ -1,7 +1,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository import cats.effect.concurrent.Deferred -import cats.effect.{ConcurrentEffect, Fiber, IO, Sync, SyncIO} +import cats.effect.{ConcurrentEffect, Fiber, IO, SyncIO} import com.github.unchama.concurrent.RepeatingTaskContext import com.github.unchama.datarepository.template.finalization.RepositoryFinalization import com.github.unchama.datarepository.template.initialization.TwoPhasedRepositoryInitialization @@ -28,7 +28,7 @@ object FairyManaRecoveryRoutineFiberRepositoryDefinition { } yield promise } - def finalization[F[_]: Sync, Player] + def finalization[Player] : RepositoryFinalization[SyncIO, Player, Deferred[IO, Fiber[IO, Nothing]]] = RepositoryFinalization .withoutAnyPersistence[SyncIO, Player, Deferred[IO, Fiber[IO, Nothing]]] { (_, promise) => From 140853020ff218508089f95609e38f2c1aa31bf4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:28:18 +0900 Subject: [PATCH 274/482] =?UTF-8?q?docs:=20FairyRoutine=E3=81=AB=E3=83=89?= =?UTF-8?q?=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/application/actions/FairyRoutine.scala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala index 2bf138b817..4e77ba338e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala @@ -2,6 +2,9 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applica trait FairyRoutine[F[_], Player] { + /** + * 妖精の定期実行プロセスを開始する作用 + */ def start(player: Player): F[Nothing] } From c5b2cc643e16fdc2de0b063cbf51c8c4ede99049 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:29:37 +0900 Subject: [PATCH 275/482] =?UTF-8?q?refactor:=20unsafeRunSyncAndForget?= =?UTF-8?q?=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/bukkit/command/VoteCommand.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala index 3c7ca3301b..52262dbe24 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala @@ -32,7 +32,7 @@ class VoteCommand[F[_]: ConcurrentEffect](implicit votePersistence: VotePersiste _ <- votePersistence.voteCounterIncrement(playerName) _ <- votePersistence.updateChainVote(playerName) } yield () - eff.toIO.unsafeRunSync() + eff.toIO.unsafeRunAsyncAndForget() } ) } From d625520b2faa0250fa0853024e2338cf21601d78 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:34:42 +0900 Subject: [PATCH 276/482] =?UTF-8?q?refactor:=20fairyContractSettingToggle?= =?UTF-8?q?=E3=81=AEIO=E3=82=92for=E3=81=A7=E3=81=BE=E3=81=A8=E3=82=81?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/menus/VoteMenu.scala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index c5ef24e7df..968815d320 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -200,11 +200,14 @@ object VoteMenu extends Menu { } val fairyContractSettingToggle: IO[Button] = - RecomputedButton(IO { + RecomputedButton(for { + fairyLore <- fairyAPI.getFairyLore(uuid) + appleOpenState <- fairyAPI.appleOpenState(uuid) + } yield { Button( new IconItemStackBuilder(Material.PAPER) .title(s"$GOLD$UNDERLINE${BOLD}妖精とのお約束") - .lore(fairyAPI.getFairyLore(uuid).unsafeRunSync().lore.toList) + .lore(fairyLore.lore.toList) .build(), LeftClickButtonEffect { SequentialEffect( @@ -212,8 +215,7 @@ object VoteMenu extends Menu { fairyAPI .updateAppleOpenState( uuid, - AppleOpenStateDependency - .dependency(fairyAPI.appleOpenState(uuid).unsafeRunSync()) + AppleOpenStateDependency.dependency(appleOpenState) ) .unsafeRunAsyncAndForget() }, From 0691ace817e4afc2b6312d804e671a22fd935a46 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:36:15 +0900 Subject: [PATCH 277/482] =?UTF-8?q?refactor:=20fairyPlaySoundToggleButton?= =?UTF-8?q?=E3=81=AEIO=E3=82=92for=E3=81=A7=E3=81=BE=E3=81=A8=E3=82=81?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/seichiassist/menus/VoteMenu.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 968815d320..a036edd9fb 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -231,13 +231,14 @@ object VoteMenu extends Menu { val playSoundOnLore = List(s"$RESET${GREEN}現在音が鳴る設定になっています。") ++ description val playSoundOffLore = List(s"$RESET${RED}現在音が鳴らない設定になっています。") ++ description - RecomputedButton(IO { + RecomputedButton(for { + fairySpeechSound <- fairyAPI.fairySpeechSound(player.getUniqueId) + } yield { Button( new IconItemStackBuilder(Material.JUKEBOX) .title(s"$GOLD$UNDERLINE${BOLD}マナ妖精の音トグル") .lore( - if (fairyAPI.fairySpeechSound(player.getUniqueId).unsafeRunSync()) - playSoundOnLore + if (fairySpeechSound) playSoundOnLore else playSoundOffLore ) .build(), From 1cee079f2dbb7dbaf254d97931220b8f0181c37c Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:38:29 +0900 Subject: [PATCH 278/482] =?UTF-8?q?refactor:=20fairySummonButton=E3=81=AEI?= =?UTF-8?q?O=E3=82=92for=E3=81=A7=E3=81=8F=E3=81=8F=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/seichiassist/menus/VoteMenu.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index a036edd9fb..04e2f01ca2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -254,9 +254,10 @@ object VoteMenu extends Menu { }) } - val fairySummonButton: IO[Button] = IO { - val fairySummonState = - fairyAPI.fairySummonCost(player).unsafeRunSync() + val fairySummonButton: IO[Button] = for { + fairySummonState <- fairyAPI.fairySummonCost(player) + fairySummonRequestResult <- fairyAPI.fairySummonRequest(player) + } yield { Button( new IconItemStackBuilder(Material.GHAST_TEAR) .title(s"$LIGHT_PURPLE$UNDERLINE${BOLD}マナ妖精 召喚") @@ -272,7 +273,7 @@ object VoteMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - fairyAPI.fairySummonRequest(player).unsafeRunSync() match { + fairySummonRequestResult match { case Left(errorResult) => errorResult match { case NotEnoughSeichiLevel => From 3b3cc77440f47d3e5225b65210bb6ede38511b16 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:41:11 +0900 Subject: [PATCH 279/482] =?UTF-8?q?refactor:=20gachaRingoInformation?= =?UTF-8?q?=E3=81=AEIO=E3=82=92for=E3=81=A7=E3=81=8F=E3=81=8F=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 04e2f01ca2..95b7efe55b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -328,7 +328,11 @@ object VoteMenu extends Menu { ) } - val gachaRingoInformation: IO[Button] = IO { + val gachaRingoInformation: IO[Button] = for { + myRank <- fairyAPI.appleAteByFairyMyRanking(player) + topFourRanking <- fairyAPI.appleAteByFairyRanking(4) + allEatenAppleAmount <- fairyAPI.allEatenAppleAmount + } yield { val staticLore = List( s"$RESET$RED$BOLD※ニンゲンに見られないように気を付けること!", s"$RESET$RED$BOLD 毎日大妖精からデータを更新すること!", @@ -337,25 +341,27 @@ object VoteMenu extends Menu { s"$RESET$GOLD${BOLD}たくさんくれたニンゲンたち", s"$RESET${DARK_GRAY}召喚されたらラッキーだよ!" ) - val topFour = fairyAPI.appleAteByFairyRanking(4).unsafeRunSync() val topFourRankingLore = - List(topFour.headOption, topFour.lift(1), topFour.lift(2), topFour.lift(3)).flatMap { - rankDataOpt => - if (rankDataOpt.nonEmpty) { - val rankData = rankDataOpt.get.get - List( - s"${GRAY}たくさんくれたニンゲン第${rankData.rank}位!", - s"${GRAY}なまえ:${rankData.name} りんご:${rankData.appleAmount.amount}個" - ) - } else Nil + List( + topFourRanking.headOption, + topFourRanking.lift(1), + topFourRanking.lift(2), + topFourRanking.lift(3) + ).flatMap { rankDataOpt => + if (rankDataOpt.nonEmpty) { + val rankData = rankDataOpt.get.get + List( + s"${GRAY}たくさんくれたニンゲン第${rankData.rank}位!", + s"${GRAY}なまえ:${rankData.name} りんご:${rankData.appleAmount.amount}個" + ) + } else Nil } - val myRank = fairyAPI.appleAteByFairyMyRanking(player).unsafeRunSync().get val statistics = List( - s"${AQUA}ぜーんぶで${fairyAPI.allEatenAppleAmount.unsafeRunSync().amount}個もらえた!", + s"${AQUA}ぜーんぶで${allEatenAppleAmount.amount}個もらえた!", "", s"$GREEN↓呼び出したニンゲンの情報↓", - s"${GREEN}今までに${myRank.appleAmount.amount}個もらった", - s"${GREEN}ニンゲンの中では${myRank.rank}番目にたくさんくれる!" + s"${GREEN}今までに${myRank.get.appleAmount.amount}個もらった", + s"${GREEN}ニンゲンの中では${myRank.get.rank}番目にたくさんくれる!" ) Button( From c8dc22634f7c4c1a15f2901406f10f1dd5109a63 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:42:19 +0900 Subject: [PATCH 280/482] =?UTF-8?q?refactor:=20fairySummonTimeToggleButton?= =?UTF-8?q?=E3=81=AEIO=E3=82=92for=E3=81=A7=E3=81=8F=E3=81=8F=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/seichiassist/menus/VoteMenu.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 95b7efe55b..b5a0797e54 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -165,9 +165,9 @@ object VoteMenu extends Menu { ) val fairySummonTimeToggleButton: IO[Button] = { - RecomputedButton(IO { - val fairySummonCost = fairyAPI.fairySummonCost(player).unsafeRunSync() - + RecomputedButton(for { + fairySummonCost <- fairyAPI.fairySummonCost(player) + } yield { Button( new IconItemStackBuilder(Material.WATCH) .title(s"$AQUA$UNDERLINE${BOLD}マナ妖精 時間設定") From 0ab8849fa4a5a41c2a79a24f2948a1347792b49d Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 22:59:03 +0900 Subject: [PATCH 281/482] =?UTF-8?q?refactor:=20implicits.=5F=E3=82=92impor?= =?UTF-8?q?t=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scala/com/github/unchama/seichiassist/menus/VoteMenu.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index b5a0797e54..cc478ee9e0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -2,7 +2,7 @@ package com.github.unchama.seichiassist.menus import cats.data.Kleisli import cats.effect.{ConcurrentEffect, IO, SyncIO} -import cats.implicits.toTraverseOps +import cats.implicits._ import com.github.unchama.itemstackbuilder.IconItemStackBuilder import com.github.unchama.menuinventory.router.CanOpen import com.github.unchama.menuinventory.slot.button.action.LeftClickButtonEffect From 734859162fa210c186203bf0dfe659d14616c7cc Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 23:04:25 +0900 Subject: [PATCH 282/482] style: eff -> program --- .../fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index e8ce6bc8cf..3ad29b1cf6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -22,7 +22,7 @@ class FairyPlayerJoinGreeter( def onJoin(e: PlayerJoinEvent): Unit = { val player = e.getPlayer val uuid = player.getUniqueId - val eff = for { + val program = for { _ <- fairyPersistence.createPlayerData(uuid) isUsing <- fairyPersistence.isFairyUsing(uuid) endTime <- fairyPersistence.fairyEndTime(uuid) @@ -35,7 +35,7 @@ class FairyPlayerJoinGreeter( }.whenA(isUsing && isEnd) _ <- fairySpeech.welcomeBack(player).whenA(isUsing && !isEnd) } yield () - eff.unsafeRunSync() + program.unsafeRunSync() } } From db4bc9ed969af17d563fb40fbec05c0fb5fec51e Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 23:05:17 +0900 Subject: [PATCH 283/482] style: fairySpeechSound -> isPlayFairySpeechSound --- .../com/github/unchama/seichiassist/menus/VoteMenu.scala | 2 +- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 2 +- .../subsystems/vote/subsystems/fairy/System.scala | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index cc478ee9e0..21b465a5a7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -232,7 +232,7 @@ object VoteMenu extends Menu { val playSoundOffLore = List(s"$RESET${RED}現在音が鳴らない設定になっています。") ++ description RecomputedButton(for { - fairySpeechSound <- fairyAPI.fairySpeechSound(player.getUniqueId) + fairySpeechSound <- fairyAPI.isPlayFairySpeechSound(player.getUniqueId) } yield { Button( new IconItemStackBuilder(Material.JUKEBOX) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 4d8df1e1b9..ba56569415 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -84,7 +84,7 @@ trait FairySpeechAPI[F[_], Player] { /** * 妖精が喋ったときに音を再生するか取得する */ - def fairySpeechSound(uuid: UUID): F[Boolean] + def isPlayFairySpeechSound(uuid: UUID): F[Boolean] /** * @return 妖精がいつ帰るのかを[[Player]]に送信する作用 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 7cf3329b5d..60347c56d5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -137,11 +137,11 @@ object System { override def allEatenAppleAmount: IO[AppleAmount] = persistence.allEatenAppleAmount - override def fairySpeechSound(uuid: UUID): IO[Boolean] = + override def isPlayFairySpeechSound(uuid: UUID): IO[Boolean] = persistence.fairySpeechSound(uuid) override def toggleFairySpeechSound(uuid: UUID): IO[Unit] = - persistence.toggleFairySpeechSound(uuid, !fairySpeechSound(uuid).unsafeRunSync()) + persistence.toggleFairySpeechSound(uuid, !isPlayFairySpeechSound(uuid).unsafeRunSync()) override def speechEndTime(player: Player): IO[Unit] = fairySpeech.speechEndTime(player) From 97139d3d9aca6a7d776b720ef99516495cdf5639 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Oct 2022 23:08:36 +0900 Subject: [PATCH 284/482] =?UTF-8?q?refactor:=20toggleFairySpeechSound?= =?UTF-8?q?=E3=81=AEfor=E3=81=A7=E3=81=BE=E3=81=A8=E3=82=81=E3=82=89?= =?UTF-8?q?=E3=82=8C=E3=82=8B=E3=81=A8=E3=81=93=E3=82=8D=E3=82=92=E3=81=BE?= =?UTF-8?q?=E3=81=A8=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/System.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 60347c56d5..4451c4b77b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -140,8 +140,9 @@ object System { override def isPlayFairySpeechSound(uuid: UUID): IO[Boolean] = persistence.fairySpeechSound(uuid) - override def toggleFairySpeechSound(uuid: UUID): IO[Unit] = - persistence.toggleFairySpeechSound(uuid, !isPlayFairySpeechSound(uuid).unsafeRunSync()) + override def toggleFairySpeechSound(uuid: UUID): IO[Unit] = for { + isPlayFairySpeechSound <- isPlayFairySpeechSound(uuid) + } yield persistence.toggleFairySpeechSound(uuid, !isPlayFairySpeechSound) override def speechEndTime(player: Player): IO[Unit] = fairySpeech.speechEndTime(player) From 0cbaeaa5e7417b7a497675a990ffb89df05da0ee Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 24 Oct 2022 17:52:41 +0900 Subject: [PATCH 285/482] =?UTF-8?q?refactor:=20makeSpeech=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E3=81=A7=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=82=92=E8=A4=87=E6=95=B0=E5=8F=97=E3=81=91=E5=8F=96=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/BukkitFairySpeech.scala | 15 ++++++++------- .../bukkit/gateway/BukkitFairySpeechGateway.scala | 7 +++++-- .../fairy/domain/speech/FairySpeechGateway.scala | 2 +- .../fairy/service/FairySpeechService.scala | 5 ++--- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index 21908e7451..f9291b8998 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -47,7 +47,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( fairyPersistence.fairySpeechSound(player.getUniqueId) } _ <- ContextCoercion { - serviceRepository.makeSpeech(message, fairySpeechSound) + serviceRepository.makeSpeech(Seq(message), fairySpeechSound) } } yield () @@ -68,7 +68,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( message <- randomMessage(messages(nameCalledByFairy)) fairyPlaySound <- fairyPersistence.fairySpeechSound(player.getUniqueId) _ <- ContextCoercion { - fairySpeechServiceRepository(player).makeSpeech(message, fairyPlaySound) + fairySpeechServiceRepository(player).makeSpeech(Seq(message), fairyPlaySound) } } yield () } @@ -80,7 +80,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( endTime = endTimeOpt.get.endTimeOpt.get _ <- ContextCoercion { fairySpeechServiceRepository(player).makeSpeech( - FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。"), + Seq(FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。")), playSound ) } @@ -91,7 +91,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( playSound <- fairyPersistence.fairySpeechSound(player.getUniqueId) _ <- ContextCoercion { fairySpeechServiceRepository(player) - .makeSpeech(FairyMessage(s"おかえり!${player.getName}"), playSound) + .makeSpeech(Seq(FairyMessage(s"おかえり!${player.getName}")), playSound) } } yield () @@ -99,9 +99,10 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( playSound <- fairyPersistence.fairySpeechSound(player.getUniqueId) repository = fairySpeechServiceRepository(player) _ <- ContextCoercion { - repository.makeSpeech(FairyMessage(s"あっ、もうこんな時間だ!"), fairyPlaySound = false) - } >> ContextCoercion { - repository.makeSpeech(FairyMessage(s"じゃーねー!${player.getName}"), playSound) + repository.makeSpeech( + Seq(FairyMessage(s"あっ、もうこんな時間だ!"), FairyMessage(s"じゃーねー!${player.getName}")), + playSound + ) } } yield () diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala index d3ac2e8fb4..83c85fe165 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala @@ -11,8 +11,11 @@ import org.bukkit.entity.Player class BukkitFairySpeechGateway[F[_]: Sync](player: Player) extends FairySpeechGateway[F] { - override def sendMessage(fairyMessage: FairyMessage): F[Unit] = - MessageEffectF[F](s"$AQUA$BOLD<マナ妖精>$RESET${fairyMessage.message}").run(player) + override def sendMessage(fairyMessages: Seq[FairyMessage]): F[Unit] = { + val defaultFairyMessage = f"$AQUA$BOLD<マナ妖精>$RESET%s" + MessageEffectF[F](fairyMessages.map(input => defaultFairyMessage.format(input)).toList) + .run(player) + } override def playSpeechSound: F[Unit] = FocusedSoundEffectF(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f).run(player) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeechGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeechGateway.scala index d4ab9b77fe..b44da96c30 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeechGateway.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeechGateway.scala @@ -7,7 +7,7 @@ trait FairySpeechGateway[F[_]] { /** * @return 妖精からメッセージを送信する作用 */ - def sendMessage(fairyMessage: FairyMessage): F[Unit] + def sendMessage(fairyMessages: Seq[FairyMessage]): F[Unit] /** * @return 妖精がメッセージを送信した時の音を再生する作用 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala index a00d7e4aa1..882c50b768 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala @@ -1,14 +1,13 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service import cats.effect.Sync -import cats.implicits.catsSyntaxFlatMapOps +import cats.implicits._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeechGateway class FairySpeechService[F[_]: Sync](gateway: FairySpeechGateway[F]) { - def makeSpeech(fairyMessage: FairyMessage, fairyPlaySound: Boolean): F[Unit] = { + def makeSpeech(fairyMessage: Seq[FairyMessage], fairyPlaySound: Boolean): F[Unit] = gateway.sendMessage(fairyMessage) >> Sync[F].whenA(fairyPlaySound)(gateway.playSpeechSound) - } } From c3157ee169f28ccc10e0d86360d36d61064ba729 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 6 Dec 2022 15:50:59 +0900 Subject: [PATCH 286/482] style: tab -> space --- .../migration/V1.13.2__Move_vote_column.sql | 52 +++++++------- .../V1.13.3__Move_vote_fairy_column.sql | 68 +++++++++---------- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/main/resources/db/migration/V1.13.2__Move_vote_column.sql b/src/main/resources/db/migration/V1.13.2__Move_vote_column.sql index 8e15a731de..a8e3bab92b 100644 --- a/src/main/resources/db/migration/V1.13.2__Move_vote_column.sql +++ b/src/main/resources/db/migration/V1.13.2__Move_vote_column.sql @@ -1,36 +1,36 @@ USE seichiassist; CREATE TABLE vote( - uuid CHAR(36) PRIMARY KEY, - vote_number INT, - chain_vote_number INT, - effect_point INT, - given_effect_point INT, - last_vote DATETIME + uuid CHAR(36) PRIMARY KEY, + vote_number INT, + chain_vote_number INT, + effect_point INT, + given_effect_point INT, + last_vote DATETIME ); INSERT INTO - vote( - uuid, - vote_number, - chain_vote_number, - effect_point, - given_effect_point, - last_vote - ) + vote( + uuid, + vote_number, + chain_vote_number, + effect_point, + given_effect_point, + last_vote + ) SELECT - uuid, - p_vote, - chainvote, - effectpoint, - p_givenvote, - CONVERT(lastvote, DATE) + uuid, + p_vote, + chainvote, + effectpoint, + p_givenvote, + CONVERT(lastvote, DATE) FROM - playerdata; + playerdata; ALTER TABLE - playerdata DROP p_vote, - DROP chainvote, - DROP effectpoint, - DROP p_givenvote, - DROP lastvote; \ No newline at end of file + playerdata DROP p_vote, + DROP chainvote, + DROP effectpoint, + DROP p_givenvote, + DROP lastvote; \ No newline at end of file diff --git a/src/main/resources/db/migration/V1.13.3__Move_vote_fairy_column.sql b/src/main/resources/db/migration/V1.13.3__Move_vote_fairy_column.sql index b9d6b3fc50..bee90ce5f4 100644 --- a/src/main/resources/db/migration/V1.13.3__Move_vote_fairy_column.sql +++ b/src/main/resources/db/migration/V1.13.3__Move_vote_fairy_column.sql @@ -1,44 +1,44 @@ USE seichiassist; CREATE TABLE vote_fairy( - uuid CHAR(36) PRIMARY KEY, - apple_open_state INT DEFAULT 1, - fairy_summon_cost INT DEFAULT 1, - is_fairy_using BOOLEAN DEFAULT false, - fairy_recovery_mana_value INT DEFAULT 0, - fairy_end_time DATETIME DEFAULT NULL, - given_apple_amount BIGINT DEFAULT 0, - is_play_fairy_speech_sound BOOLEAN DEFAULT true + uuid CHAR(36) PRIMARY KEY, + apple_open_state INT DEFAULT 1, + fairy_summon_cost INT DEFAULT 1, + is_fairy_using BOOLEAN DEFAULT false, + fairy_recovery_mana_value INT DEFAULT 0, + fairy_end_time DATETIME DEFAULT NULL, + given_apple_amount BIGINT DEFAULT 0, + is_play_fairy_speech_sound BOOLEAN DEFAULT true ); INSERT INTO - vote_fairy( - uuid, - apple_open_state, - fairy_summon_cost, - is_fairy_using, - fairy_recovery_mana_value, - fairy_end_time, - given_apple_amount, - is_play_fairy_speech_sound - ) + vote_fairy( + uuid, + apple_open_state, + fairy_summon_cost, + is_fairy_using, + fairy_recovery_mana_value, + fairy_end_time, + given_apple_amount, + is_play_fairy_speech_sound + ) SELECT - uuid, - toggleGiveApple, - toggleVotingFairy, - canVotingFairyUse, - VotingFairyRecoveryValue, - newVotingFairyTime, - p_apple, - is_fairy_speech_play_sound + uuid, + toggleGiveApple, + toggleVotingFairy, + canVotingFairyUse, + VotingFairyRecoveryValue, + newVotingFairyTime, + p_apple, + is_fairy_speech_play_sound FROM - playerdata; + playerdata; ALTER TABLE - playerdata DROP toggleGiveApple, - DROP toggleVotingFairy, - DROP canVotingFairyUse, - DROP VotingFairyRecoveryValue, - DROP newVotingFairyTime, - DROP p_apple, - DROP is_fairy_speech_play_sound \ No newline at end of file + playerdata DROP toggleGiveApple, + DROP toggleVotingFairy, + DROP canVotingFairyUse, + DROP VotingFairyRecoveryValue, + DROP newVotingFairyTime, + DROP p_apple, + DROP is_fairy_speech_play_sound \ No newline at end of file From 9e3f13e1dd4b1ec160b3f9e926203a091aa1f306 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 6 Dec 2022 15:55:07 +0900 Subject: [PATCH 287/482] =?UTF-8?q?fix:=20=E4=BD=9C=E6=88=90=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=83=86=E3=83=BC=E3=83=96=E3=83=AB=E3=81=AE=E3=82=AB?= =?UTF-8?q?=E3=83=A9=E3=83=A0=E3=81=ABNOTNULL=E5=88=B6=E7=B4=84=E3=82=92?= =?UTF-8?q?=E3=81=A4=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V1.13.2__Move_vote_column.sql | 12 ++++++------ .../migration/V1.13.3__Move_vote_fairy_column.sql | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/resources/db/migration/V1.13.2__Move_vote_column.sql b/src/main/resources/db/migration/V1.13.2__Move_vote_column.sql index a8e3bab92b..f7a2c227e2 100644 --- a/src/main/resources/db/migration/V1.13.2__Move_vote_column.sql +++ b/src/main/resources/db/migration/V1.13.2__Move_vote_column.sql @@ -1,12 +1,12 @@ USE seichiassist; CREATE TABLE vote( - uuid CHAR(36) PRIMARY KEY, - vote_number INT, - chain_vote_number INT, - effect_point INT, - given_effect_point INT, - last_vote DATETIME + uuid CHAR(36) NOT NULL PRIMARY KEY, + vote_number INT NOT NULL , + chain_vote_number INT NOT NULL , + effect_point INT NOT NULL , + given_effect_point INT NOT NULL , + last_vote DATETIME NOT NULL ); INSERT INTO diff --git a/src/main/resources/db/migration/V1.13.3__Move_vote_fairy_column.sql b/src/main/resources/db/migration/V1.13.3__Move_vote_fairy_column.sql index bee90ce5f4..b558c29a0b 100644 --- a/src/main/resources/db/migration/V1.13.3__Move_vote_fairy_column.sql +++ b/src/main/resources/db/migration/V1.13.3__Move_vote_fairy_column.sql @@ -1,14 +1,14 @@ USE seichiassist; CREATE TABLE vote_fairy( - uuid CHAR(36) PRIMARY KEY, - apple_open_state INT DEFAULT 1, - fairy_summon_cost INT DEFAULT 1, - is_fairy_using BOOLEAN DEFAULT false, - fairy_recovery_mana_value INT DEFAULT 0, + uuid CHAR(36) NOT NULL PRIMARY KEY, + apple_open_state INT NOT NULL DEFAULT 1, + fairy_summon_cost INT NOT NULL DEFAULT 1, + is_fairy_using BOOLEAN NOT NULL DEFAULT false, + fairy_recovery_mana_value INT NOT NULL DEFAULT 0, fairy_end_time DATETIME DEFAULT NULL, - given_apple_amount BIGINT DEFAULT 0, - is_play_fairy_speech_sound BOOLEAN DEFAULT true + given_apple_amount BIGINT NOT NULL DEFAULT 0, + is_play_fairy_speech_sound BOOLEAN NOT NULL DEFAULT true ); INSERT INTO From 7e5f6c4315ae1546bdc090eb941b706d2bf1e34b Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 6 Dec 2022 16:19:21 +0900 Subject: [PATCH 288/482] =?UTF-8?q?fix:=20not=20null=E5=88=B6=E7=B4=84?= =?UTF-8?q?=E3=82=92=E3=81=A4=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration/V1.13.2__Move_vote_column.sql | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/resources/db/migration/V1.13.2__Move_vote_column.sql b/src/main/resources/db/migration/V1.13.2__Move_vote_column.sql index f7a2c227e2..04794742ba 100644 --- a/src/main/resources/db/migration/V1.13.2__Move_vote_column.sql +++ b/src/main/resources/db/migration/V1.13.2__Move_vote_column.sql @@ -1,11 +1,11 @@ USE seichiassist; -CREATE TABLE vote( +CREATE TABLE IF NOT EXISTS vote( uuid CHAR(36) NOT NULL PRIMARY KEY, - vote_number INT NOT NULL , - chain_vote_number INT NOT NULL , - effect_point INT NOT NULL , - given_effect_point INT NOT NULL , + vote_number INT NOT NULL, + chain_vote_number INT NOT NULL, + effect_point INT NOT NULL, + given_effect_point INT NOT NULL, last_vote DATETIME NOT NULL ); @@ -29,8 +29,8 @@ FROM playerdata; ALTER TABLE - playerdata DROP p_vote, - DROP chainvote, - DROP effectpoint, - DROP p_givenvote, - DROP lastvote; \ No newline at end of file + playerdata DROP IF EXISTS p_vote, + DROP IF EXISTS chainvote, + DROP IF EXISTS effectpoint, + DROP IF EXISTS p_givenvote, + DROP IF EXISTS lastvote; \ No newline at end of file From febf40767e4714a0230a567c239e341a99126ab1 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 29 Dec 2022 23:41:06 +0900 Subject: [PATCH 289/482] style: apply scalafmt --- .../unchama/seichiassist/SeichiAssist.scala | 26 ++++++++++++++----- .../menus/skill/ActiveSkillEffectMenu.scala | 7 ++--- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 1be7ec2919..bbb714c060 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -11,7 +11,10 @@ import com.github.unchama.bungeesemaphoreresponder.domain.PlayerDataFinalizer import com.github.unchama.bungeesemaphoreresponder.{System => BungeeSemaphoreResponderSystem} import com.github.unchama.chatinterceptor.{ChatInterceptor, InterceptionScope} import com.github.unchama.concurrent.RepeatingRoutine -import com.github.unchama.datarepository.bukkit.player.{BukkitRepositoryControls, PlayerDataRepository} +import com.github.unchama.datarepository.bukkit.player.{ + BukkitRepositoryControls, + PlayerDataRepository +} import com.github.unchama.datarepository.definitions.SessionMutexRepositoryDefinition import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.datarepository.template.finalization.RepositoryFinalization @@ -23,17 +26,26 @@ import com.github.unchama.generic.effect.unsafe.EffectEnvironment import com.github.unchama.menuinventory.MenuHandler import com.github.unchama.menuinventory.router.CanOpen import com.github.unchama.minecraft.actions.{GetConnectedPlayers, SendMinecraftMessage} -import com.github.unchama.minecraft.bukkit.actions.{GetConnectedBukkitPlayers, SendBukkitMessage} +import com.github.unchama.minecraft.bukkit.actions.{ + GetConnectedBukkitPlayers, + SendBukkitMessage +} import com.github.unchama.seichiassist.MaterialSets.BlockBreakableBySkill import com.github.unchama.seichiassist.SeichiAssist.seichiAssistConfig import com.github.unchama.seichiassist.bungee.BungeeReceiver import com.github.unchama.seichiassist.commands._ import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts -import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.{asyncShift, onMainThread} +import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.{ + asyncShift, + onMainThread +} import com.github.unchama.seichiassist.data.MineStackGachaData import com.github.unchama.seichiassist.data.player.PlayerData import com.github.unchama.seichiassist.database.DatabaseGateway -import com.github.unchama.seichiassist.domain.actions.{GetNetworkConnectionCount, UuidToLastSeenName} +import com.github.unchama.seichiassist.domain.actions.{ + GetNetworkConnectionCount, + UuidToLastSeenName +} import com.github.unchama.seichiassist.domain.configuration.RedisBungeeRedisConfiguration import com.github.unchama.seichiassist.infrastructure.akka.ConfiguredActorSystemProvider import com.github.unchama.seichiassist.infrastructure.logging.jul.NamedJULLogger @@ -51,9 +63,11 @@ import com.github.unchama.seichiassist.subsystems.breakcountbar.BreakCountBarAPI import com.github.unchama.seichiassist.subsystems.buildcount.BuildCountAPI import com.github.unchama.seichiassist.subsystems.discordnotification.DiscordNotificationAPI import com.github.unchama.seichiassist.subsystems.donate.DonatePremiumPointAPI -import com.github.unchama.seichiassist.subsystems.donate.bukkit.commands.DonationCommand import com.github.unchama.seichiassist.subsystems.fastdiggingeffect.application.Configuration -import com.github.unchama.seichiassist.subsystems.fastdiggingeffect.{FastDiggingEffectApi, FastDiggingSettingsApi} +import com.github.unchama.seichiassist.subsystems.fastdiggingeffect.{ + FastDiggingEffectApi, + FastDiggingSettingsApi +} import com.github.unchama.seichiassist.subsystems.fourdimensionalpocket.FourDimensionalPocketApi import com.github.unchama.seichiassist.subsystems.gacha.GachaAPI import com.github.unchama.seichiassist.subsystems.gacha.subsystems.consumegachaticket.ConsumeGachaTicketAPI diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/skill/ActiveSkillEffectMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/skill/ActiveSkillEffectMenu.scala index 70a652d224..bcef47f214 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/skill/ActiveSkillEffectMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/skill/ActiveSkillEffectMenu.scala @@ -52,9 +52,10 @@ object ActiveSkillEffectMenu extends Menu { } } - private def unlockOrSet( - effect: ActiveSkillEffect - )(implicit voteAPI: VoteAPI[IO, Player], donateAPI: DonatePremiumPointAPI[IO]): TargetedEffect[Player] = Kleisli { player => + private def unlockOrSet(effect: ActiveSkillEffect)( + implicit voteAPI: VoteAPI[IO, Player], + donateAPI: DonatePremiumPointAPI[IO] + ): TargetedEffect[Player] = Kleisli { player => val playerData = SeichiAssist.playermap(player.getUniqueId) def unlockNormalEffect(effect: ActiveSkillNormalEffect): IO[Unit] = From fd6bf6a4cdf88bc8bcd10be41ae855de1e869639 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 29 Dec 2022 23:44:35 +0900 Subject: [PATCH 290/482] =?UTF-8?q?chore:=20=E3=83=9E=E3=82=A4=E3=82=B0?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E3=81=AE=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E9=87=8D=E8=A4=87=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...airy_time_type.sql => V1.14.0__Change_new_fairy_time_type.sql} | 0 ...13.1__Add_fairy_columns.sql => V1.14.1__Add_fairy_columns.sql} | 0 ...1.13.2__Move_vote_column.sql => V1.14.2__Move_vote_column.sql} | 0 ..._vote_fairy_column.sql => V1.14.3__Move_vote_fairy_column.sql} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V1.13.0__Change_new_fairy_time_type.sql => V1.14.0__Change_new_fairy_time_type.sql} (100%) rename src/main/resources/db/migration/{V1.13.1__Add_fairy_columns.sql => V1.14.1__Add_fairy_columns.sql} (100%) rename src/main/resources/db/migration/{V1.13.2__Move_vote_column.sql => V1.14.2__Move_vote_column.sql} (100%) rename src/main/resources/db/migration/{V1.13.3__Move_vote_fairy_column.sql => V1.14.3__Move_vote_fairy_column.sql} (100%) diff --git a/src/main/resources/db/migration/V1.13.0__Change_new_fairy_time_type.sql b/src/main/resources/db/migration/V1.14.0__Change_new_fairy_time_type.sql similarity index 100% rename from src/main/resources/db/migration/V1.13.0__Change_new_fairy_time_type.sql rename to src/main/resources/db/migration/V1.14.0__Change_new_fairy_time_type.sql diff --git a/src/main/resources/db/migration/V1.13.1__Add_fairy_columns.sql b/src/main/resources/db/migration/V1.14.1__Add_fairy_columns.sql similarity index 100% rename from src/main/resources/db/migration/V1.13.1__Add_fairy_columns.sql rename to src/main/resources/db/migration/V1.14.1__Add_fairy_columns.sql diff --git a/src/main/resources/db/migration/V1.13.2__Move_vote_column.sql b/src/main/resources/db/migration/V1.14.2__Move_vote_column.sql similarity index 100% rename from src/main/resources/db/migration/V1.13.2__Move_vote_column.sql rename to src/main/resources/db/migration/V1.14.2__Move_vote_column.sql diff --git a/src/main/resources/db/migration/V1.13.3__Move_vote_fairy_column.sql b/src/main/resources/db/migration/V1.14.3__Move_vote_fairy_column.sql similarity index 100% rename from src/main/resources/db/migration/V1.13.3__Move_vote_fairy_column.sql rename to src/main/resources/db/migration/V1.14.3__Move_vote_fairy_column.sql From f9baddd76154a1b4815920834077097919894935 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:01:52 +0900 Subject: [PATCH 291/482] =?UTF-8?q?chore:=20=E3=83=9E=E3=82=A4=E3=82=B0?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E3=81=AE=E6=9C=80=E5=BE=8C=E3=81=AB=E6=94=B9?= =?UTF-8?q?=E8=A1=8C=E3=82=92=E5=85=A5=E3=82=8C=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/db/migration/V1.14.2__Move_vote_column.sql | 2 +- .../resources/db/migration/V1.14.3__Move_vote_fairy_column.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/db/migration/V1.14.2__Move_vote_column.sql b/src/main/resources/db/migration/V1.14.2__Move_vote_column.sql index 04794742ba..9690a151b8 100644 --- a/src/main/resources/db/migration/V1.14.2__Move_vote_column.sql +++ b/src/main/resources/db/migration/V1.14.2__Move_vote_column.sql @@ -33,4 +33,4 @@ ALTER TABLE DROP IF EXISTS chainvote, DROP IF EXISTS effectpoint, DROP IF EXISTS p_givenvote, - DROP IF EXISTS lastvote; \ No newline at end of file + DROP IF EXISTS lastvote; diff --git a/src/main/resources/db/migration/V1.14.3__Move_vote_fairy_column.sql b/src/main/resources/db/migration/V1.14.3__Move_vote_fairy_column.sql index b558c29a0b..1653f85146 100644 --- a/src/main/resources/db/migration/V1.14.3__Move_vote_fairy_column.sql +++ b/src/main/resources/db/migration/V1.14.3__Move_vote_fairy_column.sql @@ -41,4 +41,4 @@ ALTER TABLE DROP VotingFairyRecoveryValue, DROP newVotingFairyTime, DROP p_apple, - DROP is_fairy_speech_play_sound \ No newline at end of file + DROP is_fairy_speech_play_sound From d187b0d69418407beb234dfa5e1f79127f07cd1f Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:05:53 +0900 Subject: [PATCH 292/482] =?UTF-8?q?refactor:=20receiveVoteBenefits?= =?UTF-8?q?=E3=81=8CKleisli=E3=82=92=E8=BF=94=E3=81=99=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/seichiassist/menus/VoteMenu.scala | 6 ++---- .../unchama/seichiassist/subsystems/vote/System.scala | 4 +++- .../unchama/seichiassist/subsystems/vote/VoteAPI.scala | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 21b465a5a7..df36df435f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -26,7 +26,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.player.PlayerEffects.closeInventoryEffect -import com.github.unchama.targetedeffect.{SequentialEffect, TargetedEffect, UnfocusedEffect} +import com.github.unchama.targetedeffect.{DeferredEffect, SequentialEffect, UnfocusedEffect} import org.bukkit.ChatColor._ import org.bukkit.entity.Player import org.bukkit.{Material, Sound} @@ -124,9 +124,7 @@ object VoteMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - TargetedEffect.delay { player => - voteAPI.receiveVoteBenefits(player).unsafeRunAsyncAndForget() - }, + DeferredEffect(IO(voteAPI.receiveVoteBenefits)), MessageEffect( s"${GOLD}投票特典$WHITE(${voteCounter.value - benefits.value}票分)を受け取りました" ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index 573bbb40fc..f2f5fd0f18 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -1,5 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote +import cats.data.Kleisli import cats.effect.{ConcurrentEffect, SyncEffect} import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem @@ -46,8 +47,9 @@ object System { override def receivedVoteBenefits(uuid: UUID): F[VoteBenefit] = _votePersistence.receivedVoteBenefits(uuid) - override def receiveVoteBenefits(player: Player): F[Unit] = + override def receiveVoteBenefits: Kleisli[F, Player, Unit] = Kleisli { player => _receiveVoteBenefits.receive(player) + } } override val commands: Map[String, TabExecutor] = Map( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index bed527a3c4..06b256d3b7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -1,5 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote +import cats.data.Kleisli import com.github.unchama.seichiassist.subsystems.vote.domain._ import java.util.UUID @@ -54,7 +55,7 @@ trait VoteReceiveAPI[F[_], Player] { /** * @return 投票特典を受け取る作用 */ - def receiveVoteBenefits(player: Player): F[Unit] + def receiveVoteBenefits: Kleisli[F, Player, Unit] } From dd168c72d7c2e94d5487ab8fa4509d04e9aaab2c Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:08:18 +0900 Subject: [PATCH 293/482] =?UTF-8?q?refactor:=20List=E3=81=AE=E7=B5=90?= =?UTF-8?q?=E5=90=88=E3=81=A7String=E3=82=92=E7=9B=B4=E6=8E=A5=E7=B5=90?= =?UTF-8?q?=E5=90=88=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/seichiassist/menus/VoteMenu.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index df36df435f..69242207e3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -226,8 +226,8 @@ object VoteMenu extends Menu { val fairyPlaySoundToggleButton: IO[Button] = { val description = List(s"$RESET$DARK_GRAY※この機能はデフォルトでONです。", s"$RESET$DARK_RED${UNDERLINE}クリックで切り替え") - val playSoundOnLore = List(s"$RESET${GREEN}現在音が鳴る設定になっています。") ++ description - val playSoundOffLore = List(s"$RESET${RED}現在音が鳴らない設定になっています。") ++ description + val playSoundOnLore = s"$RESET${GREEN}現在音が鳴る設定になっています。" +: description + val playSoundOffLore = s"$RESET${RED}現在音が鳴らない設定になっています。" +: description RecomputedButton(for { fairySpeechSound <- fairyAPI.isPlayFairySpeechSound(player.getUniqueId) From 82eba4f45bcd8d39a815cde1518d9d7cf92c6013 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:09:21 +0900 Subject: [PATCH 294/482] style: spawnFailedEffect -> errorEffectOnSpawn --- .../com/github/unchama/seichiassist/menus/VoteMenu.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 69242207e3..dbcc6911fd 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -275,11 +275,11 @@ object VoteMenu extends Menu { case Left(errorResult) => errorResult match { case NotEnoughSeichiLevel => - spawnFailedEffect(s"${GOLD}プレイヤーレベルが足りません") + errorEffectOnSpawn(s"${GOLD}プレイヤーレベルが足りません") case AlreadyFairySpawned => - spawnFailedEffect(s"${GOLD}既に妖精を召喚しています") + errorEffectOnSpawn(s"${GOLD}既に妖精を召喚しています") case NotEnoughEffectPoint => - spawnFailedEffect(s"${GOLD}投票ptが足りません") + errorEffectOnSpawn(s"${GOLD}投票ptが足りません") } case Right(process) => UnfocusedEffect { @@ -301,7 +301,7 @@ object VoteMenu extends Menu { } } - private def spawnFailedEffect(message: String): Kleisli[IO, Player, Unit] = { + private def errorEffectOnSpawn(message: String): Kleisli[IO, Player, Unit] = { SequentialEffect( MessageEffect(message), FocusedSoundEffect(Sound.BLOCK_GLASS_PLACE, 1f, 0.1f) From bd4b875ed1ac0ebf64e5c72a427b0c79fa9aae69 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:10:40 +0900 Subject: [PATCH 295/482] =?UTF-8?q?style:=20VoteAPI=E3=81=AE=E3=83=89?= =?UTF-8?q?=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AB@return?= =?UTF-8?q?=E3=82=92=E3=81=A4=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/subsystems/vote/VoteAPI.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index 06b256d3b7..f1232d1dbe 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -8,7 +8,7 @@ import java.util.UUID trait VoteWriteAPI[F[_]] { /** - * effectPointを減少させる作用 + * @return effectPointを減少させる作用 */ def decreaseEffectPoint(uuid: UUID, effectPoint: EffectPoint): F[Unit] @@ -23,22 +23,22 @@ object VoteWriteAPI { trait VoteReadAPI[F[_], Player] { /** - * 投票回数を返す作用 + * @return 投票回数を返す作用 */ def voteCounter(uuid: UUID): F[VoteCounter] /** - * 連続投票日数を返す作用 + * @return 連続投票日数を返す作用 */ def chainVoteDayNumber(uuid: UUID): F[ChainVoteDayNumber] /** - * effectPointを返す作用 + * @return effectPointを返す作用 */ def effectPoints(player: Player): F[EffectPoint] /** - * 投票特典を受け取った回数を返す作用 + * @return 投票特典を受け取った回数を返す作用 */ def receivedVoteBenefits(uuid: UUID): F[VoteBenefit] From 0900f0e924314ebc3596c24e375205ab6ff27167 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:13:04 +0900 Subject: [PATCH 296/482] =?UTF-8?q?style:=20BukkitReceiveVoteBenefits?= =?UTF-8?q?=E3=81=AE=E5=A4=89=E6=95=B0=E5=90=8D=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/BukkitReceiveVoteBenefits.scala | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 65d9cc769d..cf28aa824a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -27,29 +27,30 @@ class BukkitReceiveVoteBenefits[F[_]: OnMinecraftServerThread: Sync, G[ override def receive(player: Player): F[Unit] = { val uuid = player.getUniqueId for { - voteCounter <- votePersistence.voteCounter(uuid) + totalVote <- votePersistence.voteCounter(uuid) receivedVote <- votePersistence.receivedVoteBenefits(uuid) - notReceivedBenefits = VoteBenefit(voteCounter.value - receivedVote.value) + pendingCount = VoteBenefit(totalVote.value - receivedVote.value) + // 受け取ってない分を受け取ったことにする _ <- votePersistence.increaseVoteBenefits( uuid, - notReceivedBenefits - ) // 受け取ってない分を受け取ったことにする + pendingCount + ) playerLevel <- ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read.map { _.levelCorrespondingToExp.level }) - gachaSkulls = Seq.fill(10 * notReceivedBenefits.value)( + gachaSkulls = Seq.fill(10 * pendingCount.value)( BukkitGachaSkullData.gachaForVoting ) - elseVoteBenefits = Seq.fill(notReceivedBenefits.value)( + elseVoteBenefits = Seq.fill(pendingCount.value)( if (playerLevel < 50) ItemData.getSuperPickaxe(1) else ItemData.getVotingGift(1) ) grantItems = gachaSkulls ++ elseVoteBenefits _ <- { ContextCoercion(votePersistence.increaseEffectPoints(uuid, EffectPoint(10))) - .replicateA(notReceivedBenefits.value) >> + .replicateA(pendingCount.value) >> grantItemStacksEffect[F](grantItems: _*).apply(player) - }.whenA(notReceivedBenefits.value != 0) + }.whenA(pendingCount.value != 0) } yield () } From 64ad0dcc59e16da6d4137037be4a3340b0a74821 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:13:43 +0900 Subject: [PATCH 297/482] style: voteCounter -> Count --- .../github/unchama/seichiassist/data/player/PlayerData.scala | 2 +- .../scala/com/github/unchama/seichiassist/menus/VoteMenu.scala | 2 +- .../github/unchama/seichiassist/subsystems/vote/System.scala | 2 +- .../github/unchama/seichiassist/subsystems/vote/VoteAPI.scala | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala index 3481b63d59..760d6c6ea1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala +++ b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala @@ -99,7 +99,7 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { // 二つ名関連用にp_vote(投票数)を引っ張る。(予期せぬエラー回避のため名前を複雑化) // TODO: Achievementシステムが再実装されたら速攻でこれを消すべき var p_vote_forT: Int = - SeichiAssist.instance.voteSystem.api.voteCounter(uuid).unsafeRunSync().value + SeichiAssist.instance.voteSystem.api.count(uuid).unsafeRunSync().value // 二つ名配布予約NOの保存 var giveachvNo = 0 // 実績ポイント用 diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index dbcc6911fd..390c47b23f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -105,7 +105,7 @@ object VoteMenu extends Menu { val uuid = player.getUniqueId for { benefits <- voteAPI.receivedVoteBenefits(uuid) - voteCounter <- voteAPI.voteCounter(uuid) + voteCounter <- voteAPI.count(uuid) effectPoint <- voteAPI.effectPoints(player) } yield { Button( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index f2f5fd0f18..3e77dc91b3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -32,7 +32,7 @@ object System { new System[F, Player] { override implicit val api: VoteAPI[F, Player] = new VoteAPI[F, Player] { - override def voteCounter(uuid: UUID): F[VoteCounter] = + override def count(uuid: UUID): F[VoteCounter] = _votePersistence.voteCounter(uuid) override def chainVoteDayNumber(uuid: UUID): F[ChainVoteDayNumber] = diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index f1232d1dbe..9c4a132af5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -25,7 +25,7 @@ trait VoteReadAPI[F[_], Player] { /** * @return 投票回数を返す作用 */ - def voteCounter(uuid: UUID): F[VoteCounter] + def count(uuid: UUID): F[VoteCounter] /** * @return 連続投票日数を返す作用 From fc7f5ef4fb763df4ef41741b85e0999fea97779a Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:14:09 +0900 Subject: [PATCH 298/482] style chainVoteDayNumber -> currentConsecutiveVoteStreakDays --- .../github/unchama/seichiassist/subsystems/vote/System.scala | 2 +- .../github/unchama/seichiassist/subsystems/vote/VoteAPI.scala | 2 +- .../subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index 3e77dc91b3..c34e0e67a2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -35,7 +35,7 @@ object System { override def count(uuid: UUID): F[VoteCounter] = _votePersistence.voteCounter(uuid) - override def chainVoteDayNumber(uuid: UUID): F[ChainVoteDayNumber] = + override def currentConsecutiveVoteStreakDays(uuid: UUID): F[ChainVoteDayNumber] = _votePersistence.chainVoteDays(uuid) override def decreaseEffectPoint(uuid: UUID, effectPoint: EffectPoint): F[Unit] = diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index 9c4a132af5..bf26d47b53 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -30,7 +30,7 @@ trait VoteReadAPI[F[_], Player] { /** * @return 連続投票日数を返す作用 */ - def chainVoteDayNumber(uuid: UUID): F[ChainVoteDayNumber] + def currentConsecutiveVoteStreakDays(uuid: UUID): F[ChainVoteDayNumber] /** * @return effectPointを返す作用 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 0d5ab53947..cc046af4fb 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -107,7 +107,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] */ private def computeAppleConsumptionAmount: F[Int] = for { seichiAmountData <- ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read) - chainVoteNumber <- voteAPI.chainVoteDayNumber(uuid) + chainVoteNumber <- voteAPI.currentConsecutiveVoteStreakDays(uuid) appleOpenState <- fairyPersistence.appleOpenState(uuid) oldManaAmount <- ContextCoercion { manaApi.readManaAmount(player) From deb4aa0de07525d61b969659a5c0d8d63e32bab7 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:24:29 +0900 Subject: [PATCH 299/482] =?UTF-8?q?style:=20BukkitReceiveVoteBenefits?= =?UTF-8?q?=E3=81=AE=E5=A4=89=E6=95=B0=E5=90=8D=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/bukkit/actions/BukkitReceiveVoteBenefits.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index cf28aa824a..9b3841d3f4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -38,14 +38,14 @@ class BukkitReceiveVoteBenefits[F[_]: OnMinecraftServerThread: Sync, G[ playerLevel <- ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read.map { _.levelCorrespondingToExp.level }) - gachaSkulls = Seq.fill(10 * pendingCount.value)( + gachaTicketAmount = Seq.fill(10 * pendingCount.value)( BukkitGachaSkullData.gachaForVoting ) - elseVoteBenefits = Seq.fill(pendingCount.value)( + additionalVoteBenefit = Seq.fill(pendingCount.value)( if (playerLevel < 50) ItemData.getSuperPickaxe(1) else ItemData.getVotingGift(1) ) - grantItems = gachaSkulls ++ elseVoteBenefits + grantItems = gachaTicketAmount ++ additionalVoteBenefit _ <- { ContextCoercion(votePersistence.increaseEffectPoints(uuid, EffectPoint(10))) .replicateA(pendingCount.value) >> From 3e8e8e9d87ebe3fd2f3dbcf1df66679fd88efb0a Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:26:52 +0900 Subject: [PATCH 300/482] =?UTF-8?q?style:=20VotePersistence=E3=81=AE?= =?UTF-8?q?=E9=96=A2=E6=95=B0=E5=90=8D=E3=82=92=E9=81=A9=E5=88=87=E3=81=AA?= =?UTF-8?q?=E3=82=82=E3=81=AE=E3=81=AB=E5=A4=89=E3=81=88=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/subsystems/vote/System.scala | 4 ++-- .../vote/bukkit/actions/BukkitReceiveVoteBenefits.scala | 2 +- .../subsystems/vote/bukkit/command/VoteCommand.scala | 4 ++-- .../subsystems/vote/domain/VotePersistence.scala | 8 ++++---- .../vote/infrastructure/JdbcVotePersistence.scala | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index c34e0e67a2..295e900560 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -33,10 +33,10 @@ object System { new System[F, Player] { override implicit val api: VoteAPI[F, Player] = new VoteAPI[F, Player] { override def count(uuid: UUID): F[VoteCounter] = - _votePersistence.voteCounter(uuid) + _votePersistence.currentVoteCount(uuid) override def currentConsecutiveVoteStreakDays(uuid: UUID): F[ChainVoteDayNumber] = - _votePersistence.chainVoteDays(uuid) + _votePersistence.currentConsecutiveVoteStreakDay(uuid) override def decreaseEffectPoint(uuid: UUID, effectPoint: EffectPoint): F[Unit] = _votePersistence.decreaseEffectPoints(uuid, effectPoint) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 9b3841d3f4..96f9dbb20c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -27,7 +27,7 @@ class BukkitReceiveVoteBenefits[F[_]: OnMinecraftServerThread: Sync, G[ override def receive(player: Player): F[Unit] = { val uuid = player.getUniqueId for { - totalVote <- votePersistence.voteCounter(uuid) + totalVote <- votePersistence.currentVoteCount(uuid) receivedVote <- votePersistence.receivedVoteBenefits(uuid) pendingCount = VoteBenefit(totalVote.value - receivedVote.value) // 受け取ってない分を受け取ったことにする diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala index 52262dbe24..d658d7a82b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala @@ -29,8 +29,8 @@ class VoteCommand[F[_]: ConcurrentEffect](implicit votePersistence: VotePersiste UnfocusedEffect { val playerName = PlayerName(lowerCasePlayerName) val eff = for { - _ <- votePersistence.voteCounterIncrement(playerName) - _ <- votePersistence.updateChainVote(playerName) + _ <- votePersistence.incrementVoteCount(playerName) + _ <- votePersistence.updateConsecutiveVoteStreak(playerName) } yield () eff.toIO.unsafeRunAsyncAndForget() } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala index ba91636f63..1036280e6e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala @@ -12,22 +12,22 @@ trait VotePersistence[F[_]] { /** * 投票回数をインクリメントする作用 */ - def voteCounterIncrement(playerName: PlayerName): F[Unit] + def incrementVoteCount(playerName: PlayerName): F[Unit] /** * 投票回数を返す作用 */ - def voteCounter(uuid: UUID): F[VoteCounter] + def currentVoteCount(uuid: UUID): F[VoteCounter] /** * 連続投票回数を更新する作用 */ - def updateChainVote(playerName: PlayerName): F[Unit] + def updateConsecutiveVoteStreak(playerName: PlayerName): F[Unit] /** * 連続投票日数を返す作用 */ - def chainVoteDays(uuid: UUID): F[ChainVoteDayNumber] + def currentConsecutiveVoteStreakDay(uuid: UUID): F[ChainVoteDayNumber] /** * [[EffectPoint]]を指定分だけ増加させる作用 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index 52874a2c88..cd19439fb3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -20,7 +20,7 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { } } - override def voteCounterIncrement(playerName: PlayerName): F[Unit] = Sync[F].delay { + override def incrementVoteCount(playerName: PlayerName): F[Unit] = Sync[F].delay { DB.localTx { implicit session => sql"UPDATE vote SET vote_number = vote_number + 1 WHERE uuid = (SELECT uuid FROM playerdata WHERE name = ${playerName.name})" .execute() @@ -28,7 +28,7 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { } } - override def voteCounter(uuid: UUID): F[VoteCounter] = Sync[F].delay { + override def currentVoteCount(uuid: UUID): F[VoteCounter] = Sync[F].delay { DB.readOnly { implicit session => val votePoint = sql"SELECT vote_number FROM vote WHERE uuid = ${uuid.toString}" .map(_.int("vote_number")) @@ -39,7 +39,7 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { } } - override def updateChainVote(playerName: PlayerName): F[Unit] = Sync[F].delay { + override def updateConsecutiveVoteStreak(playerName: PlayerName): F[Unit] = Sync[F].delay { DB.localTx { implicit session => /* NOTE: 最終投票日時より(連続投票許容幅 - 1)した日時よりも @@ -58,7 +58,7 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { } } - override def chainVoteDays(uuid: UUID): F[ChainVoteDayNumber] = Sync[F].delay { + override def currentConsecutiveVoteStreakDay(uuid: UUID): F[ChainVoteDayNumber] = Sync[F].delay { DB.readOnly { implicit session => val chainVoteDays = sql"SELECT chain_vote_number FROM vote WHERE uuid = ${uuid.toString}" .map(_.int("chain_vote_number")) From 4177df3ebec5302ed80e6e325ca735aaa19000d3 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:28:41 +0900 Subject: [PATCH 301/482] style: VoteCounter -> VoteCount --- .../seichiassist/subsystems/vote/System.scala | 2 +- .../subsystems/vote/VoteAPI.scala | 2 +- .../subsystems/vote/domain/VoteCount.scala | 5 +++++ .../subsystems/vote/domain/VoteCounter.scala | 5 ----- .../vote/domain/VotePersistence.scala | 22 +++++++++---------- .../infrastructure/JdbcVotePersistence.scala | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCount.scala delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCounter.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala index 295e900560..143aded858 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/System.scala @@ -32,7 +32,7 @@ object System { new System[F, Player] { override implicit val api: VoteAPI[F, Player] = new VoteAPI[F, Player] { - override def count(uuid: UUID): F[VoteCounter] = + override def count(uuid: UUID): F[VoteCount] = _votePersistence.currentVoteCount(uuid) override def currentConsecutiveVoteStreakDays(uuid: UUID): F[ChainVoteDayNumber] = diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala index bf26d47b53..866ee3b7a2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/VoteAPI.scala @@ -25,7 +25,7 @@ trait VoteReadAPI[F[_], Player] { /** * @return 投票回数を返す作用 */ - def count(uuid: UUID): F[VoteCounter] + def count(uuid: UUID): F[VoteCount] /** * @return 連続投票日数を返す作用 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCount.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCount.scala new file mode 100644 index 0000000000..fa56a30deb --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCount.scala @@ -0,0 +1,5 @@ +package com.github.unchama.seichiassist.subsystems.vote.domain + +case class VoteCount(value: Int) { + require(value >= 0, "VoteCountは非負である必要があります。") +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCounter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCounter.scala deleted file mode 100644 index 05a280f493..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VoteCounter.scala +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.domain - -case class VoteCounter(value: Int) { - require(value >= 0, "VoteCounterは非負である必要があります。") -} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala index 1036280e6e..cad0c09f94 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala @@ -5,52 +5,52 @@ import java.util.UUID trait VotePersistence[F[_]] { /** - * プレイヤーデータを作成する作用 + * @return プレイヤーデータを作成する作用 */ def createPlayerData(uuid: UUID): F[Unit] /** - * 投票回数をインクリメントする作用 + * @return 投票回数をインクリメントする作用 */ def incrementVoteCount(playerName: PlayerName): F[Unit] /** - * 投票回数を返す作用 + * @return 投票回数を返す作用 */ - def currentVoteCount(uuid: UUID): F[VoteCounter] + def currentVoteCount(uuid: UUID): F[VoteCount] /** - * 連続投票回数を更新する作用 + * @return 連続投票回数を更新する作用 */ def updateConsecutiveVoteStreak(playerName: PlayerName): F[Unit] /** - * 連続投票日数を返す作用 + * @return 連続投票日数を返す作用 */ def currentConsecutiveVoteStreakDay(uuid: UUID): F[ChainVoteDayNumber] /** - * [[EffectPoint]]を指定分だけ増加させる作用 + * @return [[EffectPoint]]を指定分だけ増加させる作用 */ def increaseEffectPoints(uuid: UUID, effectPoint: EffectPoint): F[Unit] /** - * [[EffectPoint]]を減少させる作用 + * @return [[EffectPoint]]を減少させる作用 */ def decreaseEffectPoints(uuid: UUID, effectPoint: EffectPoint): F[Unit] /** - * 指定プレイヤーの[[EffectPoint]]を返す作用 + * @return 指定プレイヤーの[[EffectPoint]]を返す作用 */ def effectPoints(uuid: UUID): F[EffectPoint] /** - * 投票特典を受け取った回数を増加させる作用 + * @return 投票特典を受け取った回数を増加させる作用 */ def increaseVoteBenefits(uuid: UUID, amount: VoteBenefit): F[Unit] /** - * 投票特典を受け取った回数を返す作用 + * @return 投票特典を受け取った回数を返す作用 */ def receivedVoteBenefits(uuid: UUID): F[VoteBenefit] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index cd19439fb3..23246c20b3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -28,14 +28,14 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { } } - override def currentVoteCount(uuid: UUID): F[VoteCounter] = Sync[F].delay { + override def currentVoteCount(uuid: UUID): F[VoteCount] = Sync[F].delay { DB.readOnly { implicit session => val votePoint = sql"SELECT vote_number FROM vote WHERE uuid = ${uuid.toString}" .map(_.int("vote_number")) .single() .apply() .get - VoteCounter(votePoint) + VoteCount(votePoint) } } From f3908367017bb5d1a3598d1bb586324727a6419c Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:30:57 +0900 Subject: [PATCH 302/482] =?UTF-8?q?docs:=20createPlayerData=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E3=81=AE=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=82=92=E3=82=88=E3=82=8A=E8=A9=B3=E7=B4=B0=E3=81=AB?= =?UTF-8?q?=E6=9B=B8=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/domain/VotePersistence.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala index cad0c09f94..30bdf89c1d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala @@ -5,6 +5,8 @@ import java.util.UUID trait VotePersistence[F[_]] { /** + * プレイヤーの投票データを初期化します。この作用はプレイヤーがサーバーに参加するたびに呼ばれるため、作用が冪等でなければなりません。 + * * @return プレイヤーデータを作成する作用 */ def createPlayerData(uuid: UUID): F[Unit] From 9b78c9dc65254b812ddf7f70b40363aa57bf50ee Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:31:58 +0900 Subject: [PATCH 303/482] style: chainVoteAllowableWidth -> consecutiveVoteStreakDaysThreshold --- .../subsystems/vote/infrastructure/JdbcVotePersistence.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index 23246c20b3..493ffe86c5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -9,7 +9,7 @@ import java.util.UUID class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { // NOTE: 連続投票許容幅を変更する場合はここを変更してください。 - private val chainVoteAllowableWidth = 4 + private val consecutiveVoteStreakDaysThreshold = 4 def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { DB.localTx { implicit session => @@ -46,7 +46,7 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { 小さかった場合に連続投票を0に戻します。 */ sql"""UPDATE vote SET chain_vote_number = - | CASE WHEN DATEDIFF(last_vote, NOW()) <= ${-chainVoteAllowableWidth - 1} + | CASE WHEN DATEDIFF(last_vote, NOW()) <= ${-consecutiveVoteStreakDaysThreshold - 1} | THEN 0 | ELSE chain_vote_number + 1 | END, From ad5ff4931d8d9474af690c478614772dff10eb05 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:32:21 +0900 Subject: [PATCH 304/482] =?UTF-8?q?fix:=20=E9=80=A3=E7=B6=9A=E6=8A=95?= =?UTF-8?q?=E7=A5=A8=E6=97=A5=E6=95=B0=E8=A8=B1=E5=AE=B9=E5=B9=85=E3=82=92?= =?UTF-8?q?4=E3=81=8B=E3=82=891=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/infrastructure/JdbcVotePersistence.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index 493ffe86c5..6ba6920c1a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -9,7 +9,7 @@ import java.util.UUID class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { // NOTE: 連続投票許容幅を変更する場合はここを変更してください。 - private val consecutiveVoteStreakDaysThreshold = 4 + private val consecutiveVoteStreakDaysThreshold = 1 def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { DB.localTx { implicit session => From 9ff2a42ce83941bae306ff36ee1368ecf6cd199c Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:32:59 +0900 Subject: [PATCH 305/482] =?UTF-8?q?docs:=20consecutiveVoteStreakDaysThresh?= =?UTF-8?q?old=E3=81=AE=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=81=AE=E8=84=B1=E5=AD=97=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/infrastructure/JdbcVotePersistence.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index 6ba6920c1a..063c04a123 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -8,7 +8,7 @@ import java.util.UUID class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { - // NOTE: 連続投票許容幅を変更する場合はここを変更してください。 + // NOTE: 連続投票日数許容幅を変更する場合はここを変更してください。 private val consecutiveVoteStreakDaysThreshold = 1 def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { From 63f4091c4255047fae26b5651107817873126934 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:38:41 +0900 Subject: [PATCH 306/482] =?UTF-8?q?docs:=20FairyAPI=E3=81=AE=E3=83=89?= =?UTF-8?q?=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/FairyAPI.scala | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index ba56569415..641981eb7f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -8,12 +8,12 @@ import java.util.UUID trait FairyWriteAPI[F[_], G[_], Player] { /** - * 妖精にあげるりんごの開放状態を変更する + * @return 妖精にあげるりんごの開放状態を変更する作用 */ def updateAppleOpenState(uuid: UUID, appleConsumeStrategy: FairyAppleConsumeStrategy): F[Unit] /** - * 妖精を召喚するためのコストを変更します。 + * @return 妖精を召喚するためのコストを変更する作用 */ def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] @@ -30,37 +30,37 @@ object FairyWriteAPI { trait FairyReadAPI[F[_], G[_], Player] { /** - * 妖精にあげるりんごの開放状態を取得する + * @return 妖精にあげるりんごの開放状態を取得する作用 */ def appleOpenState(uuid: UUID): F[FairyAppleConsumeStrategy] /** - * 妖精を召喚するためのコストを取得する + * @return 妖精を召喚するためのコストを取得する作用 */ def fairySummonCost(player: Player): F[FairySummonCost] /** - * `FairyLoreTable`からLoreを取得する + * @return `FairyLoreTable`からLoreを取得する作用 */ def getFairyLore(uuid: UUID): F[FairyLore] /** - * 妖精を使っているかを取得する + * @return 妖精を使っているかを取得する作用 */ def isFairyUsing(player: Player): F[Boolean] /** - * 自分の妖精に食べさせたりんごの量の順位を返す + * @return 自分の妖精に食べさせたりんごの量の順位を返す作用 */ def appleAteByFairyMyRanking(player: Player): F[Option[AppleAteByFairyRank]] /** - * 妖精に食べさせたりんごの量の順位上`number`件を返す + * @return 妖精に食べさせたりんごの量の順位上`number`件を返す作用 */ def appleAteByFairyRanking(number: Int): F[Vector[Option[AppleAteByFairyRank]]] /** - * 妖精が食べたりんごの合計数を返す + * @return 妖精が食べたりんごの合計数を返す作用 */ def allEatenAppleAmount: F[AppleAmount] @@ -77,17 +77,17 @@ object FairyReadAPI { trait FairySpeechAPI[F[_], Player] { /** - * 妖精が喋るときに音をだすかをトグルする + * @return 妖精が喋るときに音をだすかをトグルする作用 */ def toggleFairySpeechSound(uuid: UUID): F[Unit] /** - * 妖精が喋ったときに音を再生するか取得する + * @return 妖精が喋ったときに音を再生するか取得する作用 */ def isPlayFairySpeechSound(uuid: UUID): F[Boolean] /** - * @return 妖精がいつ帰るのかを[[Player]]に送信する作用 + * @return 妖精がいつ帰るのかを`player`に送信する作用作用 */ def speechEndTime(player: Player): F[Unit] @@ -103,9 +103,9 @@ object FairySpeechAPI { trait FairySummonAPI[F[_], Player] { /** - * 妖精の召喚をリクエストする * 召喚に失敗した場合はエラーを返す * 成功した場合は召喚する作用を返す + * @return 妖精の召喚をリクエストする作用 */ def fairySummonRequest(player: Player): F[FairySpawnRequestErrorOrSpawn[F]] } From 3d442977968ae52119a1decdda7b5f51e8870754 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:41:41 +0900 Subject: [PATCH 307/482] =?UTF-8?q?style:=20FairyAPI=E3=81=AE=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E5=90=8D=E3=82=92=E9=81=A9=E5=88=87=E3=81=AA=E3=82=82?= =?UTF-8?q?=E3=81=AE=E3=81=AB=E5=A4=89=E3=81=88=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LICENSE | 4 ++-- localDependencies/LICENSES/worldedit-bukkit | 4 ++-- localDependencies/LICENSES/worldguard-bukkit | 4 ++-- .../fs2/workaround/fs3/Fs3Channel.scala | 4 ++-- .../unchama/fs2/workaround/fs3/Fs3Topic.scala | 8 +++---- .../unchama/seichiassist/menus/VoteMenu.scala | 16 ++++++------- .../vote/subsystems/fairy/FairyAPI.scala | 18 +++++++------- .../vote/subsystems/fairy/System.scala | 24 +++++++++---------- .../fairy/domain/FairyPersistence.scala | 2 +- 9 files changed, 42 insertions(+), 42 deletions(-) diff --git a/LICENSE b/LICENSE index f288702d2f..5981e7d210 100644 --- a/LICENSE +++ b/LICENSE @@ -567,12 +567,12 @@ the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - Each version is given a distinguishing version number. If the + Each version is given a distinguishing version top. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the +Foundation. If the Program does not specify a version top of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. diff --git a/localDependencies/LICENSES/worldedit-bukkit b/localDependencies/LICENSES/worldedit-bukkit index f288702d2f..5981e7d210 100644 --- a/localDependencies/LICENSES/worldedit-bukkit +++ b/localDependencies/LICENSES/worldedit-bukkit @@ -567,12 +567,12 @@ the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - Each version is given a distinguishing version number. If the + Each version is given a distinguishing version top. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the +Foundation. If the Program does not specify a version top of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. diff --git a/localDependencies/LICENSES/worldguard-bukkit b/localDependencies/LICENSES/worldguard-bukkit index 954b09aba2..70707608c0 100644 --- a/localDependencies/LICENSES/worldguard-bukkit +++ b/localDependencies/LICENSES/worldguard-bukkit @@ -148,13 +148,13 @@ of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - Each version is given a distinguishing version number. If the + Each version is given a distinguishing version top. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser +received it does not specify a version top of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. diff --git a/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Channel.scala b/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Channel.scala index 98c3d0f4af..491e1b267d 100644 --- a/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Channel.scala +++ b/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Channel.scala @@ -67,8 +67,8 @@ sealed trait Fs3Channel[F[_], A] { * Every time `stream` is pulled, it will serve all the elements that are queued up in a * single chunk, including those from producers that might be semantically blocked on a * bounded channel, which will then become unblocked. That is, a bound on a channel represents - * the maximum number of elements that can be queued up before a producer blocks, and not the - * maximum number of elements that will be received by `stream` at once. + * the maximum top of elements that can be queued up before a producer blocks, and not the + * maximum top of elements that will be received by `stream` at once. */ def stream: Stream[F, A] diff --git a/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Topic.scala b/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Topic.scala index 58bced3bb3..f873c592b0 100644 --- a/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Topic.scala +++ b/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Topic.scala @@ -33,10 +33,10 @@ import scala.collection.immutable.LongMap */ /** - * Topic allows you to distribute `A`s published by an arbitrary number of publishers to an - * arbitrary number of subscribers. + * Topic allows you to distribute `A`s published by an arbitrary top of publishers to an + * arbitrary top of subscribers. * - * Topic has built-in back-pressure support implemented as the maximum number of elements + * Topic has built-in back-pressure support implemented as the maximum top of elements * (`maxQueued`) that a subscriber is allowed to enqueue. * * Once that bound is hit, any publishing action will semantically block until the lagging @@ -77,7 +77,7 @@ trait Fs3Topic[F[_], A] { self => * queue. * * @param maxQueued - * maximum number of elements to enqueue to the subscription queue before blocking + * maximum top of elements to enqueue to the subscription queue before blocking * publishers */ def subscribe(maxQueued: Int): Stream[F, A] diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 390c47b23f..90596cdcb0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -76,7 +76,7 @@ object VoteMenu extends Menu { .traverse(_.sequence) for { - isFairyUsing <- environment.fairyAPI.isFairyUsing(constantButtons.player) + isFairyUsing <- environment.fairyAPI.isFairyAppearing(constantButtons.player) computeButtons <- computeButtonsIO dynamicButtons <- dynamicButtonsIO } yield { @@ -200,7 +200,7 @@ object VoteMenu extends Menu { val fairyContractSettingToggle: IO[Button] = RecomputedButton(for { fairyLore <- fairyAPI.getFairyLore(uuid) - appleOpenState <- fairyAPI.appleOpenState(uuid) + appleOpenState <- fairyAPI.consumeStrategy(uuid) } yield { Button( new IconItemStackBuilder(Material.PAPER) @@ -230,7 +230,7 @@ object VoteMenu extends Menu { val playSoundOffLore = s"$RESET${RED}現在音が鳴らない設定になっています。" +: description RecomputedButton(for { - fairySpeechSound <- fairyAPI.isPlayFairySpeechSound(player.getUniqueId) + fairySpeechSound <- fairyAPI.doPlaySoundOnSpeak(player.getUniqueId) } yield { Button( new IconItemStackBuilder(Material.JUKEBOX) @@ -244,7 +244,7 @@ object VoteMenu extends Menu { SequentialEffect( FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), UnfocusedEffect { - fairyAPI.toggleFairySpeechSound(player.getUniqueId).unsafeRunAsyncAndForget() + fairyAPI.toggleSoundOnSpeak(player.getUniqueId).unsafeRunAsyncAndForget() } ) } @@ -318,7 +318,7 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( UnfocusedEffect { - fairyAPI.speechEndTime(player).unsafeRunAsyncAndForget() + fairyAPI.sendDisappearTimeToChat(player).unsafeRunAsyncAndForget() }, closeInventoryEffect ) @@ -327,9 +327,9 @@ object VoteMenu extends Menu { } val gachaRingoInformation: IO[Button] = for { - myRank <- fairyAPI.appleAteByFairyMyRanking(player) - topFourRanking <- fairyAPI.appleAteByFairyRanking(4) - allEatenAppleAmount <- fairyAPI.allEatenAppleAmount + myRank <- fairyAPI.rankByMostConsumedApple(player) + topFourRanking <- fairyAPI.rankingByMostConsumedApple(4) + allEatenAppleAmount <- fairyAPI.totalConsumedApple } yield { val staticLore = List( s"$RESET$RED$BOLD※ニンゲンに見られないように気を付けること!", diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 641981eb7f..587674933f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -32,7 +32,7 @@ trait FairyReadAPI[F[_], G[_], Player] { /** * @return 妖精にあげるりんごの開放状態を取得する作用 */ - def appleOpenState(uuid: UUID): F[FairyAppleConsumeStrategy] + def consumeStrategy(uuid: UUID): F[FairyAppleConsumeStrategy] /** * @return 妖精を召喚するためのコストを取得する作用 @@ -47,22 +47,22 @@ trait FairyReadAPI[F[_], G[_], Player] { /** * @return 妖精を使っているかを取得する作用 */ - def isFairyUsing(player: Player): F[Boolean] + def isFairyAppearing(player: Player): F[Boolean] /** * @return 自分の妖精に食べさせたりんごの量の順位を返す作用 */ - def appleAteByFairyMyRanking(player: Player): F[Option[AppleAteByFairyRank]] + def rankByMostConsumedApple(player: Player): F[Option[AppleAteByFairyRank]] /** - * @return 妖精に食べさせたりんごの量の順位上`number`件を返す作用 + * @return 妖精に食べさせたりんごの量の順位上`top`件を返す作用 */ - def appleAteByFairyRanking(number: Int): F[Vector[Option[AppleAteByFairyRank]]] + def rankingByMostConsumedApple(top: Int): F[Vector[Option[AppleAteByFairyRank]]] /** * @return 妖精が食べたりんごの合計数を返す作用 */ - def allEatenAppleAmount: F[AppleAmount] + def totalConsumedApple: F[AppleAmount] } @@ -79,17 +79,17 @@ trait FairySpeechAPI[F[_], Player] { /** * @return 妖精が喋るときに音をだすかをトグルする作用 */ - def toggleFairySpeechSound(uuid: UUID): F[Unit] + def toggleSoundOnSpeak(uuid: UUID): F[Unit] /** * @return 妖精が喋ったときに音を再生するか取得する作用 */ - def isPlayFairySpeechSound(uuid: UUID): F[Boolean] + def doPlaySoundOnSpeak(uuid: UUID): F[Boolean] /** * @return 妖精がいつ帰るのかを`player`に送信する作用作用 */ - def speechEndTime(player: Player): F[Unit] + def sendDisappearTimeToChat(player: Player): F[Unit] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 4451c4b77b..3bf4cd47b7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -99,7 +99,7 @@ object System { override implicit val api: FairyAPI[IO, SyncIO, Player] = new FairyAPI[IO, SyncIO, Player] { - override def appleOpenState(uuid: UUID): IO[FairyAppleConsumeStrategy] = + override def consumeStrategy(uuid: UUID): IO[FairyAppleConsumeStrategy] = persistence.appleOpenState(uuid) override def updateAppleOpenState( @@ -109,7 +109,7 @@ object System { persistence.changeAppleOpenState(uuid, appleConsumeStrategy) override def getFairyLore(uuid: UUID): IO[FairyLore] = for { - state <- appleOpenState(uuid) + state <- consumeStrategy(uuid) } yield FairyLoreTable.loreTable(state) override def updateFairySummonCost( @@ -121,30 +121,30 @@ object System { override def fairySummonCost(player: Player): IO[FairySummonCost] = persistence.fairySummonCost(player.getUniqueId) - override def isFairyUsing(player: Player): IO[Boolean] = + override def isFairyAppearing(player: Player): IO[Boolean] = persistence.isFairyUsing(player.getUniqueId) - override def appleAteByFairyMyRanking( + override def rankByMostConsumedApple( player: Player ): IO[Option[AppleAteByFairyRank]] = persistence.appleAteByFairyMyRanking(player.getUniqueId) - override def appleAteByFairyRanking( - number: Int + override def rankingByMostConsumedApple( + top: Int ): IO[Vector[Option[AppleAteByFairyRank]]] = - persistence.appleAteByFairyRanking(number) + persistence.appleAteByFairyRanking(top) - override def allEatenAppleAmount: IO[AppleAmount] = + override def totalConsumedApple: IO[AppleAmount] = persistence.allEatenAppleAmount - override def isPlayFairySpeechSound(uuid: UUID): IO[Boolean] = + override def doPlaySoundOnSpeak(uuid: UUID): IO[Boolean] = persistence.fairySpeechSound(uuid) - override def toggleFairySpeechSound(uuid: UUID): IO[Unit] = for { - isPlayFairySpeechSound <- isPlayFairySpeechSound(uuid) + override def toggleSoundOnSpeak(uuid: UUID): IO[Unit] = for { + isPlayFairySpeechSound <- doPlaySoundOnSpeak(uuid) } yield persistence.toggleFairySpeechSound(uuid, !isPlayFairySpeechSound) - override def speechEndTime(player: Player): IO[Unit] = + override def sendDisappearTimeToChat(player: Player): IO[Unit] = fairySpeech.speechEndTime(player) override def fairySummonRequest( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index 3a50814ca3..5e0590ae76 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -84,7 +84,7 @@ trait FairyPersistence[F[_]] { def appleAteByFairyMyRanking(uuid: UUID): F[Option[AppleAteByFairyRank]] /** - * 妖精に食べさせたりんごの量の順位上位`number`件を返す + * 妖精に食べさせたりんごの量の順位上位`top`件を返す */ def appleAteByFairyRanking(number: Int): F[Vector[Option[AppleAteByFairyRank]]] From 9f9892e40655f03b8deb50347671d62ea8bb4de2 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 00:42:38 +0900 Subject: [PATCH 308/482] =?UTF-8?q?docs:=20=E3=83=89=E3=82=AD=E3=83=A5?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AE=E8=AA=A4=E5=AD=97=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 587674933f..349c0d7c0f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -87,7 +87,7 @@ trait FairySpeechAPI[F[_], Player] { def doPlaySoundOnSpeak(uuid: UUID): F[Boolean] /** - * @return 妖精がいつ帰るのかを`player`に送信する作用作用 + * @return 妖精がいつ帰るのかを`player`に送信する作用 */ def sendDisappearTimeToChat(player: Player): F[Unit] From 751d878a38c20d9d4d9ad16da48a309836bd0b6f Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 01:42:57 +0900 Subject: [PATCH 309/482] =?UTF-8?q?refactor:=20recordExecutor=E3=81=8B?= =?UTF-8?q?=E3=82=89=E9=96=A2=E6=95=B0=E3=81=B8UUID=E3=82=92=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E6=B8=A1=E3=81=99=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../minecraft}/JdbcLastSeenNameToUuid.scala | 2 +- .../bukkit/commands/LastQuitCommand.scala | 5 +-- .../vote/bukkit/command/VoteCommand.scala | 38 +++++++++++++------ .../vote/domain/VotePersistence.scala | 4 +- .../infrastructure/JdbcVotePersistence.scala | 28 +++++++------- 5 files changed, 45 insertions(+), 32 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/{subsystems/lastquit/infrastructure => infrastructure/minecraft}/JdbcLastSeenNameToUuid.scala (93%) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/lastquit/infrastructure/JdbcLastSeenNameToUuid.scala b/src/main/scala/com/github/unchama/seichiassist/infrastructure/minecraft/JdbcLastSeenNameToUuid.scala similarity index 93% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/lastquit/infrastructure/JdbcLastSeenNameToUuid.scala rename to src/main/scala/com/github/unchama/seichiassist/infrastructure/minecraft/JdbcLastSeenNameToUuid.scala index 8340792ef4..446ef4d58b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/lastquit/infrastructure/JdbcLastSeenNameToUuid.scala +++ b/src/main/scala/com/github/unchama/seichiassist/infrastructure/minecraft/JdbcLastSeenNameToUuid.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.lastquit.infrastructure +package com.github.unchama.seichiassist.infrastructure.minecraft import cats.effect.Sync import com.github.unchama.seichiassist.domain.actions.LastSeenNameToUuid diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/lastquit/bukkit/commands/LastQuitCommand.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/lastquit/bukkit/commands/LastQuitCommand.scala index 44b55ea9d8..86b62b90a2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/lastquit/bukkit/commands/LastQuitCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/lastquit/bukkit/commands/LastQuitCommand.scala @@ -3,11 +3,8 @@ package com.github.unchama.seichiassist.subsystems.lastquit.bukkit.commands import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import cats.effect.{ConcurrentEffect, IO} import com.github.unchama.contextualexecutor.builder.{ContextualExecutorBuilder, Parsers} +import com.github.unchama.seichiassist.infrastructure.minecraft.{JdbcLastSeenNameToUuid, LastSeenNameToUuidError} import com.github.unchama.seichiassist.subsystems.lastquit.LastQuitAPI -import com.github.unchama.seichiassist.subsystems.lastquit.infrastructure.{ - JdbcLastSeenNameToUuid, - LastSeenNameToUuidError -} import com.github.unchama.targetedeffect.commandsender.MessageEffect import org.bukkit.ChatColor.RED import org.bukkit.command.TabExecutor diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala index d658d7a82b..d090463c6c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/command/VoteCommand.scala @@ -4,9 +4,13 @@ import cats.effect.ConcurrentEffect import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import com.github.unchama.contextualexecutor.builder.ContextualExecutorBuilder import com.github.unchama.contextualexecutor.executors.{BranchedExecutor, EchoExecutor} -import com.github.unchama.seichiassist.subsystems.vote.domain.{PlayerName, VotePersistence} +import com.github.unchama.seichiassist.infrastructure.minecraft.{ + JdbcLastSeenNameToUuid, + LastSeenNameToUuidError +} +import com.github.unchama.seichiassist.subsystems.vote.domain.VotePersistence import com.github.unchama.targetedeffect.commandsender.MessageEffect -import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} +import com.github.unchama.targetedeffect.{DeferredEffect, SequentialEffect} import org.bukkit.ChatColor._ import org.bukkit.command.TabExecutor @@ -22,18 +26,28 @@ class VoteCommand[F[_]: ConcurrentEffect](implicit votePersistence: VotePersiste ContextualExecutorBuilder .beginConfiguration() .executionCSEffect { context => - val lowerCasePlayerName = context.args.yetToBeParsed.head + val playerName = context.args.yetToBeParsed.head + val distributionProcess = for { + uuidEither <- new JdbcLastSeenNameToUuid[F].of(playerName) + program <- uuidEither.traverse { uuid => + votePersistence.incrementVoteCount(uuid) >> votePersistence + .updateConsecutiveVoteStreak(uuid) + } + } yield program match { + case Left(error) => + error match { + case LastSeenNameToUuidError.MultipleFound => + MessageEffect(s"${RED}指定された名前のプレイヤーが複数見つかりました。") + case LastSeenNameToUuidError.NotFound => + MessageEffect(s"${RED}指定された名前のプレイヤーが見つかりませんでした。") + } + case Right(_) => + MessageEffect(s"$AQUA${playerName}への特典配布処理に成功しました。") + } SequentialEffect( - MessageEffect(s"$YELLOW${lowerCasePlayerName}の特典配布処理開始…"), - UnfocusedEffect { - val playerName = PlayerName(lowerCasePlayerName) - val eff = for { - _ <- votePersistence.incrementVoteCount(playerName) - _ <- votePersistence.updateConsecutiveVoteStreak(playerName) - } yield () - eff.toIO.unsafeRunAsyncAndForget() - } + MessageEffect(s"$YELLOW${playerName}の特典配布処理開始…"), + DeferredEffect(distributionProcess.toIO) ) } .build() diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala index 30bdf89c1d..480de89fda 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/VotePersistence.scala @@ -14,7 +14,7 @@ trait VotePersistence[F[_]] { /** * @return 投票回数をインクリメントする作用 */ - def incrementVoteCount(playerName: PlayerName): F[Unit] + def incrementVoteCount(uuid: UUID): F[Unit] /** * @return 投票回数を返す作用 @@ -24,7 +24,7 @@ trait VotePersistence[F[_]] { /** * @return 連続投票回数を更新する作用 */ - def updateConsecutiveVoteStreak(playerName: PlayerName): F[Unit] + def updateConsecutiveVoteStreak(uuid: UUID): F[Unit] /** * @return 連続投票日数を返す作用 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index 063c04a123..d1005d150f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -20,9 +20,9 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { } } - override def incrementVoteCount(playerName: PlayerName): F[Unit] = Sync[F].delay { + override def incrementVoteCount(uuid: UUID): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE vote SET vote_number = vote_number + 1 WHERE uuid = (SELECT uuid FROM playerdata WHERE name = ${playerName.name})" + sql"UPDATE vote SET vote_number = vote_number + 1 WHERE uuid = (SELECT uuid FROM playerdata WHERE uuid = ${uuid.toString})" .execute() .apply() } @@ -39,7 +39,7 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { } } - override def updateConsecutiveVoteStreak(playerName: PlayerName): F[Unit] = Sync[F].delay { + override def updateConsecutiveVoteStreak(uuid: UUID): F[Unit] = Sync[F].delay { DB.localTx { implicit session => /* NOTE: 最終投票日時より(連続投票許容幅 - 1)した日時よりも @@ -51,23 +51,25 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { | ELSE chain_vote_number + 1 | END, | last_vote = NOW() - | WHERE uuid = (SELECT uuid FROM playerdata WHERE name = ${playerName.name})""" + | WHERE uuid = (SELECT uuid FROM playerdata WHERE uuid = ${uuid.toString})""" .stripMargin .execute() .apply() } } - override def currentConsecutiveVoteStreakDay(uuid: UUID): F[ChainVoteDayNumber] = Sync[F].delay { - DB.readOnly { implicit session => - val chainVoteDays = sql"SELECT chain_vote_number FROM vote WHERE uuid = ${uuid.toString}" - .map(_.int("chain_vote_number")) - .single() - .apply() - .get - ChainVoteDayNumber(chainVoteDays) + override def currentConsecutiveVoteStreakDay(uuid: UUID): F[ChainVoteDayNumber] = + Sync[F].delay { + DB.readOnly { implicit session => + val chainVoteDays = + sql"SELECT chain_vote_number FROM vote WHERE uuid = ${uuid.toString}" + .map(_.int("chain_vote_number")) + .single() + .apply() + .get + ChainVoteDayNumber(chainVoteDays) + } } - } override def increaseEffectPoints(uuid: UUID, effectPoint: EffectPoint): F[Unit] = Sync[F].delay { From c30ae0355504cb272328318898b65d66d3fe6fec Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 01:47:10 +0900 Subject: [PATCH 310/482] =?UTF-8?q?refactor:=20sendDisappearTimeToChat?= =?UTF-8?q?=E3=81=AE=E5=9E=8B=E3=82=92Kleisli=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/seichiassist/menus/VoteMenu.scala | 4 +--- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 5 +++-- .../subsystems/vote/subsystems/fairy/System.scala | 8 +++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 90596cdcb0..2f762666e1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -317,9 +317,7 @@ object VoteMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - UnfocusedEffect { - fairyAPI.sendDisappearTimeToChat(player).unsafeRunAsyncAndForget() - }, + DeferredEffect(IO(fairyAPI.sendDisappearTimeToChat)), closeInventoryEffect ) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 349c0d7c0f..089c52b8a7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -1,5 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy +import cats.data.Kleisli import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairySpawnRequestErrorOrSpawn import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ @@ -87,9 +88,9 @@ trait FairySpeechAPI[F[_], Player] { def doPlaySoundOnSpeak(uuid: UUID): F[Boolean] /** - * @return 妖精がいつ帰るのかを`player`に送信する作用 + * @return 妖精がいつ帰るのかを送信する作用 */ - def sendDisappearTimeToChat(player: Player): F[Unit] + def sendDisappearTimeToChat: Kleisli[F, Player, Unit] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 3bf4cd47b7..832c9657bc 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -1,5 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy +import cats.data.Kleisli import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.concurrent.RepeatingTaskContext import com.github.unchama.datarepository.bukkit.player.{ @@ -130,7 +131,7 @@ object System { persistence.appleAteByFairyMyRanking(player.getUniqueId) override def rankingByMostConsumedApple( - top: Int + top: Int ): IO[Vector[Option[AppleAteByFairyRank]]] = persistence.appleAteByFairyRanking(top) @@ -144,8 +145,9 @@ object System { isPlayFairySpeechSound <- doPlaySoundOnSpeak(uuid) } yield persistence.toggleFairySpeechSound(uuid, !isPlayFairySpeechSound) - override def sendDisappearTimeToChat(player: Player): IO[Unit] = - fairySpeech.speechEndTime(player) + override def sendDisappearTimeToChat: Kleisli[IO, Player, Unit] = Kleisli { + player => fairySpeech.speechEndTime(player) + } override def fairySummonRequest( player: Player From f0484eeece06770166376b07a503d64d2d7ef0d4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 01:52:09 +0900 Subject: [PATCH 311/482] =?UTF-8?q?refactor:=20toggleSoundOnSpeck=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E3=81=AE=E5=9E=8B=E3=82=92Kleisli=E3=81=AB=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/menus/VoteMenu.scala | 4 +--- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 2 +- .../subsystems/vote/subsystems/fairy/System.scala | 10 +++++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 2f762666e1..72d725eeba 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -243,9 +243,7 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), - UnfocusedEffect { - fairyAPI.toggleSoundOnSpeak(player.getUniqueId).unsafeRunAsyncAndForget() - } + DeferredEffect(IO(fairyAPI.toggleSoundOnSpeak)) ) } ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 089c52b8a7..145bbc2bde 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -80,7 +80,7 @@ trait FairySpeechAPI[F[_], Player] { /** * @return 妖精が喋るときに音をだすかをトグルする作用 */ - def toggleSoundOnSpeak(uuid: UUID): F[Unit] + def toggleSoundOnSpeak: Kleisli[F, Player, Unit] /** * @return 妖精が喋ったときに音を再生するか取得する作用 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 832c9657bc..bc5d216572 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -2,6 +2,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.data.Kleisli import cats.effect.{ConcurrentEffect, IO, SyncIO} +import cats.instances.uuid import com.github.unchama.concurrent.RepeatingTaskContext import com.github.unchama.datarepository.bukkit.player.{ BukkitRepositoryControls, @@ -141,9 +142,12 @@ object System { override def doPlaySoundOnSpeak(uuid: UUID): IO[Boolean] = persistence.fairySpeechSound(uuid) - override def toggleSoundOnSpeak(uuid: UUID): IO[Unit] = for { - isPlayFairySpeechSound <- doPlaySoundOnSpeak(uuid) - } yield persistence.toggleFairySpeechSound(uuid, !isPlayFairySpeechSound) + override def toggleSoundOnSpeak: Kleisli[IO, Player, Unit] = Kleisli { player => + val uuid = player.getUniqueId + for { + isPlayFairySpeechSound <- doPlaySoundOnSpeak(uuid) + } yield persistence.toggleFairySpeechSound(uuid, !isPlayFairySpeechSound) + } override def sendDisappearTimeToChat: Kleisli[IO, Player, Unit] = Kleisli { player => fairySpeech.speechEndTime(player) From 70fd86b912cd9a4f197231557ce84899016df979 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 01:54:55 +0900 Subject: [PATCH 312/482] =?UTF-8?q?refactor:=20updateAppleOpenState?= =?UTF-8?q?=E3=81=AE=E5=9E=8B=E3=82=92Kleisli=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 14 ++++++-------- .../vote/subsystems/fairy/FairyAPI.scala | 2 +- .../subsystems/vote/subsystems/fairy/System.scala | 6 +++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 72d725eeba..07fb8fb1d5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -209,14 +209,12 @@ object VoteMenu extends Menu { .build(), LeftClickButtonEffect { SequentialEffect( - UnfocusedEffect { - fairyAPI - .updateAppleOpenState( - uuid, - AppleOpenStateDependency.dependency(appleOpenState) - ) - .unsafeRunAsyncAndForget() - }, + DeferredEffect( + IO( + fairyAPI + .updateAppleOpenState(AppleOpenStateDependency.dependency(appleOpenState)) + ) + ), FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) ) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 145bbc2bde..95722d96d6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -11,7 +11,7 @@ trait FairyWriteAPI[F[_], G[_], Player] { /** * @return 妖精にあげるりんごの開放状態を変更する作用 */ - def updateAppleOpenState(uuid: UUID, appleConsumeStrategy: FairyAppleConsumeStrategy): F[Unit] + def updateAppleOpenState(appleConsumeStrategy: FairyAppleConsumeStrategy): Kleisli[F, Player, Unit] /** * @return 妖精を召喚するためのコストを変更する作用 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index bc5d216572..b4e853c70b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -105,10 +105,10 @@ object System { persistence.appleOpenState(uuid) override def updateAppleOpenState( - uuid: UUID, appleConsumeStrategy: FairyAppleConsumeStrategy - ): IO[Unit] = - persistence.changeAppleOpenState(uuid, appleConsumeStrategy) + ): Kleisli[IO, Player, Unit] = Kleisli { player => + persistence.changeAppleOpenState(player.getUniqueId, appleConsumeStrategy) + } override def getFairyLore(uuid: UUID): IO[FairyLore] = for { state <- consumeStrategy(uuid) From 72099ef1539fd5e1e0057c72cb11fc02509f41f4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 01:57:36 +0900 Subject: [PATCH 313/482] =?UTF-8?q?refactor:=20updateFairySummonCost?= =?UTF-8?q?=E3=81=AE=E5=9E=8B=E3=82=92Kleisli=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 11 +++---- .../vote/subsystems/fairy/FairyAPI.scala | 2 +- .../vote/subsystems/fairy/System.scala | 33 +++++-------------- 3 files changed, 13 insertions(+), 33 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 07fb8fb1d5..01b2fd6942 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -183,13 +183,10 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), - UnfocusedEffect( - fairyAPI - .updateFairySummonCost( - player.getUniqueId, - FairySummonCost(fairySummonCost.value % 4 + 1) - ) - .unsafeRunAsyncAndForget() + DeferredEffect( + IO( + fairyAPI.updateFairySummonCost(FairySummonCost(fairySummonCost.value % 4 + 1)) + ) ) ) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 95722d96d6..1b12513af0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -16,7 +16,7 @@ trait FairyWriteAPI[F[_], G[_], Player] { /** * @return 妖精を召喚するためのコストを変更する作用 */ - def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] + def updateFairySummonCost(fairySummonCost: FairySummonCost): Kleisli[F, Player, Unit] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index b4e853c70b..55a2f13bfc 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -2,12 +2,8 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.data.Kleisli import cats.effect.{ConcurrentEffect, IO, SyncIO} -import cats.instances.uuid import com.github.unchama.concurrent.RepeatingTaskContext -import com.github.unchama.datarepository.bukkit.player.{ - BukkitRepositoryControls, - PlayerDataRepository -} +import com.github.unchama.datarepository.bukkit.player.{BukkitRepositoryControls, PlayerDataRepository} import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem @@ -15,29 +11,16 @@ import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{ - FairyManaRecoveryRoutineFiberRepositoryDefinition, - SpeechServiceRepositoryDefinitions -} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{ - BukkitFairySpeech, - BukkitFairySummonRequest -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{FairyManaRecoveryRoutineFiberRepositoryDefinition, SpeechServiceRepositoryDefinitions} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{BukkitFairySpeech, BukkitFairySummonRequest} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{ - FairySpeech, - FairySpeechGateway -} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - FairyPersistence, - FairySpawnRequestErrorOrSpawn, - FairySummonRequest -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{FairySpeech, FairySpeechGateway} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpawnRequestErrorOrSpawn, FairySummonRequest} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player @@ -115,10 +98,10 @@ object System { } yield FairyLoreTable.loreTable(state) override def updateFairySummonCost( - uuid: UUID, fairySummonCost: FairySummonCost - ): IO[Unit] = - persistence.updateFairySummonCost(uuid, fairySummonCost) + ): Kleisli[IO, Player, Unit] = Kleisli { player => + persistence.updateFairySummonCost(player.getUniqueId, fairySummonCost) + } override def fairySummonCost(player: Player): IO[FairySummonCost] = persistence.fairySummonCost(player.getUniqueId) From b0785e2e042c47d199e987155981852caf72cb4a Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 02:08:45 +0900 Subject: [PATCH 314/482] =?UTF-8?q?refactor:=20fairySummonButton=E5=86=85?= =?UTF-8?q?=E3=81=AEunsafeRunsync=E3=82=92=E6=8A=B9=E6=AE=BA=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/seichiassist/menus/VoteMenu.scala | 6 +++--- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 7 ++++--- .../subsystems/vote/subsystems/fairy/System.scala | 5 ++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 01b2fd6942..d6dc588758 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -26,7 +26,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.player.PlayerEffects.closeInventoryEffect -import com.github.unchama.targetedeffect.{DeferredEffect, SequentialEffect, UnfocusedEffect} +import com.github.unchama.targetedeffect.{DeferredEffect, SequentialEffect} import org.bukkit.ChatColor._ import org.bukkit.entity.Player import org.bukkit.{Material, Sound} @@ -275,8 +275,8 @@ object VoteMenu extends Menu { errorEffectOnSpawn(s"${GOLD}投票ptが足りません") } case Right(process) => - UnfocusedEffect { - process.unsafeRunAsyncAndForget() + DeferredEffect { + process.map(program => Kleisli { _ => IO(program) }) } }, closeInventoryEffect diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index 1b12513af0..f1318ddd6d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -11,7 +11,9 @@ trait FairyWriteAPI[F[_], G[_], Player] { /** * @return 妖精にあげるりんごの開放状態を変更する作用 */ - def updateAppleOpenState(appleConsumeStrategy: FairyAppleConsumeStrategy): Kleisli[F, Player, Unit] + def updateAppleOpenState( + appleConsumeStrategy: FairyAppleConsumeStrategy + ): Kleisli[F, Player, Unit] /** * @return 妖精を召喚するためのコストを変更する作用 @@ -106,9 +108,8 @@ trait FairySummonAPI[F[_], Player] { /** * 召喚に失敗した場合はエラーを返す * 成功した場合は召喚する作用を返す - * @return 妖精の召喚をリクエストする作用 */ - def fairySummonRequest(player: Player): F[FairySpawnRequestErrorOrSpawn[F]] + def fairySummonRequest: Kleisli[F, Player, FairySpawnRequestErrorOrSpawn[F]] } object FairySummonAPI { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 55a2f13bfc..27e43e5553 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -136,10 +136,9 @@ object System { player => fairySpeech.speechEndTime(player) } - override def fairySummonRequest( - player: Player - ): IO[FairySpawnRequestErrorOrSpawn[IO]] = + override def fairySummonRequest: Kleisli[IO, Player, FairySpawnRequestErrorOrSpawn[IO]] = Kleisli { player => summonRequest.summonRequest(player) + } } From f7daba5280678cfbaf221cb01948c5c22b8864db Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 02:16:33 +0900 Subject: [PATCH 315/482] fix: compile error --- .../unchama/seichiassist/menus/VoteMenu.scala | 5 +++- .../bukkit/commands/LastQuitCommand.scala | 5 +++- .../actions/BukkitReceiveVoteBenefits.scala | 9 ++---- .../vote/subsystems/fairy/System.scala | 29 +++++++++++++++---- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index d6dc588758..e5d5e65c35 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -23,6 +23,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p AppleOpenStateDependency, FairySummonCost } +import com.github.unchama.targetedeffect.TargetedEffect.emptyEffect import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.player.PlayerEffects.closeInventoryEffect @@ -276,7 +277,9 @@ object VoteMenu extends Menu { } case Right(process) => DeferredEffect { - process.map(program => Kleisli { _ => IO(program) }) + for { + _ <- process + } yield emptyEffect } }, closeInventoryEffect diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/lastquit/bukkit/commands/LastQuitCommand.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/lastquit/bukkit/commands/LastQuitCommand.scala index 86b62b90a2..d6bbe2eff1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/lastquit/bukkit/commands/LastQuitCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/lastquit/bukkit/commands/LastQuitCommand.scala @@ -3,7 +3,10 @@ package com.github.unchama.seichiassist.subsystems.lastquit.bukkit.commands import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import cats.effect.{ConcurrentEffect, IO} import com.github.unchama.contextualexecutor.builder.{ContextualExecutorBuilder, Parsers} -import com.github.unchama.seichiassist.infrastructure.minecraft.{JdbcLastSeenNameToUuid, LastSeenNameToUuidError} +import com.github.unchama.seichiassist.infrastructure.minecraft.{ + JdbcLastSeenNameToUuid, + LastSeenNameToUuidError +} import com.github.unchama.seichiassist.subsystems.lastquit.LastQuitAPI import com.github.unchama.targetedeffect.commandsender.MessageEffect import org.bukkit.ChatColor.RED diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 96f9dbb20c..6de8d8f13d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -31,16 +31,11 @@ class BukkitReceiveVoteBenefits[F[_]: OnMinecraftServerThread: Sync, G[ receivedVote <- votePersistence.receivedVoteBenefits(uuid) pendingCount = VoteBenefit(totalVote.value - receivedVote.value) // 受け取ってない分を受け取ったことにする - _ <- votePersistence.increaseVoteBenefits( - uuid, - pendingCount - ) + _ <- votePersistence.increaseVoteBenefits(uuid, pendingCount) playerLevel <- ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read.map { _.levelCorrespondingToExp.level }) - gachaTicketAmount = Seq.fill(10 * pendingCount.value)( - BukkitGachaSkullData.gachaForVoting - ) + gachaTicketAmount = Seq.fill(10 * pendingCount.value)(BukkitGachaSkullData.gachaForVoting) additionalVoteBenefit = Seq.fill(pendingCount.value)( if (playerLevel < 50) ItemData.getSuperPickaxe(1) else ItemData.getVotingGift(1) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 27e43e5553..8963de971b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -3,7 +3,10 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.data.Kleisli import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.concurrent.RepeatingTaskContext -import com.github.unchama.datarepository.bukkit.player.{BukkitRepositoryControls, PlayerDataRepository} +import com.github.unchama.datarepository.bukkit.player.{ + BukkitRepositoryControls, + PlayerDataRepository +} import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem @@ -11,16 +14,29 @@ import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{FairyManaRecoveryRoutineFiberRepositoryDefinition, SpeechServiceRepositoryDefinitions} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{ + FairyManaRecoveryRoutineFiberRepositoryDefinition, + SpeechServiceRepositoryDefinitions +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{BukkitFairySpeech, BukkitFairySummonRequest} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{ + BukkitFairySpeech, + BukkitFairySummonRequest +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{FairySpeech, FairySpeechGateway} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpawnRequestErrorOrSpawn, FairySummonRequest} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{ + FairySpeech, + FairySpeechGateway +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ + FairyPersistence, + FairySpawnRequestErrorOrSpawn, + FairySummonRequest +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player @@ -136,7 +152,8 @@ object System { player => fairySpeech.speechEndTime(player) } - override def fairySummonRequest: Kleisli[IO, Player, FairySpawnRequestErrorOrSpawn[IO]] = Kleisli { player => + override def fairySummonRequest + : Kleisli[IO, Player, FairySpawnRequestErrorOrSpawn[IO]] = Kleisli { player => summonRequest.summonRequest(player) } From 956851d53e7e9e2e4f0280090279cd81f524550c Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 30 Dec 2022 02:20:17 +0900 Subject: [PATCH 316/482] =?UTF-8?q?chore:=20=E8=AC=8E=E3=81=AE=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=82=92=E6=89=93=E3=81=A1=E6=B6=88=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LICENSE | 4 ++-- localDependencies/LICENSES/worldedit-bukkit | 4 ++-- localDependencies/LICENSES/worldguard-bukkit | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/LICENSE b/LICENSE index 5981e7d210..f288702d2f 100644 --- a/LICENSE +++ b/LICENSE @@ -567,12 +567,12 @@ the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - Each version is given a distinguishing version top. If the + Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software -Foundation. If the Program does not specify a version top of the +Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. diff --git a/localDependencies/LICENSES/worldedit-bukkit b/localDependencies/LICENSES/worldedit-bukkit index 5981e7d210..f288702d2f 100644 --- a/localDependencies/LICENSES/worldedit-bukkit +++ b/localDependencies/LICENSES/worldedit-bukkit @@ -567,12 +567,12 @@ the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - Each version is given a distinguishing version top. If the + Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software -Foundation. If the Program does not specify a version top of the +Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. diff --git a/localDependencies/LICENSES/worldguard-bukkit b/localDependencies/LICENSES/worldguard-bukkit index 70707608c0..954b09aba2 100644 --- a/localDependencies/LICENSES/worldguard-bukkit +++ b/localDependencies/LICENSES/worldguard-bukkit @@ -148,13 +148,13 @@ of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - Each version is given a distinguishing version top. If the + Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you -received it does not specify a version top of the GNU Lesser +received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. From d2be8fe695fd5903035d3d6dd0c36302fc3e6cf1 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 8 Jan 2023 22:36:13 +0900 Subject: [PATCH 317/482] =?UTF-8?q?fix:=20drop=E5=91=BD=E4=BB=A4=E3=81=ABI?= =?UTF-8?q?F=20EXISTS=E5=8F=A5=E3=82=92=E3=81=A4=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../V1.14.3__Move_vote_fairy_column.sql | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/resources/db/migration/V1.14.3__Move_vote_fairy_column.sql b/src/main/resources/db/migration/V1.14.3__Move_vote_fairy_column.sql index 1653f85146..44c7961983 100644 --- a/src/main/resources/db/migration/V1.14.3__Move_vote_fairy_column.sql +++ b/src/main/resources/db/migration/V1.14.3__Move_vote_fairy_column.sql @@ -34,11 +34,11 @@ SELECT FROM playerdata; -ALTER TABLE - playerdata DROP toggleGiveApple, - DROP toggleVotingFairy, - DROP canVotingFairyUse, - DROP VotingFairyRecoveryValue, - DROP newVotingFairyTime, - DROP p_apple, - DROP is_fairy_speech_play_sound +ALTER TABLE playerdata + DROP IF EXISTS toggleGiveApple, + DROP IF EXISTS toggleVotingFairy, + DROP IF EXISTS canVotingFairyUse, + DROP IF EXISTS VotingFairyRecoveryValue, + DROP IF EXISTS newVotingFairyTime, + DROP IF EXISTS p_apple, + DROP IF EXISTS is_fairy_speech_play_sound From f1c4cf691d2a05239fa99e2befd5d98dc577feca Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 8 Jan 2023 22:37:47 +0900 Subject: [PATCH 318/482] =?UTF-8?q?chore:=20=E9=96=93=E9=81=95=E3=81=88?= =?UTF-8?q?=E3=81=A6=E6=9B=B8=E3=81=8D=E6=8F=9B=E3=81=88=E3=81=9F=E5=B7=AE?= =?UTF-8?q?=E5=88=86=E3=82=92=E6=89=93=E3=81=A1=E6=B6=88=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kisaragi <48310258+KisaragiEffective@users.noreply.github.com> --- .../com/github/unchama/fs2/workaround/fs3/Fs3Channel.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Channel.scala b/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Channel.scala index 491e1b267d..98c3d0f4af 100644 --- a/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Channel.scala +++ b/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Channel.scala @@ -67,8 +67,8 @@ sealed trait Fs3Channel[F[_], A] { * Every time `stream` is pulled, it will serve all the elements that are queued up in a * single chunk, including those from producers that might be semantically blocked on a * bounded channel, which will then become unblocked. That is, a bound on a channel represents - * the maximum top of elements that can be queued up before a producer blocks, and not the - * maximum top of elements that will be received by `stream` at once. + * the maximum number of elements that can be queued up before a producer blocks, and not the + * maximum number of elements that will be received by `stream` at once. */ def stream: Stream[F, A] From fa09859e2cc818766b1beaa0ae255796b1cee6ad Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 8 Jan 2023 22:39:21 +0900 Subject: [PATCH 319/482] =?UTF-8?q?chore:=20=E9=96=93=E9=81=95=E3=81=88?= =?UTF-8?q?=E3=81=A6=E6=9B=B8=E3=81=8D=E6=8F=9B=E3=81=88=E3=81=9F=E5=B7=AE?= =?UTF-8?q?=E5=88=86=E3=82=92=E6=89=93=E3=81=A1=E6=B6=88=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/fs2/workaround/fs3/Fs3Topic.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Topic.scala b/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Topic.scala index f873c592b0..c42320cfcb 100644 --- a/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Topic.scala +++ b/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Topic.scala @@ -33,10 +33,10 @@ import scala.collection.immutable.LongMap */ /** - * Topic allows you to distribute `A`s published by an arbitrary top of publishers to an + * Topic allows you to distribute `A`s published by an arbitrary number of publishers to an * arbitrary top of subscribers. * - * Topic has built-in back-pressure support implemented as the maximum top of elements + * Topic has built-in back-pressure support implemented as the maximum number of elements * (`maxQueued`) that a subscriber is allowed to enqueue. * * Once that bound is hit, any publishing action will semantically block until the lagging @@ -77,7 +77,7 @@ trait Fs3Topic[F[_], A] { self => * queue. * * @param maxQueued - * maximum top of elements to enqueue to the subscription queue before blocking + * maximum number of elements to enqueue to the subscription queue before blocking * publishers */ def subscribe(maxQueued: Int): Stream[F, A] From 9a4df4c2a0c2d7a5b144e8985fcaef82f5e35f45 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 8 Jan 2023 23:01:25 +0900 Subject: [PATCH 320/482] =?UTF-8?q?style:=20BukkitRecoveryMana=E3=81=AE?= =?UTF-8?q?=E5=A4=89=E6=95=B0=E5=90=8D=E3=82=92=E9=81=A9=E5=88=87=E3=81=AA?= =?UTF-8?q?=E3=82=82=E3=81=AE=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/actions/BukkitRecoveryMana.scala | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index cc046af4fb..e1bde9784f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -107,7 +107,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] */ private def computeAppleConsumptionAmount: F[Int] = for { seichiAmountData <- ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read) - chainVoteNumber <- voteAPI.currentConsecutiveVoteStreakDays(uuid) + voteStreaks <- voteAPI.currentConsecutiveVoteStreakDays(uuid) appleOpenState <- fairyPersistence.appleOpenState(uuid) oldManaAmount <- ContextCoercion { manaApi.readManaAmount(player) @@ -115,28 +115,28 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] } yield { val playerLevel = seichiAmountData.levelCorrespondingToExp - val isAppleOpenStateIsOpenOrOpenALittle = + val isStrategyConsumeOrLessConsume = appleOpenState == FairyAppleConsumeStrategy.LessConsume || appleOpenState == FairyAppleConsumeStrategy.Consume val isEnoughMana = oldManaAmount.ratioToCap.exists(_ >= 0.75) val defaultAmount = Math.pow(playerLevel.level / 10, 2) - val chainVoteDayNumber = chainVoteNumber.value + val voteStreakDays = voteStreaks.value // 連続投票を適用した除算量 - val chainVoteDivisionAmount = - if (chainVoteDayNumber >= 30) 2 - else if (chainVoteDayNumber >= 10) 1.5 - else if (chainVoteDayNumber >= 3) 1.25 + val chainVoteDivisor = + if (voteStreakDays >= 30) 2 + else if (voteStreakDays >= 10) 1.5 + else if (voteStreakDays >= 3) 1.25 else 1 // りんごの開放状況を適用した除算量 - val appleOpenStateDivisionAmount = - if (isAppleOpenStateIsOpenOrOpenALittle && isEnoughMana) 2 + val appleConsumeStrategyDivisor = + if (isStrategyConsumeOrLessConsume && isEnoughMana) 2 else 1 // りんごの開放状況まで適用したりんごの消費量 (暫定) val appleOpenStateReflectedAmount = - (defaultAmount / chainVoteDivisionAmount).toInt / appleOpenStateDivisionAmount + (defaultAmount / chainVoteDivisor).toInt / appleConsumeStrategyDivisor // 妖精がつまみ食いする量 val amountEatenByKnob = From adccd6dd6c1a85eae08cbf02f9925564db514657 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 9 Jan 2023 00:24:23 +0900 Subject: [PATCH 321/482] =?UTF-8?q?fix:=20BukkitRecoveryMana=E3=81=AE?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E3=82=88=E3=82=8A=E5=8D=98=E7=B4=94?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/actions/BukkitRecoveryMana.scala | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index e1bde9784f..012a3ba178 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions -import cats.effect.{ConcurrentEffect, LiftIO} +import cats.effect.{ConcurrentEffect, LiftIO, Sync} import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi @@ -44,13 +44,13 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] isFairyUsing <- fairyPersistence.isFairyUsing(uuid) fairyEndTimeOpt <- fairyPersistence.fairyEndTime(uuid) endTime = fairyEndTimeOpt.get.endTimeOpt.get + finishUse <- Sync[F] + .delay(LocalDateTime.now()) + .map(now => isFairyUsing && endTime.isBefore(now)) _ <- { fairySpeech .bye(player) >> fairyPersistence.updateIsFairyUsing(uuid, isFairyUsing = false) - }.whenA( - // 終了時間が今よりも過去だったとき(つまり有効時間終了済み) - isFairyUsing && endTime.isBefore(LocalDateTime.now()) - ) + }.whenA(finishUse) oldManaAmount <- ContextCoercion { manaApi.readManaAmount(player) } @@ -212,10 +212,10 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] else if (appleOpenState == FairyAppleConsumeStrategy.LessConsume) 4 else 2 ) - } else if ((mineStackedGachaRingoAmount / appleConsumptionAmount) <= 0.5) - (reflectedAppleOpenStateAmount * 0.5).toInt - else - (reflectedAppleOpenStateAmount * mineStackedGachaRingoAmount / appleConsumptionAmount).toInt + } else { + val multiplier = Math.max(mineStackedGachaRingoAmount / appleConsumptionAmount, 0.5) + (reflectedAppleOpenStateAmount * multiplier).toInt + } } else reflectedAppleOpenStateAmount val randomizedAdd = From 48ed1f42503d66acd68ab9eb371269f8612e36e0 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 9 Jan 2023 22:08:00 +0900 Subject: [PATCH 322/482] =?UTF-8?q?docs:=20FairyAppleConsumeStrategy?= =?UTF-8?q?=E3=81=AEserializedValue=E3=81=AE=E3=83=89=E3=82=AD=E3=83=A5?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92=E8=A9=B3=E7=B4=B0=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/domain/property/FairyAppleConsumeStrategy.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyAppleConsumeStrategy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyAppleConsumeStrategy.scala index 4b4408f58b..5b158df7ca 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyAppleConsumeStrategy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyAppleConsumeStrategy.scala @@ -5,7 +5,7 @@ import enumeratum._ /** * がちゃりんごの消費戦略を管理するクラス * @param serializedValue - * 消費戦略を永続化する際に必要な番号 + * 消費戦略を永続化する際に必要な番号であり、その値は戦略ごとに異なっていなければならない。 */ sealed class FairyAppleConsumeStrategy(val serializedValue: Int) extends EnumEntry From 2f22531277ed51772d359e748ec8c155587e9c99 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 9 Jan 2023 22:09:57 +0900 Subject: [PATCH 323/482] =?UTF-8?q?style:=20FairyManaRecoveryState?= =?UTF-8?q?=E3=81=AE=E3=82=AA=E3=83=96=E3=82=B8=E3=82=A7=E3=82=AF=E3=83=88?= =?UTF-8?q?=E5=90=8D=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala | 4 ++-- .../subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala | 4 ++-- .../fairy/domain/property/FairyManaRecoveryState.scala | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index f9291b8998..a4d1c53bc1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -59,9 +59,9 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( val messages = fairyManaRecoveryState match { case FairyManaRecoveryState.Full => FairyMessageTable.manaFullMessages - case FairyManaRecoveryState.ConsumptionApple => + case FairyManaRecoveryState.RecoveredWithApple => FairyMessageTable.consumed - case FairyManaRecoveryState.NotConsumptionApple => + case FairyManaRecoveryState.RecoveredWithoutApple => FairyMessageTable.notConsumed } for { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 012a3ba178..03ad413645 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -87,8 +87,8 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] fairySpeech.speechRandomly( player, if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) - FairyManaRecoveryState.NotConsumptionApple - else FairyManaRecoveryState.ConsumptionApple + FairyManaRecoveryState.RecoveredWithoutApple + else FairyManaRecoveryState.RecoveredWithApple ) >> SequentialEffect( MessageEffectF(s"$RESET$YELLOW${BOLD}マナ妖精が${recoveryManaAmount}マナを回復してくれました"), diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyManaRecoveryState.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyManaRecoveryState.scala index 8ece677f03..2461d27c89 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyManaRecoveryState.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyManaRecoveryState.scala @@ -15,11 +15,11 @@ object FairyManaRecoveryState { /** * マナを回復したがりんごを消費しなかった */ - case object NotConsumptionApple extends FairyManaRecoveryState + case object RecoveredWithoutApple extends FairyManaRecoveryState /** * りんごを消費してマナを回復した */ - case object ConsumptionApple extends FairyManaRecoveryState + case object RecoveredWithApple extends FairyManaRecoveryState } From 3d3f7987376e45d0794ccc3eef5d645c7ff3b411 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 9 Jan 2023 23:52:41 +0900 Subject: [PATCH 324/482] style: AlreadyFairySpawned -> AlreadyFairySummoned --- .../com/github/unchama/seichiassist/menus/VoteMenu.scala | 4 ++-- .../subsystems/fairy/bukkit/BukkitFairySummonRequest.scala | 2 +- .../fairy/domain/property/FairySummonRequestError.scala | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index e5d5e65c35..f72a105edf 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -15,7 +15,7 @@ import com.github.unchama.seichiassist.menus.stickmenu.FirstPage import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySummonRequestError.{ - AlreadyFairySpawned, + AlreadyFairySummoned, NotEnoughEffectPoint, NotEnoughSeichiLevel } @@ -270,7 +270,7 @@ object VoteMenu extends Menu { errorResult match { case NotEnoughSeichiLevel => errorEffectOnSpawn(s"${GOLD}プレイヤーレベルが足りません") - case AlreadyFairySpawned => + case AlreadyFairySummoned => errorEffectOnSpawn(s"${GOLD}既に妖精を召喚しています") case NotEnoughEffectPoint => errorEffectOnSpawn(s"${GOLD}投票ptが足りません") diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala index 58dea7f5f8..8d91c91211 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySummonRequest.scala @@ -36,7 +36,7 @@ class BukkitFairySummonRequest[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( if (seichiLevel < 10) Left(FairySummonRequestError.NotEnoughSeichiLevel) else if (usingState) - Left(FairySummonRequestError.AlreadyFairySpawned) + Left(FairySummonRequestError.AlreadyFairySummoned) else if (effectPoints.value < fairySummonCost.value * 2) Left(FairySummonRequestError.NotEnoughEffectPoint) else diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonRequestError.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonRequestError.scala index 6207350172..e0151d4590 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonRequestError.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonRequestError.scala @@ -15,7 +15,7 @@ object FairySummonRequestError { /** * 妖精がすでに召喚されている */ - case object AlreadyFairySpawned extends FairySummonRequestError + case object AlreadyFairySummoned extends FairySummonRequestError /** * 妖精の召喚ポイントが足りなかった From 43c958d5834525d390605ab9f4d7bb92227a9cdf Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 01:08:04 +0900 Subject: [PATCH 325/482] =?UTF-8?q?docs:=20FairySummonRequestError?= =?UTF-8?q?=E3=81=AE=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=92=E9=81=A9=E5=88=87=E3=81=AA=E3=82=82=E3=81=AE=E3=81=AB?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/domain/property/FairySummonRequestError.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonRequestError.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonRequestError.scala index e0151d4590..692e9e5180 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonRequestError.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonRequestError.scala @@ -3,7 +3,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain. sealed trait FairySummonRequestError /** - * 妖精の召喚をする際に発生する可能性がある一覧を定義したobject + * 妖精の召喚をする際に発生する可能性があるエラーを列挙する */ object FairySummonRequestError { From b2cebf3d422e5a351bdeb62dee7b0288eb972592 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 16:33:06 +0900 Subject: [PATCH 326/482] =?UTF-8?q?docs:=20speechEndTime=E9=96=A2=E6=95=B0?= =?UTF-8?q?=E3=81=AE=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=92=E3=82=88=E3=82=8A=E9=81=A9=E5=88=87=E3=81=AB=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/domain/speech/FairySpeech.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeech.scala index 5bca92a165..73df3b1cff 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeech.scala @@ -16,7 +16,7 @@ trait FairySpeech[F[_], Player] { def speechRandomly(player: Player, fairyManaRecoveryState: FairyManaRecoveryState): F[Unit] /** - * @return 妖精がいつ帰るのかを[[Player]]へ送信する作用 + * @return 妖精がいつ帰るのかを[[Player]]へ知らせる作用 */ def speechEndTime(player: Player): F[Unit] From 6592c9efa80de8fe63d5755a8bb8d1aaf3c849d9 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 16:49:12 +0900 Subject: [PATCH 327/482] =?UTF-8?q?feat:=20createPlayerData=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E3=81=AE=E3=83=87=E3=83=BC=E3=82=BF=E3=81=8C=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E3=81=99=E3=82=8B=E3=81=8B=E3=81=AE=E7=A2=BA=E8=AA=8D?= =?UTF-8?q?=E3=82=92=E5=88=A5=E3=81=AB=E5=88=87=E3=82=8A=E5=87=BA=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/JdbcFairyPersistence.scala | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 49a815d238..433fe1d36d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -9,10 +9,19 @@ import java.util.UUID class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { - def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { - DB.localTx { implicit session => - // ここでIGNOREするのは、作成するデータが既に存在していた場合に発生するエラーを無視するため - sql"INSERT IGNORE INTO vote_fairy (uuid) VALUES (${uuid.toString})".execute().apply() + override def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { + val hasPlayerDataCreated = DB.readOnly { implicit session => + sql"SELECT COUNT(*) as c FROM vote_fairy where uuid = ${uuid.toString}" + .map(_.int("c")) + .single() + .apply() + .nonEmpty + } + + if (!hasPlayerDataCreated) { + DB.localTx { implicit session => + sql"INSERT INTO vote_fairy (uuid) VALUES (${uuid.toString})".execute().apply() + } } } From 51f40cbc7ba44432a337fcfe6c8dc731197496f3 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 18:01:21 +0900 Subject: [PATCH 328/482] =?UTF-8?q?chore:=20FairyPersistence=E3=81=AE?= =?UTF-8?q?=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92?= =?UTF-8?q?=E9=96=A2=E6=95=B0=E5=90=8D=E3=80=81=E5=BC=95=E6=95=B0=E3=82=92?= =?UTF-8?q?=E7=9B=B4=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 14 ++-- .../fairy/bukkit/BukkitFairySpeech.scala | 10 +-- .../bukkit/actions/BukkitRecoveryMana.scala | 8 +- .../listeners/FairyPlayerJoinGreeter.scala | 2 +- .../fairy/domain/FairyPersistence.scala | 76 ++++++++++--------- .../infrastructure/JdbcFairyPersistence.scala | 66 ++++++++-------- 6 files changed, 90 insertions(+), 86 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 8963de971b..f98ebeb2c9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -101,12 +101,12 @@ object System { override implicit val api: FairyAPI[IO, SyncIO, Player] = new FairyAPI[IO, SyncIO, Player] { override def consumeStrategy(uuid: UUID): IO[FairyAppleConsumeStrategy] = - persistence.appleOpenState(uuid) + persistence.appleConsumeStrategy(uuid) override def updateAppleOpenState( appleConsumeStrategy: FairyAppleConsumeStrategy ): Kleisli[IO, Player, Unit] = Kleisli { player => - persistence.changeAppleOpenState(player.getUniqueId, appleConsumeStrategy) + persistence.updateAppleConsumeStrategy(player.getUniqueId, appleConsumeStrategy) } override def getFairyLore(uuid: UUID): IO[FairyLore] = for { @@ -128,24 +128,24 @@ object System { override def rankByMostConsumedApple( player: Player ): IO[Option[AppleAteByFairyRank]] = - persistence.appleAteByFairyMyRanking(player.getUniqueId) + persistence.rankByConsumedAppleAmountByFairy(player.getUniqueId) override def rankingByMostConsumedApple( top: Int ): IO[Vector[Option[AppleAteByFairyRank]]] = - persistence.appleAteByFairyRanking(top) + persistence.fetchMostConsumedApplePlayersByFairy(top) override def totalConsumedApple: IO[AppleAmount] = - persistence.allEatenAppleAmount + persistence.totalConsumedAppleAmount override def doPlaySoundOnSpeak(uuid: UUID): IO[Boolean] = - persistence.fairySpeechSound(uuid) + persistence.playSoundOnFairySpeech(uuid) override def toggleSoundOnSpeak: Kleisli[IO, Player, Unit] = Kleisli { player => val uuid = player.getUniqueId for { isPlayFairySpeechSound <- doPlaySoundOnSpeak(uuid) - } yield persistence.toggleFairySpeechSound(uuid, !isPlayFairySpeechSound) + } yield persistence.setPlaySoundOnSpeech(uuid, !isPlayFairySpeechSound) } override def sendDisappearTimeToChat: Kleisli[IO, Player, Unit] = Kleisli { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index a4d1c53bc1..b26fa52ed8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -44,7 +44,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( serviceRepository = fairySpeechServiceRepository(player) fairySpeechSound <- ContextCoercion { - fairyPersistence.fairySpeechSound(player.getUniqueId) + fairyPersistence.playSoundOnFairySpeech(player.getUniqueId) } _ <- ContextCoercion { serviceRepository.makeSpeech(Seq(message), fairySpeechSound) @@ -66,7 +66,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( } for { message <- randomMessage(messages(nameCalledByFairy)) - fairyPlaySound <- fairyPersistence.fairySpeechSound(player.getUniqueId) + fairyPlaySound <- fairyPersistence.playSoundOnFairySpeech(player.getUniqueId) _ <- ContextCoercion { fairySpeechServiceRepository(player).makeSpeech(Seq(message), fairyPlaySound) } @@ -76,7 +76,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( override def speechEndTime(player: Player): F[Unit] = { for { endTimeOpt <- fairyPersistence.fairyEndTime(player.getUniqueId) - playSound <- fairyPersistence.fairySpeechSound(player.getUniqueId) + playSound <- fairyPersistence.playSoundOnFairySpeech(player.getUniqueId) endTime = endTimeOpt.get.endTimeOpt.get _ <- ContextCoercion { fairySpeechServiceRepository(player).makeSpeech( @@ -88,7 +88,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( } override def welcomeBack(player: Player): F[Unit] = for { - playSound <- fairyPersistence.fairySpeechSound(player.getUniqueId) + playSound <- fairyPersistence.playSoundOnFairySpeech(player.getUniqueId) _ <- ContextCoercion { fairySpeechServiceRepository(player) .makeSpeech(Seq(FairyMessage(s"おかえり!${player.getName}")), playSound) @@ -96,7 +96,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( } yield () override def bye(player: Player): F[Unit] = for { - playSound <- fairyPersistence.fairySpeechSound(player.getUniqueId) + playSound <- fairyPersistence.playSoundOnFairySpeech(player.getUniqueId) repository = fairySpeechServiceRepository(player) _ <- ContextCoercion { repository.makeSpeech( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 03ad413645..d474c1b4fd 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -77,7 +77,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] ) _ <- { - fairyPersistence.increaseAppleAteByFairy( + fairyPersistence.increaseConsumedAppleAmountByFairy( uuid, AppleAmount(finallyAppleConsumptionAmount) ) >> @@ -108,7 +108,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] private def computeAppleConsumptionAmount: F[Int] = for { seichiAmountData <- ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read) voteStreaks <- voteAPI.currentConsecutiveVoteStreakDays(uuid) - appleOpenState <- fairyPersistence.appleOpenState(uuid) + appleOpenState <- fairyPersistence.appleConsumeStrategy(uuid) oldManaAmount <- ContextCoercion { manaApi.readManaAmount(player) } @@ -157,7 +157,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] * がちゃりんごの消費量を計算します。 */ private def computeFinallyAppleConsumptionAmount(appleConsumptionAmount: Int): F[Int] = for { - appleOpenState <- fairyPersistence.appleOpenState(uuid) + appleOpenState <- fairyPersistence.appleConsumeStrategy(uuid) gachaRingoObject <- LiftIO[F].liftIO { MineStackObjectList.findByName("gachaimo") } @@ -178,7 +178,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] */ private def computeManaRecoveryAmount(appleConsumptionAmount: Int): F[Int] = for { defaultRecoveryManaAmount <- fairyPersistence.fairyRecoveryMana(uuid) - appleOpenState <- fairyPersistence.appleOpenState(uuid) + appleOpenState <- fairyPersistence.appleConsumeStrategy(uuid) oldManaAmount <- ContextCoercion { manaApi.readManaAmount(player) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index 3ad29b1cf6..672b152475 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -23,7 +23,7 @@ class FairyPlayerJoinGreeter( val player = e.getPlayer val uuid = player.getUniqueId val program = for { - _ <- fairyPersistence.createPlayerData(uuid) + _ <- fairyPersistence.initializePlayerData(uuid) isUsing <- fairyPersistence.isFairyUsing(uuid) endTime <- fairyPersistence.fairyEndTime(uuid) isEnd = endTime.get.endTimeOpt.get.isBefore(LocalDateTime.now()) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index 5e0590ae76..b3f99f90ec 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -14,93 +14,97 @@ import java.util.UUID trait FairyPersistence[F[_]] { /** - * プレイヤーデータを作成する + * プレイヤーデータを作成する。このメソッドの実装が返す作用は、冪等でなければならない。 + * @return プレイヤーデータを作成するべき等な作用 */ - def createPlayerData(uuid: UUID): F[Unit] + def initializePlayerData(player: UUID): F[Unit] /** - * 妖精に開放するりんごの状態を変更する + * @return 妖精に開放するりんごの状態を変更する作用 */ - def changeAppleOpenState(uuid: UUID, openState: FairyAppleConsumeStrategy): F[Unit] + def updateAppleConsumeStrategy(player: UUID, openState: FairyAppleConsumeStrategy): F[Unit] /** - * 妖精に開放するりんごの状態を取得する + * @return 妖精に開放するりんごの状態を取得する作用 */ - def appleOpenState(uuid: UUID): F[FairyAppleConsumeStrategy] + def appleConsumeStrategy(player: UUID): F[FairyAppleConsumeStrategy] /** - * 妖精が召喚するためのコストを変更する + * @return 妖精が召喚するためのコストを変更する作用 */ - def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] + def updateFairySummonCost(player: UUID, fairySummonCost: FairySummonCost): F[Unit] /** - * 妖精を召喚するためのコストを取得する + * @return 妖精を召喚するためのコストを取得する作用 */ - def fairySummonCost(uuid: UUID): F[FairySummonCost] + def fairySummonCost(player: UUID): F[FairySummonCost] /** - * 妖精が召喚されているかを更新する + * @return 妖精が召喚されているかを更新する作用 */ - def updateIsFairyUsing(uuid: UUID, isFairyUsing: Boolean): F[Unit] + def updateIsFairyUsing(player: UUID, isFairyUsing: Boolean): F[Unit] /** - * 妖精が召喚されているかを取得する + * @return 妖精が召喚されているかを取得する作用 */ - def isFairyUsing(uuid: UUID): F[Boolean] + def isFairyUsing(player: UUID): F[Boolean] /** - * 妖精が回復するマナの量を変更する + * @return 妖精が回復するマナの量を変更する作用 */ - def updateFairyRecoveryMana(uuid: UUID, fairyRecoveryMana: FairyRecoveryMana): F[Unit] + def updateFairyRecoveryMana(player: UUID, fairyRecoveryMana: FairyRecoveryMana): F[Unit] /** - * 妖精が回復するマナの量を取得する + * @return 妖精が回復するマナの量を取得する作用 */ - def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] + def fairyRecoveryMana(player: UUID): F[FairyRecoveryMana] /** - * 妖精の効果が終了する時刻を変更する + * @return 妖精の効果が終了する時刻を変更する作用 */ - def updateFairyEndTime(uuid: UUID, fairyEndTime: FairyEndTime): F[Unit] + def updateFairyEndTime(player: UUID, fairyEndTime: FairyEndTime): F[Unit] /** - * 妖精の効果が終了する時刻を取得する + * @return 妖精の効果が終了する時刻を取得する作用 */ - def fairyEndTime(uuid: UUID): F[Option[FairyEndTime]] + def fairyEndTime(player: UUID): F[Option[FairyEndTime]] /** - * 妖精が食べたりんごの量を増加させる + * @return 妖精が指定プレイヤーから食べたりんごの量を増加させる作用 */ - def increaseAppleAteByFairy(uuid: UUID, appleAmount: AppleAmount): F[Unit] + def increaseConsumedAppleAmountByFairy(player: UUID, appleAmount: AppleAmount): F[Unit] /** - * 妖精が食べたりんごの量を取得する + * @return 妖精が食べたりんごの量を取得する作用 */ - def appleAteByFairy(uuid: UUID): F[Option[AppleAmount]] + def consumedAppleAmountByFairy(player: UUID): F[Option[AppleAmount]] /** - * 自分の妖精に食べさせたりんごの量の順位を返す + * @return 自分の妖精に食べさせたりんごの量の順位を返す作用 */ - def appleAteByFairyMyRanking(uuid: UUID): F[Option[AppleAteByFairyRank]] + def rankByConsumedAppleAmountByFairy(player: UUID): F[Option[AppleAteByFairyRank]] /** - * 妖精に食べさせたりんごの量の順位上位`top`件を返す + * 妖精に食べさせたりんごの量が多いプレイヤーを上位とし、そのランキングの上から指定した件数を返す + * + * @param top 最上位から何番目まで取得するか件数を指定する。0以下であってはならない。 + * @return 指定した件数が要素数となり、その並びが消費量の降順になっているような順序つきのコレクションを返す作用。 */ - def appleAteByFairyRanking(number: Int): F[Vector[Option[AppleAteByFairyRank]]] + def fetchMostConsumedApplePlayersByFairy(top: Int): F[Vector[Option[AppleAteByFairyRank]]] /** - * 妖精が食べたりんごの合計数を返す + * @return 妖精が今まで食べたりんごの合計数を返す作用 */ - def allEatenAppleAmount: F[AppleAmount] + def totalConsumedAppleAmount: F[AppleAmount] /** - * 妖精が喋るときに音をだすかをトグルする + * @return 妖精が喋るときに音をだすかをトグルする作用 */ - def toggleFairySpeechSound(uuid: UUID, fairyPlaySound: Boolean): F[Unit] + def setPlaySoundOnSpeech(player: UUID, playOnSpeech: Boolean): F[Unit] /** - * 妖精が喋ったときに音を再生するか取得する + * @return 妖精が喋ったときに音を再生するか取得する作用 */ - def fairySpeechSound(uuid: UUID): F[Boolean] + def playSoundOnFairySpeech(player: UUID): F[Boolean] } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 433fe1d36d..c8ec2178d4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -9,7 +9,7 @@ import java.util.UUID class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { - override def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { + override def initializePlayerData(player: UUID): F[Unit] = Sync[F].delay { val hasPlayerDataCreated = DB.readOnly { implicit session => sql"SELECT COUNT(*) as c FROM vote_fairy where uuid = ${uuid.toString}" .map(_.int("c")) @@ -25,7 +25,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - override def changeAppleOpenState(uuid: UUID, openState: FairyAppleConsumeStrategy): F[Unit] = + override def updateAppleConsumeStrategy(player: UUID, openState: FairyAppleConsumeStrategy): F[Unit] = Sync[F].delay { DB.localTx { implicit session => sql"UPDATE vote_fairy SET apple_open_state = ${openState.serializedValue} WHERE uuid = ${uuid.toString}" @@ -34,7 +34,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - override def appleOpenState(uuid: UUID): F[FairyAppleConsumeStrategy] = + override def appleConsumeStrategy(player: UUID): F[FairyAppleConsumeStrategy] = Sync[F].delay { val serializedValue = DB.readOnly { implicit session => sql"SELECT apple_open_state FROM vote_fairy WHERE uuid = ${uuid.toString}" @@ -46,19 +46,19 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { FairyAppleConsumeStrategy.values.find(_.serializedValue == serializedValue).get } - override def updateFairySummonCost(uuid: UUID, fairySummonCost: FairySummonCost): F[Unit] = + override def updateFairySummonCost(player: UUID, fairySummonCost: FairySummonCost): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE vote_fairy SET fairy_summon_cost = ${fairySummonCost.value} WHERE uuid = ${uuid.toString}" + sql"UPDATE vote_fairy SET fairy_summon_cost = ${fairySummonCost.value} WHERE uuid = ${player.toString}" .execute() .apply() } } - override def fairySummonCost(uuid: UUID): F[FairySummonCost] = Sync[F].delay { + override def fairySummonCost(player: UUID): F[FairySummonCost] = Sync[F].delay { DB.readOnly { implicit session => val fairySummonCost = - sql"SELECT fairy_summon_cost FROM vote_fairy WHERE uuid = ${uuid.toString}" + sql"SELECT fairy_summon_cost FROM vote_fairy WHERE uuid = ${player.toString}" .map(_.int("fairy_summon_cost")) .single() .apply() @@ -67,20 +67,20 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - override def updateIsFairyUsing(uuid: UUID, isFairyUsing: Boolean): F[Unit] = + override def updateIsFairyUsing(player: UUID, isFairyUsing: Boolean): F[Unit] = Sync[F].delay { DB.localTx { implicit session => sql"""UPDATE vote_fairy - | SET is_fairy_using = $isFairyUsing WHERE uuid = ${uuid.toString}""" + | SET is_fairy_using = $isFairyUsing WHERE uuid = ${player.toString}""" .stripMargin .execute() .apply() } } - override def isFairyUsing(uuid: UUID): F[Boolean] = Sync[F].delay { + override def isFairyUsing(player: UUID): F[Boolean] = Sync[F].delay { DB.readOnly { implicit session => - sql"SELECT is_fairy_using FROM vote_fairy WHERE uuid = ${uuid.toString}" + sql"SELECT is_fairy_using FROM vote_fairy WHERE uuid = ${player.toString}" .map(_.boolean("is_fairy_using")) .single() .apply() @@ -88,20 +88,20 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } override def updateFairyRecoveryMana( - uuid: UUID, - fairyRecoveryMana: FairyRecoveryMana + player: UUID, + fairyRecoveryMana: FairyRecoveryMana ): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE vote_fairy SET fairy_recovery_mana_value = ${fairyRecoveryMana.recoveryMana} WHERE uuid = ${uuid.toString}" + sql"UPDATE vote_fairy SET fairy_recovery_mana_value = ${fairyRecoveryMana.recoveryMana} WHERE uuid = ${player.toString}" .execute() .apply() } } - override def fairyRecoveryMana(uuid: UUID): F[FairyRecoveryMana] = Sync[F].delay { + override def fairyRecoveryMana(player: UUID): F[FairyRecoveryMana] = Sync[F].delay { DB.readOnly { implicit session => val recoveryMana = - sql"SELECT fairy_recovery_mana_value FROM vote_fairy WHERE uuid = ${uuid.toString}" + sql"SELECT fairy_recovery_mana_value FROM vote_fairy WHERE uuid = ${player.toString}" .map(_.int("fairy_recovery_mana_value")) .single() .apply() @@ -110,18 +110,18 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - override def updateFairyEndTime(uuid: UUID, fairyEndTime: FairyEndTime): F[Unit] = + override def updateFairyEndTime(player: UUID, fairyEndTime: FairyEndTime): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE vote_fairy SET fairy_end_time = ${fairyEndTime.endTimeOpt.get} WHERE uuid = ${uuid.toString}" + sql"UPDATE vote_fairy SET fairy_end_time = ${fairyEndTime.endTimeOpt.get} WHERE uuid = ${player.toString}" .execute() .apply() } } - override def fairyEndTime(uuid: UUID): F[Option[FairyEndTime]] = Sync[F].delay { + override def fairyEndTime(player: UUID): F[Option[FairyEndTime]] = Sync[F].delay { DB.readOnly { implicit session => - val dateOpt = sql"SELECT fairy_end_time FROM vote_fairy WHERE uuid = ${uuid.toString}" + val dateOpt = sql"SELECT fairy_end_time FROM vote_fairy WHERE uuid = ${player.toString}" .map(_.localDateTime("fairy_end_time")) .single() .apply() @@ -129,19 +129,19 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - override def increaseAppleAteByFairy(uuid: UUID, appleAmount: AppleAmount): F[Unit] = + override def increaseConsumedAppleAmountByFairy(player: UUID, appleAmount: AppleAmount): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE vote_fairy SET given_apple_amount = given_apple_amount + ${appleAmount.amount} WHERE uuid = ${uuid.toString}" + sql"UPDATE vote_fairy SET given_apple_amount = given_apple_amount + ${appleAmount.amount} WHERE uuid = ${player.toString}" .execute() .apply() } } - override def appleAteByFairy(uuid: UUID): F[Option[AppleAmount]] = Sync[F].delay { + override def consumedAppleAmountByFairy(player: UUID): F[Option[AppleAmount]] = Sync[F].delay { DB.readOnly { implicit session => val appleAmountOpt = - sql"SELECT given_apple_amount FROM vote_fairy WHERE uuid = ${uuid.toString}" + sql"SELECT given_apple_amount FROM vote_fairy WHERE uuid = ${player.toString}" .map(_.int("given_apple_amount")) .single() .apply() @@ -149,7 +149,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - override def appleAteByFairyMyRanking(uuid: UUID): F[Option[AppleAteByFairyRank]] = + override def rankByConsumedAppleAmountByFairy(player: UUID): F[Option[AppleAteByFairyRank]] = Sync[F].delay { DB.readOnly { implicit session => sql"""SELECT vote_fairy.uuid AS uuid,name,given_apple_amount,COUNT(*) AS rank @@ -167,17 +167,17 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { ) .toList() .apply() - .find(_._1 == uuid.toString) + .find(_._1 == player.toString) .map(_._2) } } - override def appleAteByFairyRanking(number: Int): F[Vector[Option[AppleAteByFairyRank]]] = + override def fetchMostConsumedApplePlayersByFairy(top: Int): F[Vector[Option[AppleAteByFairyRank]]] = Sync[F].delay { DB.readOnly { implicit session => sql"""SELECT name,given_apple_amount,COUNT(*) AS rank FROM vote_fairy | INNER JOIN playerdata ON (vote_fairy.uuid = playerdata.uuid) - | ORDER BY rank DESC LIMIT $number;""" + | ORDER BY rank DESC LIMIT $top;""" .stripMargin .map(rs => (rs.stringOpt("name"), rs.intOpt("rank"), rs.intOpt("given_apple_amount"))) .toList() @@ -191,7 +191,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - override def allEatenAppleAmount: F[AppleAmount] = Sync[F].delay { + override def totalConsumedAppleAmount: F[AppleAmount] = Sync[F].delay { DB.readOnly { implicit session => val amount = sql"SELECT SUM(given_apple_amount) AS allAppleAmount FROM vote_fairy;" .map(_.int("allAppleAmount")) @@ -202,19 +202,19 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - override def toggleFairySpeechSound(uuid: UUID, fairyPlaySound: Boolean): F[Unit] = + override def setPlaySoundOnSpeech(player: UUID, playOnSpeech: Boolean): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE vote_fairy SET is_play_fairy_speech_sound = $fairyPlaySound WHERE uuid = ${uuid.toString}" + sql"UPDATE vote_fairy SET is_play_fairy_speech_sound = $playOnSpeech WHERE uuid = ${player.toString}" .execute() .apply() } } - override def fairySpeechSound(uuid: UUID): F[Boolean] = + override def playSoundOnFairySpeech(player: UUID): F[Boolean] = Sync[F].delay { DB.readOnly { implicit session => - sql"SELECT is_play_fairy_speech_sound FROM vote_fairy WHERE uuid=${uuid.toString}" + sql"SELECT is_play_fairy_speech_sound FROM vote_fairy WHERE uuid=${player.toString}" .map(_.boolean("is_play_fairy_speech_sound")) .single() .apply() From e468279e46922a3099645ff63e0657cc88e824c5 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 18:13:50 +0900 Subject: [PATCH 329/482] style: AppleAteByFairyRank -> AppleConsumeAmountRank --- .../com/github/unchama/seichiassist/menus/VoteMenu.scala | 4 ++-- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 4 ++-- .../subsystems/vote/subsystems/fairy/System.scala | 4 ++-- .../vote/subsystems/fairy/domain/FairyPersistence.scala | 6 +++--- ...eAteByFairyRank.scala => AppleConsumeAmountRank.scala} | 2 +- .../fairy/infrastructure/JdbcFairyPersistence.scala | 8 ++++---- 6 files changed, 14 insertions(+), 14 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/{AppleAteByFairyRank.scala => AppleConsumeAmountRank.scala} (64%) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index f72a105edf..b4f4f70f28 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -344,7 +344,7 @@ object VoteMenu extends Menu { val rankData = rankDataOpt.get.get List( s"${GRAY}たくさんくれたニンゲン第${rankData.rank}位!", - s"${GRAY}なまえ:${rankData.name} りんご:${rankData.appleAmount.amount}個" + s"${GRAY}なまえ:${rankData.playerName} りんご:${rankData.consumed.amount}個" ) } else Nil } @@ -352,7 +352,7 @@ object VoteMenu extends Menu { s"${AQUA}ぜーんぶで${allEatenAppleAmount.amount}個もらえた!", "", s"$GREEN↓呼び出したニンゲンの情報↓", - s"${GREEN}今までに${myRank.get.appleAmount.amount}個もらった", + s"${GREEN}今までに${myRank.get.consumed.amount}個もらった", s"${GREEN}ニンゲンの中では${myRank.get.rank}番目にたくさんくれる!" ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index f1318ddd6d..c24b983cf9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -55,12 +55,12 @@ trait FairyReadAPI[F[_], G[_], Player] { /** * @return 自分の妖精に食べさせたりんごの量の順位を返す作用 */ - def rankByMostConsumedApple(player: Player): F[Option[AppleAteByFairyRank]] + def rankByMostConsumedApple(player: Player): F[Option[AppleConsumeAmountRank]] /** * @return 妖精に食べさせたりんごの量の順位上`top`件を返す作用 */ - def rankingByMostConsumedApple(top: Int): F[Vector[Option[AppleAteByFairyRank]]] + def rankingByMostConsumedApple(top: Int): F[Vector[Option[AppleConsumeAmountRank]]] /** * @return 妖精が食べたりんごの合計数を返す作用 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index f98ebeb2c9..9035704df6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -127,12 +127,12 @@ object System { override def rankByMostConsumedApple( player: Player - ): IO[Option[AppleAteByFairyRank]] = + ): IO[Option[AppleConsumeAmountRank]] = persistence.rankByConsumedAppleAmountByFairy(player.getUniqueId) override def rankingByMostConsumedApple( top: Int - ): IO[Vector[Option[AppleAteByFairyRank]]] = + ): IO[Vector[Option[AppleConsumeAmountRank]]] = persistence.fetchMostConsumedApplePlayersByFairy(top) override def totalConsumedApple: IO[AppleAmount] = diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index b3f99f90ec..99ae4c43bd 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -2,7 +2,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleAmount, - AppleAteByFairyRank, + AppleConsumeAmountRank, FairyAppleConsumeStrategy, FairyEndTime, FairyRecoveryMana, @@ -82,7 +82,7 @@ trait FairyPersistence[F[_]] { /** * @return 自分の妖精に食べさせたりんごの量の順位を返す作用 */ - def rankByConsumedAppleAmountByFairy(player: UUID): F[Option[AppleAteByFairyRank]] + def rankByConsumedAppleAmountByFairy(player: UUID): F[Option[AppleConsumeAmountRank]] /** * 妖精に食べさせたりんごの量が多いプレイヤーを上位とし、そのランキングの上から指定した件数を返す @@ -90,7 +90,7 @@ trait FairyPersistence[F[_]] { * @param top 最上位から何番目まで取得するか件数を指定する。0以下であってはならない。 * @return 指定した件数が要素数となり、その並びが消費量の降順になっているような順序つきのコレクションを返す作用。 */ - def fetchMostConsumedApplePlayersByFairy(top: Int): F[Vector[Option[AppleAteByFairyRank]]] + def fetchMostConsumedApplePlayersByFairy(top: Int): F[Vector[Option[AppleConsumeAmountRank]]] /** * @return 妖精が今まで食べたりんごの合計数を返す作用 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRank.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleConsumeAmountRank.scala similarity index 64% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRank.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleConsumeAmountRank.scala index 3d5286f405..30c0c132a8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleAteByFairyRank.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleConsumeAmountRank.scala @@ -1,5 +1,5 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property -case class AppleAteByFairyRank(name: String, rank: Int, appleAmount: AppleAmount) { +case class AppleConsumeAmountRank(playerName: String, rank: Int, consumed: AppleAmount) { require(rank >= 1, "rankは1以上の値で指定してください。") } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index c8ec2178d4..2fe67e0731 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -149,7 +149,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - override def rankByConsumedAppleAmountByFairy(player: UUID): F[Option[AppleAteByFairyRank]] = + override def rankByConsumedAppleAmountByFairy(player: UUID): F[Option[AppleConsumeAmountRank]] = Sync[F].delay { DB.readOnly { implicit session => sql"""SELECT vote_fairy.uuid AS uuid,name,given_apple_amount,COUNT(*) AS rank @@ -159,7 +159,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { | ORDER BY rank DESC;""" .stripMargin .map(rs => - rs.string("uuid") -> AppleAteByFairyRank( + rs.string("uuid") -> AppleConsumeAmountRank( rs.string("name"), rs.int("rank"), AppleAmount(rs.int("given_apple_amount")) @@ -172,7 +172,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - override def fetchMostConsumedApplePlayersByFairy(top: Int): F[Vector[Option[AppleAteByFairyRank]]] = + override def fetchMostConsumedApplePlayersByFairy(top: Int): F[Vector[Option[AppleConsumeAmountRank]]] = Sync[F].delay { DB.readOnly { implicit session => sql"""SELECT name,given_apple_amount,COUNT(*) AS rank FROM vote_fairy @@ -184,7 +184,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { .apply() .map(data => if (data._1.nonEmpty) - Some(AppleAteByFairyRank(data._1.get, data._2.get, AppleAmount(data._3.get))) + Some(AppleConsumeAmountRank(data._1.get, data._2.get, AppleAmount(data._3.get))) else None ) .toVector From d41934c650be7c79b64fa20a6d49a9c50d5451c4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 18:16:29 +0900 Subject: [PATCH 330/482] =?UTF-8?q?style:=20AppleOpenStateDependency?= =?UTF-8?q?=E3=82=92menu=E3=81=AB=E7=B5=B1=E5=90=88=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 28 +++++++++++-------- .../property/AppleOpenStateDependency.scala | 18 ------------ 2 files changed, 16 insertions(+), 30 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index b4f4f70f28..0e716fa849 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -14,15 +14,9 @@ import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMain import com.github.unchama.seichiassist.menus.stickmenu.FirstPage import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySummonRequestError.{ - AlreadyFairySummoned, - NotEnoughEffectPoint, - NotEnoughSeichiLevel -} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - AppleOpenStateDependency, - FairySummonCost -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyAppleConsumeStrategy.{Consume, LessConsume, NoConsume, Permissible} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySummonRequestError.{AlreadyFairySummoned, NotEnoughEffectPoint, NotEnoughSeichiLevel} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{FairyAppleConsumeStrategy, FairySummonCost} import com.github.unchama.targetedeffect.TargetedEffect.emptyEffect import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect @@ -195,10 +189,19 @@ object VoteMenu extends Menu { }) } - val fairyContractSettingToggle: IO[Button] = + val fairyContractSettingToggle: IO[Button] = { + val appleConsumeStrategyDependency + : Map[FairyAppleConsumeStrategy, FairyAppleConsumeStrategy] = + Map( + Permissible -> Consume, + Consume -> LessConsume, + LessConsume -> NoConsume, + NoConsume -> Permissible + ) + RecomputedButton(for { fairyLore <- fairyAPI.getFairyLore(uuid) - appleOpenState <- fairyAPI.consumeStrategy(uuid) + consumeStrategy <- fairyAPI.consumeStrategy(uuid) } yield { Button( new IconItemStackBuilder(Material.PAPER) @@ -210,7 +213,7 @@ object VoteMenu extends Menu { DeferredEffect( IO( fairyAPI - .updateAppleOpenState(AppleOpenStateDependency.dependency(appleOpenState)) + .updateAppleOpenState(appleConsumeStrategyDependency(consumeStrategy)) ) ), FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) @@ -218,6 +221,7 @@ object VoteMenu extends Menu { } ) }) + } val fairyPlaySoundToggleButton: IO[Button] = { val description = diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala deleted file mode 100644 index 284b67ed6a..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/AppleOpenStateDependency.scala +++ /dev/null @@ -1,18 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property - -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyAppleConsumeStrategy._ - -/** - * 妖精に開放するりんごの状態の順番を定義したオブジェクト - */ -object AppleOpenStateDependency { - - val dependency: Map[FairyAppleConsumeStrategy, FairyAppleConsumeStrategy] = - Map( - Permissible -> Consume, - Consume -> LessConsume, - LessConsume -> NoConsume, - NoConsume -> Permissible - ) - -} From 15c0844996f359fe0f8b896cb4cd38b57e5f7dc7 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 18:20:02 +0900 Subject: [PATCH 331/482] style: FairyMessages -> FairyMessageChoice --- .../fairy/bukkit/BukkitFairySpeech.scala | 4 +-- ...essages.scala => FairyMessageChoice.scala} | 2 +- .../domain/resources/FairyMessageTable.scala | 26 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/{FairyMessages.scala => FairyMessageChoice.scala} (63%) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index b26fa52ed8..ef46246cb7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -26,7 +26,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( private def getSummonMessagesByStartHour( startHour: Int, nameCalledByFairy: NameCalledByFairy - ): FairyMessages = { + ): FairyMessageChoice = { if (4 <= startHour && startHour < 10) FairyMessageTable.morningMessages(nameCalledByFairy) else if (10 <= startHour && startHour < 18) @@ -106,7 +106,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( } } yield () - private def randomMessage(fairyMessages: FairyMessages): F[FairyMessage] = Sync[F].delay { + private def randomMessage(fairyMessages: FairyMessageChoice): F[FairyMessage] = Sync[F].delay { val messages = fairyMessages.messages.toVector messages(Random.nextInt(messages.size)) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyMessages.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyMessageChoice.scala similarity index 63% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyMessages.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyMessageChoice.scala index af84be0c26..dd375f5caf 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyMessages.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyMessageChoice.scala @@ -2,4 +2,4 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain. import cats.data.NonEmptyVector -case class FairyMessages(messages: NonEmptyVector[FairyMessage]) +case class FairyMessageChoice(messages: NonEmptyVector[FairyMessage]) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala index 733615e6b6..2eb767be3e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala @@ -3,7 +3,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain. import cats.data.NonEmptyVector import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ FairyMessage, - FairyMessages, + FairyMessageChoice, NameCalledByFairy } @@ -12,8 +12,8 @@ object FairyMessageTable { /** * 朝に妖精を召喚したときに表示されるメッセージ */ - val morningMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => - FairyMessages( + val morningMessages: NameCalledByFairy => FairyMessageChoice = (name: NameCalledByFairy) => + FairyMessageChoice( NonEmptyVector.of( FairyMessage(s"おはよ!${name.value}"), FairyMessage(s"ヤッホー${name.value}"), @@ -26,8 +26,8 @@ object FairyMessageTable { /** * 昼に妖精を召喚したときに表示されるメッセージ */ - val dayMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => - FairyMessages( + val dayMessages: NameCalledByFairy => FairyMessageChoice = (name: NameCalledByFairy) => + FairyMessageChoice( NonEmptyVector.of( FairyMessage(s"やあ!${name.value}"), FairyMessage(s"ヤッホー${name.value}!"), @@ -38,8 +38,8 @@ object FairyMessageTable { ) // 夜に妖精を召喚したときに表示されるメッセージ - val nightMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => - FairyMessages( + val nightMessages: NameCalledByFairy => FairyMessageChoice = (name: NameCalledByFairy) => + FairyMessageChoice( NonEmptyVector.of( FairyMessage(s"やあ!${name.value}"), FairyMessage(s"ヤッホー${name.value}!"), @@ -52,8 +52,8 @@ object FairyMessageTable { /** * マナが満タンだったときに表示されるメッセージ */ - val manaFullMessages: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => - FairyMessages( + val manaFullMessages: NameCalledByFairy => FairyMessageChoice = (name: NameCalledByFairy) => + FairyMessageChoice( NonEmptyVector.of( FairyMessage("整地しないのー?"), FairyMessage("たくさん働いて、たくさんりんごを食べようね!"), @@ -67,8 +67,8 @@ object FairyMessageTable { /** * 妖精にりんごが消費されたときに表示されるメッセージ */ - val consumed: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => - FairyMessages( + val consumed: NameCalledByFairy => FairyMessageChoice = (name: NameCalledByFairy) => + FairyMessageChoice( NonEmptyVector.of( FairyMessage("(´~`)モグモグ…"), FairyMessage("がちゃりんごって美味しいよね!"), @@ -81,8 +81,8 @@ object FairyMessageTable { /** * 妖精がりんごを消費しなかったときに表示されるメッセージ */ - val notConsumed: NameCalledByFairy => FairyMessages = (name: NameCalledByFairy) => - FairyMessages( + val notConsumed: NameCalledByFairy => FairyMessageChoice = (name: NameCalledByFairy) => + FairyMessageChoice( NonEmptyVector.of( FairyMessage("お腹空いたなぁー。"), FairyMessage("がちゃりんごがっ!食べたいっ!"), From 42d8d643241f2de749c6cb2b769b7a152af39f9c Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 18:20:42 +0900 Subject: [PATCH 332/482] style: NameCalledByFairy -> ScreenNameForFairy --- .../fairy/bukkit/BukkitFairySpeech.scala | 6 +-- ...ByFairy.scala => ScreenNameForFairy.scala} | 2 +- .../domain/resources/FairyMessageTable.scala | 44 +++++++++---------- 3 files changed, 26 insertions(+), 26 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/{NameCalledByFairy.scala => ScreenNameForFairy.scala} (67%) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index ef46246cb7..edbf60245c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -25,7 +25,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( */ private def getSummonMessagesByStartHour( startHour: Int, - nameCalledByFairy: NameCalledByFairy + nameCalledByFairy: ScreenNameForFairy ): FairyMessageChoice = { if (4 <= startHour && startHour < 10) FairyMessageTable.morningMessages(nameCalledByFairy) @@ -38,7 +38,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( override def summonSpeech(player: Player): F[Unit] = for { startHour <- Sync[F].delay(LocalTime.now().getHour) - nameCalledByFairy = NameCalledByFairy(player.getName) + nameCalledByFairy = ScreenNameForFairy(player.getName) fairyMessages = getSummonMessagesByStartHour(startHour, nameCalledByFairy) message <- randomMessage(fairyMessages) @@ -55,7 +55,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( player: Player, fairyManaRecoveryState: FairyManaRecoveryState ): F[Unit] = { - val nameCalledByFairy = NameCalledByFairy(player.getName) + val nameCalledByFairy = ScreenNameForFairy(player.getName) val messages = fairyManaRecoveryState match { case FairyManaRecoveryState.Full => FairyMessageTable.manaFullMessages diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/NameCalledByFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/ScreenNameForFairy.scala similarity index 67% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/NameCalledByFairy.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/ScreenNameForFairy.scala index 141ed4aa63..fcfeb7a494 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/NameCalledByFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/ScreenNameForFairy.scala @@ -1,3 +1,3 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property -case class NameCalledByFairy(value: String) +case class ScreenNameForFairy(name: String) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala index 2eb767be3e..5458f1bca6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala @@ -4,7 +4,7 @@ import cats.data.NonEmptyVector import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ FairyMessage, FairyMessageChoice, - NameCalledByFairy + ScreenNameForFairy } object FairyMessageTable { @@ -12,39 +12,39 @@ object FairyMessageTable { /** * 朝に妖精を召喚したときに表示されるメッセージ */ - val morningMessages: NameCalledByFairy => FairyMessageChoice = (name: NameCalledByFairy) => + val morningMessages: ScreenNameForFairy => FairyMessageChoice = (name: ScreenNameForFairy) => FairyMessageChoice( NonEmptyVector.of( - FairyMessage(s"おはよ!${name.value}"), - FairyMessage(s"ヤッホー${name.value}"), - FairyMessage(s"ふわぁ。。。${name.value}朝は早いね。"), + FairyMessage(s"おはよ!${name.name}"), + FairyMessage(s"ヤッホー${name.name}"), + FairyMessage(s"ふわぁ。。。${name.name}朝は早いね。"), FairyMessage("うーん、今日も一日頑張ろ!"), - FairyMessage(s"今日は整地日和だね!${name.value}") + FairyMessage(s"今日は整地日和だね!${name.name}") ) ) /** * 昼に妖精を召喚したときに表示されるメッセージ */ - val dayMessages: NameCalledByFairy => FairyMessageChoice = (name: NameCalledByFairy) => + val dayMessages: ScreenNameForFairy => FairyMessageChoice = (name: ScreenNameForFairy) => FairyMessageChoice( NonEmptyVector.of( - FairyMessage(s"やあ!${name.value}"), - FairyMessage(s"ヤッホー${name.value}!"), - FairyMessage(s"あっ、${name.value}じゃん。丁度お腹空いてたんだ!"), - FairyMessage(s"この匂い…${name.value}ってがちゃりんごいっぱい持ってる…?"), + FairyMessage(s"やあ!${name.name}"), + FairyMessage(s"ヤッホー${name.name}!"), + FairyMessage(s"あっ、${name.name}じゃん。丁度お腹空いてたんだ!"), + FairyMessage(s"この匂い…${name.name}ってがちゃりんごいっぱい持ってる…?"), FairyMessage("今日のおやつはがちゃりんごいっぱいだ!") ) ) // 夜に妖精を召喚したときに表示されるメッセージ - val nightMessages: NameCalledByFairy => FairyMessageChoice = (name: NameCalledByFairy) => + val nightMessages: ScreenNameForFairy => FairyMessageChoice = (name: ScreenNameForFairy) => FairyMessageChoice( NonEmptyVector.of( - FairyMessage(s"やあ!${name.value}"), - FairyMessage(s"ヤッホー${name.value}!"), - FairyMessage(s"ふわぁ。。。${name.value}は夜も元気だね。"), - FairyMessage(s"もう寝ようと思ってたのにー。${name.value}はしょうがないなぁ"), + FairyMessage(s"やあ!${name.name}"), + FairyMessage(s"ヤッホー${name.name}!"), + FairyMessage(s"ふわぁ。。。${name.name}は夜も元気だね。"), + FairyMessage(s"もう寝ようと思ってたのにー。${name.name}はしょうがないなぁ"), FairyMessage("こんな時間に呼ぶなんて…りんごははずんでもらうよ?") ) ) @@ -52,14 +52,14 @@ object FairyMessageTable { /** * マナが満タンだったときに表示されるメッセージ */ - val manaFullMessages: NameCalledByFairy => FairyMessageChoice = (name: NameCalledByFairy) => + val manaFullMessages: ScreenNameForFairy => FairyMessageChoice = (name: ScreenNameForFairy) => FairyMessageChoice( NonEmptyVector.of( FairyMessage("整地しないのー?"), FairyMessage("たくさん働いて、たくさんりんごを食べようね!"), FairyMessage("僕はいつか大きながちゃりんごを食べ尽して見せるっ!"), FairyMessage("ちょっと食べ疲れちゃった"), - FairyMessage(s"${name.value}はどのりんごが好き?僕はがちゃりんご!"), + FairyMessage(s"${name.name}はどのりんごが好き?僕はがちゃりんご!"), FairyMessage("動いてお腹を空かしていっぱい食べるぞー!") ) ) @@ -67,13 +67,13 @@ object FairyMessageTable { /** * 妖精にりんごが消費されたときに表示されるメッセージ */ - val consumed: NameCalledByFairy => FairyMessageChoice = (name: NameCalledByFairy) => + val consumed: ScreenNameForFairy => FairyMessageChoice = (name: ScreenNameForFairy) => FairyMessageChoice( NonEmptyVector.of( FairyMessage("(´~`)モグモグ…"), FairyMessage("がちゃりんごって美味しいよね!"), FairyMessage("あぁ!幸せ!"), - FairyMessage(s"${name.value}のりんごはおいしいなぁ"), + FairyMessage(s"${name.name}のりんごはおいしいなぁ"), FairyMessage("いつもりんごをありがとう!") ) ) @@ -81,13 +81,13 @@ object FairyMessageTable { /** * 妖精がりんごを消費しなかったときに表示されるメッセージ */ - val notConsumed: NameCalledByFairy => FairyMessageChoice = (name: NameCalledByFairy) => + val notConsumed: ScreenNameForFairy => FairyMessageChoice = (name: ScreenNameForFairy) => FairyMessageChoice( NonEmptyVector.of( FairyMessage("お腹空いたなぁー。"), FairyMessage("がちゃりんごがっ!食べたいっ!"), FairyMessage("(´;ω;`)ウゥゥ ヒモジイ..."), - FairyMessage(s"@うんちゃま ${name.value}が意地悪するんだっ!"), + FairyMessage(s"@うんちゃま ${name.name}が意地悪するんだっ!"), FairyMessage("うわーん!お腹空いたよー!") ) ) From f12d5a324be367ae58682296e06cca15f373b666 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 18:24:33 +0900 Subject: [PATCH 333/482] =?UTF-8?q?style:=20fairyLoreTable=E3=82=92Menu?= =?UTF-8?q?=E3=81=AB=E7=B5=84=E3=81=BF=E8=BE=BC=E3=82=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 35 ++++++++++++-- .../vote/subsystems/fairy/FairyAPI.scala | 5 -- .../vote/subsystems/fairy/System.scala | 4 -- .../resources/bukkit/FairyLoreTable.scala | 46 ------------------- 4 files changed, 31 insertions(+), 59 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 0e716fa849..8626981f64 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.menus -import cats.data.Kleisli +import cats.data.{Kleisli, NonEmptyList} import cats.effect.{ConcurrentEffect, IO, SyncIO} import cats.implicits._ import com.github.unchama.itemstackbuilder.IconItemStackBuilder @@ -16,7 +16,7 @@ import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyAppleConsumeStrategy.{Consume, LessConsume, NoConsume, Permissible} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySummonRequestError.{AlreadyFairySummoned, NotEnoughEffectPoint, NotEnoughSeichiLevel} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{FairyAppleConsumeStrategy, FairySummonCost} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{FairyAppleConsumeStrategy, FairyLore, FairySummonCost} import com.github.unchama.targetedeffect.TargetedEffect.emptyEffect import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect @@ -199,14 +199,41 @@ object VoteMenu extends Menu { NoConsume -> Permissible ) + val fairyLoreTable: Map[FairyAppleConsumeStrategy, FairyLore] = Map( + Permissible -> FairyLore( + NonEmptyList.of( + s"$RED$UNDERLINE${BOLD}ガンガンたべるぞ", + s"$RESET${GRAY}とにかく妖精さんにりんごを開放します。", + s"$RESET${GRAY}めっちゃ喜ばれます。" + ) + ), + Consume -> FairyLore( + NonEmptyList.of( + s"$YELLOW$UNDERLINE${BOLD}バッチリたべよう", + s"$RESET${GRAY}食べ過ぎないように注意しつつ", + s"$RESET${GRAY}妖精さんにりんごを開放します。", + s"$RESET${GRAY}喜ばれます。" + ) + ), + LessConsume -> FairyLore( + NonEmptyList.of( + s"$GREEN$UNDERLINE${BOLD}リンゴだいじに", + s"$RESET${GRAY}少しだけ妖精さんにりんごを開放します。", + s"$RESET${GRAY}伝えると大抵落ち込みます。" + ) + ), + NoConsume -> FairyLore( + NonEmptyList.of(s"$BLUE$UNDERLINE${BOLD}リンゴつかうな", s"$RESET${GRAY}絶対にりんごを開放しません。", "") + ) + ) + RecomputedButton(for { - fairyLore <- fairyAPI.getFairyLore(uuid) consumeStrategy <- fairyAPI.consumeStrategy(uuid) } yield { Button( new IconItemStackBuilder(Material.PAPER) .title(s"$GOLD$UNDERLINE${BOLD}妖精とのお約束") - .lore(fairyLore.lore.toList) + .lore(fairyLoreTable(consumeStrategy).lore.toList) .build(), LeftClickButtonEffect { SequentialEffect( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index c24b983cf9..db0b3da2b2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -42,11 +42,6 @@ trait FairyReadAPI[F[_], G[_], Player] { */ def fairySummonCost(player: Player): F[FairySummonCost] - /** - * @return `FairyLoreTable`からLoreを取得する作用 - */ - def getFairyLore(uuid: UUID): F[FairyLore] - /** * @return 妖精を使っているかを取得する作用 */ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 9035704df6..b733c8ae9f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -109,10 +109,6 @@ object System { persistence.updateAppleConsumeStrategy(player.getUniqueId, appleConsumeStrategy) } - override def getFairyLore(uuid: UUID): IO[FairyLore] = for { - state <- consumeStrategy(uuid) - } yield FairyLoreTable.loreTable(state) - override def updateFairySummonCost( fairySummonCost: FairySummonCost ): Kleisli[IO, Player, Unit] = Kleisli { player => diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala deleted file mode 100644 index 93a680a63a..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/bukkit/FairyLoreTable.scala +++ /dev/null @@ -1,46 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit - -import cats.data.NonEmptyList -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyAppleConsumeStrategy.{ - NoConsume, - Consume, - LessConsume, - Permissible -} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - FairyAppleConsumeStrategy, - FairyLore -} -import org.bukkit.ChatColor._ - -object FairyLoreTable { - - val loreTable: Map[FairyAppleConsumeStrategy, FairyLore] = Map( - Permissible -> FairyLore( - NonEmptyList.of( - s"$RED$UNDERLINE${BOLD}ガンガンたべるぞ", - s"$RESET${GRAY}とにかく妖精さんにりんごを開放します。", - s"$RESET${GRAY}めっちゃ喜ばれます。" - ) - ), - Consume -> FairyLore( - NonEmptyList.of( - s"$YELLOW$UNDERLINE${BOLD}バッチリたべよう", - s"$RESET${GRAY}食べ過ぎないように注意しつつ", - s"$RESET${GRAY}妖精さんにりんごを開放します。", - s"$RESET${GRAY}喜ばれます。" - ) - ), - LessConsume -> FairyLore( - NonEmptyList.of( - s"$GREEN$UNDERLINE${BOLD}リンゴだいじに", - s"$RESET${GRAY}少しだけ妖精さんにりんごを開放します。", - s"$RESET${GRAY}伝えると大抵落ち込みます。" - ) - ), - NoConsume -> FairyLore( - NonEmptyList.of(s"$BLUE$UNDERLINE${BOLD}リンゴつかうな", s"$RESET${GRAY}絶対にりんごを開放しません。", "") - ) - ) - -} From c22c3df162c38dccebc66be5a4a3d0432f65f8c2 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 18:30:47 +0900 Subject: [PATCH 334/482] fix: compile error --- .../unchama/seichiassist/menus/VoteMenu.scala | 24 ++++++--- .../vote/subsystems/fairy/System.scala | 1 - .../fairy/bukkit/BukkitFairySpeech.scala | 9 ++-- .../infrastructure/JdbcFairyPersistence.scala | 49 ++++++++++++------- 4 files changed, 53 insertions(+), 30 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 8626981f64..1d0132aa17 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -14,9 +14,22 @@ import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMain import com.github.unchama.seichiassist.menus.stickmenu.FirstPage import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyAppleConsumeStrategy.{Consume, LessConsume, NoConsume, Permissible} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySummonRequestError.{AlreadyFairySummoned, NotEnoughEffectPoint, NotEnoughSeichiLevel} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{FairyAppleConsumeStrategy, FairyLore, FairySummonCost} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyAppleConsumeStrategy.{ + Consume, + LessConsume, + NoConsume, + Permissible +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairySummonRequestError.{ + AlreadyFairySummoned, + NotEnoughEffectPoint, + NotEnoughSeichiLevel +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ + FairyAppleConsumeStrategy, + FairyLore, + FairySummonCost +} import com.github.unchama.targetedeffect.TargetedEffect.emptyEffect import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect @@ -191,7 +204,7 @@ object VoteMenu extends Menu { val fairyContractSettingToggle: IO[Button] = { val appleConsumeStrategyDependency - : Map[FairyAppleConsumeStrategy, FairyAppleConsumeStrategy] = + : Map[FairyAppleConsumeStrategy, FairyAppleConsumeStrategy] = Map( Permissible -> Consume, Consume -> LessConsume, @@ -239,8 +252,7 @@ object VoteMenu extends Menu { SequentialEffect( DeferredEffect( IO( - fairyAPI - .updateAppleOpenState(appleConsumeStrategyDependency(consumeStrategy)) + fairyAPI.updateAppleOpenState(appleConsumeStrategyDependency(consumeStrategy)) ) ), FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index b733c8ae9f..70304c6a3a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -27,7 +27,6 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{ BukkitFairySummonRequest } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.bukkit.FairyLoreTable import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{ FairySpeech, FairySpeechGateway diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index edbf60245c..5465f5f381 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -106,9 +106,10 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( } } yield () - private def randomMessage(fairyMessages: FairyMessageChoice): F[FairyMessage] = Sync[F].delay { - val messages = fairyMessages.messages.toVector - messages(Random.nextInt(messages.size)) - } + private def randomMessage(fairyMessages: FairyMessageChoice): F[FairyMessage] = + Sync[F].delay { + val messages = fairyMessages.messages.toVector + messages(Random.nextInt(messages.size)) + } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 2fe67e0731..40abfc7a92 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -11,7 +11,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def initializePlayerData(player: UUID): F[Unit] = Sync[F].delay { val hasPlayerDataCreated = DB.readOnly { implicit session => - sql"SELECT COUNT(*) as c FROM vote_fairy where uuid = ${uuid.toString}" + sql"SELECT COUNT(*) as c FROM vote_fairy where uuid = ${player.toString}" .map(_.int("c")) .single() .apply() @@ -20,15 +20,18 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { if (!hasPlayerDataCreated) { DB.localTx { implicit session => - sql"INSERT INTO vote_fairy (uuid) VALUES (${uuid.toString})".execute().apply() + sql"INSERT INTO vote_fairy (uuid) VALUES (${player.toString})".execute().apply() } } } - override def updateAppleConsumeStrategy(player: UUID, openState: FairyAppleConsumeStrategy): F[Unit] = + override def updateAppleConsumeStrategy( + player: UUID, + openState: FairyAppleConsumeStrategy + ): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE vote_fairy SET apple_open_state = ${openState.serializedValue} WHERE uuid = ${uuid.toString}" + sql"UPDATE vote_fairy SET apple_open_state = ${openState.serializedValue} WHERE uuid = ${player.toString}" .execute() .apply() } @@ -37,7 +40,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def appleConsumeStrategy(player: UUID): F[FairyAppleConsumeStrategy] = Sync[F].delay { val serializedValue = DB.readOnly { implicit session => - sql"SELECT apple_open_state FROM vote_fairy WHERE uuid = ${uuid.toString}" + sql"SELECT apple_open_state FROM vote_fairy WHERE uuid = ${player.toString}" .map(_.int("apple_open_state")) .single() .apply() @@ -88,8 +91,8 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } override def updateFairyRecoveryMana( - player: UUID, - fairyRecoveryMana: FairyRecoveryMana + player: UUID, + fairyRecoveryMana: FairyRecoveryMana ): F[Unit] = Sync[F].delay { DB.localTx { implicit session => sql"UPDATE vote_fairy SET fairy_recovery_mana_value = ${fairyRecoveryMana.recoveryMana} WHERE uuid = ${player.toString}" @@ -129,7 +132,10 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - override def increaseConsumedAppleAmountByFairy(player: UUID, appleAmount: AppleAmount): F[Unit] = + override def increaseConsumedAppleAmountByFairy( + player: UUID, + appleAmount: AppleAmount + ): F[Unit] = Sync[F].delay { DB.localTx { implicit session => sql"UPDATE vote_fairy SET given_apple_amount = given_apple_amount + ${appleAmount.amount} WHERE uuid = ${player.toString}" @@ -138,18 +144,21 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - override def consumedAppleAmountByFairy(player: UUID): F[Option[AppleAmount]] = Sync[F].delay { - DB.readOnly { implicit session => - val appleAmountOpt = - sql"SELECT given_apple_amount FROM vote_fairy WHERE uuid = ${player.toString}" - .map(_.int("given_apple_amount")) - .single() - .apply() - appleAmountOpt.map(AppleAmount) + override def consumedAppleAmountByFairy(player: UUID): F[Option[AppleAmount]] = + Sync[F].delay { + DB.readOnly { implicit session => + val appleAmountOpt = + sql"SELECT given_apple_amount FROM vote_fairy WHERE uuid = ${player.toString}" + .map(_.int("given_apple_amount")) + .single() + .apply() + appleAmountOpt.map(AppleAmount) + } } - } - override def rankByConsumedAppleAmountByFairy(player: UUID): F[Option[AppleConsumeAmountRank]] = + override def rankByConsumedAppleAmountByFairy( + player: UUID + ): F[Option[AppleConsumeAmountRank]] = Sync[F].delay { DB.readOnly { implicit session => sql"""SELECT vote_fairy.uuid AS uuid,name,given_apple_amount,COUNT(*) AS rank @@ -172,7 +181,9 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { } } - override def fetchMostConsumedApplePlayersByFairy(top: Int): F[Vector[Option[AppleConsumeAmountRank]]] = + override def fetchMostConsumedApplePlayersByFairy( + top: Int + ): F[Vector[Option[AppleConsumeAmountRank]]] = Sync[F].delay { DB.readOnly { implicit session => sql"""SELECT name,given_apple_amount,COUNT(*) AS rank FROM vote_fairy From 9d9b606a1cceb541832e4c0f25b28afca2a7452b Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 19:39:49 +0900 Subject: [PATCH 335/482] fix: compile error --- .../unchama/seichiassist/SeichiAssist.scala | 2 - .../actions/BukkitReceiveVoteBenefits.scala | 2 +- .../vote/subsystems/fairy/System.scala | 3 ++ .../bukkit/actions/BukkitRecoveryMana.scala | 41 +++++++++---------- .../bukkit/routines/BukkitFairyRoutine.scala | 5 ++- .../PlayerDataRecalculationRoutine.scala | 2 - 6 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 1a66e5a273..e0cdf7b877 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -452,7 +452,6 @@ class SeichiAssist extends JavaPlugin() { subsystems.idletime.subsystems.awayscreenname.System.wired[IO].unsafeRunSync() } - // TODO: これはprivateであるべきだが、Achievementシステムが再実装されるまでやむを得ずpublicにする lazy val voteSystem: subsystems.vote.System[IO, Player] = { implicit val breakCountAPI: BreakCountAPI[IO, SyncIO, Player] = breakCountSystem.api @@ -475,7 +474,6 @@ class SeichiAssist extends JavaPlugin() { lazy val mineStackSystem: subsystems.minestack.System[IO, Player, ItemStack] = subsystems.minestack.System.wired[IO, SyncIO].unsafeRunSync() - private lazy val wiredSubsystems: List[Subsystem[IO]] = List( mebiusSystem, expBottleStackSystem, diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala index 6de8d8f13d..3ae4cae002 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/actions/BukkitReceiveVoteBenefits.scala @@ -5,7 +5,7 @@ import com.github.unchama.generic.ContextCoercion import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.data.ItemData import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI -import com.github.unchama.seichiassist.subsystems.gacha.bukkit.factories.BukkitGachaSkullData +import com.github.unchama.seichiassist.subsystems.gachaprize.bukkit.factories.BukkitGachaSkullData import com.github.unchama.seichiassist.subsystems.vote.application.actions.ReceiveVoteBenefits import com.github.unchama.seichiassist.subsystems.vote.domain.{ EffectPoint, diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 70304c6a3a..3d48d46350 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -12,6 +12,7 @@ import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi +import com.github.unchama.seichiassist.subsystems.minestack.MineStackAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{ @@ -40,6 +41,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastr import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player import org.bukkit.event.Listener +import org.bukkit.inventory.ItemStack import java.util.UUID @@ -53,6 +55,7 @@ object System { implicit breakCountAPI: BreakCountAPI[IO, SyncIO, Player], voteAPI: VoteAPI[IO, Player], manaApi: ManaApi[IO, SyncIO, Player], + mineStackAPI: MineStackAPI[IO, Player, ItemStack], repeatingTaskContext: RepeatingTaskContext, concurrentEffect: ConcurrentEffect[IO], minecraftServerThread: OnMinecraftServerThread[IO] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index d474c1b4fd..004417ad07 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -1,24 +1,25 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions -import cats.effect.{ConcurrentEffect, LiftIO, Sync} +import cats.effect.{ConcurrentEffect, Sync} import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.mana.domain.ManaAmount +import com.github.unchama.seichiassist.subsystems.minestack.MineStackAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.RecoveryMana +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ AppleAmount, FairyAppleConsumeStrategy, FairyManaRecoveryState } -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech -import com.github.unchama.seichiassist.{MineStackObjectList, SeichiAssist} import com.github.unchama.targetedeffect.SequentialEffect import com.github.unchama.targetedeffect.commandsender.MessageEffectF import org.bukkit.ChatColor._ import org.bukkit.entity.Player +import org.bukkit.inventory.ItemStack import java.time.LocalDateTime import java.util.UUID @@ -31,11 +32,11 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] implicit breakCountAPI: BreakCountAPI[F, G, Player], voteAPI: VoteAPI[F, Player], manaApi: ManaApi[F, G, Player], - fairyPersistence: FairyPersistence[F] + fairyPersistence: FairyPersistence[F], + mineStackAPI: MineStackAPI[F, Player, ItemStack] ) extends RecoveryMana[F] { private val uuid: UUID = player.getUniqueId - private val playerdata = SeichiAssist.playermap(uuid) import cats.implicits._ @@ -64,11 +65,11 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] ) recoveryManaAmount <- computeManaRecoveryAmount(appleConsumptionAmount) - gachaRingoObject <- LiftIO[F].liftIO { - MineStackObjectList.findByName("gachaimo") - } - mineStackedGachaRingoAmount = - playerdata.minestack.getStackedAmountOf(gachaRingoObject.get) + gachaRingoObject <- mineStackAPI.mineStackObjectList.findByName("gachaimo") + + mineStackedGachaRingoAmount <- mineStackAPI + .mineStackRepository + .getStackedAmountOf(player, gachaRingoObject.get) _ <- MessageEffectF(s"$RESET$YELLOW${BOLD}MineStackにがちゃりんごがないようです。。。") .apply(player) @@ -158,13 +159,11 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] */ private def computeFinallyAppleConsumptionAmount(appleConsumptionAmount: Int): F[Int] = for { appleOpenState <- fairyPersistence.appleConsumeStrategy(uuid) - gachaRingoObject <- LiftIO[F].liftIO { - MineStackObjectList.findByName("gachaimo") - } + gachaRingoObject <- mineStackAPI.mineStackObjectList.findByName("gachaimo") + mineStackedGachaRingoAmount <- mineStackAPI + .mineStackRepository + .getStackedAmountOf(player, gachaRingoObject.get) } yield { - val mineStackedGachaRingoAmount = - playerdata.minestack.getStackedAmountOf(gachaRingoObject.get) - // りんごの消費量 if (appleOpenState == FairyAppleConsumeStrategy.NoConsume) 0 @@ -182,17 +181,15 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] oldManaAmount <- ContextCoercion { manaApi.readManaAmount(player) } - gachaRingoObject <- LiftIO[F].liftIO { - MineStackObjectList.findByName("gachaimo") - } + gachaRingoObject <- mineStackAPI.mineStackObjectList.findByName("gachaimo") + mineStackedGachaRingoAmount <- mineStackAPI + .mineStackRepository + .getStackedAmountOf(player, gachaRingoObject.get) } yield { val isAppleOpenStateIsOpenOrOpenALittle = appleOpenState == FairyAppleConsumeStrategy.LessConsume || appleOpenState == FairyAppleConsumeStrategy.Consume val isEnoughMana = oldManaAmount.ratioToCap.exists(_ >= 0.75) - val mineStackedGachaRingoAmount = - playerdata.minestack.getStackedAmountOf(gachaRingoObject.get) - // マナの回復量を算出する val appleOpenStateDivision = diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index e179dadb14..95507e5cc9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -5,12 +5,14 @@ import com.github.unchama.concurrent.{RepeatingRoutine, RepeatingTaskContext} import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi +import com.github.unchama.seichiassist.subsystems.minestack.MineStackAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitRecoveryMana import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import org.bukkit.entity.Player +import org.bukkit.inventory.ItemStack import scala.concurrent.duration.FiniteDuration @@ -21,7 +23,8 @@ class BukkitFairyRoutine(fairySpeech: FairySpeech[IO, Player])( context: RepeatingTaskContext, fairyPersistence: FairyPersistence[IO], concurrentEffect: ConcurrentEffect[IO], - minecraftServerThread: OnMinecraftServerThread[IO] + minecraftServerThread: OnMinecraftServerThread[IO], + mineStackAPI: MineStackAPI[IO, Player, ItemStack] ) extends FairyRoutine[IO, Player] { override def start(player: Player): IO[Nothing] = { diff --git a/src/main/scala/com/github/unchama/seichiassist/task/global/PlayerDataRecalculationRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/task/global/PlayerDataRecalculationRoutine.scala index 45ac57335b..2381a263c7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/task/global/PlayerDataRecalculationRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/task/global/PlayerDataRecalculationRoutine.scala @@ -6,8 +6,6 @@ import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.SeichiAssist import com.github.unchama.seichiassist.achievement.SeichiAchievement import org.bukkit.Bukkit -import org.bukkit.entity.Player -import org.bukkit.inventory.ItemStack import scala.concurrent.duration.FiniteDuration From 3c12f43785b04f99f44ed63238e6d77d18419c0a Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 19:41:11 +0900 Subject: [PATCH 336/482] =?UTF-8?q?chore:=20=E9=96=93=E9=81=95=E3=81=88?= =?UTF-8?q?=E3=81=9F=E5=B7=AE=E5=88=86=E3=82=92=E6=89=93=E3=81=A1=E6=B6=88?= =?UTF-8?q?=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scala/com/github/unchama/fs2/workaround/fs3/Fs3Topic.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Topic.scala b/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Topic.scala index c42320cfcb..58bced3bb3 100644 --- a/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Topic.scala +++ b/src/main/scala/com/github/unchama/fs2/workaround/fs3/Fs3Topic.scala @@ -34,7 +34,7 @@ import scala.collection.immutable.LongMap /** * Topic allows you to distribute `A`s published by an arbitrary number of publishers to an - * arbitrary top of subscribers. + * arbitrary number of subscribers. * * Topic has built-in back-pressure support implemented as the maximum number of elements * (`maxQueued`) that a subscriber is allowed to enqueue. From 10f8fb8d6feb1eda0e75371ef0df0b7f49f6f729 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 19:45:25 +0900 Subject: [PATCH 337/482] =?UTF-8?q?fix:=20=E3=83=9E=E3=82=A4=E3=82=B0?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E3=81=AE=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E9=87=8D=E8=A4=87=E3=82=92=E7=9B=B4=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...airy_time_type.sql => V1.16.0__Change_new_fairy_time_type.sql} | 0 ...14.1__Add_fairy_columns.sql => V1.16.1__Add_fairy_columns.sql} | 0 ...1.14.2__Move_vote_column.sql => V1.16.2__Move_vote_column.sql} | 0 ..._vote_fairy_column.sql => V1.16.3__Move_vote_fairy_column.sql} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V1.14.0__Change_new_fairy_time_type.sql => V1.16.0__Change_new_fairy_time_type.sql} (100%) rename src/main/resources/db/migration/{V1.14.1__Add_fairy_columns.sql => V1.16.1__Add_fairy_columns.sql} (100%) rename src/main/resources/db/migration/{V1.14.2__Move_vote_column.sql => V1.16.2__Move_vote_column.sql} (100%) rename src/main/resources/db/migration/{V1.14.3__Move_vote_fairy_column.sql => V1.16.3__Move_vote_fairy_column.sql} (100%) diff --git a/src/main/resources/db/migration/V1.14.0__Change_new_fairy_time_type.sql b/src/main/resources/db/migration/V1.16.0__Change_new_fairy_time_type.sql similarity index 100% rename from src/main/resources/db/migration/V1.14.0__Change_new_fairy_time_type.sql rename to src/main/resources/db/migration/V1.16.0__Change_new_fairy_time_type.sql diff --git a/src/main/resources/db/migration/V1.14.1__Add_fairy_columns.sql b/src/main/resources/db/migration/V1.16.1__Add_fairy_columns.sql similarity index 100% rename from src/main/resources/db/migration/V1.14.1__Add_fairy_columns.sql rename to src/main/resources/db/migration/V1.16.1__Add_fairy_columns.sql diff --git a/src/main/resources/db/migration/V1.14.2__Move_vote_column.sql b/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql similarity index 100% rename from src/main/resources/db/migration/V1.14.2__Move_vote_column.sql rename to src/main/resources/db/migration/V1.16.2__Move_vote_column.sql diff --git a/src/main/resources/db/migration/V1.14.3__Move_vote_fairy_column.sql b/src/main/resources/db/migration/V1.16.3__Move_vote_fairy_column.sql similarity index 100% rename from src/main/resources/db/migration/V1.14.3__Move_vote_fairy_column.sql rename to src/main/resources/db/migration/V1.16.3__Move_vote_fairy_column.sql From a4fd7555b91b5da6d8e5b33d33b0ddcb03b154e6 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 19:49:08 +0900 Subject: [PATCH 338/482] =?UTF-8?q?chore:=20=E4=BD=BF=E3=82=8F=E3=82=8C?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84PlayerData=E5=9E=8B?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/domain/PlayerName.scala | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/PlayerName.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/PlayerName.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/PlayerName.scala deleted file mode 100644 index ccd2b53f16..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/domain/PlayerName.scala +++ /dev/null @@ -1,3 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.domain - -case class PlayerName(name: String) From 0202f15a8dce18880f06074eb618fb762ca1a9ed Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 19:50:38 +0900 Subject: [PATCH 339/482] =?UTF-8?q?docs:=20fairy/application/actions?= =?UTF-8?q?=E3=81=AE=E9=96=A2=E6=95=B0=E3=81=AE=E3=83=89=E3=82=AD=E3=83=A5?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92=E9=81=A9=E5=88=87=E3=81=AA?= =?UTF-8?q?=E3=82=82=E3=81=AE=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/application/actions/FairyRoutine.scala | 2 +- .../subsystems/fairy/application/actions/RecoveryMana.scala | 2 +- .../vote/subsystems/fairy/application/actions/SummonFairy.scala | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala index 4e77ba338e..da2893a256 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/FairyRoutine.scala @@ -3,7 +3,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applica trait FairyRoutine[F[_], Player] { /** - * 妖精の定期実行プロセスを開始する作用 + * @return 妖精の定期実行プロセスを開始する作用 */ def start(player: Player): F[Nothing] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/RecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/RecoveryMana.scala index 3596325e57..520faebb95 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/RecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/RecoveryMana.scala @@ -3,7 +3,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applica trait RecoveryMana[F[_]] { /** - * 妖精がマナを回復する作用 + * @return 妖精がマナを回復する作用 */ def recovery: F[Unit] diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala index 37b0cac8c1..784963cd13 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/actions/SummonFairy.scala @@ -3,7 +3,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applica trait SummonFairy[F[_], Player] { /** - * 妖精を召喚する作用 + * @return 妖精を召喚する作用 */ def summon(player: Player): F[Unit] From b05ae7e6e8ecc3068887bb6e862fd6aaa596888a Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 19:52:21 +0900 Subject: [PATCH 340/482] =?UTF-8?q?docs:=20=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92?= =?UTF-8?q?=E6=B6=88=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index 5465f5f381..5df84d31ac 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -20,9 +20,6 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( import cats.implicits._ - /** - * @return 時間から妖精の召喚メッセージを返す - */ private def getSummonMessagesByStartHour( startHour: Int, nameCalledByFairy: ScreenNameForFairy From 3d11d4e4c6c6686967cb2d47e233538183cc498c Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 19:53:33 +0900 Subject: [PATCH 341/482] =?UTF-8?q?docs:=20=E3=83=89=E3=82=AD=E3=83=A5?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AE=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E7=A9=BA=E7=99=BD=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/domain/resources/FairyMessageTable.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala index 5458f1bca6..484c3619cc 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/resources/FairyMessageTable.scala @@ -10,7 +10,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p object FairyMessageTable { /** - * 朝に妖精を召喚したときに表示されるメッセージ + * 朝に妖精を召喚したときに表示されるメッセージ */ val morningMessages: ScreenNameForFairy => FairyMessageChoice = (name: ScreenNameForFairy) => FairyMessageChoice( From 7455a527dc25ca01f6863aa7b126da71b6ea3224 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 10 Jan 2023 19:59:20 +0900 Subject: [PATCH 342/482] =?UTF-8?q?docs:=20summonRequest=E3=81=AE=E3=83=89?= =?UTF-8?q?=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92=E9=81=A9?= =?UTF-8?q?=E5=88=87=E3=81=AA=E3=82=82=E3=81=AE=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/domain/FairySummonRequest.scala | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonRequest.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonRequest.scala index 3a73010f61..cf044fd6e3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonRequest.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairySummonRequest.scala @@ -3,9 +3,8 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain trait FairySummonRequest[F[_], Player] { /** - * 妖精の召喚をリクエストする - * 召喚に失敗した場合は[[FairySpawnRequestError]]を返す - * 成功した場合は召喚する作用を返す + * @return 妖精の召喚をリクエストする作用 + * 失敗した場合は失敗理由 */ def summonRequest(player: Player): F[FairySpawnRequestErrorOrSpawn[F]] From a42e72f098b1685aa69e4d934ac84d38b648a766 Mon Sep 17 00:00:00 2001 From: Kisaragi <48310258+KisaragiEffective@users.noreply.github.com> Date: Fri, 3 Feb 2023 19:16:49 +0900 Subject: [PATCH 343/482] chore(deps): bump protoc library --- project/scalapb.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/scalapb.sbt b/project/scalapb.sbt index a0a6ca4c91..8363432e9d 100644 --- a/project/scalapb.sbt +++ b/project/scalapb.sbt @@ -1,3 +1,3 @@ -addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.28") +addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6") -libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.10.1" +libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.11.11" From 35c8b903803ccb6754d660f3f54eb22c97c46852 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 12 Feb 2023 00:30:07 +0900 Subject: [PATCH 344/482] =?UTF-8?q?feat:=20NickNameMenu=E3=81=AEFrame?= =?UTF-8?q?=E3=82=92=E6=8C=87=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/nicknames/NickNameMenu.scala | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala new file mode 100644 index 0000000000..7eccc2c8ee --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala @@ -0,0 +1,22 @@ +package com.github.unchama.seichiassist.menus.nicknames + +import cats.effect.IO +import com.github.unchama.itemstackbuilder.IconItemStackBuilder +import com.github.unchama.menuinventory.slot.button.Button +import com.github.unchama.menuinventory.syntax.IntInventorySizeOps +import com.github.unchama.menuinventory.{Menu, MenuFrame, MenuSlotLayout} +import org.bukkit.Material +import org.bukkit.entity.Player +import org.bukkit.ChatColor._ + +object NickNameMenu extends Menu { + + override type Environment = this.type + + override val frame: MenuFrame = MenuFrame(4.chestRows, s"$DARK_PURPLE${BOLD}二つ名組み合わせシステム") + + override def computeMenuLayout(player: Player)( + implicit environment: Environment + ): IO[MenuSlotLayout] = ??? + +} From 5fda73e321d482d4d383240efffae0b51fa68e2a Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 12 Feb 2023 00:34:24 +0900 Subject: [PATCH 345/482] =?UTF-8?q?feat:=20achievementPointsInformation?= =?UTF-8?q?=E3=82=92=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/nicknames/NickNameMenu.scala | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala index 7eccc2c8ee..f9b41e983a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala @@ -5,6 +5,7 @@ import com.github.unchama.itemstackbuilder.IconItemStackBuilder import com.github.unchama.menuinventory.slot.button.Button import com.github.unchama.menuinventory.syntax.IntInventorySizeOps import com.github.unchama.menuinventory.{Menu, MenuFrame, MenuSlotLayout} +import com.github.unchama.seichiassist.SeichiAssist import org.bukkit.Material import org.bukkit.entity.Player import org.bukkit.ChatColor._ @@ -19,4 +20,24 @@ object NickNameMenu extends Menu { implicit environment: Environment ): IO[MenuSlotLayout] = ??? + private case class NickNameMenuButtons(player: Player) { + + private val playerData = SeichiAssist.playermap.apply(player.getUniqueId) + + val achievementPointsInformation: Button = Button( + new IconItemStackBuilder(Material.EMERALD_ORE) + .title(s"$YELLOW$UNDERLINE${BOLD}実績ポイント情報") + .lore( + List( + s"${GREEN}クリックで情報を最新化", + s"${RED}累計獲得量:${playerData.achievePoint.cumulativeTotal}", + s"${RED}累計消費量:${playerData.achievePoint.used}", + s"${RED}使用可能量:${playerData.achievePoint.left}" + ) + ) + .build() + ) + + } + } From 71b811e4d8e60e319faac970b83d6aafb6ab8488 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 12 Feb 2023 00:39:52 +0900 Subject: [PATCH 346/482] =?UTF-8?q?feat:=20pointConvertButton=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/nicknames/NickNameMenu.scala | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala index f9b41e983a..fa80ab4d21 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala @@ -38,6 +38,22 @@ object NickNameMenu extends Menu { .build() ) + val pointConvertButton: Button = Button( + new IconItemStackBuilder(Material.EMERALD) + .title(s"$YELLOW$UNDERLINE${BOLD}ポイント変換ボタン") + .lore( + List( + s"${RED}JMS投票で手に入るポイントを", + s"${RED}実績ポイントに変換できます。", + s"$YELLOW${BOLD}投票pt 10pt → 実績pt 3pt", + s"${AQUA}クリックで変換を一回行います。", + s"${GREEN}所有投票pt:${playerData.effectPoint}", + s"${GREEN}所有実績pt;${playerData.achievePoint.left}" + ) + ) + .build() + ) + } } From dbcd61c7afd85168a5a121eb7d90bace0d215168 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 12 Feb 2023 21:51:21 +0900 Subject: [PATCH 347/482] =?UTF-8?q?feat:=20currentNickName=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/nicknames/NickNameMenu.scala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala index fa80ab4d21..916d77db42 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala @@ -6,6 +6,7 @@ import com.github.unchama.menuinventory.slot.button.Button import com.github.unchama.menuinventory.syntax.IntInventorySizeOps import com.github.unchama.menuinventory.{Menu, MenuFrame, MenuSlotLayout} import com.github.unchama.seichiassist.SeichiAssist +import com.github.unchama.seichiassist.achievement.Nicknames import org.bukkit.Material import org.bukkit.entity.Player import org.bukkit.ChatColor._ @@ -54,6 +55,19 @@ object NickNameMenu extends Menu { .build() ) + val currentNickName: Button = { + val nickname = playerData.settings.nickname + val playerTitle = + Nicknames.getCombinedNicknameFor(nickname.id1, nickname.id2, nickname.id3) + + Button( + new IconItemStackBuilder(Material.BOOK) + .title(s"$YELLOW$UNDERLINE${BOLD}現在の二つ名の確認") + .lore(List(s"$RED「$playerTitle」")) + .build() + ) + } + } } From 1d907cf3bff95c2bbcb21918f69525f67ba4274a Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 12 Feb 2023 22:15:07 +0900 Subject: [PATCH 348/482] =?UTF-8?q?feat:=20headPartsSelect=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/nicknames/NickNameMenu.scala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala index 916d77db42..cfebd5c14b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala @@ -68,6 +68,20 @@ object NickNameMenu extends Menu { ) } + val achievementPointShop: Button = Button( + new IconItemStackBuilder(Material.ITEM_FRAME) + .title(s"$YELLOW$UNDERLINE${BOLD}実績ポイントショップ") + .lore(List(s"${GREEN}クリックで開きます")) + .build() + ) + + val headPartsSelect: Button = Button( + new IconItemStackBuilder(Material.WATER_BUCKET) + .title(s"$YELLOW$UNDERLINE${BOLD}前パーツ選択画面") + .lore(List(s"${RED}クリックで移動します。")) + .build() + ) + } } From 952c756900f04ad829c6e88b5e6d503ca9af3ec2 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 12 Feb 2023 22:17:20 +0900 Subject: [PATCH 349/482] =?UTF-8?q?feat:=20PartsSelect=E3=83=9C=E3=82=BF?= =?UTF-8?q?=E3=83=B3=E3=82=92=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/nicknames/NickNameMenu.scala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala index cfebd5c14b..096e2349c2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala @@ -82,6 +82,20 @@ object NickNameMenu extends Menu { .build() ) + val middlePartsSelect: Button = Button( + new IconItemStackBuilder(Material.MILK_BUCKET) + .title(s"$YELLOW$UNDERLINE${BOLD}中パーツ選択画面") + .lore(List(s"${RED}クリックで移動します")) + .build() + ) + + val tailPartsSelect: Button = Button( + new IconItemStackBuilder(Material.LAVA_BUCKET) + .title(s"$YELLOW$UNDERLINE${BOLD}後パーツ選択画面") + .lore(List(s"${RED}クリックで移動します。")) + .build() + ) + } } From e3d6823a532b2e9bb3bd6b529c959698e655a734 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 14 Feb 2023 17:50:18 +0900 Subject: [PATCH 350/482] =?UTF-8?q?feat:=20NickNameMenu=E3=81=AB=E3=83=9C?= =?UTF-8?q?=E3=82=BF=E3=83=B3=E3=82=92=E9=85=8D=E7=BD=AE=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/nicknames/NickNameMenu.scala | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala index 096e2349c2..2b31c7fb4e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala @@ -1,25 +1,54 @@ package com.github.unchama.seichiassist.menus.nicknames import cats.effect.IO -import com.github.unchama.itemstackbuilder.IconItemStackBuilder +import com.github.unchama.itemstackbuilder.{IconItemStackBuilder, SkullItemStackBuilder} +import com.github.unchama.menuinventory.router.CanOpen import com.github.unchama.menuinventory.slot.button.Button import com.github.unchama.menuinventory.syntax.IntInventorySizeOps -import com.github.unchama.menuinventory.{Menu, MenuFrame, MenuSlotLayout} -import com.github.unchama.seichiassist.SeichiAssist +import com.github.unchama.menuinventory.{ChestSlotRef, Menu, MenuFrame, MenuSlotLayout} +import com.github.unchama.seichiassist.{SeichiAssist, SkullOwners} import com.github.unchama.seichiassist.achievement.Nicknames +import com.github.unchama.seichiassist.menus.CommonButtons +import com.github.unchama.seichiassist.menus.achievement.AchievementMenu import org.bukkit.Material import org.bukkit.entity.Player import org.bukkit.ChatColor._ object NickNameMenu extends Menu { - override type Environment = this.type + class Environment(implicit val ioCanOpenAchievementMenu: IO CanOpen AchievementMenu.type) override val frame: MenuFrame = MenuFrame(4.chestRows, s"$DARK_PURPLE${BOLD}二つ名組み合わせシステム") - override def computeMenuLayout(player: Player)( - implicit environment: Environment - ): IO[MenuSlotLayout] = ??? + import eu.timepit.refined.auto._ + + override def computeMenuLayout( + player: Player + )(implicit environment: Environment): IO[MenuSlotLayout] = { + import environment._ + + val backToAchievementMenu = CommonButtons.transferButton( + new SkullItemStackBuilder(SkullOwners.MHF_ArrowLeft), + s"$YELLOW$BOLD${UNDERLINE}実績・二つ名メニューへ", + AchievementMenu + ) + + val buttons = NickNameMenuButtons(player) + import buttons._ + + IO( + MenuSlotLayout( + ChestSlotRef(0, 0) -> achievementPointsInformation, + ChestSlotRef(0, 1) -> pointConvertButton, + ChestSlotRef(0, 4) -> currentNickName, + ChestSlotRef(1, 0) -> achievementPointShop, + ChestSlotRef(1, 2) -> headPartsSelect, + ChestSlotRef(1, 4) -> middlePartsSelect, + ChestSlotRef(1, 6) -> tailPartsSelect, + ChestSlotRef(3, 0) -> backToAchievementMenu + ) + ) + } private case class NickNameMenuButtons(player: Player) { From b096387dffef453c6f7171258954cf17b8c2f810 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 14 Feb 2023 19:43:57 +0900 Subject: [PATCH 351/482] =?UTF-8?q?feat:=20AchievementMenu=E3=81=8B?= =?UTF-8?q?=E3=82=89=E6=96=B0=E3=81=97=E3=81=84NickNameMenu=E3=82=92?= =?UTF-8?q?=E9=96=8B=E3=81=8F=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/TopLevelRouter.scala | 4 ++++ .../menus/achievement/AchievementMenu.scala | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala index baef15275d..4b3dd9670c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala @@ -16,6 +16,7 @@ import com.github.unchama.seichiassist.menus.minestack.{ MineStackMainMenu, MineStackSelectItemColorMenu } +import com.github.unchama.seichiassist.menus.nicknames.NickNameMenu import com.github.unchama.seichiassist.menus.ranking.{RankingMenu, RankingRootMenu} import com.github.unchama.seichiassist.menus.skill.{ ActiveSkillEffectMenu, @@ -104,6 +105,8 @@ object TopLevelRouter { new PremiumPointTransactionHistoryMenu.Environment implicit lazy val serverSwitchMenuEnv: ServerSwitchMenu.Environment = new ServerSwitchMenu.Environment + implicit lazy val nickNameMenuEnv: NickNameMenu.Environment = + new NickNameMenu.Environment implicit lazy val achievementMenuEnv: AchievementMenu.Environment = new AchievementMenu.Environment implicit lazy val homeMenuEnv: HomeMenu.Environment = new HomeMenu.Environment @@ -133,6 +136,7 @@ object TopLevelRouter { implicit lazy val stickMenuEnv: FirstPage.Environment = new FirstPage.Environment + implicit lazy val ioCanOpenNickNameMenu: IO CanOpen NickNameMenu.type = _.open implicit lazy val ioCanOpenSelectItemColorMenu: IO CanOpen MineStackSelectItemColorMenu = _.open implicit lazy val ioCanOpenAchievementGroupMenu: IO CanOpen AchievementGroupMenu = _.open diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/achievement/AchievementMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/achievement/AchievementMenu.scala index 6bc773881a..764d272d93 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/achievement/AchievementMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/achievement/AchievementMenu.scala @@ -12,6 +12,7 @@ import com.github.unchama.seichiassist.achievement.hierarchy.AchievementCategory import com.github.unchama.seichiassist.data.MenuInventoryData import com.github.unchama.seichiassist.data.player.NicknameStyle import com.github.unchama.seichiassist.effects.player.CommonSoundEffects +import com.github.unchama.seichiassist.menus.nicknames.NickNameMenu import com.github.unchama.seichiassist.menus.stickmenu.FirstPage import com.github.unchama.seichiassist.menus.{ColorScheme, CommonButtons} import com.github.unchama.targetedeffect.player.{FocusedSoundEffect, PlayerEffects} @@ -28,7 +29,8 @@ object AchievementMenu extends Menu { class Environment( implicit val ioCanOpenStickMenu: IO CanOpen FirstPage.type, val ioCanOpenCategoryMenu: IO CanOpen AchievementCategoryMenu, - val ioOnMainThread: OnMinecraftServerThread[IO] + val ioOnMainThread: OnMinecraftServerThread[IO], + val ioCanOpenNickNameMenu: IO CanOpen NickNameMenu.type ) override val frame: MenuFrame = MenuFrame(4.chestRows, s"$DARK_PURPLE${BOLD}実績・二つ名システム") @@ -108,8 +110,10 @@ object AchievementMenu extends Menu { .lore(s"${RED}設定画面を表示します。") .build(), action.LeftClickButtonEffect( - CommonSoundEffects.menuTransitionFenceSound, - PlayerEffects.openInventoryEffect(MenuInventoryData.computeRefreshedCombineMenu(player)) + SequentialEffect( + CommonSoundEffects.menuTransitionFenceSound, + ioCanOpenNickNameMenu.open(NickNameMenu) + ) ) ) From ffbf3d37ad34ab3e36073c6fd0c10a3503868df8 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 14 Feb 2023 19:46:01 +0900 Subject: [PATCH 352/482] =?UTF-8?q?fix:=20currentNickName=E3=83=9C?= =?UTF-8?q?=E3=82=BF=E3=83=B3=E3=81=A7None=E3=81=AB=E3=81=AA=E3=82=8B?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/nicknames/NickNameMenu.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala index 2b31c7fb4e..57bd4b761b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala @@ -87,7 +87,7 @@ object NickNameMenu extends Menu { val currentNickName: Button = { val nickname = playerData.settings.nickname val playerTitle = - Nicknames.getCombinedNicknameFor(nickname.id1, nickname.id2, nickname.id3) + Nicknames.getCombinedNicknameFor(nickname.id1, nickname.id2, nickname.id3).getOrElse("") Button( new IconItemStackBuilder(Material.BOOK) From 6bd707d45a0c893acff02421985603ee7649e77e Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 14 Feb 2023 22:01:42 +0900 Subject: [PATCH 353/482] =?UTF-8?q?feat:=20bungeecord=E3=81=ABRedisBungee?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index cb6587fe23..b1882b70e4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -83,6 +83,7 @@ services: - REDIS_HOST=redis - REDIS_PORT=6379 - SERVER_ID=bungeecord_1 + - PLUGINS=https://github.com/ProxioDev/RedisBungee/releases/download/0.10.1/RedisBungee-Bungee-0.10.1-SNAPSHOT.jar depends_on: - spigota - spigotb From c02da3d8edd8e5a3cee76ce576f9033024ab2c5f Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 14 Feb 2023 22:24:48 +0900 Subject: [PATCH 354/482] =?UTF-8?q?feat:=20redisbungee=E3=81=AEconfig.yml?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=A6=E3=83=9E=E3=82=A6?= =?UTF-8?q?=E3=83=B3=E3=83=88=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 4 +- .../serverfiles/redisbungee/config.yml | 77 +++++++++++++++++++ 2 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 docker/bungeecord/serverfiles/redisbungee/config.yml diff --git a/docker-compose.yml b/docker-compose.yml index b1882b70e4..0a5683256f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -77,12 +77,10 @@ services: - "25565:25577" volumes: - ./docker/bungeecord/serverfiles:/config + - ./docker/bungeecord/serverfiles/redisbungee/config.yml:/plugins/RedisBungee/config.yml networks: - seichi environment: - - REDIS_HOST=redis - - REDIS_PORT=6379 - - SERVER_ID=bungeecord_1 - PLUGINS=https://github.com/ProxioDev/RedisBungee/releases/download/0.10.1/RedisBungee-Bungee-0.10.1-SNAPSHOT.jar depends_on: - spigota diff --git a/docker/bungeecord/serverfiles/redisbungee/config.yml b/docker/bungeecord/serverfiles/redisbungee/config.yml new file mode 100644 index 0000000000..80267875a9 --- /dev/null +++ b/docker/bungeecord/serverfiles/redisbungee/config.yml @@ -0,0 +1,77 @@ +# RedisBungee configuration file. + +# Cluster Mode +# enabling this option will enable cluster mode. +cluster-mode-enabled: false + +# FORMAT: +# redis-cluster-servers: +# - host: 127.0.0.1 +# port: 2020 +# - host: 127.0.0.1 +# port: 2021 +# - host: 127.0.0.1 +# port: 2021 + +# you can set single server and Jedis will automatically discover cluster nodes, +# but might fail if this single redis node is down when Proxy startup, its recommended put the all the nodes +redis-cluster-servers: + - host: 127.0.0.1 + port: 6379 + +# Get Redis from http://redis.io/ +# The Redis server you use. +# these settings are ignored when cluster mode is enabled. +redis-server: redis +redis-port: 6379 + +# OPTIONAL but recommended: If your Redis server uses AUTH, set the password required. +redis-password: "" +# Maximum connections that will be maintained to the Redis server. +# The default is 10. This setting should be left as-is unless you have some wildly +# inefficient plugins or a lot of players. +max-redis-connections: 10 + +# since redis can support ssl by version 6 you can use ssl / tls in redis bungee too! +# but there is more configuration needed to work see https://github.com/ProxioDev/RedisBungee/issues/18 +# Keep note that SSL/TLS connections will decrease redis performance so use it when needed. +useSSL: false + +# An identifier for this BungeeCord / Velocity instance. Will randomly generate if leaving it blank. +proxy-id: "bungeecord_1" + +# since version 0.8.0 Internally now uses JedisPooled instead of Jedis, JedisPool. +# which will break compatibility with old plugins that uses RedisBungee JedisPool +# so to mitigate this issue, we will instruct RedisBungee to init an JedisPool for compatibility reasons. +# enabled by default +# ignored when cluster mode is enabled +enable-jedis-pool-compatibility: true +# max connections for the compatibility pool +compatibility-max-connections: 3 + +# Register redis bungee legacy commands +# if this disabled override-bungee-commands will be ignored +register-legacy-commands: false + +# Whether or not RedisBungee should install its version of regular BungeeCord commands. +# Often, the RedisBungee commands are desired, but in some cases someone may wish to +# override the commands using another plugin. +# +# If you are just denying access to the commands, RedisBungee uses the default BungeeCord +# permissions - just deny them and access will be denied. +# +# Please note that with build 787+, most commands overridden by RedisBungee were moved to +# modules, and these must be disabled or overridden yourself. +override-bungee-commands: false + +# A list of IP addresses for which RedisBungee will not modify the response for, useful for automatic +# restart scripts. +exempt-ip-addresses: [] + +# restore old login when online behavior before 0.9.0 update +# uncomment to enable it + +# disable-kick-when-online: true + +# Config version DO NOT CHANGE!!!! +config-version: 1 \ No newline at end of file From fc785aea7ce0808d8f3b9958ca5430a2c6627261 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 14 Feb 2023 22:38:33 +0900 Subject: [PATCH 355/482] =?UTF-8?q?fix:=20proxy-id=E3=82=92randomly=20gene?= =?UTF-8?q?rate=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kory | Ryosuke Kondo <6561358+kory33@users.noreply.github.com> --- docker/bungeecord/serverfiles/redisbungee/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/bungeecord/serverfiles/redisbungee/config.yml b/docker/bungeecord/serverfiles/redisbungee/config.yml index 80267875a9..e431463453 100644 --- a/docker/bungeecord/serverfiles/redisbungee/config.yml +++ b/docker/bungeecord/serverfiles/redisbungee/config.yml @@ -38,7 +38,7 @@ max-redis-connections: 10 useSSL: false # An identifier for this BungeeCord / Velocity instance. Will randomly generate if leaving it blank. -proxy-id: "bungeecord_1" +proxy-id: "" # since version 0.8.0 Internally now uses JedisPooled instead of Jedis, JedisPool. # which will break compatibility with old plugins that uses RedisBungee JedisPool From 90c7df1e6f672099829a8f3548c2858a426bfdeb Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 14 Feb 2023 22:51:47 +0900 Subject: [PATCH 356/482] =?UTF-8?q?fix:=20expBottle=E3=81=AE=E6=95=B0?= =?UTF-8?q?=E3=82=9220=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/subsystems/gachaprize/System.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala index 163077308f..c8998691f2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala @@ -57,7 +57,7 @@ object System { val system: F[System[F]] = for { persistedGachaPrizes <- _gachaPersistence.list expBottle = GachaPrize( - new ItemStack(Material.EXP_BOTTLE, 1), + new ItemStack(Material.EXP_BOTTLE, 20), GachaProbability(0.1), signOwner = false, GachaPrizeId(2), From 8b077010687c2f8b988966e55e980ad48c25a88f Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 14 Feb 2023 23:19:59 +0900 Subject: [PATCH 357/482] =?UTF-8?q?feat:=20achievementPointsInformation?= =?UTF-8?q?=E3=81=AB=E5=8B=95=E4=BD=9C=E3=82=92=E3=81=A4=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/nicknames/NickNameMenu.scala | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala index 57bd4b761b..dea4ee77b4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala @@ -4,13 +4,15 @@ import cats.effect.IO import com.github.unchama.itemstackbuilder.{IconItemStackBuilder, SkullItemStackBuilder} import com.github.unchama.menuinventory.router.CanOpen import com.github.unchama.menuinventory.slot.button.Button +import com.github.unchama.menuinventory.slot.button.action.LeftClickButtonEffect import com.github.unchama.menuinventory.syntax.IntInventorySizeOps import com.github.unchama.menuinventory.{ChestSlotRef, Menu, MenuFrame, MenuSlotLayout} import com.github.unchama.seichiassist.{SeichiAssist, SkullOwners} import com.github.unchama.seichiassist.achievement.Nicknames import com.github.unchama.seichiassist.menus.CommonButtons import com.github.unchama.seichiassist.menus.achievement.AchievementMenu -import org.bukkit.Material +import com.github.unchama.targetedeffect.player.FocusedSoundEffect +import org.bukkit.{Material, Sound} import org.bukkit.entity.Player import org.bukkit.ChatColor._ @@ -54,8 +56,8 @@ object NickNameMenu extends Menu { private val playerData = SeichiAssist.playermap.apply(player.getUniqueId) - val achievementPointsInformation: Button = Button( - new IconItemStackBuilder(Material.EMERALD_ORE) + val achievementPointsInformation: Button = { + val itemStack = new IconItemStackBuilder(Material.EMERALD_ORE) .title(s"$YELLOW$UNDERLINE${BOLD}実績ポイント情報") .lore( List( @@ -66,7 +68,14 @@ object NickNameMenu extends Menu { ) ) .build() - ) + + Button( + itemStack, + LeftClickButtonEffect { + FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f, 1.0f) + } + ) + } val pointConvertButton: Button = Button( new IconItemStackBuilder(Material.EMERALD) From 3636a7f86418210dbbbc69eb4b105768b89a858e Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 14 Feb 2023 23:31:15 +0900 Subject: [PATCH 358/482] =?UTF-8?q?feat:=20achievementPointShop=E3=81=AB?= =?UTF-8?q?=E5=8B=95=E4=BD=9C=E3=82=92=E3=81=A4=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/nicknames/NickNameMenu.scala | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala index dea4ee77b4..a0a0ee7fb4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala @@ -9,9 +9,13 @@ import com.github.unchama.menuinventory.syntax.IntInventorySizeOps import com.github.unchama.menuinventory.{ChestSlotRef, Menu, MenuFrame, MenuSlotLayout} import com.github.unchama.seichiassist.{SeichiAssist, SkullOwners} import com.github.unchama.seichiassist.achievement.Nicknames +import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMainThread +import com.github.unchama.seichiassist.data.MenuInventoryData import com.github.unchama.seichiassist.menus.CommonButtons import com.github.unchama.seichiassist.menus.achievement.AchievementMenu +import com.github.unchama.targetedeffect.SequentialEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect +import com.github.unchama.targetedeffect.player.PlayerEffects.openInventoryEffect import org.bukkit.{Material, Sound} import org.bukkit.entity.Player import org.bukkit.ChatColor._ @@ -106,12 +110,22 @@ object NickNameMenu extends Menu { ) } - val achievementPointShop: Button = Button( - new IconItemStackBuilder(Material.ITEM_FRAME) + val achievementPointShop: Button = { + val itemStack = new IconItemStackBuilder(Material.ITEM_FRAME) .title(s"$YELLOW$UNDERLINE${BOLD}実績ポイントショップ") .lore(List(s"${GREEN}クリックで開きます")) .build() - ) + + Button( + itemStack, + LeftClickButtonEffect { + SequentialEffect( + FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f, 0.1f), + openInventoryEffect(MenuInventoryData.computePartsShopMenu(player)) + ) + } + ) + } val headPartsSelect: Button = Button( new IconItemStackBuilder(Material.WATER_BUCKET) From 7511d955e6b0fab4ae78422e501f2bbc00ec3749 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 14 Feb 2023 23:42:49 +0900 Subject: [PATCH 359/482] =?UTF-8?q?feat:=20Parts=E9=81=B8=E6=8A=9E?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E3=81=AB=E9=A3=9B=E3=81=B0=E3=81=99=E3=83=9C?= =?UTF-8?q?=E3=82=BF=E3=83=B3=E3=81=AB=E5=8B=95=E4=BD=9C=E3=82=92=E4=BB=98?= =?UTF-8?q?=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/nicknames/NickNameMenu.scala | 48 +++++++++++++++---- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala index a0a0ee7fb4..7e300df357 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala @@ -127,26 +127,56 @@ object NickNameMenu extends Menu { ) } - val headPartsSelect: Button = Button( - new IconItemStackBuilder(Material.WATER_BUCKET) + val headPartsSelect: Button = { + val itemStack = new IconItemStackBuilder(Material.WATER_BUCKET) .title(s"$YELLOW$UNDERLINE${BOLD}前パーツ選択画面") .lore(List(s"${RED}クリックで移動します。")) .build() - ) - val middlePartsSelect: Button = Button( - new IconItemStackBuilder(Material.MILK_BUCKET) + Button( + itemStack, + LeftClickButtonEffect { + SequentialEffect( + FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f, 0.1f), + openInventoryEffect(MenuInventoryData.computeHeadPartCustomMenu(player)) + ) + } + ) + } + + val middlePartsSelect: Button = { + val itemStack = new IconItemStackBuilder(Material.MILK_BUCKET) .title(s"$YELLOW$UNDERLINE${BOLD}中パーツ選択画面") .lore(List(s"${RED}クリックで移動します")) .build() - ) - val tailPartsSelect: Button = Button( - new IconItemStackBuilder(Material.LAVA_BUCKET) + Button( + itemStack, + LeftClickButtonEffect { + SequentialEffect( + FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f, 0.1f), + openInventoryEffect(MenuInventoryData.computeMiddlePartCustomMenu(player)) + ) + } + ) + } + + val tailPartsSelect: Button = { + val itemStack = new IconItemStackBuilder(Material.LAVA_BUCKET) .title(s"$YELLOW$UNDERLINE${BOLD}後パーツ選択画面") .lore(List(s"${RED}クリックで移動します。")) .build() - ) + + Button( + itemStack, + LeftClickButtonEffect { + SequentialEffect( + FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f, 0.1f), + openInventoryEffect(MenuInventoryData.computeTailPartCustomMenu(player)) + ) + } + ) + } } From 457d9a90dc7f2b75101575df7b6ff730f7876791 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 14 Feb 2023 23:49:29 +0900 Subject: [PATCH 360/482] =?UTF-8?q?feat:=20pointConvertButton=E3=81=AB?= =?UTF-8?q?=E5=8B=95=E4=BD=9C=E3=82=92=E3=81=A4=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/nicknames/NickNameMenu.scala | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala index 7e300df357..bd961413ec 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala @@ -13,7 +13,7 @@ import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMain import com.github.unchama.seichiassist.data.MenuInventoryData import com.github.unchama.seichiassist.menus.CommonButtons import com.github.unchama.seichiassist.menus.achievement.AchievementMenu -import com.github.unchama.targetedeffect.SequentialEffect +import com.github.unchama.targetedeffect.{SequentialEffect, UnfocusedEffect} import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.player.PlayerEffects.openInventoryEffect import org.bukkit.{Material, Sound} @@ -81,8 +81,8 @@ object NickNameMenu extends Menu { ) } - val pointConvertButton: Button = Button( - new IconItemStackBuilder(Material.EMERALD) + val pointConvertButton: Button = { + val itemStack = new IconItemStackBuilder(Material.EMERALD) .title(s"$YELLOW$UNDERLINE${BOLD}ポイント変換ボタン") .lore( List( @@ -95,7 +95,20 @@ object NickNameMenu extends Menu { ) ) .build() - ) + + Button( + itemStack, + LeftClickButtonEffect { + UnfocusedEffect { + if (playerData.effectPoint >= 10) { + playerData.convertEffectPointToAchievePoint() + } else { + player.sendMessage("エフェクトポイントが不足しています。") + } + } + } + ) + } val currentNickName: Button = { val nickname = playerData.settings.nickname From baffceb57add7c4938fe7b9aa0fca53e248c1abb Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 14 Feb 2023 23:52:10 +0900 Subject: [PATCH 361/482] =?UTF-8?q?refactor:=20=E5=8F=A4=E3=81=84GUI?= =?UTF-8?q?=E7=94=A8=E3=81=AE=E5=8B=95=E4=BD=9C=E3=82=92=E6=B6=88=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../invlistener/OnClickTitleMenu.scala | 46 ------------------- 1 file changed, 46 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala b/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala index d671dca91c..5d04d4ad65 100644 --- a/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala @@ -79,52 +79,6 @@ object OnClickTitleMenu { topInventory.getTitle match { case MenuType.COMBINE.invName => event.setCancelled(true) - // 二つ名組み合わせトップ - mat match { - // 実績ポイント最新化 - case Material.EMERALD_ORE => - clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) - - // エフェクトポイント→実績ポイント変換 - case Material.EMERALD => - clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) - if (pd.effectPoint >= 10) { - pd.convertEffectPointToAchievePoint() - } else { - player.sendMessage("エフェクトポイントが不足しています。") - } - - // パーツショップ - case Material.ITEM_FRAME => - clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - player.openInventory(MenuInventoryData.computePartsShopMenu(player)) - - // 前パーツ - case Material.WATER_BUCKET => - clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - player.openInventory(MenuInventoryData.computeHeadPartCustomMenu(player)) - - // 中パーツ - case Material.MILK_BUCKET => - clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - player.openInventory(MenuInventoryData.computeMiddlePartCustomMenu(player)) - - // 後パーツ - case Material.LAVA_BUCKET => - clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - player.openInventory(MenuInventoryData.computeTailPartCustomMenu(player)) - - case _ if isSkull && isApplicableAsPrevPageButton(current) => - effectEnvironment.unsafeRunAsyncTargetedEffect(player)( - SequentialEffect( - CommonSoundEffects.menuTransitionFenceSound, - ioCanOpenAchievementMenu.open(AchievementMenu) - ), - "実績メニューを開く" - ) - - case _ => - } // refresh if needed mat match { From 267f7d18aff5c02d2d7ba7d875b40ffef6f74c8a Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 14 Feb 2023 23:57:51 +0900 Subject: [PATCH 362/482] =?UTF-8?q?feat:=20achievementPointsInformation?= =?UTF-8?q?=E3=82=92=E3=82=AF=E3=83=AA=E3=83=83=E3=82=AF=E3=81=A7=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E3=81=95=E3=82=8C=E3=82=8B=E3=83=9C=E3=82=BF=E3=83=B3?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/nicknames/NickNameMenu.scala | 110 ++++++++++-------- 1 file changed, 64 insertions(+), 46 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala index bd961413ec..52f5b2dc20 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala @@ -3,10 +3,16 @@ package com.github.unchama.seichiassist.menus.nicknames import cats.effect.IO import com.github.unchama.itemstackbuilder.{IconItemStackBuilder, SkullItemStackBuilder} import com.github.unchama.menuinventory.router.CanOpen -import com.github.unchama.menuinventory.slot.button.Button +import com.github.unchama.menuinventory.slot.button.{Button, RecomputedButton} import com.github.unchama.menuinventory.slot.button.action.LeftClickButtonEffect import com.github.unchama.menuinventory.syntax.IntInventorySizeOps -import com.github.unchama.menuinventory.{ChestSlotRef, Menu, MenuFrame, MenuSlotLayout} +import com.github.unchama.menuinventory.{ + ChestSlotRef, + LayoutPreparationContext, + Menu, + MenuFrame, + MenuSlotLayout +} import com.github.unchama.seichiassist.{SeichiAssist, SkullOwners} import com.github.unchama.seichiassist.achievement.Nicknames import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMainThread @@ -22,7 +28,10 @@ import org.bukkit.ChatColor._ object NickNameMenu extends Menu { - class Environment(implicit val ioCanOpenAchievementMenu: IO CanOpen AchievementMenu.type) + class Environment( + implicit val ioCanOpenAchievementMenu: IO CanOpen AchievementMenu.type, + implicit val layoutPreparationContext: LayoutPreparationContext + ) override val frame: MenuFrame = MenuFrame(4.chestRows, s"$DARK_PURPLE${BOLD}二つ名組み合わせシステム") @@ -42,7 +51,10 @@ object NickNameMenu extends Menu { val buttons = NickNameMenuButtons(player) import buttons._ - IO( + for { + achievementPointsInformation <- achievementPointsInformation + pointConvertButton <- pointConvertButton + } yield { MenuSlotLayout( ChestSlotRef(0, 0) -> achievementPointsInformation, ChestSlotRef(0, 1) -> pointConvertButton, @@ -53,61 +65,67 @@ object NickNameMenu extends Menu { ChestSlotRef(1, 6) -> tailPartsSelect, ChestSlotRef(3, 0) -> backToAchievementMenu ) - ) + } } - private case class NickNameMenuButtons(player: Player) { + private case class NickNameMenuButtons(player: Player)(implicit environment: Environment) { + + import environment._ private val playerData = SeichiAssist.playermap.apply(player.getUniqueId) - val achievementPointsInformation: Button = { - val itemStack = new IconItemStackBuilder(Material.EMERALD_ORE) - .title(s"$YELLOW$UNDERLINE${BOLD}実績ポイント情報") - .lore( - List( - s"${GREEN}クリックで情報を最新化", - s"${RED}累計獲得量:${playerData.achievePoint.cumulativeTotal}", - s"${RED}累計消費量:${playerData.achievePoint.used}", - s"${RED}使用可能量:${playerData.achievePoint.left}" + val achievementPointsInformation: IO[Button] = RecomputedButton { + IO { + val itemStack = new IconItemStackBuilder(Material.EMERALD_ORE) + .title(s"$YELLOW$UNDERLINE${BOLD}実績ポイント情報") + .lore( + List( + s"${GREEN}クリックで情報を最新化", + s"${RED}累計獲得量:${playerData.achievePoint.cumulativeTotal}", + s"${RED}累計消費量:${playerData.achievePoint.used}", + s"${RED}使用可能量:${playerData.achievePoint.left}" + ) ) - ) - .build() + .build() - Button( - itemStack, - LeftClickButtonEffect { - FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f, 1.0f) - } - ) + Button( + itemStack, + LeftClickButtonEffect { + FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f, 1.0f) + } + ) + } } - val pointConvertButton: Button = { - val itemStack = new IconItemStackBuilder(Material.EMERALD) - .title(s"$YELLOW$UNDERLINE${BOLD}ポイント変換ボタン") - .lore( - List( - s"${RED}JMS投票で手に入るポイントを", - s"${RED}実績ポイントに変換できます。", - s"$YELLOW${BOLD}投票pt 10pt → 実績pt 3pt", - s"${AQUA}クリックで変換を一回行います。", - s"${GREEN}所有投票pt:${playerData.effectPoint}", - s"${GREEN}所有実績pt;${playerData.achievePoint.left}" + val pointConvertButton: IO[Button] = RecomputedButton { + IO { + val itemStack = new IconItemStackBuilder(Material.EMERALD) + .title(s"$YELLOW$UNDERLINE${BOLD}ポイント変換ボタン") + .lore( + List( + s"${RED}JMS投票で手に入るポイントを", + s"${RED}実績ポイントに変換できます。", + s"$YELLOW${BOLD}投票pt 10pt → 実績pt 3pt", + s"${AQUA}クリックで変換を一回行います。", + s"${GREEN}所有投票pt:${playerData.effectPoint}", + s"${GREEN}所有実績pt;${playerData.achievePoint.left}" + ) ) - ) - .build() + .build() - Button( - itemStack, - LeftClickButtonEffect { - UnfocusedEffect { - if (playerData.effectPoint >= 10) { - playerData.convertEffectPointToAchievePoint() - } else { - player.sendMessage("エフェクトポイントが不足しています。") + Button( + itemStack, + LeftClickButtonEffect { + UnfocusedEffect { + if (playerData.effectPoint >= 10) { + playerData.convertEffectPointToAchievePoint() + } else { + player.sendMessage("エフェクトポイントが不足しています。") + } } } - } - ) + ) + } } val currentNickName: Button = { From df64e07c6203385b2426618678e02574c2d4f7c7 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 15 Feb 2023 00:01:23 +0900 Subject: [PATCH 363/482] style: apply scalafmt and scalafix --- .../seichiassist/listener/invlistener/OnClickTitleMenu.scala | 5 +---- .../seichiassist/menus/achievement/AchievementMenu.scala | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala b/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala index 5d04d4ad65..924cd7977c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala @@ -7,9 +7,7 @@ import com.github.unchama.seichiassist.SeichiAssist import com.github.unchama.seichiassist.achievement.Nicknames import com.github.unchama.seichiassist.data.MenuInventoryData import com.github.unchama.seichiassist.data.MenuInventoryData.MenuType -import com.github.unchama.seichiassist.effects.player.CommonSoundEffects import com.github.unchama.seichiassist.menus.achievement.AchievementMenu -import com.github.unchama.targetedeffect.SequentialEffect import org.bukkit.entity.{EntityType, Player} import org.bukkit.event.inventory.{InventoryClickEvent, InventoryType} import org.bukkit.inventory.ItemStack @@ -24,8 +22,7 @@ object OnClickTitleMenu { private def clickedSound(player: Player, sound: Sound, pitch: Float): Unit = player.playSound(player.getLocation, sound, 1f, pitch) - private def isApplicableAsPrevPageButton(is: ItemStack): Boolean = - is.getItemMeta.asInstanceOf[SkullMeta].getOwningPlayer.getName == "MHF_ArrowLeft" + private def isApplicableAsNextPageButton(is: ItemStack): Boolean = is.getItemMeta.asInstanceOf[SkullMeta].getOwningPlayer.getName == "MHF_ArrowRight" diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/achievement/AchievementMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/achievement/AchievementMenu.scala index 764d272d93..19d6d6e197 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/achievement/AchievementMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/achievement/AchievementMenu.scala @@ -9,13 +9,12 @@ import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.SeichiAssist import com.github.unchama.seichiassist.achievement.hierarchy.AchievementCategory import com.github.unchama.seichiassist.achievement.hierarchy.AchievementCategory._ -import com.github.unchama.seichiassist.data.MenuInventoryData import com.github.unchama.seichiassist.data.player.NicknameStyle import com.github.unchama.seichiassist.effects.player.CommonSoundEffects import com.github.unchama.seichiassist.menus.nicknames.NickNameMenu import com.github.unchama.seichiassist.menus.stickmenu.FirstPage import com.github.unchama.seichiassist.menus.{ColorScheme, CommonButtons} -import com.github.unchama.targetedeffect.player.{FocusedSoundEffect, PlayerEffects} +import com.github.unchama.targetedeffect.player.FocusedSoundEffect import com.github.unchama.targetedeffect.{SequentialEffect, TargetedEffect} import org.bukkit.ChatColor._ import org.bukkit.entity.Player From 3f05d827505829bb428d9507590a4df162284a42 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 15 Feb 2023 00:17:04 +0900 Subject: [PATCH 364/482] =?UTF-8?q?refactor:=20=E5=8F=A4=E3=81=84=E3=83=A1?= =?UTF-8?q?=E3=83=8B=E3=83=A5=E3=83=BC=E3=82=92=E6=B6=88=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/SeichiAssist.scala | 1 + .../seichiassist/data/MenuInventoryData.java | 119 ------------------ .../listener/PlayerInventoryListener.scala | 2 + .../invlistener/OnClickTitleMenu.scala | 16 +-- .../seichiassist/menus/TopLevelRouter.scala | 2 + 5 files changed, 13 insertions(+), 127 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 121729670e..1267c580d6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -680,6 +680,7 @@ class SeichiAssist extends JavaPlugin() { } import menuRouter.canOpenAchievementMenu + import menuRouter.ioCanOpenNickNameMenu // リスナーの登録 val listeners = Seq( new PlayerJoinListener(), diff --git a/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java b/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java index 8bd6a40f97..93b29cdad9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java +++ b/src/main/scala/com/github/unchama/seichiassist/data/MenuInventoryData.java @@ -101,125 +101,6 @@ private static List getVoteButtonLore(final PlayerData playerdata) { ); } - /** - * 二つ名組み合わせ - * @param p プレイヤー - * @return メニュー - */ - public static Inventory computeRefreshedCombineMenu(final Player p) { - final UUID uuid = p.getUniqueId(); - final PlayerData playerdata = SeichiAssist.playermap().apply(uuid); - //念のためエラー分岐 - if (isError(p, playerdata, "二つ名組み合わせ")) return null; - final Inventory inventory = getEmptyInventory(4, MenuType.COMBINE.invName); - - //各ボタンの設定 - finishedHeadPageBuild.put(uuid, false); - finishedMiddlePageBuild.put(uuid, false); - finishedTailPageBuild.put(uuid, false); - finishedShopPageBuild.put(uuid, false); - headPartIndex.put(uuid, 0); - middlePartIndex.put(uuid, 0); - tailPartIndex.put(uuid, 0); - shopIndex.put(uuid, 0); - taihiIndex.put(uuid, 0); - - //実績ポイントの最新情報反映ボタン - { - // dynamic button - final List lore = Arrays.asList( - ChatColor.RESET + "" + ChatColor.GREEN + "クリックで情報を最新化", - ChatColor.RESET + "" + ChatColor.RED + "累計獲得量:" + playerdata.achievePoint().cumulativeTotal(), - ChatColor.RESET + "" + ChatColor.RED + "累計消費量:" + playerdata.achievePoint().used(), - ChatColor.RESET + "" + ChatColor.AQUA + "使用可能量:" + playerdata.achievePoint().left() - ); - - final ItemStack itemstack = build( - Material.EMERALD_ORE, - ChatColor.YELLOW + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "実績ポイント 情報", - lore - ); - - AsyncInventorySetter.setItemAsync(inventory, 0, itemstack); - } - //パーツショップ - { - // const button - final ItemStack itemstack = build( - Material.ITEM_FRAME, - ChatColor.YELLOW + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "実績ポイントショップ", - ChatColor.RESET + "" + ChatColor.GREEN + "クリックで開きます" - ); - AsyncInventorySetter.setItemAsync(inventory, 9, itemstack); - } - //エフェクトポイントからの変換ボタン - { - // dynamic button - final List lore = Arrays.asList(ChatColor.RESET + "" + ChatColor.RED + "JMS投票で手に入るポイントを", - ChatColor.RESET + "" + ChatColor.RED + "実績ポイントに変換できます。", - ChatColor.RESET + "" + ChatColor.YELLOW + "" + ChatColor.BOLD + "投票pt 10pt → 実績pt 3pt", - ChatColor.RESET + "" + ChatColor.AQUA + "クリックで変換を一回行います。", - ChatColor.RESET + "" + ChatColor.GREEN + "所有投票pt :" + playerdata.effectPoint(), - ChatColor.RESET + "" + ChatColor.GREEN + "所有実績pt :" + playerdata.achievePoint().left() - ); - - final ItemStack itemstack = build( - Material.EMERALD, - ChatColor.YELLOW + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "ポイント変換ボタン", - lore - ); - AsyncInventorySetter.setItemAsync(inventory, 1, itemstack); - } - - { - final PlayerNickname nickname = playerdata.settings().nickname(); - final String playerTitle = Nicknames.getTitleFor(nickname.id1(), nickname.id2(), nickname.id3()); - final ItemStack itemStack = build( - Material.BOOK, - ChatColor.YELLOW + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "現在の二つ名の確認", - ChatColor.RESET + "" + ChatColor.RED + "「" + playerTitle + "」" - ); - AsyncInventorySetter.setItemAsync(inventory, 4, itemStack); - } - - { - // const button - final ItemStack toHeadSelection = build( - Material.WATER_BUCKET, - ChatColor.YELLOW + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "前パーツ選択画面", - ChatColor.RESET + "" + ChatColor.RED + "クリックで移動します" - ); - - // const button - final ItemStack toMiddleSelection = build( - Material.MILK_BUCKET, - ChatColor.YELLOW + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "中パーツ選択画面", - ChatColor.RESET + "" + ChatColor.RED + "クリックで移動します" - ); - - // const button - final ItemStack toTailSelection = build( - Material.LAVA_BUCKET, - ChatColor.YELLOW + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "後パーツ選択画面", - ChatColor.RESET + "" + ChatColor.RED + "クリックで移動します" - ); - AsyncInventorySetter.setItemAsync(inventory, 11, toHeadSelection); - AsyncInventorySetter.setItemAsync(inventory, 13, toMiddleSelection); - AsyncInventorySetter.setItemAsync(inventory, 15, toTailSelection); - } - - // 1ページ目を開く - { - // const Button - final ItemStack itemstack = buildPlayerSkull( - ChatColor.YELLOW + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "実績・二つ名メニューへ", - ChatColor.RESET + "" + ChatColor.DARK_RED + "" + ChatColor.UNDERLINE + "クリックで移動", - "MHF_ArrowLeft" - ); - AsyncInventorySetter.setItemAsync(inventory, 27, itemstack.clone()); - } - return inventory; - } public enum MenuType { HEAD("" + ChatColor.DARK_PURPLE + ChatColor.BOLD + "二つ名組合せ「前」"), diff --git a/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala b/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala index 93e6d174d3..5068f80a19 100644 --- a/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala +++ b/src/main/scala/com/github/unchama/seichiassist/listener/PlayerInventoryListener.scala @@ -10,6 +10,7 @@ import com.github.unchama.seichiassist.data.{ItemData, MenuInventoryData} import com.github.unchama.seichiassist.effects.player.CommonSoundEffects import com.github.unchama.seichiassist.listener.invlistener.OnClickTitleMenu import com.github.unchama.seichiassist.menus.achievement.AchievementMenu +import com.github.unchama.seichiassist.menus.nicknames.NickNameMenu import com.github.unchama.seichiassist.menus.stickmenu.{FirstPage, StickMenu} import com.github.unchama.seichiassist.subsystems.gachaprize.bukkit.factories.BukkitGachaSkullData import com.github.unchama.seichiassist.subsystems.mana.ManaApi @@ -31,6 +32,7 @@ class PlayerInventoryListener( manaApi: ManaApi[IO, SyncIO, Player], ioCanOpenFirstPage: IO CanOpen FirstPage.type, ioCanOpenAchievementMenu: IO CanOpen AchievementMenu.type, + ioCanOpenNicknameMenu: IO CanOpen NickNameMenu.type, ioOnMainThread: OnMinecraftServerThread[IO] ) extends Listener { diff --git a/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala b/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala index 924cd7977c..3057b9a6fe 100644 --- a/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala @@ -8,6 +8,7 @@ import com.github.unchama.seichiassist.achievement.Nicknames import com.github.unchama.seichiassist.data.MenuInventoryData import com.github.unchama.seichiassist.data.MenuInventoryData.MenuType import com.github.unchama.seichiassist.menus.achievement.AchievementMenu +import com.github.unchama.seichiassist.menus.nicknames.NickNameMenu import org.bukkit.entity.{EntityType, Player} import org.bukkit.event.inventory.{InventoryClickEvent, InventoryType} import org.bukkit.inventory.ItemStack @@ -22,14 +23,13 @@ object OnClickTitleMenu { private def clickedSound(player: Player, sound: Sound, pitch: Float): Unit = player.playSound(player.getLocation, sound, 1f, pitch) - - private def isApplicableAsNextPageButton(is: ItemStack): Boolean = is.getItemMeta.asInstanceOf[SkullMeta].getOwningPlayer.getName == "MHF_ArrowRight" def onPlayerClickTitleMenuEvent(event: InventoryClickEvent)( implicit effectEnvironment: EffectEnvironment, - ioCanOpenAchievementMenu: IO CanOpen AchievementMenu.type + ioCanOpenAchievementMenu: IO CanOpen AchievementMenu.type, + ioCanOpenNicknameMenu: IO CanOpen NickNameMenu.type ): Unit = { import com.github.unchama.util.syntax.Nullability.NullabilityExtensionReceiver @@ -81,7 +81,7 @@ object OnClickTitleMenu { mat match { case Material.EMERALD_ORE | Material.EMERALD => pd.recalculateAchievePoint() - player.openInventory(MenuInventoryData.computeRefreshedCombineMenu(player)) + ioCanOpenNicknameMenu.open(NickNameMenu).apply(player).unsafeRunAsyncAndForget() case _ => } @@ -116,7 +116,7 @@ object OnClickTitleMenu { case Material.BARRIER => clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - player.openInventory(MenuInventoryData.computeRefreshedCombineMenu(player)) + ioCanOpenNicknameMenu.open(NickNameMenu).apply(player).unsafeRunAsyncAndForget() case _ if isSkull && isApplicableAsNextPageButton(current) => // 次ページ @@ -162,7 +162,7 @@ object OnClickTitleMenu { case Material.BARRIER => clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - player.openInventory(MenuInventoryData.computeRefreshedCombineMenu(player)) + ioCanOpenNicknameMenu.open(NickNameMenu).apply(player).unsafeRunAsyncAndForget() case _ if isSkull && isApplicableAsNextPageButton(current) => clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) @@ -207,7 +207,7 @@ object OnClickTitleMenu { case Material.BARRIER => clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - player.openInventory(MenuInventoryData.computeRefreshedCombineMenu(player)) + ioCanOpenNicknameMenu.open(NickNameMenu).apply(player).unsafeRunAsyncAndForget() case _ if isSkull && isApplicableAsNextPageButton(current) => clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) @@ -255,7 +255,7 @@ object OnClickTitleMenu { case Material.BARRIER => clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - player.openInventory(MenuInventoryData.computeRefreshedCombineMenu(player)) + ioCanOpenNicknameMenu.open(NickNameMenu).apply(player).unsafeRunAsyncAndForget() case _ if isSkull && isApplicableAsNextPageButton(current) => clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala index 4b3dd9670c..739473674b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala @@ -60,6 +60,8 @@ trait TopLevelRouter[F[_]] { implicit val ioCanOpenCategorizedMineStackMenu: F CanOpen CategorizedMineStackMenu + implicit val ioCanOpenNickNameMenu: F CanOpen NickNameMenu.type + } object TopLevelRouter { From 792e0abf5ac25a0589a41ddfcc0bb03a4613f0ea Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 15 Feb 2023 00:46:14 +0900 Subject: [PATCH 365/482] =?UTF-8?q?fix:=20convertEffectPointToAchievePoint?= =?UTF-8?q?=E3=82=92=E3=83=A1=E3=82=A4=E3=83=B3=E3=82=B9=E3=83=AC=E3=83=83?= =?UTF-8?q?=E3=83=89=E3=81=A7=E5=AE=9F=E8=A1=8C=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/nicknames/NickNameMenu.scala | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala index 52f5b2dc20..d3065e337c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/nicknames/NickNameMenu.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.menus.nicknames -import cats.effect.IO +import cats.effect.{IO, SyncIO} import com.github.unchama.itemstackbuilder.{IconItemStackBuilder, SkullItemStackBuilder} import com.github.unchama.menuinventory.router.CanOpen import com.github.unchama.menuinventory.slot.button.{Button, RecomputedButton} @@ -13,9 +13,9 @@ import com.github.unchama.menuinventory.{ MenuFrame, MenuSlotLayout } +import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.{SeichiAssist, SkullOwners} import com.github.unchama.seichiassist.achievement.Nicknames -import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.onMainThread import com.github.unchama.seichiassist.data.MenuInventoryData import com.github.unchama.seichiassist.menus.CommonButtons import com.github.unchama.seichiassist.menus.achievement.AchievementMenu @@ -30,7 +30,8 @@ object NickNameMenu extends Menu { class Environment( implicit val ioCanOpenAchievementMenu: IO CanOpen AchievementMenu.type, - implicit val layoutPreparationContext: LayoutPreparationContext + implicit val layoutPreparationContext: LayoutPreparationContext, + implicit val onMinecraftServerThread: OnMinecraftServerThread[IO] ) override val frame: MenuFrame = MenuFrame(4.chestRows, s"$DARK_PURPLE${BOLD}二つ名組み合わせシステム") @@ -117,10 +118,14 @@ object NickNameMenu extends Menu { itemStack, LeftClickButtonEffect { UnfocusedEffect { - if (playerData.effectPoint >= 10) { - playerData.convertEffectPointToAchievePoint() - } else { - player.sendMessage("エフェクトポイントが不足しています。") + onMinecraftServerThread.runAction { + SyncIO { + if (playerData.effectPoint >= 10) { + playerData.convertEffectPointToAchievePoint() + } else { + player.sendMessage("エフェクトポイントが不足しています。") + } + } } } } From 007784c856531de5682a9ab0ef6709a4e1754455 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 20 Feb 2023 17:02:39 +0900 Subject: [PATCH 366/482] =?UTF-8?q?docs:=20FairyAPI=E3=81=AE=E3=83=89?= =?UTF-8?q?=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92=E9=81=A9?= =?UTF-8?q?=E5=88=87=E3=81=AA=E3=82=82=E3=81=AE=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index db0b3da2b2..c66a5535be 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -53,7 +53,7 @@ trait FairyReadAPI[F[_], G[_], Player] { def rankByMostConsumedApple(player: Player): F[Option[AppleConsumeAmountRank]] /** - * @return 妖精に食べさせたりんごの量の順位上`top`件を返す作用 + * @return 妖精に食べさせたりんごの量の上位`top`件を返す作用 */ def rankingByMostConsumedApple(top: Int): F[Vector[Option[AppleConsumeAmountRank]]] @@ -75,7 +75,7 @@ object FairyReadAPI { trait FairySpeechAPI[F[_], Player] { /** - * @return 妖精が喋るときに音をだすかをトグルする作用 + * @return 妖精が喋るときに音を再生するかをトグルする作用 */ def toggleSoundOnSpeak: Kleisli[F, Player, Unit] From 3b601b4567cb06a1ffc17223e1199d7c16043a54 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 20 Feb 2023 17:07:03 +0900 Subject: [PATCH 367/482] =?UTF-8?q?fix:=20BukkitFairySpeech=E3=81=A7JavaTi?= =?UTF-8?q?me=E3=82=92=E8=A6=81=E6=B1=82=E3=81=97=E3=81=A6=E3=81=9D?= =?UTF-8?q?=E3=82=8C=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 27 +++++-------------- .../fairy/bukkit/BukkitFairySpeech.scala | 7 ++--- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 3d48d46350..0a99a27f64 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -3,40 +3,25 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.data.Kleisli import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.concurrent.RepeatingTaskContext -import com.github.unchama.datarepository.bukkit.player.{ - BukkitRepositoryControls, - PlayerDataRepository -} +import com.github.unchama.datarepository.bukkit.player.{BukkitRepositoryControls, PlayerDataRepository} import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.minecraft.actions.OnMinecraftServerThread +import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.timer import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.minestack.MineStackAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{ - FairyManaRecoveryRoutineFiberRepositoryDefinition, - SpeechServiceRepositoryDefinitions -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{FairyManaRecoveryRoutineFiberRepositoryDefinition, SpeechServiceRepositoryDefinitions} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{ - BukkitFairySpeech, - BukkitFairySummonRequest -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{BukkitFairySpeech, BukkitFairySummonRequest} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{ - FairySpeech, - FairySpeechGateway -} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ - FairyPersistence, - FairySpawnRequestErrorOrSpawn, - FairySummonRequest -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{FairySpeech, FairySpeechGateway} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{FairyPersistence, FairySpawnRequestErrorOrSpawn, FairySummonRequest} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import org.bukkit.entity.Player diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index 5df84d31ac..529da5370e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -8,12 +8,13 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.r import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService +import io.chrisdavenport.cats.effect.time.JavaTime import org.bukkit.entity.Player -import java.time.LocalTime +import java.time.{LocalTime, ZoneId} import scala.util.Random -class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( +class BukkitFairySpeech[F[_]: Sync: JavaTime, G[_]: ContextCoercion[*[_], F]]( fairySpeechServiceRepository: PlayerDataRepository[FairySpeechService[G]], fairyPersistence: FairyPersistence[F] ) extends FairySpeech[F, Player] { @@ -34,7 +35,7 @@ class BukkitFairySpeech[F[_]: Sync, G[_]: ContextCoercion[*[_], F]]( override def summonSpeech(player: Player): F[Unit] = for { - startHour <- Sync[F].delay(LocalTime.now().getHour) + startHour <- JavaTime[F].getLocalDateTime(ZoneId.systemDefault()).map(_.getHour) nameCalledByFairy = ScreenNameForFairy(player.getName) fairyMessages = getSummonMessagesByStartHour(startHour, nameCalledByFairy) message <- randomMessage(fairyMessages) From 5e74c4ff155645f85f7851a8c0aebdee54b47f8c Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 20 Feb 2023 17:08:46 +0900 Subject: [PATCH 368/482] =?UTF-8?q?fix:=20BukkitRecoveryMana=E3=81=A7JavaT?= =?UTF-8?q?ime=E3=82=92=E8=A6=81=E6=B1=82=E3=81=97=E3=81=A6=E3=81=9D?= =?UTF-8?q?=E3=82=8C=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/BukkitFairySpeech.scala | 4 ++-- .../bukkit/actions/BukkitRecoveryMana.scala | 17 +++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index 529da5370e..83c54ae0ac 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -3,15 +3,15 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit import cats.effect.Sync import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository import com.github.unchama.generic.ContextCoercion +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.FairyMessageTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService import io.chrisdavenport.cats.effect.time.JavaTime import org.bukkit.entity.Player -import java.time.{LocalTime, ZoneId} +import java.time.ZoneId import scala.util.Random class BukkitFairySpeech[F[_]: Sync: JavaTime, G[_]: ContextCoercion[*[_], F]]( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 004417ad07..42457123e6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions -import cats.effect.{ConcurrentEffect, Sync} +import cats.effect.ConcurrentEffect import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI import com.github.unchama.seichiassist.subsystems.mana.ManaApi @@ -9,23 +9,20 @@ import com.github.unchama.seichiassist.subsystems.minestack.MineStackAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.RecoveryMana import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{ - AppleAmount, - FairyAppleConsumeStrategy, - FairyManaRecoveryState -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.{AppleAmount, FairyAppleConsumeStrategy, FairyManaRecoveryState} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import com.github.unchama.targetedeffect.SequentialEffect import com.github.unchama.targetedeffect.commandsender.MessageEffectF +import io.chrisdavenport.cats.effect.time.JavaTime import org.bukkit.ChatColor._ import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack -import java.time.LocalDateTime +import java.time.ZoneId import java.util.UUID import scala.util.Random -class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]]( +class BukkitRecoveryMana[F[_]: ConcurrentEffect: JavaTime, G[_]: ContextCoercion[*[_], F]]( player: Player, fairySpeech: FairySpeech[F, Player] )( @@ -45,8 +42,8 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect, G[_]: ContextCoercion[*[_], F]] isFairyUsing <- fairyPersistence.isFairyUsing(uuid) fairyEndTimeOpt <- fairyPersistence.fairyEndTime(uuid) endTime = fairyEndTimeOpt.get.endTimeOpt.get - finishUse <- Sync[F] - .delay(LocalDateTime.now()) + finishUse <- JavaTime[F] + .getLocalDateTime(ZoneId.systemDefault()) .map(now => isFairyUsing && endTime.isBefore(now)) _ <- { fairySpeech From a632fcd6f0206619602b0ea53a59dc1a31de2a80 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 21 Feb 2023 21:44:06 +0900 Subject: [PATCH 369/482] =?UTF-8?q?chore:=20last=5Fvote=E3=82=AB=E3=83=A9?= =?UTF-8?q?=E3=83=A0=E3=81=8B=E3=82=89NOT=20NULL=E5=88=B6=E7=B4=84?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/db/migration/V1.16.2__Move_vote_column.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql b/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql index 9690a151b8..448de2f87d 100644 --- a/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql +++ b/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql @@ -6,7 +6,7 @@ CREATE TABLE IF NOT EXISTS vote( chain_vote_number INT NOT NULL, effect_point INT NOT NULL, given_effect_point INT NOT NULL, - last_vote DATETIME NOT NULL + last_vote DATETIME ); INSERT INTO From e0e736282bc46cce5947a2473412162c98b5e009 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 23 Feb 2023 16:49:57 +0900 Subject: [PATCH 370/482] =?UTF-8?q?fix:=20lastvote=E3=82=AB=E3=83=A9?= =?UTF-8?q?=E3=83=A0=E3=81=AE=E6=8C=BF=E5=85=A5=E3=82=92yyyy/MM/dd?= =?UTF-8?q?=E3=81=AE=E3=81=A8=E3=81=8D=E4=BB=A5=E5=A4=96=E3=81=AFNULL?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/db/migration/V1.16.2__Move_vote_column.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql b/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql index 448de2f87d..c02565155d 100644 --- a/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql +++ b/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql @@ -24,7 +24,9 @@ SELECT chainvote, effectpoint, p_givenvote, - CONVERT(lastvote, DATE) + CASE + WHEN lastvote REGEXP '[0-9]{4}/[0-9]{2}/[0-9]{2}' THEN lastvote + END FROM playerdata; From 3075fa33ea5c1f5b28de60d2b1761c4bf82f19ef Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 23 Feb 2023 16:51:38 +0900 Subject: [PATCH 371/482] =?UTF-8?q?fix:=20convert=E3=82=B7=E3=83=AF?= =?UTF-8?q?=E3=82=B9=E3=83=AC=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/db/migration/V1.16.2__Move_vote_column.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql b/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql index c02565155d..ffe210598a 100644 --- a/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql +++ b/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql @@ -25,7 +25,7 @@ SELECT effectpoint, p_givenvote, CASE - WHEN lastvote REGEXP '[0-9]{4}/[0-9]{2}/[0-9]{2}' THEN lastvote + WHEN lastvote REGEXP '[0-9]{4}/[0-9]{2}/[0-9]{2}' THEN CONVERT(lastvote, DATE) END FROM playerdata; From c544c20941bb4e38fa6e7755346bfb3f19046890 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 25 Feb 2023 20:04:06 +0900 Subject: [PATCH 372/482] =?UTF-8?q?chore:=20vote=E3=83=86=E3=83=BC?= =?UTF-8?q?=E3=83=96=E3=83=AB=E3=81=AEuuid=E3=82=AB=E3=83=A9=E3=83=A0?= =?UTF-8?q?=E3=81=8B=E3=82=89primary=5Fkey=E3=82=92=E5=A4=96=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/db/migration/V1.16.2__Move_vote_column.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql b/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql index ffe210598a..cd0881de5c 100644 --- a/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql +++ b/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql @@ -1,7 +1,7 @@ USE seichiassist; CREATE TABLE IF NOT EXISTS vote( - uuid CHAR(36) NOT NULL PRIMARY KEY, + uuid CHAR(36) NOT NULL, vote_number INT NOT NULL, chain_vote_number INT NOT NULL, effect_point INT NOT NULL, From 33b2f7590c3f55f58a97abb5d5a663a40d1b0e14 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 25 Feb 2023 20:28:03 +0900 Subject: [PATCH 373/482] =?UTF-8?q?chore:=20playerdata=E3=83=86=E3=83=BC?= =?UTF-8?q?=E3=83=96=E3=83=AB=E3=81=8B=E3=82=89uuid=E3=82=AB=E3=83=A9?= =?UTF-8?q?=E3=83=A0=E3=81=8C=E9=87=8D=E8=A4=87=E3=81=97=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=82=8B=E3=83=87=E3=83=BC=E3=82=BF=E3=82=92=E5=8F=96=E3=82=8A?= =?UTF-8?q?=E9=99=A4=E3=81=8F=E3=83=9E=E3=82=A4=E3=82=B0=E3=83=AC=E3=83=BC?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../V1.16.2__Remove_duplicate_playerdata.sql | 14 ++++++++++++++ ...te_column.sql => V1.16.3__Move_vote_column.sql} | 2 +- ...umn.sql => V1.16.4__Move_vote_fairy_column.sql} | 0 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/db/migration/V1.16.2__Remove_duplicate_playerdata.sql rename src/main/resources/db/migration/{V1.16.2__Move_vote_column.sql => V1.16.3__Move_vote_column.sql} (94%) rename src/main/resources/db/migration/{V1.16.3__Move_vote_fairy_column.sql => V1.16.4__Move_vote_fairy_column.sql} (100%) diff --git a/src/main/resources/db/migration/V1.16.2__Remove_duplicate_playerdata.sql b/src/main/resources/db/migration/V1.16.2__Remove_duplicate_playerdata.sql new file mode 100644 index 0000000000..6d1275bb03 --- /dev/null +++ b/src/main/resources/db/migration/V1.16.2__Remove_duplicate_playerdata.sql @@ -0,0 +1,14 @@ +-- 本来重複しないはずのuuidにunique制約をかけていなかった & +-- それによって何故か全く同じデータをもつデータがplayerdataテーブルに存在しているのでそれを取り除く + +USE seichiassist; + +CREATE TEMPORARY TABLE playerdata_tmp AS SELECT DISTINCT * FROM playerdata; +DELETE FROM playerdata; + +INSERT INTO playerdata SELECT * FROM playerdata_tmp; +DROP TABLE playerdata_tmp; + +-- ゆるせないのでplayerdataテーブルのuuidカラムをprimary keyとして設定する + +ALTER TABLE playerdata ADD PRIMARY KEY(uuid) diff --git a/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql b/src/main/resources/db/migration/V1.16.3__Move_vote_column.sql similarity index 94% rename from src/main/resources/db/migration/V1.16.2__Move_vote_column.sql rename to src/main/resources/db/migration/V1.16.3__Move_vote_column.sql index cd0881de5c..ffe210598a 100644 --- a/src/main/resources/db/migration/V1.16.2__Move_vote_column.sql +++ b/src/main/resources/db/migration/V1.16.3__Move_vote_column.sql @@ -1,7 +1,7 @@ USE seichiassist; CREATE TABLE IF NOT EXISTS vote( - uuid CHAR(36) NOT NULL, + uuid CHAR(36) NOT NULL PRIMARY KEY, vote_number INT NOT NULL, chain_vote_number INT NOT NULL, effect_point INT NOT NULL, diff --git a/src/main/resources/db/migration/V1.16.3__Move_vote_fairy_column.sql b/src/main/resources/db/migration/V1.16.4__Move_vote_fairy_column.sql similarity index 100% rename from src/main/resources/db/migration/V1.16.3__Move_vote_fairy_column.sql rename to src/main/resources/db/migration/V1.16.4__Move_vote_fairy_column.sql From 72a69b22dd69fd4559806728a6c613a6596a1ae7 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 25 Feb 2023 20:32:56 +0900 Subject: [PATCH 374/482] =?UTF-8?q?chore:=20delete=20from=20=E3=81=A7?= =?UTF-8?q?=E3=81=AF=E3=81=AA=E3=81=8F=20truncate=20table=E3=82=92?= =?UTF-8?q?=E4=BD=BF=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V1.16.2__Remove_duplicate_playerdata.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/db/migration/V1.16.2__Remove_duplicate_playerdata.sql b/src/main/resources/db/migration/V1.16.2__Remove_duplicate_playerdata.sql index 6d1275bb03..7d51ecbf95 100644 --- a/src/main/resources/db/migration/V1.16.2__Remove_duplicate_playerdata.sql +++ b/src/main/resources/db/migration/V1.16.2__Remove_duplicate_playerdata.sql @@ -4,7 +4,7 @@ USE seichiassist; CREATE TEMPORARY TABLE playerdata_tmp AS SELECT DISTINCT * FROM playerdata; -DELETE FROM playerdata; +TRUNCATE TABLE playerdata; INSERT INTO playerdata SELECT * FROM playerdata_tmp; DROP TABLE playerdata_tmp; From e796b7b308c2f15377a8dfb7d53d3cf900684cea Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 26 Feb 2023 00:18:06 +0900 Subject: [PATCH 375/482] =?UTF-8?q?fix:=20=E5=88=9D=E5=8F=82=E5=8A=A0?= =?UTF-8?q?=E3=83=97=E3=83=AC=E3=82=A4=E3=83=A4=E3=83=BC=E3=81=AE=E6=8A=95?= =?UTF-8?q?=E7=A5=A8=E3=83=87=E3=83=BC=E3=82=BF=E3=81=8C=E4=BD=9C=E6=88=90?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=E4=B8=8D=E5=85=B7=E5=90=88?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/bukkit/listeners/PlayerDataCreator.scala | 10 +++++----- .../vote/infrastructure/JdbcVotePersistence.scala | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/listeners/PlayerDataCreator.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/listeners/PlayerDataCreator.scala index 0755e987b9..91ec918ba0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/listeners/PlayerDataCreator.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/bukkit/listeners/PlayerDataCreator.scala @@ -3,15 +3,15 @@ package com.github.unchama.seichiassist.subsystems.vote.bukkit.listeners import cats.effect.ConcurrentEffect import cats.effect.ConcurrentEffect.ops.toAllConcurrentEffectOps import com.github.unchama.seichiassist.subsystems.vote.domain.VotePersistence -import org.bukkit.event.player.PlayerJoinEvent -import org.bukkit.event.{EventHandler, Listener} +import org.bukkit.event.player.AsyncPlayerPreLoginEvent +import org.bukkit.event.{EventHandler, EventPriority, Listener} class PlayerDataCreator[F[_]: ConcurrentEffect](implicit votePersistence: VotePersistence[F]) extends Listener { - @EventHandler - def onJoin(e: PlayerJoinEvent): Unit = { - votePersistence.createPlayerData(e.getPlayer.getUniqueId).toIO.unsafeRunSync() + @EventHandler(priority = EventPriority.HIGHEST) + def onPlayerPreLoginEvent(e: AsyncPlayerPreLoginEvent): Unit = { + votePersistence.createPlayerData(e.getUniqueId).toIO.unsafeRunAsyncAndForget() } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala index d1005d150f..35d8b6644a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/infrastructure/JdbcVotePersistence.scala @@ -11,7 +11,7 @@ class JdbcVotePersistence[F[_]: Sync] extends VotePersistence[F] { // NOTE: 連続投票日数許容幅を変更する場合はここを変更してください。 private val consecutiveVoteStreakDaysThreshold = 1 - def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { + override def createPlayerData(uuid: UUID): F[Unit] = Sync[F].delay { DB.localTx { implicit session => sql"""INSERT IGNORE INTO vote | (uuid, vote_number, chain_vote_number, effect_point, given_effect_point, last_vote) From 7b69ecb27057af25291d764e11dd5f460e82b8e8 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 26 Feb 2023 00:23:37 +0900 Subject: [PATCH 376/482] =?UTF-8?q?fix:=20=E5=88=9D=E5=8F=82=E5=8A=A0?= =?UTF-8?q?=E3=81=AE=E3=83=97=E3=83=AC=E3=82=A4=E3=83=A4=E3=83=BC=E3=81=AE?= =?UTF-8?q?=E6=8A=95=E7=A5=A8=E5=A6=96=E7=B2=BE=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=81=8C=E4=BD=9C=E6=88=90=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84?= =?UTF-8?q?=E4=B8=8D=E5=85=B7=E5=90=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/listeners/FairyPlayerJoinGreeter.scala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index 672b152475..aee5353c35 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -5,8 +5,8 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.F import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import org.bukkit.ChatColor._ import org.bukkit.entity.Player -import org.bukkit.event.player.PlayerJoinEvent -import org.bukkit.event.{EventHandler, Listener} +import org.bukkit.event.player.{AsyncPlayerPreLoginEvent, PlayerJoinEvent} +import org.bukkit.event.{EventHandler, EventPriority, Listener} import java.time.LocalDateTime @@ -18,12 +18,16 @@ class FairyPlayerJoinGreeter( import cats.implicits._ + @EventHandler(priority = EventPriority.HIGHEST) + def onAsyncPlayerPreLogin(e: AsyncPlayerPreLoginEvent): Unit = { + fairyPersistence.initializePlayerData(e.getUniqueId).unsafeRunAsyncAndForget() + } + @EventHandler def onJoin(e: PlayerJoinEvent): Unit = { val player = e.getPlayer val uuid = player.getUniqueId val program = for { - _ <- fairyPersistence.initializePlayerData(uuid) isUsing <- fairyPersistence.isFairyUsing(uuid) endTime <- fairyPersistence.fairyEndTime(uuid) isEnd = endTime.get.endTimeOpt.get.isBefore(LocalDateTime.now()) From b6a9627fcce14e4fbd1624c37d51ed402256974c Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 26 Feb 2023 00:56:20 +0900 Subject: [PATCH 377/482] =?UTF-8?q?fix:=20FairyEndTime=E3=81=AE=E5=9E=8B?= =?UTF-8?q?=E3=82=B7=E3=82=B0=E3=83=8D=E3=83=81=E3=83=A3=E3=82=92=E7=9B=B4?= =?UTF-8?q?=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/bukkit/BukkitFairySpeech.scala | 2 +- .../fairy/bukkit/actions/BukkitRecoveryMana.scala | 3 +-- .../bukkit/listeners/FairyPlayerJoinGreeter.scala | 2 +- .../fairy/domain/property/FairyEndTime.scala | 2 +- .../fairy/domain/property/FairySummonCost.scala | 8 ++++---- .../fairy/infrastructure/JdbcFairyPersistence.scala | 10 +++++----- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index 83c54ae0ac..ccdf5e485f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -75,7 +75,7 @@ class BukkitFairySpeech[F[_]: Sync: JavaTime, G[_]: ContextCoercion[*[_], F]]( for { endTimeOpt <- fairyPersistence.fairyEndTime(player.getUniqueId) playSound <- fairyPersistence.playSoundOnFairySpeech(player.getUniqueId) - endTime = endTimeOpt.get.endTimeOpt.get + endTime = endTimeOpt.get.endTime _ <- ContextCoercion { fairySpeechServiceRepository(player).makeSpeech( Seq(FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。")), diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 9505354096..85ae29ed5b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -45,10 +45,9 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: JavaTime, G[_]: ContextCoercion for { isFairyUsing <- fairyPersistence.isFairyUsing(uuid) fairyEndTimeOpt <- fairyPersistence.fairyEndTime(uuid) - endTime = fairyEndTimeOpt.get.endTimeOpt.get finishUse <- JavaTime[F] .getLocalDateTime(ZoneId.systemDefault()) - .map(now => isFairyUsing && endTime.isBefore(now)) + .map(now => isFairyUsing && fairyEndTimeOpt.exists(_.endTime.isBefore(now))) _ <- { fairySpeech .bye(player) >> fairyPersistence.updateIsFairyUsing(uuid, isFairyUsing = false) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index aee5353c35..ca64614baa 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -30,7 +30,7 @@ class FairyPlayerJoinGreeter( val program = for { isUsing <- fairyPersistence.isFairyUsing(uuid) endTime <- fairyPersistence.fairyEndTime(uuid) - isEnd = endTime.get.endTimeOpt.get.isBefore(LocalDateTime.now()) + isEnd <- IO(LocalDateTime.now()).map(now => endTime.exists(_.endTime.isBefore(now))) _ <- { fairyPersistence.updateIsFairyUsing(uuid, isFairyUsing = false) >> IO( player.sendMessage(s"$LIGHT_PURPLE${BOLD}妖精は何処かへ行ってしまったようだ...") diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyEndTime.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyEndTime.scala index f40da12776..82ec271312 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyEndTime.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairyEndTime.scala @@ -2,4 +2,4 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain. import java.time.LocalDateTime -case class FairyEndTime(endTimeOpt: Option[LocalDateTime]) +case class FairyEndTime(endTime: LocalDateTime) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala index 11b5bc6a5b..42fef30db2 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/property/FairySummonCost.scala @@ -13,13 +13,13 @@ case class FairySummonCost(value: Int) { val now = LocalDateTime.now() val validTime = value match { case 1 => - FairyEndTime(Some(now.plusMinutes(30))) + FairyEndTime(now.plusMinutes(30)) case 2 => - FairyEndTime(Some(now.plusHours(1))) + FairyEndTime(now.plusHours(1)) case 3 => - FairyEndTime(Some(now.plusHours(1).plusMinutes(30))) + FairyEndTime(now.plusHours(1).plusMinutes(30)) case 4 => - FairyEndTime(Some(now.plusHours(2))) + FairyEndTime(now.plusHours(2)) } validTime } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 40abfc7a92..feb5a66bbe 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -10,15 +10,15 @@ import java.util.UUID class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def initializePlayerData(player: UUID): F[Unit] = Sync[F].delay { - val hasPlayerDataCreated = DB.readOnly { implicit session => + val playerDataCount = DB.readOnly { implicit session => sql"SELECT COUNT(*) as c FROM vote_fairy where uuid = ${player.toString}" .map(_.int("c")) .single() .apply() - .nonEmpty + .getOrElse(0) } - if (!hasPlayerDataCreated) { + if (playerDataCount == 0) { DB.localTx { implicit session => sql"INSERT INTO vote_fairy (uuid) VALUES (${player.toString})".execute().apply() } @@ -116,7 +116,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { override def updateFairyEndTime(player: UUID, fairyEndTime: FairyEndTime): F[Unit] = Sync[F].delay { DB.localTx { implicit session => - sql"UPDATE vote_fairy SET fairy_end_time = ${fairyEndTime.endTimeOpt.get} WHERE uuid = ${player.toString}" + sql"UPDATE vote_fairy SET fairy_end_time = ${fairyEndTime.endTime} WHERE uuid = ${player.toString}" .execute() .apply() } @@ -128,7 +128,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { .map(_.localDateTime("fairy_end_time")) .single() .apply() - dateOpt.map { date => FairyEndTime(Some(date)) } + dateOpt.map(FairyEndTime) } } From ce93b1ffbd6d78ff8efcaa3520605c6f9b83fcfc Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 26 Feb 2023 01:10:05 +0900 Subject: [PATCH 378/482] =?UTF-8?q?fix:=20=E5=A6=96=E7=B2=BE=E3=81=8C?= =?UTF-8?q?=E5=96=8B=E3=81=A3=E3=81=9F=E3=81=A8=E3=81=8D=E3=81=AB=E9=9F=B3?= =?UTF-8?q?=E3=82=92=E9=B3=B4=E3=82=89=E3=81=99=E3=81=8B=E3=83=88=E3=82=B0?= =?UTF-8?q?=E3=83=AB=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84=E4=B8=8D=E5=85=B7?= =?UTF-8?q?=E5=90=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/vote/subsystems/fairy/System.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 57626fdc46..85af0797ff 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -144,7 +144,8 @@ object System { val uuid = player.getUniqueId for { isPlayFairySpeechSound <- doPlaySoundOnSpeak(uuid) - } yield persistence.setPlaySoundOnSpeech(uuid, !isPlayFairySpeechSound) + _ <- persistence.setPlaySoundOnSpeech(uuid, !isPlayFairySpeechSound) + } yield () } override def sendDisappearTimeToChat: Kleisli[IO, Player, Unit] = Kleisli { From baf9111575ba95cce7ac2a971337e3c3e7982977 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 26 Feb 2023 02:21:05 +0900 Subject: [PATCH 379/482] =?UTF-8?q?refactor:=20=E5=85=B1=E6=9C=89=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=83=99=E3=83=B3=E3=83=88=E3=83=AA=E6=A9=9F=E8=83=BD?= =?UTF-8?q?=E3=81=AE=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89=E5=87=A6=E7=90=86?= =?UTF-8?q?=E5=91=A8=E3=82=8A=E3=82=92=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/ShareInventoryCommand.scala | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/sharedinventory/bukkit/command/ShareInventoryCommand.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/sharedinventory/bukkit/command/ShareInventoryCommand.scala index befec2347a..0fa77c95a9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/sharedinventory/bukkit/command/ShareInventoryCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/sharedinventory/bukkit/command/ShareInventoryCommand.scala @@ -8,6 +8,7 @@ import com.github.unchama.seichiassist.subsystems.sharedinventory.SharedInventor import com.github.unchama.seichiassist.subsystems.sharedinventory.domain.SharedFlag import com.github.unchama.seichiassist.subsystems.sharedinventory.domain.bukkit.InventoryContents import com.github.unchama.seichiassist.util.InventoryOperations +import com.github.unchama.targetedeffect.TargetedEffect.emptyEffect import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.CommandEffect import com.github.unchama.targetedeffect.{SequentialEffect, TargetedEffect} @@ -21,20 +22,24 @@ class ShareInventoryCommand[F[_]: ConcurrentEffect]( implicit sharedInventoryAPI: SharedInventoryAPI[F, Player] ) { + import cats.implicits._ + val executor: TabExecutor = playerCommandBuilder .execution { context => val sender = context.sender - - if (sharedInventoryAPI.sharedFlag(sender).toIO.unsafeRunSync() == SharedFlag.Sharing) - withdrawFromSharedInventory(sender) - else depositToSharedInventory(sender) - + for { + sharedFlag <- sharedInventoryAPI.sharedFlag(sender).toIO + _ <- + if (sharedFlag == SharedFlag.Sharing) { + withdrawFromSharedInventory(sender) + } else { + depositToSharedInventory(sender) + } + } yield emptyEffect } .build() .asNonBlockingTabExecutor() - import cats.implicits._ - private def withdrawFromSharedInventory(player: Player): IO[TargetedEffect[Player]] = { val uuid = player.getUniqueId val eff = for { @@ -42,12 +47,10 @@ class ShareInventoryCommand[F[_]: ConcurrentEffect]( loadedInventory <- sharedInventoryAPI.load(uuid) _ <- sharedInventoryAPI.clear(uuid) newSharedFlag <- sharedInventoryAPI.sharedFlag(player) - playerInventory = player.getInventory _ <- Sync[F] .delay { - val inventoryContents = loadedInventory - .getOrElse(return IO.pure(MessageEffect(s"$RESET$RED${BOLD}収納アイテムが存在しません。"))) - .inventoryContents + val playerInventory = player.getInventory + val inventoryContents = loadedInventory.get.inventoryContents // 手持ちのアイテムをドロップする playerInventory .getContents From 17d68f1ad5da4ae5b7efd28bd3e230d809a2a7e8 Mon Sep 17 00:00:00 2001 From: Kisaragi <48310258+KisaragiEffective@users.noreply.github.com> Date: Sun, 26 Feb 2023 20:41:33 +0900 Subject: [PATCH 380/482] =?UTF-8?q?fix(ci):=20assemblyMergeStrategy?= =?UTF-8?q?=E3=82=92=E6=8C=87=E5=AE=9A=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sbt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build.sbt b/build.sbt index b6108f6653..c82f20a7ba 100644 --- a/build.sbt +++ b/build.sbt @@ -127,6 +127,15 @@ assembly / assemblyExcludedJars := { } } +// protocol配下とルートのLICENSEが衝突してCIが落ちる +// cf. https://github.com/sbt/sbt-assembly/issues/141 +assembly / assemblyMergeStrategy := { + case PathList(ps @ _*) if ps.last endsWith "LICENSE" => MergeStrategy.rename + case otherFile => + val oldStrategy = (assembly / assemblyMergeStrategy).value + oldStrategy(otherFile) +} + // endregion // region プラグインJarに埋め込むリソースの処理 From ff7e404f344e7e4c1d0440663ded658a90556dc5 Mon Sep 17 00:00:00 2001 From: Kisaragi <48310258+KisaragiEffective@users.noreply.github.com> Date: Sun, 26 Feb 2023 20:54:57 +0900 Subject: [PATCH 381/482] rollback to legacy syntax --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index c82f20a7ba..2d57457d0f 100644 --- a/build.sbt +++ b/build.sbt @@ -129,10 +129,10 @@ assembly / assemblyExcludedJars := { // protocol配下とルートのLICENSEが衝突してCIが落ちる // cf. https://github.com/sbt/sbt-assembly/issues/141 -assembly / assemblyMergeStrategy := { +assemblyMergeStrategy in assembly := { case PathList(ps @ _*) if ps.last endsWith "LICENSE" => MergeStrategy.rename case otherFile => - val oldStrategy = (assembly / assemblyMergeStrategy).value + val oldStrategy = (assemblyMergeStrategy in assembly).value oldStrategy(otherFile) } From 3be6e51c42ac917bf873bd4f9fde84af0bc8cacb Mon Sep 17 00:00:00 2001 From: Kory | Ryosuke Kondo <6561358+kory33@users.noreply.github.com> Date: Sun, 26 Feb 2023 22:47:34 +0000 Subject: [PATCH 382/482] fix: apply suggestion --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 2d57457d0f..1da3be3b6f 100644 --- a/build.sbt +++ b/build.sbt @@ -129,10 +129,10 @@ assembly / assemblyExcludedJars := { // protocol配下とルートのLICENSEが衝突してCIが落ちる // cf. https://github.com/sbt/sbt-assembly/issues/141 -assemblyMergeStrategy in assembly := { +assemblyMergeStrategy in ThisBuild := { case PathList(ps @ _*) if ps.last endsWith "LICENSE" => MergeStrategy.rename case otherFile => - val oldStrategy = (assemblyMergeStrategy in assembly).value + val oldStrategy = (assemblyMergeStrategy in ThisBuild).value oldStrategy(otherFile) } From 89ef5358b8bc9a01bd733e43d74aef14bf007ae0 Mon Sep 17 00:00:00 2001 From: Kory | Ryosuke Kondo <6561358+kory33@users.noreply.github.com> Date: Sun, 26 Feb 2023 22:54:29 +0000 Subject: [PATCH 383/482] revert previous suggestion --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 1da3be3b6f..2d57457d0f 100644 --- a/build.sbt +++ b/build.sbt @@ -129,10 +129,10 @@ assembly / assemblyExcludedJars := { // protocol配下とルートのLICENSEが衝突してCIが落ちる // cf. https://github.com/sbt/sbt-assembly/issues/141 -assemblyMergeStrategy in ThisBuild := { +assemblyMergeStrategy in assembly := { case PathList(ps @ _*) if ps.last endsWith "LICENSE" => MergeStrategy.rename case otherFile => - val oldStrategy = (assemblyMergeStrategy in ThisBuild).value + val oldStrategy = (assemblyMergeStrategy in assembly).value oldStrategy(otherFile) } From 082821799a3dea71afef64f83e22fb1c91fc6999 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 28 Feb 2023 22:26:07 +0900 Subject: [PATCH 384/482] =?UTF-8?q?refactor:=20fetchMostConsumedApplePlaye?= =?UTF-8?q?rsByFairy=E9=96=A2=E6=95=B0=E3=81=A7for=E3=82=92=E4=BD=BF?= =?UTF-8?q?=E3=81=A3=E3=81=A6=E4=B8=AD=E8=BA=AB=E3=82=92=E5=B1=95=E9=96=8B?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/JdbcFairyPersistence.scala | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index feb5a66bbe..bf4d3461c0 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -190,14 +190,19 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { | INNER JOIN playerdata ON (vote_fairy.uuid = playerdata.uuid) | ORDER BY rank DESC LIMIT $top;""" .stripMargin - .map(rs => (rs.stringOpt("name"), rs.intOpt("rank"), rs.intOpt("given_apple_amount"))) + .map { rs => + (rs.stringOpt("name"), rs.intOpt("rank"), rs.intOpt("given_apple_amount")) + } .toList() .apply() - .map(data => - if (data._1.nonEmpty) - Some(AppleConsumeAmountRank(data._1.get, data._2.get, AppleAmount(data._3.get))) - else None - ) + .map { + case (name, rank, givenAppleAmount) => + for { + name <- name + rank <- rank + givenAppleAmount <- givenAppleAmount + } yield AppleConsumeAmountRank(name, rank, AppleAmount(givenAppleAmount)) + } .toVector } } From 985747a813960d06b16c661843dfc756acae60c4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 28 Feb 2023 22:30:41 +0900 Subject: [PATCH 385/482] =?UTF-8?q?refactor:=20map=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E4=B8=80=E3=81=A4=E3=81=AB=E3=81=BE=E3=81=A8=E3=82=81?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/JdbcFairyPersistence.scala | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index bf4d3461c0..4c2f411c95 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -191,18 +191,14 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { | ORDER BY rank DESC LIMIT $top;""" .stripMargin .map { rs => - (rs.stringOpt("name"), rs.intOpt("rank"), rs.intOpt("given_apple_amount")) + for { + name <- rs.stringOpt("name") + rank <- rs.intOpt("rank") + givenAppleAmount <- rs.intOpt("given_apple_amount") + } yield AppleConsumeAmountRank(name, rank, AppleAmount(givenAppleAmount)) } .toList() .apply() - .map { - case (name, rank, givenAppleAmount) => - for { - name <- name - rank <- rank - givenAppleAmount <- givenAppleAmount - } yield AppleConsumeAmountRank(name, rank, AppleAmount(givenAppleAmount)) - } .toVector } } From d6b2b28c0f833f3a4f1e848b87fc513f9b9e56db Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 28 Feb 2023 22:42:50 +0900 Subject: [PATCH 386/482] =?UTF-8?q?docs:=20fetchMOstConsumedApplePlayersBy?= =?UTF-8?q?Fairy=E9=96=A2=E6=95=B0=E3=81=AE=E3=83=89=E3=82=AD=E3=83=A5?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AB=E6=8C=87=E5=AE=9A=E3=81=97?= =?UTF-8?q?=E3=81=9F=E5=88=86=E3=81=A0=E3=81=91=E8=A6=81=E7=B4=A0=E3=81=8C?= =?UTF-8?q?=E3=81=82=E3=82=8B=E3=81=93=E3=81=A8=E3=82=92=E4=BF=9D=E8=A8=BC?= =?UTF-8?q?=E3=81=97=E3=81=AA=E3=81=84=E6=96=87=E8=A8=80=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/domain/FairyPersistence.scala | 1 + .../subsystems/fairy/infrastructure/JdbcFairyPersistence.scala | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala index 99ae4c43bd..9331e34689 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/FairyPersistence.scala @@ -86,6 +86,7 @@ trait FairyPersistence[F[_]] { /** * 妖精に食べさせたりんごの量が多いプレイヤーを上位とし、そのランキングの上から指定した件数を返す + * ただし、要素数が`top`件あることは保証しない。 * * @param top 最上位から何番目まで取得するか件数を指定する。0以下であってはならない。 * @return 指定した件数が要素数となり、その並びが消費量の降順になっているような順序つきのコレクションを返す作用。 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala index 4c2f411c95..1e86fc4584 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/infrastructure/JdbcFairyPersistence.scala @@ -186,7 +186,7 @@ class JdbcFairyPersistence[F[_]: Sync] extends FairyPersistence[F] { ): F[Vector[Option[AppleConsumeAmountRank]]] = Sync[F].delay { DB.readOnly { implicit session => - sql"""SELECT name,given_apple_amount,COUNT(*) AS rank FROM vote_fairy + sql"""SELECT name,given_apple_amount,COUNT(*) AS rank FROM vote_fairy | INNER JOIN playerdata ON (vote_fairy.uuid = playerdata.uuid) | ORDER BY rank DESC LIMIT $top;""" .stripMargin From 7a0b7c76921c3fd3326eef3c064d451dce6000a9 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 28 Feb 2023 22:55:13 +0900 Subject: [PATCH 387/482] =?UTF-8?q?fix:=20topFourRankingLore=E3=81=A7Optio?= =?UTF-8?q?n.get=E3=81=97=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 1d0132aa17..cd74e0eaa5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -382,14 +382,11 @@ object VoteMenu extends Menu { topFourRanking.lift(1), topFourRanking.lift(2), topFourRanking.lift(3) - ).flatMap { rankDataOpt => - if (rankDataOpt.nonEmpty) { - val rankData = rankDataOpt.get.get - List( - s"${GRAY}たくさんくれたニンゲン第${rankData.rank}位!", - s"${GRAY}なまえ:${rankData.playerName} りんご:${rankData.consumed.amount}個" - ) - } else Nil + ).flatMap(_.flatten).flatMap { rankData => + List( + s"${GRAY}たくさんくれたニンゲン第${rankData.rank}位!", + s"${GRAY}なまえ:${rankData.playerName} りんご:${rankData.consumed.amount}個" + ) } val statistics = List( s"${AQUA}ぜーんぶで${allEatenAppleAmount.amount}個もらえた!", From 75d130b4743ad4205ef873664225a341596286a1 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 28 Feb 2023 22:59:49 +0900 Subject: [PATCH 388/482] =?UTF-8?q?fix:=20statistics=E3=82=92=E6=B1=82?= =?UTF-8?q?=E3=82=81=E3=82=8B=E9=9A=9B=E3=81=AB.get=E3=81=97=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index cd74e0eaa5..829b904c78 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -388,13 +388,15 @@ object VoteMenu extends Menu { s"${GRAY}なまえ:${rankData.playerName} りんご:${rankData.consumed.amount}個" ) } - val statistics = List( - s"${AQUA}ぜーんぶで${allEatenAppleAmount.amount}個もらえた!", - "", - s"$GREEN↓呼び出したニンゲンの情報↓", - s"${GREEN}今までに${myRank.get.consumed.amount}個もらった", - s"${GREEN}ニンゲンの中では${myRank.get.rank}番目にたくさんくれる!" - ) + val statistics = myRank.map { rank => + List( + s"${AQUA}ぜーんぶで${allEatenAppleAmount.amount}個もらえた!", + "", + s"$GREEN↓呼び出したニンゲンの情報↓", + s"${GREEN}今までに${rank.consumed.amount}個もらった", + s"${GREEN}ニンゲンの中では${rank.rank}番目にたくさんくれる!" + ) + }.orEmpty Button( new IconItemStackBuilder(Material.GOLDEN_APPLE) From 7e752813dd562202cc19d411145e14f52e7850d2 Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 1 Mar 2023 21:54:58 +0900 Subject: [PATCH 389/482] =?UTF-8?q?fix:=20p=5Fgivenvote=E3=82=92=E5=89=8A?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/data/player/PlayerData.scala | 2 -- .../github/unchama/seichiassist/task/PlayerDataLoading.scala | 1 - 2 files changed, 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala index c8fcfb7fb1..45dc3fd9e5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala +++ b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala @@ -79,8 +79,6 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { var playTick = 0L // 合計経験値 var totalexp = 0L - // 特典受け取り済み投票数 - var p_givenvote = 0 // 連続・通算ログイン用 // ロード時に初期化される var lastcheckdate: String = _ diff --git a/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala b/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala index f7ad4665a4..89fcde5729 100644 --- a/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala +++ b/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala @@ -182,7 +182,6 @@ object PlayerDataLoading { playerData.unclaimedApologyItems = rs.getInt("numofsorryforbug") playerData.regionCount = rs.getInt("rgnum") playerData.playTick = rs.getLong("playtick") - playerData.p_givenvote = rs.getInt("p_givenvote") playerData.totalexp = rs.getInt("totalexp") From 759ed916160b6d913941f719176eed044b0758bf Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 1 Mar 2023 21:59:05 +0900 Subject: [PATCH 390/482] =?UTF-8?q?fix:=20PlayerData=E3=81=8B=E3=82=89chai?= =?UTF-8?q?nvote=E3=83=91=E3=83=A9=E3=83=A1=E3=83=BC=E3=82=BF=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../descrptions/PlayerStatsLoreGenerator.scala | 14 ++++++++++---- .../seichiassist/data/player/PlayerData.scala | 1 - .../seichiassist/task/PlayerDataLoading.scala | 2 -- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/data/descrptions/PlayerStatsLoreGenerator.scala b/src/main/scala/com/github/unchama/seichiassist/data/descrptions/PlayerStatsLoreGenerator.scala index b3838576dd..fcea2d0ff7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/descrptions/PlayerStatsLoreGenerator.scala +++ b/src/main/scala/com/github/unchama/seichiassist/data/descrptions/PlayerStatsLoreGenerator.scala @@ -13,6 +13,7 @@ import com.github.unchama.seichiassist.subsystems.ranking.domain.{ Ranking, RankingRecordWithPosition } +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.util.TypeConverter import org.bukkit.Bukkit import org.bukkit.ChatColor._ @@ -25,7 +26,8 @@ class PlayerStatsLoreGenerator( playerData: PlayerData, seichiRanking: Ranking[SeichiAmountData], seichiAmountData: SeichiAmountData, - expBarVisibility: BreakCountBarVisibility + expBarVisibility: BreakCountBarVisibility, + voteAPI: VoteAPI[IO, Player] ) { private val targetPlayer: Player = Bukkit.getPlayer(playerData.uuid) @@ -167,11 +169,15 @@ class PlayerStatsLoreGenerator( /** * 連続投票日数の説明文. */ - private def totalChainVoteDaysDescription(): List[String] = - if (playerData.ChainVote > 0) - List(s"$RESET${GRAY}連続投票日数:${playerData.ChainVote}日") + private def totalChainVoteDaysDescription(): List[String] = { + val consecutiveVoteStreakDays = + voteAPI.currentConsecutiveVoteStreakDays(targetPlayer.getUniqueId).unsafeRunSync().value + + if (consecutiveVoteStreakDays > 0) + List(s"$RESET${GRAY}連続投票日数:${consecutiveVoteStreakDays}日") else Nil + } /** * Expバーの説明文. diff --git a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala index 45dc3fd9e5..89299af394 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala +++ b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala @@ -85,7 +85,6 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { var loginStatus: LoginStatus = LoginStatus(null) // 期間限定ログイン用 var LimitedLoginCount = 0 - var ChainVote = 0 // region スキル関連のデータ val skillState: Ref[IO, PlayerSkillState] = Ref.unsafe(PlayerSkillState.initial) diff --git a/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala b/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala index 89fcde5729..ef1eac42e8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala +++ b/src/main/scala/com/github/unchama/seichiassist/task/PlayerDataLoading.scala @@ -251,8 +251,6 @@ object PlayerDataLoading { playerData.lastcheckdate = sdf.format(cal.getTime) - playerData.ChainVote = rs.getInt("chainvote") - // 実績解除フラグのBitSet型への復元処理 // 初回nullエラー回避のための分岐 try { From 9a4d049239b4ecd74ab4f26f777ee540f53e823e Mon Sep 17 00:00:00 2001 From: rito528 Date: Wed, 1 Mar 2023 22:01:43 +0900 Subject: [PATCH 391/482] =?UTF-8?q?fix:=20FirtstPage=E3=81=AB=E4=B8=8D?= =?UTF-8?q?=E8=B6=B3=E3=81=97=E3=81=A6=E3=81=84=E3=81=9FvoteAPI=E3=81=AE?= =?UTF-8?q?=E5=BC=95=E6=95=B0=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/menus/stickmenu/FirstPage.scala | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/stickmenu/FirstPage.scala b/src/main/scala/com/github/unchama/seichiassist/menus/stickmenu/FirstPage.scala index 9f8677f628..02262db2d1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/stickmenu/FirstPage.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/stickmenu/FirstPage.scala @@ -44,6 +44,7 @@ import com.github.unchama.seichiassist.subsystems.gachapoint.GachaPointApi import com.github.unchama.seichiassist.subsystems.ranking.api.RankingProvider import com.github.unchama.seichiassist.task.CoolDownTask import com.github.unchama.seichiassist.ManagedWorld._ +import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.{SeichiAssist, SkullOwners, util} import com.github.unchama.targetedeffect.TargetedEffect.emptyEffect import com.github.unchama.targetedeffect.commandsender.MessageEffect @@ -92,7 +93,8 @@ object FirstPage extends Menu { val ioCanOpenRankingRootMenu: IO CanOpen RankingRootMenu.type, val ioCanOpenVoteMenu: IO CanOpen VoteMenu.type, val enderChestAccessApi: AnywhereEnderChestAPI[IO], - val gachaTicketAPI: GachaTicketAPI[IO] + val gachaTicketAPI: GachaTicketAPI[IO], + val voteAPI: VoteAPI[IO, Player] ) override val frame: MenuFrame = @@ -175,8 +177,13 @@ object FirstPage extends Menu { environment.breakCountAPI.seichiAmountDataRepository(player).read.toIO ranking <- environment.rankingApi.ranking.read visibility <- visibilityRef.get.toIO - lore <- new PlayerStatsLoreGenerator(openerData, ranking, seichiAmountData, visibility) - .computeLore() + lore <- new PlayerStatsLoreGenerator( + openerData, + ranking, + seichiAmountData, + visibility, + environment.voteAPI + ).computeLore() } yield Button( new SkullItemStackBuilder(getUniqueId) .title(s"$YELLOW$BOLD$UNDERLINE${getName}の統計データ") From f580b0a00fd5ab6f46d9aef280b469e88bf68b5c Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 12 Mar 2023 14:21:02 +0900 Subject: [PATCH 392/482] =?UTF-8?q?build:=20unmanagedResource=E3=81=ABLICE?= =?UTF-8?q?NCE=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=AA=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sbt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index 2d57457d0f..bfdf6be2f1 100644 --- a/build.sbt +++ b/build.sbt @@ -129,10 +129,10 @@ assembly / assemblyExcludedJars := { // protocol配下とルートのLICENSEが衝突してCIが落ちる // cf. https://github.com/sbt/sbt-assembly/issues/141 -assemblyMergeStrategy in assembly := { - case PathList(ps @ _*) if ps.last endsWith "LICENSE" => MergeStrategy.rename +assembly / assemblyMergeStrategy := { + case PathList(ps @ _*) if ps.last endsWith "LICENSE" => MergeStrategy.first case otherFile => - val oldStrategy = (assemblyMergeStrategy in assembly).value + val oldStrategy = (assembly / assemblyMergeStrategy).value oldStrategy(otherFile) } @@ -159,8 +159,6 @@ Compile / filteredResourceGenerator := Compile / resourceGenerators += (Compile / filteredResourceGenerator) -Compile / unmanagedResources += baseDirectory.value / "LICENSE" - // トークン置換を行ったファイルをunmanagedResourcesのコピーから除外する unmanagedResources / excludeFilter := filesToBeReplacedInResourceFolder.foldLeft((unmanagedResources / excludeFilter).value)( From 7dcfb39e7d16e0de16119e1837d2b51b5b65e843 Mon Sep 17 00:00:00 2001 From: Kisaragi <48310258+KisaragiEffective@users.noreply.github.com> Date: Mon, 13 Mar 2023 04:55:59 +0900 Subject: [PATCH 393/482] =?UTF-8?q?build:=20LICENSE=E3=82=92=E4=B8=A1?= =?UTF-8?q?=E6=96=B9=E5=90=AB=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 6e332c9c99..260477a124 100644 --- a/build.sbt +++ b/build.sbt @@ -130,7 +130,7 @@ assembly / assemblyExcludedJars := { // protocol配下とルートのLICENSEが衝突してCIが落ちる // cf. https://github.com/sbt/sbt-assembly/issues/141 assembly / assemblyMergeStrategy := { - case PathList(ps @ _*) if ps.last endsWith "LICENSE" => MergeStrategy.first + case PathList(ps @ _*) if ps.last endsWith "LICENSE" => MergeStrategy.rename case otherFile => val oldStrategy = (assembly / assemblyMergeStrategy).value oldStrategy(otherFile) From 526bbdf12b88e1e97256f7a771997184cd33b775 Mon Sep 17 00:00:00 2001 From: lis2a Date: Mon, 20 Mar 2023 02:17:07 +0900 Subject: [PATCH 394/482] fix(docs): fix item region comment --- .../seasonalevents/valentine/ValentineItemData.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/seasonalevents/valentine/ValentineItemData.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/seasonalevents/valentine/ValentineItemData.scala index db1078b250..5a9fd9c243 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/seasonalevents/valentine/ValentineItemData.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/seasonalevents/valentine/ValentineItemData.scala @@ -83,10 +83,10 @@ object ValentineItemData { // endregion - // region GiftedCookie -> 棒メニューでもらえるやつ + // region GiftedCookie -> イベント期間中にログイン時に入手できる /** - * 棒メニューからチョコチップクッキーのアイテムID。2は有効期限が[[java.time.LocalDate]]のもの + * イベント期間中のログインでもらえるチョコチップクッキーのアイテムID。2は有効期限が[[java.time.LocalDate]]のもの */ private val giftedCookieTypeId = 4 From 6d67c0385a8698aac2a582c4e2662cb7eb3b4c8f Mon Sep 17 00:00:00 2001 From: lis2a Date: Mon, 20 Mar 2023 02:18:26 +0900 Subject: [PATCH 395/482] feat: change cookie name --- .../seasonalevents/valentine/ValentineItemData.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/seasonalevents/valentine/ValentineItemData.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/seasonalevents/valentine/ValentineItemData.scala index 5a9fd9c243..2ebf91d1ee 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/seasonalevents/valentine/ValentineItemData.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/seasonalevents/valentine/ValentineItemData.scala @@ -25,7 +25,9 @@ object ValentineItemData { s"${AQUA}ステータス変化(10分)$GRAY (期限内)" ).map(str => s"$RESET$str") - private val cookieName = s"$GOLD${BOLD}チョコチップクッキー" + // 配布のチョコチップクッキーと区別できるように + // FYI: https://github.com/GiganticMinecraft/SeichiAssist/issues/1910 + private val cookieName = s"$GOLD${BOLD}爆発したカップルの本命チョコチップクッキー" /** * チョコチップクッキーであるかどうかを返す From a8cbbe9314043be32e53cd2570843b8133809ce0 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 20 Mar 2023 13:51:35 +0900 Subject: [PATCH 396/482] =?UTF-8?q?chore:=20=E3=82=B3=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kisaragi Marine --- .../subsystems/seasonalevents/valentine/ValentineItemData.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/seasonalevents/valentine/ValentineItemData.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/seasonalevents/valentine/ValentineItemData.scala index 2ebf91d1ee..80a4411381 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/seasonalevents/valentine/ValentineItemData.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/seasonalevents/valentine/ValentineItemData.scala @@ -26,7 +26,7 @@ object ValentineItemData { ).map(str => s"$RESET$str") // 配布のチョコチップクッキーと区別できるように - // FYI: https://github.com/GiganticMinecraft/SeichiAssist/issues/1910 + // ref: https://github.com/GiganticMinecraft/SeichiAssist/issues/1910 private val cookieName = s"$GOLD${BOLD}爆発したカップルの本命チョコチップクッキー" /** From 3343e8732f42eda8a259ee79b79beb4d39c432f6 Mon Sep 17 00:00:00 2001 From: lis2a Date: Tue, 21 Mar 2023 01:37:04 +0900 Subject: [PATCH 397/482] feat: add other metarial options --- .../MebiusCommandExecutorProvider.scala | 3 +++ .../property/MebiusForcedMaterial.scala | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/bukkit/command/MebiusCommandExecutorProvider.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/bukkit/command/MebiusCommandExecutorProvider.scala index 08e5ad679e..9fad985635 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/bukkit/command/MebiusCommandExecutorProvider.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/bukkit/command/MebiusCommandExecutorProvider.scala @@ -126,6 +126,9 @@ class MebiusCommandExecutorProvider( val newMaterialName = newProperty.forcedMaterial match { case MebiusForcedMaterial.None => "ダイヤモンド" case MebiusForcedMaterial.Leather => "革" + case MebiusForcedMaterial.Gold => "金" + case MebiusForcedMaterial.Iron => "鉄" + case MebiusForcedMaterial.Chain => "チェーン" } IO.pure { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala index 965ddaf463..95fd27c489 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala @@ -16,13 +16,36 @@ sealed trait MebiusForcedMaterial { object MebiusForcedMaterial { import cats.implicits._ + // ダイヤモンド case object None extends MebiusForcedMaterial { override def allowedAt(level: MebiusLevel): Boolean = true override def next: MebiusForcedMaterial = Leather } + // 革 case object Leather extends MebiusForcedMaterial { override def allowedAt(level: MebiusLevel): Boolean = level >= MebiusLevel(30) override def next: MebiusForcedMaterial = None } + + // 金 + case object Gold extends MebiusForcedMaterial { + override def allowedAt(level: MebiusLevel): Boolean = level >= MebiusLevel(30) + + override def next: MebiusForcedMaterial = Gold + } + + // 鉄 + case object Iron extends MebiusForcedMaterial { + override def allowedAt(level: MebiusLevel): Boolean = level >= MebiusLevel(30) + + override def next: MebiusForcedMaterial = Iron + } + + // チェーン + case object Chain extends MebiusForcedMaterial { + override def allowedAt(level: MebiusLevel): Boolean = level >= MebiusLevel(30) + + override def next: MebiusForcedMaterial = Chain + } } From ab08e2e54e6d01d7c454de282db70d707feb39c9 Mon Sep 17 00:00:00 2001 From: lis2a Date: Tue, 21 Mar 2023 01:55:45 +0900 Subject: [PATCH 398/482] feat: tying of metarials --- .../mebius/bukkit/codec/BukkitMebiusItemStackCodec.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/bukkit/codec/BukkitMebiusItemStackCodec.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/bukkit/codec/BukkitMebiusItemStackCodec.scala index 3a10d9bd02..86da79e491 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/bukkit/codec/BukkitMebiusItemStackCodec.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/bukkit/codec/BukkitMebiusItemStackCodec.scala @@ -117,7 +117,10 @@ object BukkitMebiusItemStackCodec { val material = property.forcedMaterial match { case MebiusForcedMaterial.None => BukkitMebiusAppearanceMaterialCodec.appearanceMaterialAt(property.level) - case MebiusForcedMaterial.Leather => Material.LEATHER_HELMET + case MebiusForcedMaterial.Leather => Material.LEATHER_HELMET // 革のヘルメット + case MebiusForcedMaterial.Iron => Material.IRON_HELMET // 鉄のヘルメット + case MebiusForcedMaterial.Chain => Material.CHAINMAIL_HELMET // チェーンのヘルメット + case MebiusForcedMaterial.Gold => Material.GOLD_HELMET // 金のヘルメット } import scala.util.chaining._ From 0c0bb423e7e3b876b9dfc07953061b33250baa19 Mon Sep 17 00:00:00 2001 From: lis2a Date: Tue, 21 Mar 2023 03:30:47 +0900 Subject: [PATCH 399/482] fix: correct the following materials --- .../mebius/domain/property/MebiusForcedMaterial.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala index 95fd27c489..3fa36b1754 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala @@ -25,27 +25,27 @@ object MebiusForcedMaterial { // 革 case object Leather extends MebiusForcedMaterial { override def allowedAt(level: MebiusLevel): Boolean = level >= MebiusLevel(30) - override def next: MebiusForcedMaterial = None + override def next: MebiusForcedMaterial = Gold } // 金 case object Gold extends MebiusForcedMaterial { override def allowedAt(level: MebiusLevel): Boolean = level >= MebiusLevel(30) - override def next: MebiusForcedMaterial = Gold + override def next: MebiusForcedMaterial = Iron } // 鉄 case object Iron extends MebiusForcedMaterial { override def allowedAt(level: MebiusLevel): Boolean = level >= MebiusLevel(30) - override def next: MebiusForcedMaterial = Iron + override def next: MebiusForcedMaterial = Chain } // チェーン case object Chain extends MebiusForcedMaterial { override def allowedAt(level: MebiusLevel): Boolean = level >= MebiusLevel(30) - override def next: MebiusForcedMaterial = Chain + override def next: MebiusForcedMaterial = None } } From 25ab3e260571b13dd7622b8736dbf18812e5ac93 Mon Sep 17 00:00:00 2001 From: lis2a Date: Tue, 21 Mar 2023 03:32:08 +0900 Subject: [PATCH 400/482] docs: fix feature description --- .../mebius/domain/property/MebiusForcedMaterial.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala index 3fa36b1754..1775161bc7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala @@ -2,8 +2,7 @@ package com.github.unchama.seichiassist.subsystems.mebius.domain.property /** * Mebiusの材質を強制的に変更する設定。 - * - * 「30レベル以上でのみ革に戻すことができる」という機能のため。 + * 『30レベル以上で革や鉄、金、チェーンなどの素材に変更できる』機能。 */ sealed trait MebiusForcedMaterial { From 9a0a46eb0b8a7d8e86519784d9df120d9fbce910 Mon Sep 17 00:00:00 2001 From: lis2a Date: Tue, 21 Mar 2023 13:12:18 +0900 Subject: [PATCH 401/482] fix(docs): word endings --- .../mebius/domain/property/MebiusForcedMaterial.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala index 1775161bc7..f5638c7436 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala @@ -2,7 +2,7 @@ package com.github.unchama.seichiassist.subsystems.mebius.domain.property /** * Mebiusの材質を強制的に変更する設定。 - * 『30レベル以上で革や鉄、金、チェーンなどの素材に変更できる』機能。 + * 『30レベル以上で革や鉄、金、チェーンなどの素材に変更できる』機能のため。 */ sealed trait MebiusForcedMaterial { From 005577ad8e4a78680376aed563166ea35807e735 Mon Sep 17 00:00:00 2001 From: lis2a Date: Tue, 21 Mar 2023 13:16:30 +0900 Subject: [PATCH 402/482] refactor: fix intents --- .../domain/property/MebiusForcedMaterial.scala | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala index f5638c7436..0c06d6c347 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/domain/property/MebiusForcedMaterial.scala @@ -17,34 +17,47 @@ object MebiusForcedMaterial { // ダイヤモンド case object None extends MebiusForcedMaterial { + override def allowedAt(level: MebiusLevel): Boolean = true + override def next: MebiusForcedMaterial = Leather + } // 革 case object Leather extends MebiusForcedMaterial { + override def allowedAt(level: MebiusLevel): Boolean = level >= MebiusLevel(30) + override def next: MebiusForcedMaterial = Gold + } // 金 case object Gold extends MebiusForcedMaterial { + override def allowedAt(level: MebiusLevel): Boolean = level >= MebiusLevel(30) override def next: MebiusForcedMaterial = Iron + } // 鉄 case object Iron extends MebiusForcedMaterial { + override def allowedAt(level: MebiusLevel): Boolean = level >= MebiusLevel(30) override def next: MebiusForcedMaterial = Chain + } // チェーン case object Chain extends MebiusForcedMaterial { + override def allowedAt(level: MebiusLevel): Boolean = level >= MebiusLevel(30) override def next: MebiusForcedMaterial = None + } + } From 3798a33e55deb75058f7ba2ab2172f7e12b7a734 Mon Sep 17 00:00:00 2001 From: lis2a Date: Tue, 21 Mar 2023 16:19:08 +0900 Subject: [PATCH 403/482] feat: add command to get cookies --- .../subsystems/seasonalevents/commands/EventCommand.scala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/seasonalevents/commands/EventCommand.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/seasonalevents/commands/EventCommand.scala index 39a448dd55..205bd28943 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/seasonalevents/commands/EventCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/seasonalevents/commands/EventCommand.scala @@ -7,6 +7,7 @@ import com.github.unchama.seichiassist.subsystems.seasonalevents.anniversary.Ann import com.github.unchama.seichiassist.subsystems.seasonalevents.christmas.ChristmasItemData._ import com.github.unchama.seichiassist.subsystems.seasonalevents.halloween.HalloweenItemData._ import com.github.unchama.seichiassist.subsystems.seasonalevents.newyear.NewYearItemData._ +import com.github.unchama.seichiassist.subsystems.seasonalevents.valentine.ValentineItemData._ import com.github.unchama.seichiassist.util.InventoryOperations import com.github.unchama.targetedeffect.TargetedEffect._ import org.bukkit.command.TabExecutor @@ -39,6 +40,9 @@ class EventCommand(implicit ioOnMainThread: OnMinecraftServerThread[IO]) { anniversaryShovel ) + val valentineGrantEffect: TargetedEffect[Player] = + InventoryOperations.grantItemStacksEffect(droppedCookie) + val executor: TabExecutor = playerCommandBuilder .execution { context => val effect = context.args.yetToBeParsed match { @@ -46,6 +50,7 @@ class EventCommand(implicit ioOnMainThread: OnMinecraftServerThread[IO]) { case "christmas" :: _ => christsmasGrantEffect case "newyear" :: _ => newYearGrantEffect case "halloween" :: _ => halloweenGrantEffect + case "valentine" :: _ => valentineGrantEffect case _ => emptyEffect } From 9244421c52fc92203d751a9fcf62cbc4d70b212a Mon Sep 17 00:00:00 2001 From: lis2a Date: Wed, 22 Mar 2023 01:25:49 +0900 Subject: [PATCH 404/482] fix(docs): display image correctly --- CONTRIBUTING.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 579b344ff6..e3dc19dae5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -69,7 +69,10 @@ $ docker compose up --build -d 最初に、[GiganticMinecraftのページ][gm-gh-repo]を開いて、画面右上にある「fork」と書かれた枝分かれしているアイコンがあるボタンを押します。 すると「Create a new fork」と書かれた画面に移動します。 -![img.png](img.png) + + +![img.png](https://user-images.githubusercontent.com/127779256/226674317-3ad07000-a272-4f2e-905a-15e07b394bae.png) + いくつか入力欄がありますが、何も触らずにCreate forkを押します。 また画面が切り替わります。画面左上に書かれた文字が「GiganticMinecraft/SeichiAssist」ではなく、「(あなたのID)/SeichiAssist」になっていることを確認できたら次へ進みます。 From 0ec6a14919e6a5ac2f44b0a7ec2ad08f086db3e4 Mon Sep 17 00:00:00 2001 From: lis2a Date: Sat, 25 Mar 2023 01:20:56 +0900 Subject: [PATCH 405/482] refactor: remove rem removeAll cmd --- .../seichiassist/commands/RmpCommand.scala | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/commands/RmpCommand.scala b/src/main/scala/com/github/unchama/seichiassist/commands/RmpCommand.scala index b2ac950f93..fd23febada 100644 --- a/src/main/scala/com/github/unchama/seichiassist/commands/RmpCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/commands/RmpCommand.scala @@ -28,9 +28,6 @@ object RmpCommand { s"$RED/rmp remove [world名] [日数]", "全Ownerが[日数]間ログインしていないRegionを削除します(整地ワールドのみ)", "", - s"$RED/rmp removeAll [world名]", - "原則全てのRegionを削除します(整地ワールドのみ)", - "", s"$RED/rmp list [world名] [日数]", "全Ownerが[日数]間ログインしていないRegionを表示します" ) @@ -59,16 +56,6 @@ object RmpCommand { } .build() - private val removeAllExecutor = argsAndSenderConfiguredBuilder - .execution { context => - val world = context.args.parsed.head.asInstanceOf[World] - // -1を指定することで実質的に原則すべての保護を削除することになる - val days = -1 - - removeRegions(world, days) - } - .build() - private val listExecutor = argsAndSenderConfiguredBuilder .execution { context => val world = context.args.parsed.head.asInstanceOf[World] @@ -144,7 +131,7 @@ object RmpCommand { val executor: TabExecutor = BranchedExecutor( - Map("remove" -> removeExecutor, "removeAll" -> removeAllExecutor, "list" -> listExecutor), + Map("remove" -> removeExecutor, "list" -> listExecutor), whenArgInsufficient = Some(printDescriptionExecutor), whenBranchNotFound = Some(printDescriptionExecutor) ).asNonBlockingTabExecutor() From f97296f37bbf715dbad0d7edc667d1cc26fe1f94 Mon Sep 17 00:00:00 2001 From: lis2a Date: Sat, 25 Mar 2023 01:24:48 +0900 Subject: [PATCH 406/482] refactor: change error message --- .../github/unchama/seichiassist/commands/RmpCommand.scala | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/commands/RmpCommand.scala b/src/main/scala/com/github/unchama/seichiassist/commands/RmpCommand.scala index fd23febada..3481e84a88 100644 --- a/src/main/scala/com/github/unchama/seichiassist/commands/RmpCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/commands/RmpCommand.scala @@ -79,10 +79,9 @@ object RmpCommand { val isSeichiWorldWithWGRegionsOption = ManagedWorld.fromBukkitWorld(world).map(_.isSeichiWorldWithWGRegions) - val commandName = if (days == -1) "removeAll" else "remove" - isSeichiWorldWithWGRegionsOption match { - case None | Some(false) => MessageEffect(s"${commandName}コマンドは保護をかけて整地する整地ワールドでのみ使用出来ます") + // CHANGED: /rmp removeAll 削除時のエラーメッセージではすこし不親切だったので追加 + case None | Some(false) => MessageEffect(s"第一整地以外の保護をかけて整地する整地ワールドでのみ使用出来ます") case Some(true) => getOldRegionsIn(world, days).map { removalTargets => removalTargets.foreach { target => From 2908cd928bb0dbf2ebfc306cefc0233081f9e8df Mon Sep 17 00:00:00 2001 From: lis2a Date: Sat, 25 Mar 2023 02:54:32 +0900 Subject: [PATCH 407/482] fix(docs): remove annotation comment --- .../com/github/unchama/seichiassist/commands/RmpCommand.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/commands/RmpCommand.scala b/src/main/scala/com/github/unchama/seichiassist/commands/RmpCommand.scala index 3481e84a88..1c5cf26b84 100644 --- a/src/main/scala/com/github/unchama/seichiassist/commands/RmpCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/commands/RmpCommand.scala @@ -80,7 +80,6 @@ object RmpCommand { ManagedWorld.fromBukkitWorld(world).map(_.isSeichiWorldWithWGRegions) isSeichiWorldWithWGRegionsOption match { - // CHANGED: /rmp removeAll 削除時のエラーメッセージではすこし不親切だったので追加 case None | Some(false) => MessageEffect(s"第一整地以外の保護をかけて整地する整地ワールドでのみ使用出来ます") case Some(true) => getOldRegionsIn(world, days).map { removalTargets => From 156024815039cc72bd61935be814cdd4163c6f3b Mon Sep 17 00:00:00 2001 From: lis2a Date: Sat, 25 Mar 2023 22:55:57 +0900 Subject: [PATCH 408/482] refactor: change arabic numeral --- .../com/github/unchama/seichiassist/commands/RmpCommand.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/commands/RmpCommand.scala b/src/main/scala/com/github/unchama/seichiassist/commands/RmpCommand.scala index 1c5cf26b84..05d57d7de7 100644 --- a/src/main/scala/com/github/unchama/seichiassist/commands/RmpCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/commands/RmpCommand.scala @@ -80,7 +80,7 @@ object RmpCommand { ManagedWorld.fromBukkitWorld(world).map(_.isSeichiWorldWithWGRegions) isSeichiWorldWithWGRegionsOption match { - case None | Some(false) => MessageEffect(s"第一整地以外の保護をかけて整地する整地ワールドでのみ使用出来ます") + case None | Some(false) => MessageEffect(s"第1整地以外の保護をかけて整地する整地ワールドでのみ使用出来ます") case Some(true) => getOldRegionsIn(world, days).map { removalTargets => removalTargets.foreach { target => From 67f3dbe6a200e8efc65cd9093f4c92d89d90d641 Mon Sep 17 00:00:00 2001 From: Kisaragi Marine Date: Sat, 8 Apr 2023 21:05:31 +0900 Subject: [PATCH 409/482] =?UTF-8?q?fix:=20=E4=B8=8A=E4=BB=98=E3=81=8D?= =?UTF-8?q?=E3=83=8F=E3=83=BC=E3=83=95=E3=83=96=E3=83=AD=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=82=92=E7=A0=B4=E5=A3=8A=E3=81=97=E3=81=9F=E9=9A=9B=E3=80=81?= =?UTF-8?q?=E4=B8=8B=E4=BB=98=E3=81=8D=E3=83=8F=E3=83=BC=E3=83=95=E3=83=96?= =?UTF-8?q?=E3=83=AD=E3=83=83=E3=82=AF=E3=81=A8=E3=81=97=E3=81=A6=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kisaragi Marine --- .../scala/com/github/unchama/seichiassist/util/BreakUtil.scala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala index 3f62687dfd..f0308a7d71 100644 --- a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala +++ b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala @@ -299,6 +299,9 @@ object BreakUtil { Some(BlockBreakResult.SpawnSilverFish(blockLocation)) case Material.LOG | Material.LOG_2 => Some(BlockBreakResult.ItemDrop(new ItemStack(blockMaterial, 1, b_tree.toShort))) + case Material.WOOD_SLAB | Material.STONE_SLAB | Material.STONE_SLAB2 if (blockDataLeast4Bits & 8) != 0 => + // 上付きハーフブロックをそのままドロップするとmissing textureとして描画されるため、下付きの扱いとする + Some(BlockBreakResult.ItemDrop(new ItemStack(blockMaterial, 1, (blockDataLeast4Bits & 7).toShort))) case _ => Some( BlockBreakResult From 84960a7f6996a3705e07fdcbfdf517efa3d3da6e Mon Sep 17 00:00:00 2001 From: Kisaragi Marine Date: Sat, 8 Apr 2023 21:37:21 +0900 Subject: [PATCH 410/482] =?UTF-8?q?chore:=20=E3=82=B3=E3=83=B3=E3=83=91?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E3=82=A8=E3=83=A9=E3=83=BC=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kisaragi Marine --- .../com/github/unchama/seichiassist/util/BreakUtil.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala index f0308a7d71..c10be5ab3c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala +++ b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala @@ -299,9 +299,9 @@ object BreakUtil { Some(BlockBreakResult.SpawnSilverFish(blockLocation)) case Material.LOG | Material.LOG_2 => Some(BlockBreakResult.ItemDrop(new ItemStack(blockMaterial, 1, b_tree.toShort))) - case Material.WOOD_SLAB | Material.STONE_SLAB | Material.STONE_SLAB2 if (blockDataLeast4Bits & 8) != 0 => + case Material.WOOD_STEP | Material.STEP | Material.STONE_SLAB2 if (blockDataLeast4Bits & 8) != 0 => // 上付きハーフブロックをそのままドロップするとmissing textureとして描画されるため、下付きの扱いとする - Some(BlockBreakResult.ItemDrop(new ItemStack(blockMaterial, 1, (blockDataLeast4Bits & 7).toShort))) + Some(BlockBreakResult.ItemDrop(new ItemStack(blockMaterial, 1, (blockDataLeast4Bits & 7).toShort))) case _ => Some( BlockBreakResult From 4cd7e230f406e0ce4aec3827759825e9e1e3f6af Mon Sep 17 00:00:00 2001 From: lis2a Date: Sun, 9 Apr 2023 18:00:24 +0900 Subject: [PATCH 411/482] fix: new material byte --- .../mebius/bukkit/codec/BukkitMebiusItemStackCodec.scala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/bukkit/codec/BukkitMebiusItemStackCodec.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/bukkit/codec/BukkitMebiusItemStackCodec.scala index 86da79e491..226a5afa8e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/bukkit/codec/BukkitMebiusItemStackCodec.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/bukkit/codec/BukkitMebiusItemStackCodec.scala @@ -56,12 +56,18 @@ object BukkitMebiusItemStackCodec { def encodeForcedMaterial(forcedMaterial: MebiusForcedMaterial): Byte = forcedMaterial match { case MebiusForcedMaterial.None => 0 case MebiusForcedMaterial.Leather => 1 + case MebiusForcedMaterial.Iron => 2 + case MebiusForcedMaterial.Chain => 3 + case MebiusForcedMaterial.Gold => 4 } def decodeForcedMaterial(forcedMaterialByte: Byte): MebiusForcedMaterial = forcedMaterialByte match { case 0 => MebiusForcedMaterial.None case 1 => MebiusForcedMaterial.Leather + case 2 => MebiusForcedMaterial.Iron + case 3 => MebiusForcedMaterial.Chain + case 4 => MebiusForcedMaterial.Gold case _ => MebiusForcedMaterial.None } From d6b304e9cf08acb69a6e645d9e010748b70c2dcf Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 10 Apr 2023 17:35:24 +0900 Subject: [PATCH 412/482] =?UTF-8?q?fix:=20=E6=8A=95=E7=A5=A8=E7=89=B9?= =?UTF-8?q?=E5=85=B8=E3=81=8C=E5=8F=97=E3=81=91=E5=8F=96=E3=82=8C=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=81=A8=E3=81=8D=E3=81=AB=E3=82=820=E7=A5=A8?= =?UTF-8?q?=E5=8F=97=E3=81=91=E5=8F=96=E3=82=8A=E3=81=BE=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=81=A8=E3=81=AA=E3=82=89=E3=81=AA=E3=81=84=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/menus/VoteMenu.scala | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 829b904c78..b0f1ec280e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -115,6 +115,7 @@ object VoteMenu extends Menu { benefits <- voteAPI.receivedVoteBenefits(uuid) voteCounter <- voteAPI.count(uuid) effectPoint <- voteAPI.effectPoints(player) + notReceivedBenefits = voteCounter.value - benefits.value } yield { Button( new IconItemStackBuilder(Material.DIAMOND) @@ -124,7 +125,7 @@ object VoteMenu extends Menu { s"$RESET${GRAY}投票特典を受け取るには", s"$RESET${GRAY}投票ページで投票した後", s"$RESET${AQUA}特典受け取り済み投票回数: ${benefits.value}", - s"$RESET${AQUA}特典未受け取り投票係数: ${voteCounter.value - benefits.value}", + s"$RESET${AQUA}特典未受け取り投票係数: $notReceivedBenefits", s"$RESET${AQUA}所有pt: ${effectPoint.value}" ) ) @@ -133,9 +134,11 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( DeferredEffect(IO(voteAPI.receiveVoteBenefits)), - MessageEffect( - s"${GOLD}投票特典$WHITE(${voteCounter.value - benefits.value}票分)を受け取りました" - ) + MessageEffect(if (notReceivedBenefits == 0) { + s"$YELLOW${BOLD}投票特典はすべて受け取り済みのようです" + } else { + s"${GOLD}投票特典$WHITE(${notReceivedBenefits}票分)を受け取りました" + }) ) } ) From c1305651dd31bf6b2184ef4bb6cb43864849b193 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 10 Apr 2023 18:06:05 +0900 Subject: [PATCH 413/482] =?UTF-8?q?fix:=20=E6=8A=95=E7=A5=A8=E7=89=B9?= =?UTF-8?q?=E5=85=B8=E3=82=92=E5=8F=97=E3=81=91=E5=8F=96=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=82=82=E3=80=81=E9=80=A3=E7=B6=9A=E3=81=A7=E3=83=9C=E3=82=BF?= =?UTF-8?q?=E3=83=B3=E3=82=92=E6=8A=BC=E3=81=99=E3=81=A8=E3=83=A1=E3=83=83?= =?UTF-8?q?=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=8C=E5=A4=89=E3=82=8F=E3=82=89?= =?UTF-8?q?=E3=81=AA=E3=81=84=E4=B8=8D=E5=85=B7=E5=90=88=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/menus/VoteMenu.scala | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index b0f1ec280e..442e370431 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -109,7 +109,7 @@ object VoteMenu extends Menu { private implicit val ioCE: ConcurrentEffect[IO] = IO.ioConcurrentEffect(PluginExecutionContexts.asyncShift) - val receiveVoteBenefitsButton: IO[Button] = { + val receiveVoteBenefitsButton: IO[Button] = RecomputedButton { val uuid = player.getUniqueId for { benefits <- voteAPI.receivedVoteBenefits(uuid) @@ -132,14 +132,14 @@ object VoteMenu extends Menu { .enchanted() .build(), LeftClickButtonEffect { - SequentialEffect( - DeferredEffect(IO(voteAPI.receiveVoteBenefits)), - MessageEffect(if (notReceivedBenefits == 0) { - s"$YELLOW${BOLD}投票特典はすべて受け取り済みのようです" - } else { - s"${GOLD}投票特典$WHITE(${notReceivedBenefits}票分)を受け取りました" - }) - ) + if (notReceivedBenefits == 0) { + MessageEffect(s"$YELLOW${BOLD}投票特典はすべて受け取り済みのようです") + } else { + SequentialEffect( + DeferredEffect(IO(voteAPI.receiveVoteBenefits)), + MessageEffect(s"${GOLD}投票特典$WHITE(${notReceivedBenefits}票分)を受け取りました") + ) + } } ) } From e406df479cc98a9b6579631f60e4529684349b63 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 10 Apr 2023 22:42:23 +0900 Subject: [PATCH 414/482] chore: apply scalafmt --- .../com/github/unchama/seichiassist/util/BreakUtil.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala index c10be5ab3c..8368a43bd6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala +++ b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala @@ -299,9 +299,13 @@ object BreakUtil { Some(BlockBreakResult.SpawnSilverFish(blockLocation)) case Material.LOG | Material.LOG_2 => Some(BlockBreakResult.ItemDrop(new ItemStack(blockMaterial, 1, b_tree.toShort))) - case Material.WOOD_STEP | Material.STEP | Material.STONE_SLAB2 if (blockDataLeast4Bits & 8) != 0 => + case Material.WOOD_STEP | Material.STEP | Material.STONE_SLAB2 + if (blockDataLeast4Bits & 8) != 0 => // 上付きハーフブロックをそのままドロップするとmissing textureとして描画されるため、下付きの扱いとする - Some(BlockBreakResult.ItemDrop(new ItemStack(blockMaterial, 1, (blockDataLeast4Bits & 7).toShort))) + Some( + BlockBreakResult + .ItemDrop(new ItemStack(blockMaterial, 1, (blockDataLeast4Bits & 7).toShort)) + ) case _ => Some( BlockBreakResult From 0bd1bb4dba318e5c7beccb7d842a8e7ecb485f14 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 10 Apr 2023 23:17:24 +0900 Subject: [PATCH 415/482] =?UTF-8?q?fix:=20=E5=A6=96=E7=B2=BE=E3=81=8C?= =?UTF-8?q?=E3=81=97=E3=82=83=E3=81=B9=E3=82=89=E3=81=AA=E3=81=84=E4=B8=8D?= =?UTF-8?q?=E5=85=B7=E5=90=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/gateway/BukkitFairySpeechGateway.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala index 83c85fe165..c38aefa18c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala @@ -12,9 +12,10 @@ import org.bukkit.entity.Player class BukkitFairySpeechGateway[F[_]: Sync](player: Player) extends FairySpeechGateway[F] { override def sendMessage(fairyMessages: Seq[FairyMessage]): F[Unit] = { - val defaultFairyMessage = f"$AQUA$BOLD<マナ妖精>$RESET%s" - MessageEffectF[F](fairyMessages.map(input => defaultFairyMessage.format(input)).toList) - .run(player) + val defaultFairyMessage = s"$AQUA$BOLD<マナ妖精>$RESET%s" + MessageEffectF[F]( + fairyMessages.map(input => defaultFairyMessage.format(input.message)).toList + ).run(player) } override def playSpeechSound: F[Unit] = From 76f2771c0cb540ade366583b5c64b49a634d17d7 Mon Sep 17 00:00:00 2001 From: lis2a Date: Wed, 12 Apr 2023 00:18:41 +0900 Subject: [PATCH 416/482] feat: add first player title --- .../seichiassist/listener/PlayerJoinListener.scala | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/listener/PlayerJoinListener.scala b/src/main/scala/com/github/unchama/seichiassist/listener/PlayerJoinListener.scala index f585e8b4dd..45afbdc5ad 100644 --- a/src/main/scala/com/github/unchama/seichiassist/listener/PlayerJoinListener.scala +++ b/src/main/scala/com/github/unchama/seichiassist/listener/PlayerJoinListener.scala @@ -104,6 +104,19 @@ class PlayerJoinListener extends Listener { ) SendSoundEffect.sendEverySound(Sound.ENTITY_PLAYER_LEVELUP, 1f, 1f) + // 同時に【はじめての方へ】ページに誘導したほうがただWebサイトに誘導するよりまだ可能性がありそう + // https://github.com/GiganticMinecraft/SeichiAssist/issues/1939 + player.sendTitle( + s"${YELLOW}ようこそ! ギガンティック☆整地鯖へ!", + s"${LIGHT_PURPLE}まず初めに公式サイト【はじめての方へ】ページを確認してください", + 10, + 20 * 10, // タイトルの表示時間は10秒 + 10 + ) + player.sendMessage( + s"$YELLOW【はじめての方へ】ページ→ $YELLOW${UNDERLINE}https://www.seichi.network/helloworld" + ) + // ルール熟読をタイトルとチャットで迫る // サブタイトルと分ける理由はGUIサイズによって見切れる可能性があるため player.sendTitle( From 0fc26b35d7591b45b67dad08d81c71c2f3f6ff6e Mon Sep 17 00:00:00 2001 From: lis2a Date: Wed, 12 Apr 2023 00:53:04 +0900 Subject: [PATCH 417/482] docs: add seichi world infomation --- CONTRIBUTING.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e3dc19dae5..e9c423dff1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -166,11 +166,22 @@ DockerマシンのIPアドレス(Linux等なら`localhost`)を`DOCKER_IP`とし `docker`により各サービスが起動したら、マルチプレイヤーのメニューで`DOCKER_IP`へと接続することができます。 また、`DOCKER_IP:8080`へとWebブラウザでアクセスすることで、phpMyAdminを介してデータベースを操作することができます。 -`/op`などのコマンドを実行するためにSpigotのコンソールにアクセスする必要がある場合、 -`spigota`または`spigotb`へのコンテナ名とともに `docker attach [CONTAINER_NAME]` を実行してください。 -コンテナ名は `docker ps` を実行すると `seichiassist_spigotb_1` のような形式で表示されます。 +##### コンソールにアクセスする + +自分のアカウントに管理者権限(OP)を与える時など、Spigotのコンソールにアクセスする場合は、 +`spigota` または `spigotb` へのコンテナにアタッチする必要があります。 + +アタッチするには `docker attach [CONTAINER_NAME]` を実行します。 +コンテナを指定する際に使用するIDは `docker ps` を実行すると `seichiassist_spigotb_1` のような形式で表示されます。 + コンソールからは CtrlキーとCキーを同時押しすることで出ることができます。サーバーは停止されません。 +##### 整地ワールドの作成 + +初めてデバッグ環境のSpigotに接続した際にスポーンするワールドは整地ワールドではないため、そのままブロックを破壊しても整地Lv.は上昇しません。 + +整地ワールドを作成する場合、OP権限を付与したプレイヤーかアタッチしたシェルから `mvcreate world_SW normal` を実行します。 + ### 反映する さあ、いよいよ反映の時間がやってきました。 まずは手元で`sbt scalafixAll`をします。次に`sbt scalafmtAll`をします。 From 9d71220a9f1a75697183c9c3fa853dc27802a29a Mon Sep 17 00:00:00 2001 From: lis2a Date: Sat, 15 Apr 2023 22:41:24 +0900 Subject: [PATCH 418/482] docs(fix): fix context --- CONTRIBUTING.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e9c423dff1..7360cdddd0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -169,7 +169,7 @@ DockerマシンのIPアドレス(Linux等なら`localhost`)を`DOCKER_IP`とし ##### コンソールにアクセスする 自分のアカウントに管理者権限(OP)を与える時など、Spigotのコンソールにアクセスする場合は、 -`spigota` または `spigotb` へのコンテナにアタッチする必要があります。 +`spigota` または `spigotb` のコンテナにアタッチする必要があります。 アタッチするには `docker attach [CONTAINER_NAME]` を実行します。 コンテナを指定する際に使用するIDは `docker ps` を実行すると `seichiassist_spigotb_1` のような形式で表示されます。 @@ -178,9 +178,11 @@ DockerマシンのIPアドレス(Linux等なら`localhost`)を`DOCKER_IP`とし ##### 整地ワールドの作成 -初めてデバッグ環境のSpigotに接続した際にスポーンするワールドは整地ワールドではないため、そのままブロックを破壊しても整地Lv.は上昇しません。 +初めてデバッグ環境のSpigotに接続した際にスポーンするワールドは整地ワールドではないため、そのままブロックを破壊しても整地レベルは上昇しません。 -整地ワールドを作成する場合、OP権限を付与したプレイヤーかアタッチしたシェルから `mvcreate world_SW normal` を実行します。 +整地ワールドを作成する場合、OP権限を付与したプレイヤーかアタッチしたコンソールから `mvcreate world_SW normal` を実行します。 + +整地ワールドへ行くには、コマンドで `mvtp world_SW` を実行します。 ### 反映する さあ、いよいよ反映の時間がやってきました。 From f6f88471aafc36d332700c018cfdc90c29e1d46b Mon Sep 17 00:00:00 2001 From: lis2a Date: Sat, 15 Apr 2023 22:43:59 +0900 Subject: [PATCH 419/482] refactor: remove title --- .../seichiassist/listener/PlayerJoinListener.scala | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/listener/PlayerJoinListener.scala b/src/main/scala/com/github/unchama/seichiassist/listener/PlayerJoinListener.scala index 45afbdc5ad..765ac5277f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/listener/PlayerJoinListener.scala +++ b/src/main/scala/com/github/unchama/seichiassist/listener/PlayerJoinListener.scala @@ -117,17 +117,6 @@ class PlayerJoinListener extends Listener { s"$YELLOW【はじめての方へ】ページ→ $YELLOW${UNDERLINE}https://www.seichi.network/helloworld" ) - // ルール熟読をタイトルとチャットで迫る - // サブタイトルと分ける理由はGUIサイズによって見切れる可能性があるため - player.sendTitle( - s"${YELLOW}ルールは確認されましたか?", - s"${LIGHT_PURPLE}公式サイトで確認してください", - 10, - 20 * 10, // タイトルの表示時間は10秒 - 10 - ) - player.sendMessage(s"${YELLOW}ルール→ $YELLOW${UNDERLINE}https://www.seichi.network/rule") - import scala.util.chaining._ // 初見プレイヤーに木の棒、エリトラ、ピッケルを配布 From 8a0a55de6dc206e9c28c903a6888f40baa8d12c0 Mon Sep 17 00:00:00 2001 From: lis Date: Sat, 15 Apr 2023 23:53:17 +0900 Subject: [PATCH 420/482] Update CONTRIBUTING.md Co-authored-by: Kisaragi <48310258+KisaragiEffective@users.noreply.github.com> --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7360cdddd0..852ede135d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -172,7 +172,7 @@ DockerマシンのIPアドレス(Linux等なら`localhost`)を`DOCKER_IP`とし `spigota` または `spigotb` のコンテナにアタッチする必要があります。 アタッチするには `docker attach [CONTAINER_NAME]` を実行します。 -コンテナを指定する際に使用するIDは `docker ps` を実行すると `seichiassist_spigotb_1` のような形式で表示されます。 +コンテナを指定する際に使用するIDはコマンドプロンプトで `docker ps` を実行すると `seichiassist_spigotb_1` のような形式で表示されます。 コンソールからは CtrlキーとCキーを同時押しすることで出ることができます。サーバーは停止されません。 From 0b519bda88e3914b628d4b9f97558752b7a42d9c Mon Sep 17 00:00:00 2001 From: lis Date: Sat, 15 Apr 2023 23:53:23 +0900 Subject: [PATCH 421/482] Update CONTRIBUTING.md Co-authored-by: Kisaragi <48310258+KisaragiEffective@users.noreply.github.com> --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 852ede135d..63076deff7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -180,7 +180,7 @@ DockerマシンのIPアドレス(Linux等なら`localhost`)を`DOCKER_IP`とし 初めてデバッグ環境のSpigotに接続した際にスポーンするワールドは整地ワールドではないため、そのままブロックを破壊しても整地レベルは上昇しません。 -整地ワールドを作成する場合、OP権限を付与したプレイヤーかアタッチしたコンソールから `mvcreate world_SW normal` を実行します。 +整地ワールドを作成する場合、OP権限を付与したプレイヤーかアタッチしたコンソールからコマンドで `mvcreate world_SW normal` を実行します。 整地ワールドへ行くには、コマンドで `mvtp world_SW` を実行します。 From 65e67997a2b7cca7cc2359f8e79678e770634d75 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 16 Apr 2023 01:00:17 +0900 Subject: [PATCH 422/482] =?UTF-8?q?refactor:=20=E5=A6=96=E7=B2=BE=E3=81=AE?= =?UTF-8?q?subsystem=E3=81=8B=E3=82=89speech=E9=83=A8=E5=88=86=E3=82=92?= =?UTF-8?q?=E5=88=A5=E3=81=AEsubsystem=E3=81=A8=E3=81=97=E3=81=A6=E5=88=87?= =?UTF-8?q?=E3=82=8A=E5=87=BA=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 10 ++--- .../SpeechServiceRepositoryDefinitions.scala | 4 +- .../fairy/bukkit/BukkitFairySpeech.scala | 2 +- .../fairyspeech/FairySpeechAPI.scala | 21 +++++++++++ .../vote/subsystems/fairyspeech/System.scala | 37 +++++++++++++++++++ .../bukkit}/BukkitFairySpeechGateway.scala | 4 +- .../domain}/FairySpeechGateway.scala | 2 +- .../service/FairySpeechService.scala | 4 +- 8 files changed, 70 insertions(+), 14 deletions(-) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/FairySpeechAPI.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/{fairy/bukkit/gateway => fairyspeech/bukkit}/BukkitFairySpeechGateway.scala (93%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/{fairy/domain/speech => fairyspeech/domain}/FairySpeechGateway.scala (95%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/{fairy => fairyspeech}/service/FairySpeechService.scala (89%) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 85af0797ff..9aebfce6a3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -21,7 +21,6 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applicat SpeechServiceRepositoryDefinitions } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway.BukkitFairySpeechGateway import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{ @@ -29,17 +28,16 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{ BukkitFairySummonRequest } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.{ - FairySpeech, - FairySpeechGateway -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ FairyPersistence, FairySpawnRequestErrorOrSpawn, FairySummonRequest } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.bukkit.BukkitFairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service.FairySpeechService import org.bukkit.entity.Player import org.bukkit.event.Listener import org.bukkit.inventory.ItemStack diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala index 98cd7dc886..520925c817 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala @@ -4,8 +4,8 @@ import cats.Applicative import cats.effect.Sync import com.github.unchama.datarepository.template.finalization.RepositoryFinalization import com.github.unchama.datarepository.template.initialization.TwoPhasedRepositoryInitialization -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeechGateway -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service.FairySpeechService object SpeechServiceRepositoryDefinitions { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index ccdf5e485f..c8311b5057 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -7,7 +7,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.F import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.FairyMessageTable import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service.FairySpeechService +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service.FairySpeechService import io.chrisdavenport.cats.effect.time.JavaTime import org.bukkit.entity.Player diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/FairySpeechAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/FairySpeechAPI.scala new file mode 100644 index 0000000000..dfda861bbc --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/FairySpeechAPI.scala @@ -0,0 +1,21 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech + +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage + +import scala.collection.immutable.Seq + +trait FairySpeechAPI[F[_], Player] { + + /** + * @return `player`に対して`messages`を妖精が喋る作用 + */ + def speech(player: Player, messages: Seq[FairyMessage]): F[Unit] + +} + +object FairySpeechAPI { + + def apply[F[_], Player](implicit ev: FairySpeechAPI[F, Player]): FairySpeechAPI[F, Player] = + ev + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala new file mode 100644 index 0000000000..cd20cfd4e6 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala @@ -0,0 +1,37 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech + +import cats.effect.Sync +import com.github.unchama.seichiassist.meta.subsystem.Subsystem +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.bukkit.BukkitFairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service.FairySpeechService +import org.bukkit.entity.Player + +trait System[F[_], Player] extends Subsystem[F] { + + val api: FairySpeechAPI[F, Player] + +} + +object System { + + def wired[F[_]: Sync](): System[F, Player] = { + val speechGateway: Player => FairySpeechGateway[F] = player => + new BukkitFairySpeechGateway[F](player) + val speechService: Player => FairySpeechService[F] = player => + new FairySpeechService[F](speechGateway(player)) + + new System[F, Player] { + override val api: FairySpeechAPI[F, Player] = new FairySpeechAPI[F, Player] { + + override def speech(player: Player, messages: Seq[FairyMessage]): F[Unit] = { + // todo: fairyPlaySoundをインフラ層から取得するようにする + speechService(player).makeSpeech(messages, true) + } + + } + } + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/bukkit/BukkitFairySpeechGateway.scala similarity index 93% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/bukkit/BukkitFairySpeechGateway.scala index c38aefa18c..0b3ae14c23 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/gateway/BukkitFairySpeechGateway.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/bukkit/BukkitFairySpeechGateway.scala @@ -1,8 +1,8 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.gateway +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.bukkit import cats.effect.Sync import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeechGateway import com.github.unchama.targetedeffect.commandsender.MessageEffectF import com.github.unchama.targetedeffect.player.FocusedSoundEffectF import org.bukkit.ChatColor.{AQUA, BOLD, RESET} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeechGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/domain/FairySpeechGateway.scala similarity index 95% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeechGateway.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/domain/FairySpeechGateway.scala index b44da96c30..4b960ef9ab 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeechGateway.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/domain/FairySpeechGateway.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/service/FairySpeechService.scala similarity index 89% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/service/FairySpeechService.scala index 882c50b768..927e44989c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/service/FairySpeechService.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/service/FairySpeechService.scala @@ -1,9 +1,9 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.service +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service import cats.effect.Sync import cats.implicits._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeechGateway class FairySpeechService[F[_]: Sync](gateway: FairySpeechGateway[F]) { From 51d4e0ae321205acbaf08da0a0a21ed3aab4d808 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 16 Apr 2023 16:08:56 +0900 Subject: [PATCH 423/482] =?UTF-8?q?refactor:=20FairySpeechPersistence?= =?UTF-8?q?=E3=82=92=E4=BD=9C=E6=88=90=E3=81=97=E3=81=A6Speech=E3=81=AB?= =?UTF-8?q?=E9=96=A2=E3=81=99=E3=82=8B=E6=B0=B8=E7=B6=9A=E5=8C=96=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92=E8=A8=98=E8=BC=89=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/FairySpeechPersistence.scala | 17 +++++++++++ .../JdbcFairySpeechPersistence.scala | 30 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/domain/FairySpeechPersistence.scala create mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/infrastructure/JdbcFairySpeechPersistence.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/domain/FairySpeechPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/domain/FairySpeechPersistence.scala new file mode 100644 index 0000000000..af026b9be1 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/domain/FairySpeechPersistence.scala @@ -0,0 +1,17 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain + +import java.util.UUID + +trait FairySpeechPersistence[F[_]] { + + /** + * @return 妖精が喋るときに音を再生するかを`playOnSpeech`に変更する作用 + */ + def setPlaySoundOnSpeech(player: UUID, playOnSpeech: Boolean): F[Unit] + + /** + * @return 妖精が喋ったときに音を再生するか取得する作用 + */ + def playSoundOnFairySpeech(player: UUID): F[Boolean] + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/infrastructure/JdbcFairySpeechPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/infrastructure/JdbcFairySpeechPersistence.scala new file mode 100644 index 0000000000..d73acc49c7 --- /dev/null +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/infrastructure/JdbcFairySpeechPersistence.scala @@ -0,0 +1,30 @@ +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.infrastructure + +import cats.effect.Sync +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeechPersistence +import scalikejdbc.{DB, scalikejdbcSQLInterpolationImplicitDef} + +import java.util.UUID + +class JdbcFairySpeechPersistence[F[_]: Sync] extends FairySpeechPersistence[F] { + + override def setPlaySoundOnSpeech(player: UUID, playOnSpeech: Boolean): F[Unit] = + Sync[F].delay { + DB.localTx { implicit session => + sql"UPDATE vote_fairy SET is_play_fairy_speech_sound = $playOnSpeech WHERE uuid = ${player.toString}" + .execute() + .apply() + } + } + + override def playSoundOnFairySpeech(player: UUID): F[Boolean] = Sync[F].delay { + DB.readOnly { implicit session => + sql"SELECT is_play_fairy_speech_sound FROM vote_fairy WHERE uuid=${player.toString}" + .map(_.boolean("is_play_fairy_speech_sound")) + .single() + .apply() + .get + } + } + +} From 0cd74162ec2e3c8552974f6e5e0f7351ccbe86da Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 16 Apr 2023 16:13:00 +0900 Subject: [PATCH 424/482] =?UTF-8?q?feat:=20=E9=9F=B3=E3=82=92=E5=86=8D?= =?UTF-8?q?=E7=94=9F=E3=81=99=E3=82=8B=E3=81=8B=E3=81=A9=E3=81=86=E3=81=8B?= =?UTF-8?q?=E3=82=92=E6=B0=B8=E7=B6=9A=E5=8C=96=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=81=8B=E3=82=89=E5=8F=96=E5=BE=97=E3=81=A7=E3=81=8D=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairyspeech/System.scala | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala index cd20cfd4e6..752b835692 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala @@ -4,7 +4,11 @@ import cats.effect.Sync import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.bukkit.BukkitFairySpeechGateway -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.{ + FairySpeechGateway, + FairySpeechPersistence +} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.infrastructure.JdbcFairySpeechPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service.FairySpeechService import org.bukkit.entity.Player @@ -16,19 +20,22 @@ trait System[F[_], Player] extends Subsystem[F] { object System { + import cats.implicits._ + def wired[F[_]: Sync](): System[F, Player] = { val speechGateway: Player => FairySpeechGateway[F] = player => new BukkitFairySpeechGateway[F](player) val speechService: Player => FairySpeechService[F] = player => new FairySpeechService[F](speechGateway(player)) + val persistence: FairySpeechPersistence[F] = new JdbcFairySpeechPersistence[F] new System[F, Player] { override val api: FairySpeechAPI[F, Player] = new FairySpeechAPI[F, Player] { - override def speech(player: Player, messages: Seq[FairyMessage]): F[Unit] = { - // todo: fairyPlaySoundをインフラ層から取得するようにする - speechService(player).makeSpeech(messages, true) - } + override def speech(player: Player, messages: Seq[FairyMessage]): F[Unit] = for { + fairyPlaySound <- persistence.playSoundOnFairySpeech(player.getUniqueId) + _ <- speechService(player).makeSpeech(messages, fairyPlaySound) + } yield () } } From e5d1ddb69aa0fc78843195547144f755ee20e478 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 16 Apr 2023 16:26:54 +0900 Subject: [PATCH 425/482] =?UTF-8?q?feat:=20=E5=A6=96=E7=B2=BE=E3=81=8C?= =?UTF-8?q?=E5=96=8B=E3=81=A3=E3=81=9F=E9=9A=9B=E3=81=AB=E9=9F=B3=E3=82=92?= =?UTF-8?q?=E5=86=8D=E7=94=9F=E3=81=99=E3=82=8B=E3=81=8B=E3=81=A9=E3=81=86?= =?UTF-8?q?=E3=81=8B=E3=82=92=E8=A8=AD=E5=AE=9A=E3=83=BB=E5=8F=96=E5=BE=97?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E9=96=A2=E6=95=B0=E3=82=92=E5=AE=9F?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairyspeech/FairySpeechAPI.scala | 11 +++++++++++ .../vote/subsystems/fairyspeech/System.scala | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/FairySpeechAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/FairySpeechAPI.scala index dfda861bbc..1e168c19cf 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/FairySpeechAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/FairySpeechAPI.scala @@ -2,6 +2,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage +import java.util.UUID import scala.collection.immutable.Seq trait FairySpeechAPI[F[_], Player] { @@ -11,6 +12,16 @@ trait FairySpeechAPI[F[_], Player] { */ def speech(player: Player, messages: Seq[FairyMessage]): F[Unit] + /** + * @return `player`に対して妖精が喋った際に音を再生するかを`playOnSpeech`に設定する作用 + */ + def setPlaySoundOnSpeech(player: UUID, playOnSpeech: Boolean): F[Unit] + + /** + * @return `player`に対して妖精が喋った際に音を再生するかどうかを取得する作用 + */ + def playSoundOnSpeech(player: UUID): F[Boolean] + } object FairySpeechAPI { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala index 752b835692..0e0947464b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala @@ -12,6 +12,8 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.in import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service.FairySpeechService import org.bukkit.entity.Player +import java.util.UUID + trait System[F[_], Player] extends Subsystem[F] { val api: FairySpeechAPI[F, Player] @@ -37,6 +39,11 @@ object System { _ <- speechService(player).makeSpeech(messages, fairyPlaySound) } yield () + override def setPlaySoundOnSpeech(player: UUID, playOnSpeech: Boolean): F[Unit] = + persistence.setPlaySoundOnSpeech(player, playOnSpeech) + + override def playSoundOnSpeech(player: UUID): F[Boolean] = + persistence.playSoundOnFairySpeech(player) } } } From f76dbeac6d06cc1fd09d1996762e753804dcebff Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 16 Apr 2023 16:37:11 +0900 Subject: [PATCH 426/482] =?UTF-8?q?feat:=20fairySpeechSystem=E3=82=92Seich?= =?UTF-8?q?iAssist=E3=81=AB=E8=AA=8D=E8=AD=98=E3=81=95=E3=81=9B=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/seichiassist/SeichiAssist.scala | 7 ++++++- .../subsystems/vote/subsystems/fairyspeech/System.scala | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 5a36ed7511..63628a2b30 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -469,6 +469,10 @@ class SeichiAssist extends JavaPlugin() { subsystems.vote.subsystems.fairy.System.wired.unsafeRunSync() } + private lazy val fairySpeechSystem + : subsystems.vote.subsystems.fairyspeech.System[IO, Player] = + subsystems.vote.subsystems.fairyspeech.System.wired[IO] + /* TODO: mineStackSystemは本来privateであるべきだが、mineStackにアイテムを格納するAPIが現状の BreakUtilの実装から呼び出されている都合上やむを得ずpublicになっている。*/ lazy val mineStackSystem: subsystems.minestack.System[IO, Player, ItemStack] = @@ -508,7 +512,8 @@ class SeichiAssist extends JavaPlugin() { sharedInventorySystem, mineStackSystem, consumeGachaTicketSystem, - openirontrapdoor.System.wired + openirontrapdoor.System.wired, + fairySpeechSystem ) private lazy val buildAssist: BuildAssist = { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala index 0e0947464b..8f9de42cc4 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala @@ -24,7 +24,7 @@ object System { import cats.implicits._ - def wired[F[_]: Sync](): System[F, Player] = { + def wired[F[_]: Sync]: System[F, Player] = { val speechGateway: Player => FairySpeechGateway[F] = player => new BukkitFairySpeechGateway[F](player) val speechService: Player => FairySpeechService[F] = player => From 6f497a4679118a3308e36113cdce9ca9f0629ac5 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 16 Apr 2023 16:52:05 +0900 Subject: [PATCH 427/482] =?UTF-8?q?fix:=20api=E3=81=8B=E3=82=89=E3=81=AF?= =?UTF-8?q?=E3=83=88=E3=82=B0=E3=83=AB=E3=81=97=E3=81=8B=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairyspeech/FairySpeechAPI.scala | 5 +++-- .../vote/subsystems/fairyspeech/System.scala | 14 ++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/FairySpeechAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/FairySpeechAPI.scala index 1e168c19cf..f581572861 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/FairySpeechAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/FairySpeechAPI.scala @@ -1,5 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech +import cats.data.Kleisli import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage import java.util.UUID @@ -13,9 +14,9 @@ trait FairySpeechAPI[F[_], Player] { def speech(player: Player, messages: Seq[FairyMessage]): F[Unit] /** - * @return `player`に対して妖精が喋った際に音を再生するかを`playOnSpeech`に設定する作用 + * @return `player`に対して妖精が喋った際に音を再生するかをトグルする作用 */ - def setPlaySoundOnSpeech(player: UUID, playOnSpeech: Boolean): F[Unit] + def togglePlaySoundOnSpeech: Kleisli[F, Player, Unit] /** * @return `player`に対して妖精が喋った際に音を再生するかどうかを取得する作用 diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala index 8f9de42cc4..173e501093 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala @@ -1,13 +1,11 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech +import cats.data.Kleisli import cats.effect.Sync import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.bukkit.BukkitFairySpeechGateway -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.{ - FairySpeechGateway, - FairySpeechPersistence -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.{FairySpeechGateway, FairySpeechPersistence} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.infrastructure.JdbcFairySpeechPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service.FairySpeechService import org.bukkit.entity.Player @@ -39,8 +37,12 @@ object System { _ <- speechService(player).makeSpeech(messages, fairyPlaySound) } yield () - override def setPlaySoundOnSpeech(player: UUID, playOnSpeech: Boolean): F[Unit] = - persistence.setPlaySoundOnSpeech(player, playOnSpeech) + override def togglePlaySoundOnSpeech: Kleisli[F, Player, Unit] = Kleisli { player => + for { + fairyPlaySound <- playSoundOnSpeech(player.getUniqueId) + _ <- persistence.setPlaySoundOnSpeech(player.getUniqueId, fairyPlaySound) + } yield () + } override def playSoundOnSpeech(player: UUID): F[Boolean] = persistence.playSoundOnFairySpeech(player) From c3867f3fb3943455b2800811017d479a23671bb5 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 16 Apr 2023 17:15:12 +0900 Subject: [PATCH 428/482] =?UTF-8?q?refactor:=20=E6=96=B0=E3=81=97=E3=81=84?= =?UTF-8?q?fairySpeechAPI=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/seichiassist/menus/VoteMenu.scala | 11 +++++++---- .../subsystems/vote/subsystems/fairy/FairyAPI.scala | 10 ---------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala index 442e370431..d4537c6b78 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/VoteMenu.scala @@ -30,6 +30,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p FairyLore, FairySummonCost } +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.FairySpeechAPI import com.github.unchama.targetedeffect.TargetedEffect.emptyEffect import com.github.unchama.targetedeffect.commandsender.MessageEffect import com.github.unchama.targetedeffect.player.FocusedSoundEffect @@ -44,7 +45,8 @@ object VoteMenu extends Menu { class Environment( implicit val voteAPI: VoteAPI[IO, Player], val fairyAPI: FairyAPI[IO, SyncIO, Player], - val ioCanOpenFirstPage: IO CanOpen FirstPage.type + val ioCanOpenFirstPage: IO CanOpen FirstPage.type, + val fairySpeechAPI: FairySpeechAPI[IO, Player] ) /** @@ -99,7 +101,8 @@ object VoteMenu extends Menu { private case class ConstantButtons(player: Player)( implicit voteAPI: VoteAPI[IO, Player], - fairyAPI: FairyAPI[IO, SyncIO, Player] + fairyAPI: FairyAPI[IO, SyncIO, Player], + fairySpeechAPI: FairySpeechAPI[IO, Player] ) { import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.layoutPreparationContext @@ -272,7 +275,7 @@ object VoteMenu extends Menu { val playSoundOffLore = s"$RESET${RED}現在音が鳴らない設定になっています。" +: description RecomputedButton(for { - fairySpeechSound <- fairyAPI.doPlaySoundOnSpeak(player.getUniqueId) + fairySpeechSound <- fairySpeechAPI.playSoundOnSpeech(player.getUniqueId) } yield { Button( new IconItemStackBuilder(Material.JUKEBOX) @@ -285,7 +288,7 @@ object VoteMenu extends Menu { LeftClickButtonEffect { SequentialEffect( FocusedSoundEffect(Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1f, 1f), - DeferredEffect(IO(fairyAPI.toggleSoundOnSpeak)) + DeferredEffect(IO(fairySpeechAPI.togglePlaySoundOnSpeech)) ) } ) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala index c66a5535be..1a037693bb 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/FairyAPI.scala @@ -74,16 +74,6 @@ object FairyReadAPI { trait FairySpeechAPI[F[_], Player] { - /** - * @return 妖精が喋るときに音を再生するかをトグルする作用 - */ - def toggleSoundOnSpeak: Kleisli[F, Player, Unit] - - /** - * @return 妖精が喋ったときに音を再生するか取得する作用 - */ - def doPlaySoundOnSpeak(uuid: UUID): F[Boolean] - /** * @return 妖精がいつ帰るのかを送信する作用 */ From 66b2f9873ee64b6a86af1f96960260082ba1f7fc Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 16 Apr 2023 17:17:06 +0900 Subject: [PATCH 429/482] =?UTF-8?q?chore:=20TopLevelRouter=E3=81=ABFairySp?= =?UTF-8?q?eechAPI=E3=82=92=E6=B8=A1=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/SeichiAssist.scala | 2 ++ .../seichiassist/menus/TopLevelRouter.scala | 27 +++++-------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 63628a2b30..b9e38189af 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -87,6 +87,7 @@ import com.github.unchama.seichiassist.subsystems.sharedinventory.SharedInventor import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI import com.github.unchama.seichiassist.subsystems.tradesystems.subsystems.gttosiina.GtToSiinaAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.FairySpeechAPI import com.github.unchama.seichiassist.task.PlayerDataSaveTask import com.github.unchama.seichiassist.task.global._ import com.github.unchama.util.{ActionStatus, ClassUtils} @@ -665,6 +666,7 @@ class SeichiAssist extends JavaPlugin() { sharedInventorySystem.api implicit val voteAPI: VoteAPI[IO, Player] = voteSystem.api implicit val fairyAPI: FairyAPI[IO, SyncIO, Player] = fairySystem.api + implicit val fairySpeechAPI: FairySpeechAPI[IO, Player] = fairySpeechSystem.api implicit val donateAPI: DonatePremiumPointAPI[IO] = donateSystem.api implicit val gachaTicketAPI: GachaTicketAPI[IO] = gachaTicketSystem.api diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala index 235699c81c..2a0daa6e3a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala @@ -6,24 +6,12 @@ import com.github.unchama.menuinventory.LayoutPreparationContext import com.github.unchama.menuinventory.router.CanOpen import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.menus.achievement.group.AchievementGroupMenu -import com.github.unchama.seichiassist.menus.achievement.{ - AchievementCategoryMenu, - AchievementMenu -} +import com.github.unchama.seichiassist.menus.achievement.{AchievementCategoryMenu, AchievementMenu} import com.github.unchama.seichiassist.menus.home.{ConfirmationMenuEnvironment, HomeMenu} -import com.github.unchama.seichiassist.menus.minestack.{ - CategorizedMineStackMenu, - MineStackMainMenu, - MineStackSelectItemColorMenu -} +import com.github.unchama.seichiassist.menus.minestack.{CategorizedMineStackMenu, MineStackMainMenu, MineStackSelectItemColorMenu} import com.github.unchama.seichiassist.menus.nicknames.NickNameMenu import com.github.unchama.seichiassist.menus.ranking.{RankingMenu, RankingRootMenu} -import com.github.unchama.seichiassist.menus.skill.{ - ActiveSkillEffectMenu, - ActiveSkillMenu, - PassiveSkillMenu, - PremiumPointTransactionHistoryMenu -} +import com.github.unchama.seichiassist.menus.skill.{ActiveSkillEffectMenu, ActiveSkillMenu, PassiveSkillMenu, PremiumPointTransactionHistoryMenu} import com.github.unchama.seichiassist.menus.stickmenu.{FirstPage, SecondPage} import com.github.unchama.seichiassist.subsystems.anywhereender.AnywhereEnderChestAPI import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI @@ -32,10 +20,7 @@ import com.github.unchama.seichiassist.subsystems.breakcountbar.BreakCountBarAPI import com.github.unchama.seichiassist.subsystems.buildcount.domain.playerdata.BuildAmountData import com.github.unchama.seichiassist.subsystems.discordnotification.DiscordNotificationAPI import com.github.unchama.seichiassist.subsystems.donate.DonatePremiumPointAPI -import com.github.unchama.seichiassist.subsystems.fastdiggingeffect.{ - FastDiggingEffectApi, - FastDiggingSettingsApi -} +import com.github.unchama.seichiassist.subsystems.fastdiggingeffect.{FastDiggingEffectApi, FastDiggingSettingsApi} import com.github.unchama.seichiassist.subsystems.fourdimensionalpocket.FourDimensionalPocketApi import com.github.unchama.seichiassist.subsystems.gacha.GachaDrawAPI import com.github.unchama.seichiassist.subsystems.gacha.subsystems.consumegachaticket.ConsumeGachaTicketAPI @@ -50,6 +35,7 @@ import com.github.unchama.seichiassist.subsystems.ranking.domain.values.{LoginTi import com.github.unchama.seichiassist.subsystems.sharedinventory.SharedInventoryAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.FairySpeechAPI import io.chrisdavenport.cats.effect.time.JavaTime import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack @@ -92,7 +78,8 @@ object TopLevelRouter { gachaPrizeAPI: GachaPrizeAPI[IO, ItemStack, Player], mineStackAPI: MineStackAPI[IO, Player, ItemStack], gachaDrawAPI: GachaDrawAPI[IO, Player], - consumeGachaTicketAPI: ConsumeGachaTicketAPI[IO, Player] + consumeGachaTicketAPI: ConsumeGachaTicketAPI[IO, Player], + fairySpeechAPI: FairySpeechAPI[IO, Player] ): TopLevelRouter[IO] = new TopLevelRouter[IO] { import assortedRankingApi._ From dc3c2bce8e5d0b078974c5f23ba6643b5b74ae35 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 16 Apr 2023 17:18:04 +0900 Subject: [PATCH 430/482] =?UTF-8?q?refactor:=20=E5=8F=A4=E3=81=84=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=81=AE=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/System.scala | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index 9aebfce6a3..ae9c9c68c3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -135,17 +135,6 @@ object System { override def totalConsumedApple: IO[AppleAmount] = persistence.totalConsumedAppleAmount - override def doPlaySoundOnSpeak(uuid: UUID): IO[Boolean] = - persistence.playSoundOnFairySpeech(uuid) - - override def toggleSoundOnSpeak: Kleisli[IO, Player, Unit] = Kleisli { player => - val uuid = player.getUniqueId - for { - isPlayFairySpeechSound <- doPlaySoundOnSpeak(uuid) - _ <- persistence.setPlaySoundOnSpeech(uuid, !isPlayFairySpeechSound) - } yield () - } - override def sendDisappearTimeToChat: Kleisli[IO, Player, Unit] = Kleisli { player => fairySpeech.speechEndTime(player) } From 05f96b5f672c63f2f61046112ca83ded9db460ff Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 16 Apr 2023 17:22:26 +0900 Subject: [PATCH 431/482] style: apply scalafix, scalafmt --- .../seichiassist/menus/TopLevelRouter.scala | 23 +++++++++++++++---- .../vote/subsystems/fairyspeech/System.scala | 5 +++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala index 2a0daa6e3a..ca4af784ec 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/TopLevelRouter.scala @@ -6,12 +6,24 @@ import com.github.unchama.menuinventory.LayoutPreparationContext import com.github.unchama.menuinventory.router.CanOpen import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.menus.achievement.group.AchievementGroupMenu -import com.github.unchama.seichiassist.menus.achievement.{AchievementCategoryMenu, AchievementMenu} +import com.github.unchama.seichiassist.menus.achievement.{ + AchievementCategoryMenu, + AchievementMenu +} import com.github.unchama.seichiassist.menus.home.{ConfirmationMenuEnvironment, HomeMenu} -import com.github.unchama.seichiassist.menus.minestack.{CategorizedMineStackMenu, MineStackMainMenu, MineStackSelectItemColorMenu} +import com.github.unchama.seichiassist.menus.minestack.{ + CategorizedMineStackMenu, + MineStackMainMenu, + MineStackSelectItemColorMenu +} import com.github.unchama.seichiassist.menus.nicknames.NickNameMenu import com.github.unchama.seichiassist.menus.ranking.{RankingMenu, RankingRootMenu} -import com.github.unchama.seichiassist.menus.skill.{ActiveSkillEffectMenu, ActiveSkillMenu, PassiveSkillMenu, PremiumPointTransactionHistoryMenu} +import com.github.unchama.seichiassist.menus.skill.{ + ActiveSkillEffectMenu, + ActiveSkillMenu, + PassiveSkillMenu, + PremiumPointTransactionHistoryMenu +} import com.github.unchama.seichiassist.menus.stickmenu.{FirstPage, SecondPage} import com.github.unchama.seichiassist.subsystems.anywhereender.AnywhereEnderChestAPI import com.github.unchama.seichiassist.subsystems.breakcount.BreakCountAPI @@ -20,7 +32,10 @@ import com.github.unchama.seichiassist.subsystems.breakcountbar.BreakCountBarAPI import com.github.unchama.seichiassist.subsystems.buildcount.domain.playerdata.BuildAmountData import com.github.unchama.seichiassist.subsystems.discordnotification.DiscordNotificationAPI import com.github.unchama.seichiassist.subsystems.donate.DonatePremiumPointAPI -import com.github.unchama.seichiassist.subsystems.fastdiggingeffect.{FastDiggingEffectApi, FastDiggingSettingsApi} +import com.github.unchama.seichiassist.subsystems.fastdiggingeffect.{ + FastDiggingEffectApi, + FastDiggingSettingsApi +} import com.github.unchama.seichiassist.subsystems.fourdimensionalpocket.FourDimensionalPocketApi import com.github.unchama.seichiassist.subsystems.gacha.GachaDrawAPI import com.github.unchama.seichiassist.subsystems.gacha.subsystems.consumegachaticket.ConsumeGachaTicketAPI diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala index 173e501093..3234888895 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala @@ -5,7 +5,10 @@ import cats.effect.Sync import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.bukkit.BukkitFairySpeechGateway -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.{FairySpeechGateway, FairySpeechPersistence} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.{ + FairySpeechGateway, + FairySpeechPersistence +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.infrastructure.JdbcFairySpeechPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service.FairySpeechService import org.bukkit.entity.Player From 30dc4e717c79426f83d02f2306648835a56e634a Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 16 Apr 2023 17:26:53 +0900 Subject: [PATCH 432/482] =?UTF-8?q?refactor:=20FairySpeech=E3=82=92fairysp?= =?UTF-8?q?eech=E3=83=91=E3=83=83=E3=82=B1=E3=83=BC=E3=82=B8=E3=81=AB?= =?UTF-8?q?=E5=88=87=E3=82=8A=E5=87=BA=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/vote/subsystems/fairy/System.scala | 10 +++------- .../fairy/bukkit/actions/BukkitRecoveryMana.scala | 2 +- .../fairy/bukkit/actions/BukkitSummonFairy.scala | 2 +- .../bukkit/listeners/FairyPlayerJoinGreeter.scala | 2 +- .../fairy/bukkit/routines/BukkitFairyRoutine.scala | 2 +- .../bukkit/BukkitFairySpeech.scala | 4 ++-- .../speech => fairyspeech/domain}/FairySpeech.scala | 2 +- 7 files changed, 10 insertions(+), 14 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/{fairy => fairyspeech}/bukkit/BukkitFairySpeech.scala (98%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/{fairy/domain/speech => fairyspeech/domain}/FairySpeech.scala (97%) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index ae9c9c68c3..d2fc2a7543 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -23,20 +23,16 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applicat import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{ - BukkitFairySpeech, - BukkitFairySummonRequest -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySummonRequest import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ FairyPersistence, FairySpawnRequestErrorOrSpawn, FairySummonRequest } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.bukkit.BukkitFairySpeechGateway -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.bukkit.{BukkitFairySpeech, BukkitFairySpeechGateway} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.{FairySpeech, FairySpeechGateway} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service.FairySpeechService import org.bukkit.entity.Player import org.bukkit.event.Listener diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 85ae29ed5b..312c53bb70 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -14,7 +14,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p FairyAppleConsumeStrategy, FairyManaRecoveryState } -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeech import com.github.unchama.targetedeffect.SequentialEffect import com.github.unchama.targetedeffect.commandsender.MessageEffectF import io.chrisdavenport.cats.effect.time.JavaTime diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index 24ae552371..aa710dbd8b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -8,7 +8,7 @@ import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyRecoveryManaAmount -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeech import com.github.unchama.targetedeffect.commandsender.MessageEffectF import org.bukkit.ChatColor._ import org.bukkit.entity.Player diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index ca64614baa..38c27bcef6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -2,7 +2,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit. import cats.effect.{ConcurrentEffect, IO} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeech import org.bukkit.ChatColor._ import org.bukkit.entity.Player import org.bukkit.event.player.{AsyncPlayerPreLoginEvent, PlayerJoinEvent} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index 95507e5cc9..118630eadc 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -10,7 +10,7 @@ import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitRecoveryMana import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeech import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/bukkit/BukkitFairySpeech.scala similarity index 98% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/bukkit/BukkitFairySpeech.scala index c8311b5057..010f31a9a3 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/bukkit/BukkitFairySpeech.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.bukkit import cats.effect.Sync import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository @@ -6,7 +6,7 @@ import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.FairyMessageTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service.FairySpeechService import io.chrisdavenport.cats.effect.time.JavaTime import org.bukkit.entity.Player diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/domain/FairySpeech.scala similarity index 97% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeech.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/domain/FairySpeech.scala index 73df3b1cff..616b89200c 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/domain/FairySpeech.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyManaRecoveryState From 0236222e59ed1443f97909759d082f22d5a0de73 Mon Sep 17 00:00:00 2001 From: Kisaragi Marine Date: Mon, 17 Apr 2023 01:28:12 +0900 Subject: [PATCH 433/482] fix: pull ajd4jp from jitpack Signed-off-by: Kisaragi Marine --- .dockerignore | 1 - build.sbt | 7 ++++++- localDependencies/ajd4jp-8.0.2.2021.jar | Bin 166717 -> 0 bytes 3 files changed, 6 insertions(+), 2 deletions(-) delete mode 100644 localDependencies/ajd4jp-8.0.2.2021.jar diff --git a/.dockerignore b/.dockerignore index ae77e8985c..f6cb39af04 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,4 +9,3 @@ project target* !target/build -localDependencies/ajd4jp-8.0.2.2021.jar \ No newline at end of file diff --git a/build.sbt b/build.sbt index 260477a124..4b27dd2393 100644 --- a/build.sbt +++ b/build.sbt @@ -50,7 +50,9 @@ resolvers ++= Seq( "oss.sonatype.org" at "https://oss.sonatype.org/content/repositories/snapshots", "nexus.okkero.com" at "https://nexus.okkero.com/repository/maven-releases/", "maven.elmakers.com" at "https://maven.elmakers.com/repository/", // spigot-api 1.12.2がhub.spigotmc.orgからダウンロードできなくなったため - "repo.phoenix616.dev" at "https://repo.phoenix616.dev" // authlibのための + "repo.phoenix616.dev" at "https://repo.phoenix616.dev", // authlibのための + // ajd4jpのミラーのため + "jitpack.io" at "https://jitpack.io", ) val providedDependencies = Seq( @@ -111,6 +113,9 @@ val dependenciesToEmbed = Seq( "io.circe" %% "circe-core" % "0.14.1", "io.circe" %% "circe-generic" % "0.14.1", "io.circe" %% "circe-parser" % "0.14.1", + + // ajd4jp + "com.github.KisaragiEffective" % "ajd4jp-mirror" % "8.0.2.2021", ) // endregion diff --git a/localDependencies/ajd4jp-8.0.2.2021.jar b/localDependencies/ajd4jp-8.0.2.2021.jar deleted file mode 100644 index 66b8b660af5c8cd6b6056a94b54e8d01cd74cd54..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 166717 zcmaI7bCe~|wk=$?ZQHhO+ctOEwrzHGnO(MR+qTt({`&XseeaxezcFr(k(vL@h`m?D zij^y7%%vm?3I+oN1O)`dpU$iT^luk55EziWxSBA%w1NcV_XH4-(tkstfcXAG0|V-1 z#{a^tfq{U~{=WYoR9;v?T0&e^jX_?*K7M*)fC)+bHK=Ql&Mj#H4g9?JqE+b=bhsw= zdJNNkktwdw(UFGg+y1uQWp-*l89au*&FJ13%FWseaE(+Df|#9o=?3@IoRINb{$}PL zIHsIpkRS+X!R&i`vV5D+0xe_rElN`&R=uSL^=``Og6S z|BU*dzYq2o^q6m^BCx5d2?|sH2k?z}nKvmBH21 z)jX-+VUr0-?Dji4ND+EZs%2i)M+F}f9cL`?m~1R5UE_g=Wjt98{f}QpGz=LPBS`b$ zehzV9T!ZH5HMLQ` zI7c8mjY|VQtv)gYLfL)(IC&HSV@d=!1UY~lvid4JL8P3CWRzVTC!AQB)WJkA$Ng5M zK;S6HUfJOm%!}`#ocDns-v9NA?CKuI9K2jbvj1uc=&(>nk_DCm1Th};(jC|_n~6$t zzSM#ckMQHJqAtKQ`S%YY995jhYB7VEdw$wS0J41k&? z#bl`TtuQ}dWyV0art`M};jsJFfcE5d!~g5{Q2%FbG&LQB+am%28PEX%{o~4V)~4nT zF6RGC*0zqW%jO8W|7+bEpj6cwqBM`q8uv7+;V8UD)LN|Ffg&Y>yq>5PqJE5lDEjM} zKchRS#LVNjhI}cz^woOf=|kRa?lA0qd#^a-WFE?`TLn*<0pH`1V5-}O>%rywrO2ne z`;R8b`{&EmUA}fJPPnfe&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yW>$)1 z)M2v9V|cRGV6$$g=gqwc&aZ`xi1b&}DV{71Y?e~b{=Q4VDj3JQd6p+j6PuOat8T?% z6^>(_jN{2#i_O|5b4}q2Cd=ajPnH%o%ZBuupuX{ZNthT6m|k=F(UE3yMh5B{Fk0Y4*$Wo*toCPFmV5^@z2}dzKt`9 zhzISE&iavoft#S=cJq}JjfC@p~qk#2JqecqJRLSN4Al0kU#jTnS`jgE*}s zw)3S^{qE!e>oc&Bosy7TOcplgN3r#x!!R0|0)`<2!TshahVvo{-ngi%^2mEBbje@G zAc4|gLJB$7Q+kMiSXmljs}U0)k*5XS+E+k8cKN?RrXTKkaMa*EpH_GAQWK|#wie18 zSxVchMiIj=$PDPtyqkosGkF3p0Hg^PA+u6^H8#kKPUSHtabR&^@^hGJc?W|KWGQ9U zVzRK^lfL%uB{@*36Kq3{8}nPy7(CTY9miXvMzg-@k$^f6af7TDvhA3t(GO?P!@Z^F zx=dEU{5lc+#*@-vR|zOa_!JR10J*dB6Z? zIIf3-5_;5liUZY+*N7i|GVzF=$?PmKG;8cR#prTFA9Km&T$3Kh8GGm@8iYQ>kPDhM z6C1=m(GblFM;%kgWd+a1Vqv=*efR~J;*LX8MvuZktAgI+n+vH_L_@~z_>JbEx5MOe zKCMP`FgC|ToMjd0 z1!r7FiUa@1YLW5ls?Zqp0x>Q|*O8ycaxpXmy{L=Jr~t-rZkkvXtVLK{j01(AyF`h* ZBx{S=ROo#2@rA*^g>o>ObAklU_kS$;vfuy! From 2c567a11dba4220454a0fa454a419f4d5908d8c2 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 16 Apr 2023 20:58:35 +0900 Subject: [PATCH 434/482] =?UTF-8?q?refactor:=20=E5=A6=96=E7=B2=BE=E3=81=8C?= =?UTF-8?q?fairySpeechAPI=E3=82=92=E4=BB=8B=E3=81=97=E3=81=A6=E5=96=8B?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/SeichiAssist.scala | 10 +++- .../vote/subsystems/fairy/System.scala | 35 +++++------- .../bukkit/BukkitFairySpeech.scala | 57 ++++++------------- .../bukkit/actions/BukkitRecoveryMana.scala | 2 +- .../bukkit/actions/BukkitSummonFairy.scala | 2 +- .../listeners/FairyPlayerJoinGreeter.scala | 2 +- .../bukkit/routines/BukkitFairyRoutine.scala | 2 +- .../domain/speech}/FairySpeech.scala | 2 +- .../vote/subsystems/fairyspeech/System.scala | 3 +- 9 files changed, 46 insertions(+), 69 deletions(-) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/{fairyspeech => fairy}/bukkit/BukkitFairySpeech.scala (59%) rename src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/{fairyspeech/domain => fairy/domain/speech}/FairySpeech.scala (97%) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index b9e38189af..eb159d2e64 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -466,13 +466,17 @@ class SeichiAssist extends JavaPlugin() { implicit val breakCountAPI: BreakCountAPI[IO, SyncIO, Player] = breakCountSystem.api implicit val voteAPI: VoteAPI[IO, Player] = voteSystem.api implicit val manaApi: ManaApi[IO, SyncIO, Player] = manaSystem.manaApi + implicit val fairySpeechAPI: FairySpeechAPI[IO, Player] = fairySpeechSystem.api subsystems.vote.subsystems.fairy.System.wired.unsafeRunSync() } private lazy val fairySpeechSystem - : subsystems.vote.subsystems.fairyspeech.System[IO, Player] = + : subsystems.vote.subsystems.fairyspeech.System[IO, Player] = { + import PluginExecutionContexts.timer + subsystems.vote.subsystems.fairyspeech.System.wired[IO] + } /* TODO: mineStackSystemは本来privateであるべきだが、mineStackにアイテムを格納するAPIが現状の BreakUtilの実装から呼び出されている都合上やむを得ずpublicになっている。*/ @@ -500,6 +504,7 @@ class SeichiAssist extends JavaPlugin() { presentSystem, anywhereEnderSystem, voteSystem, + fairySpeechSystem, fairySystem, gachaPrizeSystem, idleTimeSystem, @@ -513,8 +518,7 @@ class SeichiAssist extends JavaPlugin() { sharedInventorySystem, mineStackSystem, consumeGachaTicketSystem, - openirontrapdoor.System.wired, - fairySpeechSystem + openirontrapdoor.System.wired ) private lazy val buildAssist: BuildAssist = { diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index d2fc2a7543..d3a9ced863 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -3,10 +3,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy import cats.data.Kleisli import cats.effect.{ConcurrentEffect, IO, SyncIO} import com.github.unchama.concurrent.RepeatingTaskContext -import com.github.unchama.datarepository.bukkit.player.{ - BukkitRepositoryControls, - PlayerDataRepository -} +import com.github.unchama.datarepository.bukkit.player.BukkitRepositoryControls import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.minecraft.actions.OnMinecraftServerThread import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.timer @@ -23,17 +20,20 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.applicat import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.BukkitFairySummonRequest +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.{ + BukkitFairySpeech, + BukkitFairySummonRequest +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ FairyPersistence, FairySpawnRequestErrorOrSpawn, FairySummonRequest } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.bukkit.{BukkitFairySpeech, BukkitFairySpeechGateway} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.{FairySpeech, FairySpeechGateway} -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service.FairySpeechService +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.bukkit.BukkitFairySpeechGateway +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeechGateway import org.bukkit.entity.Player import org.bukkit.event.Listener import org.bukkit.inventory.ItemStack @@ -51,6 +51,10 @@ object System { voteAPI: VoteAPI[IO, Player], manaApi: ManaApi[IO, SyncIO, Player], mineStackAPI: MineStackAPI[IO, Player, ItemStack], + fairySpeechAPI: com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.FairySpeechAPI[ + IO, + Player + ], repeatingTaskContext: RepeatingTaskContext, concurrentEffect: ConcurrentEffect[IO], minecraftServerThread: OnMinecraftServerThread[IO] @@ -58,9 +62,7 @@ object System { implicit val persistence: FairyPersistence[IO] = new JdbcFairyPersistence[IO] implicit val fairySpeechGatewayProvider: Player => FairySpeechGateway[SyncIO] = new BukkitFairySpeechGateway[SyncIO](_) - val fairySpeechProvider - : PlayerDataRepository[FairySpeechService[SyncIO]] => FairySpeech[IO, Player] = - fairySpeechService => new BukkitFairySpeech[IO, SyncIO](fairySpeechService, persistence) + implicit val fairySpeechProvider: FairySpeech[IO, Player] = new BukkitFairySpeech[IO] for { speechServiceRepositoryControls <- BukkitRepositoryControls.createHandles( @@ -71,9 +73,7 @@ object System { SpeechServiceRepositoryDefinitions.finalization[SyncIO, Player] ) ) - _fairyRoutine = new BukkitFairyRoutine( - fairySpeechProvider(speechServiceRepositoryControls.repository) - ) + _fairyRoutine = new BukkitFairyRoutine(fairySpeechProvider) fairyRecoveryRoutineFiberRepositoryControls <- BukkitRepositoryControls.createHandles( RepositoryDefinition .Phased @@ -85,11 +85,6 @@ object System { ) } yield { new System[IO, SyncIO, Player] { - val fairySpeechServiceRepository: PlayerDataRepository[FairySpeechService[SyncIO]] = - speechServiceRepositoryControls.repository - implicit val fairySpeech: FairySpeech[IO, Player] = fairySpeechProvider( - fairySpeechServiceRepository - ) implicit val summonFairy: SummonFairy[IO, Player] = new BukkitSummonFairy[IO, SyncIO] val summonRequest: FairySummonRequest[IO, Player] = @@ -132,7 +127,7 @@ object System { persistence.totalConsumedAppleAmount override def sendDisappearTimeToChat: Kleisli[IO, Player, Unit] = Kleisli { - player => fairySpeech.speechEndTime(player) + player => fairySpeechProvider.speechEndTime(player) } override def fairySummonRequest diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/bukkit/BukkitFairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala similarity index 59% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/bukkit/BukkitFairySpeech.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala index 010f31a9a3..2b524699a9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/bukkit/BukkitFairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/BukkitFairySpeech.scala @@ -1,22 +1,20 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.bukkit +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit import cats.effect.Sync -import com.github.unchama.datarepository.bukkit.player.PlayerDataRepository -import com.github.unchama.generic.ContextCoercion import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property._ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.resources.FairyMessageTable -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeech -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service.FairySpeechService +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.FairySpeechAPI import io.chrisdavenport.cats.effect.time.JavaTime import org.bukkit.entity.Player import java.time.ZoneId import scala.util.Random -class BukkitFairySpeech[F[_]: Sync: JavaTime, G[_]: ContextCoercion[*[_], F]]( - fairySpeechServiceRepository: PlayerDataRepository[FairySpeechService[G]], - fairyPersistence: FairyPersistence[F] +class BukkitFairySpeech[F[_]: Sync: JavaTime]( + implicit fairyPersistence: FairyPersistence[F], + fairySpeechAPI: FairySpeechAPI[F, Player] ) extends FairySpeech[F, Player] { import cats.implicits._ @@ -39,14 +37,7 @@ class BukkitFairySpeech[F[_]: Sync: JavaTime, G[_]: ContextCoercion[*[_], F]]( nameCalledByFairy = ScreenNameForFairy(player.getName) fairyMessages = getSummonMessagesByStartHour(startHour, nameCalledByFairy) message <- randomMessage(fairyMessages) - - serviceRepository = fairySpeechServiceRepository(player) - fairySpeechSound <- ContextCoercion { - fairyPersistence.playSoundOnFairySpeech(player.getUniqueId) - } - _ <- ContextCoercion { - serviceRepository.makeSpeech(Seq(message), fairySpeechSound) - } + _ <- fairySpeechAPI.speech(player, Seq(message)) } yield () override def speechRandomly( @@ -64,44 +55,30 @@ class BukkitFairySpeech[F[_]: Sync: JavaTime, G[_]: ContextCoercion[*[_], F]]( } for { message <- randomMessage(messages(nameCalledByFairy)) - fairyPlaySound <- fairyPersistence.playSoundOnFairySpeech(player.getUniqueId) - _ <- ContextCoercion { - fairySpeechServiceRepository(player).makeSpeech(Seq(message), fairyPlaySound) - } + _ <- fairySpeechAPI.speech(player, Seq(message)) } yield () } override def speechEndTime(player: Player): F[Unit] = { for { endTimeOpt <- fairyPersistence.fairyEndTime(player.getUniqueId) - playSound <- fairyPersistence.playSoundOnFairySpeech(player.getUniqueId) endTime = endTimeOpt.get.endTime - _ <- ContextCoercion { - fairySpeechServiceRepository(player).makeSpeech( - Seq(FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。")), - playSound - ) - } + _ <- fairySpeechAPI.speech( + player, + Seq(FairyMessage(s"僕は${endTime.getHour}:${endTime.getMinute}には帰るよー。")) + ) } yield () } override def welcomeBack(player: Player): F[Unit] = for { - playSound <- fairyPersistence.playSoundOnFairySpeech(player.getUniqueId) - _ <- ContextCoercion { - fairySpeechServiceRepository(player) - .makeSpeech(Seq(FairyMessage(s"おかえり!${player.getName}")), playSound) - } + _ <- fairySpeechAPI.speech(player, Seq(FairyMessage(s"おかえり!${player.getName}"))) } yield () override def bye(player: Player): F[Unit] = for { - playSound <- fairyPersistence.playSoundOnFairySpeech(player.getUniqueId) - repository = fairySpeechServiceRepository(player) - _ <- ContextCoercion { - repository.makeSpeech( - Seq(FairyMessage(s"あっ、もうこんな時間だ!"), FairyMessage(s"じゃーねー!${player.getName}")), - playSound - ) - } + _ <- fairySpeechAPI.speech( + player, + Seq(FairyMessage(s"あっ、もうこんな時間だ!"), FairyMessage(s"じゃーねー!${player.getName}")) + ) } yield () private def randomMessage(fairyMessages: FairyMessageChoice): F[FairyMessage] = diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 312c53bb70..85ae29ed5b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -14,7 +14,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.p FairyAppleConsumeStrategy, FairyManaRecoveryState } -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import com.github.unchama.targetedeffect.SequentialEffect import com.github.unchama.targetedeffect.commandsender.MessageEffectF import io.chrisdavenport.cats.effect.time.JavaTime diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala index aa710dbd8b..24ae552371 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitSummonFairy.scala @@ -8,7 +8,7 @@ import com.github.unchama.seichiassist.subsystems.vote.domain.EffectPoint import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyRecoveryManaAmount -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import com.github.unchama.targetedeffect.commandsender.MessageEffectF import org.bukkit.ChatColor._ import org.bukkit.entity.Player diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala index 38c27bcef6..ca64614baa 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/listeners/FairyPlayerJoinGreeter.scala @@ -2,7 +2,7 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit. import cats.effect.{ConcurrentEffect, IO} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import org.bukkit.ChatColor._ import org.bukkit.entity.Player import org.bukkit.event.player.{AsyncPlayerPreLoginEvent, PlayerJoinEvent} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala index 118630eadc..95507e5cc9 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/routines/BukkitFairyRoutine.scala @@ -10,7 +10,7 @@ import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.FairyRoutine import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitRecoveryMana import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.FairyPersistence -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeech +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech.FairySpeech import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/domain/FairySpeech.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeech.scala similarity index 97% rename from src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/domain/FairySpeech.scala rename to src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeech.scala index 616b89200c..73df3b1cff 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/domain/FairySpeech.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/domain/speech/FairySpeech.scala @@ -1,4 +1,4 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain +package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.speech import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyManaRecoveryState diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala index 3234888895..b14c8a8163 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala @@ -11,6 +11,7 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.do } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.infrastructure.JdbcFairySpeechPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service.FairySpeechService +import io.chrisdavenport.cats.effect.time.JavaTime import org.bukkit.entity.Player import java.util.UUID @@ -25,7 +26,7 @@ object System { import cats.implicits._ - def wired[F[_]: Sync]: System[F, Player] = { + def wired[F[_]: Sync: JavaTime]: System[F, Player] = { val speechGateway: Player => FairySpeechGateway[F] = player => new BukkitFairySpeechGateway[F](player) val speechService: Player => FairySpeechService[F] = player => From c26d9ffef6dc169ddcca2f338a929373fab109b1 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 18 Apr 2023 22:37:55 +0900 Subject: [PATCH 435/482] =?UTF-8?q?refactor:=20=E4=BD=BF=E3=82=8F=E3=82=8C?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=82=B3=E3=83=BC=E3=83=89=E3=81=AE=E5=89=8A?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairy/System.scala | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala index d3a9ced863..f02daa6925 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/System.scala @@ -13,10 +13,7 @@ import com.github.unchama.seichiassist.subsystems.mana.ManaApi import com.github.unchama.seichiassist.subsystems.minestack.MineStackAPI import com.github.unchama.seichiassist.subsystems.vote.VoteAPI import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.actions.SummonFairy -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.{ - FairyManaRecoveryRoutineFiberRepositoryDefinition, - SpeechServiceRepositoryDefinitions -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository.FairyManaRecoveryRoutineFiberRepositoryDefinition import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.actions.BukkitSummonFairy import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.listeners.FairyPlayerJoinGreeter import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.bukkit.routines.BukkitFairyRoutine @@ -32,8 +29,6 @@ import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.{ FairySummonRequest } import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.infrastructure.JdbcFairyPersistence -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.bukkit.BukkitFairySpeechGateway -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeechGateway import org.bukkit.entity.Player import org.bukkit.event.Listener import org.bukkit.inventory.ItemStack @@ -60,26 +55,16 @@ object System { minecraftServerThread: OnMinecraftServerThread[IO] ): SyncIO[System[IO, SyncIO, Player]] = { implicit val persistence: FairyPersistence[IO] = new JdbcFairyPersistence[IO] - implicit val fairySpeechGatewayProvider: Player => FairySpeechGateway[SyncIO] = - new BukkitFairySpeechGateway[SyncIO](_) implicit val fairySpeechProvider: FairySpeech[IO, Player] = new BukkitFairySpeech[IO] + val fairyRoutine = new BukkitFairyRoutine(fairySpeechProvider) for { - speechServiceRepositoryControls <- BukkitRepositoryControls.createHandles( - RepositoryDefinition - .Phased - .TwoPhased( - SpeechServiceRepositoryDefinitions.initialization[SyncIO, Player], - SpeechServiceRepositoryDefinitions.finalization[SyncIO, Player] - ) - ) - _fairyRoutine = new BukkitFairyRoutine(fairySpeechProvider) fairyRecoveryRoutineFiberRepositoryControls <- BukkitRepositoryControls.createHandles( RepositoryDefinition .Phased .TwoPhased( FairyManaRecoveryRoutineFiberRepositoryDefinition - .initialization[Player](_fairyRoutine), + .initialization[Player](fairyRoutine), FairyManaRecoveryRoutineFiberRepositoryDefinition.finalization[Player] ) ) @@ -138,7 +123,7 @@ object System { } override val managedRepositoryControls: Seq[BukkitRepositoryControls[IO, _]] = - Seq(speechServiceRepositoryControls, fairyRecoveryRoutineFiberRepositoryControls).map( + Seq(fairyRecoveryRoutineFiberRepositoryControls).map( _.coerceFinalizationContextTo[IO] ) From add3c7faa8d2d521b6d77fe72210a1339de1f6fc Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 18 Apr 2023 21:58:25 +0900 Subject: [PATCH 436/482] =?UTF-8?q?fix:=20=E5=A6=96=E7=B2=BE=E3=81=8C?= =?UTF-8?q?=E5=96=8B=E3=81=A3=E3=81=9F=E3=81=A8=E3=81=8D=E3=81=AE=E9=9F=B3?= =?UTF-8?q?=E3=82=92=E5=8D=98=E9=9F=B3=E3=81=A7=E3=81=AF=E3=81=AA=E3=81=8F?= =?UTF-8?q?=E9=80=A3=E7=B6=9A=E9=9F=B3=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vote/subsystems/fairyspeech/System.scala | 10 +++------- .../bukkit/BukkitFairySpeechGateway.scala | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala index b14c8a8163..746eac87ee 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala @@ -1,17 +1,13 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech import cats.data.Kleisli -import cats.effect.Sync +import cats.effect.{Sync, Timer} import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.bukkit.BukkitFairySpeechGateway -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.{ - FairySpeechGateway, - FairySpeechPersistence -} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.{FairySpeechGateway, FairySpeechPersistence} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.infrastructure.JdbcFairySpeechPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service.FairySpeechService -import io.chrisdavenport.cats.effect.time.JavaTime import org.bukkit.entity.Player import java.util.UUID @@ -26,7 +22,7 @@ object System { import cats.implicits._ - def wired[F[_]: Sync: JavaTime]: System[F, Player] = { + def wired[F[_]: Sync: Timer]: System[F, Player] = { val speechGateway: Player => FairySpeechGateway[F] = player => new BukkitFairySpeechGateway[F](player) val speechService: Player => FairySpeechService[F] = player => diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/bukkit/BukkitFairySpeechGateway.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/bukkit/BukkitFairySpeechGateway.scala index 0b3ae14c23..5cee695de1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/bukkit/BukkitFairySpeechGateway.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/bukkit/BukkitFairySpeechGateway.scala @@ -1,6 +1,6 @@ package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.bukkit -import cats.effect.Sync +import cats.effect.{Sync, Timer} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeechGateway import com.github.unchama.targetedeffect.commandsender.MessageEffectF @@ -9,7 +9,10 @@ import org.bukkit.ChatColor.{AQUA, BOLD, RESET} import org.bukkit.Sound import org.bukkit.entity.Player -class BukkitFairySpeechGateway[F[_]: Sync](player: Player) extends FairySpeechGateway[F] { +import scala.concurrent.duration.DurationInt + +class BukkitFairySpeechGateway[F[_]: Sync: Timer](player: Player) + extends FairySpeechGateway[F] { override def sendMessage(fairyMessages: Seq[FairyMessage]): F[Unit] = { val defaultFairyMessage = s"$AQUA$BOLD<マナ妖精>$RESET%s" @@ -18,7 +21,14 @@ class BukkitFairySpeechGateway[F[_]: Sync](player: Player) extends FairySpeechGa ).run(player) } - override def playSpeechSound: F[Unit] = - FocusedSoundEffectF(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f).run(player) + import cats.implicits._ + + override def playSpeechSound: F[Unit] = for { + _ <- FocusedSoundEffectF(Sound.BLOCK_NOTE_PLING, 2.0f, 1.0f).run(player) + _ <- Timer[F].sleep(100.millis) + _ <- FocusedSoundEffectF(Sound.BLOCK_NOTE_PLING, 2.0f, 1.5f).run(player) + _ <- Timer[F].sleep(100.millis) + _ <- FocusedSoundEffectF(Sound.BLOCK_NOTE_PLING, 2.0f, 2.0f).run(player) + } yield {} } From 623d3dd14b937aabc969640db0575c8ae3e581c7 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 18 Apr 2023 23:09:51 +0900 Subject: [PATCH 437/482] =?UTF-8?q?chore:=20=E4=BD=BF=E3=82=8F=E3=82=8C?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84=E3=82=B3=E3=83=BC=E3=83=89?= =?UTF-8?q?=E3=81=8C=E6=AE=8B=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE?= =?UTF-8?q?=E3=81=A7=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SpeechServiceRepositoryDefinitions.scala | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala deleted file mode 100644 index 520925c817..0000000000 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/application/repository/SpeechServiceRepositoryDefinitions.scala +++ /dev/null @@ -1,22 +0,0 @@ -package com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.application.repository - -import cats.Applicative -import cats.effect.Sync -import com.github.unchama.datarepository.template.finalization.RepositoryFinalization -import com.github.unchama.datarepository.template.initialization.TwoPhasedRepositoryInitialization -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.FairySpeechGateway -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service.FairySpeechService - -object SpeechServiceRepositoryDefinitions { - - def initialization[F[_]: Sync, Player]( - implicit gatewayProvider: Player => FairySpeechGateway[F] - ): TwoPhasedRepositoryInitialization[F, Player, FairySpeechService[F]] = - TwoPhasedRepositoryInitialization.withoutPrefetching[F, Player, FairySpeechService[F]] { - player => Applicative[F].pure(new FairySpeechService[F](gatewayProvider(player))) - } - - def finalization[F[_]: Applicative, Player] - : RepositoryFinalization[F, Player, FairySpeechService[F]] = RepositoryFinalization.trivial - -} From 329e12824e68cd663e0dfa4b8b22583377e49281 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 18 Apr 2023 23:16:11 +0900 Subject: [PATCH 438/482] style: scalafmt and scalafix --- .../subsystems/vote/subsystems/fairyspeech/System.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala index 746eac87ee..df672e185d 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairyspeech/System.scala @@ -5,7 +5,10 @@ import cats.effect.{Sync, Timer} import com.github.unchama.seichiassist.meta.subsystem.Subsystem import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.domain.property.FairyMessage import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.bukkit.BukkitFairySpeechGateway -import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.{FairySpeechGateway, FairySpeechPersistence} +import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.domain.{ + FairySpeechGateway, + FairySpeechPersistence +} import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.infrastructure.JdbcFairySpeechPersistence import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairyspeech.service.FairySpeechService import org.bukkit.entity.Player From 8015837fc60c9c975a29d77faf7a4b072a4006b4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 20 Apr 2023 23:24:47 +0900 Subject: [PATCH 439/482] =?UTF-8?q?fix:=20=E5=A6=96=E7=B2=BE=E3=81=8C?= =?UTF-8?q?=E3=83=9E=E3=83=8A=E3=82=92=E5=9B=9E=E5=BE=A9=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=81=A8=E3=81=8D=E3=81=AB=E3=80=81=E3=81=8C=E3=81=A1=E3=82=83?= =?UTF-8?q?=E3=82=8A=E3=82=93=E3=81=94=E3=82=92=E6=B6=88=E8=B2=BB=E3=81=97?= =?UTF-8?q?=E3=81=AA=E3=81=84=E4=B8=8D=E5=85=B7=E5=90=88=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/actions/BukkitRecoveryMana.scala | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 85ae29ed5b..276c1ff125 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -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") @@ -91,11 +91,18 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: JavaTime, G[_]: ContextCoercion 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) From 36ef530b20d065ca6b0d856b9b504c25227d0fe3 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 21 Apr 2023 00:09:42 +0900 Subject: [PATCH 440/482] =?UTF-8?q?fix:=20=E3=81=8C=E3=81=A1=E3=82=83?= =?UTF-8?q?=E3=82=8A=E3=82=93=E3=81=94=E3=81=8C=E3=81=AA=E3=81=8B=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E5=A0=B4=E5=90=88=E3=81=AB=E5=9B=9E=E5=BE=A9=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=83=9E=E3=83=8A=E3=81=AE=E9=87=8F=E3=82=92=E6=B8=9B?= =?UTF-8?q?=E3=82=89=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/actions/BukkitRecoveryMana.scala | 30 ++++--------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 276c1ff125..18184dbad5 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -188,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 @@ -201,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 } } From 16bcc825088b6762777fc8632bf94b88d12551fa Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 21 Apr 2023 00:22:29 +0900 Subject: [PATCH 441/482] =?UTF-8?q?fix:=20=E3=81=8C=E3=81=A1=E3=82=83?= =?UTF-8?q?=E3=82=8A=E3=82=93=E3=81=94=E3=81=8C=E3=81=AA=E3=81=8B=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E5=A0=B4=E5=90=88=E3=81=AE=E5=A6=96=E7=B2=BE=E3=81=8B?= =?UTF-8?q?=E3=82=89=E3=81=AE=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=82=92=E7=9B=B4=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 18184dbad5..eb7375c044 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -87,7 +87,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: JavaTime, G[_]: ContextCoercion ) >> fairySpeech.speechRandomly( player, - if (finallyAppleConsumptionAmount > mineStackedGachaRingoAmount) + if (finallyAppleConsumptionAmount == 0) FairyManaRecoveryState.RecoveredWithoutApple else FairyManaRecoveryState.RecoveredWithApple ) >> From 23e4a1d8959fda52c91b089d9a1e95009442e3b3 Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 21 Apr 2023 22:33:40 +0900 Subject: [PATCH 442/482] =?UTF-8?q?chore:=20=E5=A6=96=E7=B2=BE=E3=81=8C?= =?UTF-8?q?=E5=9B=9E=E5=BE=A9=E3=81=99=E3=82=8B=E3=83=9E=E3=83=8A=E3=81=AE?= =?UTF-8?q?=E9=87=8F=E3=82=92=E8=AA=BF=E6=95=B4=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/actions/BukkitRecoveryMana.scala | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index eb7375c044..26152d15d1 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -60,6 +60,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: JavaTime, G[_]: ContextCoercion }.whenA(isFairyUsing && oldManaAmount.isFull) appleConsumptionAmount <- computeAppleConsumptionAmount + _ = println(s"appleConsumptionAmount: $appleConsumptionAmount") finallyAppleConsumptionAmount <- computeFinallyAppleConsumptionAmount( appleConsumptionAmount ) @@ -117,16 +118,9 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: JavaTime, G[_]: ContextCoercion seichiAmountData <- ContextCoercion(breakCountAPI.seichiAmountDataRepository(player).read) voteStreaks <- voteAPI.currentConsecutiveVoteStreakDays(uuid) appleOpenState <- fairyPersistence.appleConsumeStrategy(uuid) - oldManaAmount <- ContextCoercion { - manaApi.readManaAmount(player) - } } yield { val playerLevel = seichiAmountData.levelCorrespondingToExp - val isStrategyConsumeOrLessConsume = - appleOpenState == FairyAppleConsumeStrategy.LessConsume || appleOpenState == FairyAppleConsumeStrategy.Consume - val isEnoughMana = oldManaAmount.ratioToCap.exists(_ >= 0.75) - val defaultAmount = Math.pow(playerLevel.level / 10, 2) val voteStreakDays = voteStreaks.value @@ -138,9 +132,12 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: JavaTime, G[_]: ContextCoercion else 1 // りんごの開放状況を適用した除算量 - val appleConsumeStrategyDivisor = - if (isStrategyConsumeOrLessConsume && isEnoughMana) 2 - else 1 + val appleConsumeStrategyDivisor = appleOpenState match { + case FairyAppleConsumeStrategy.Permissible => 1 + case FairyAppleConsumeStrategy.Consume => 2 + case FairyAppleConsumeStrategy.LessConsume => 3 + case FairyAppleConsumeStrategy.NoConsume => 4 + } // りんごの開放状況まで適用したりんごの消費量 (暫定) val appleOpenStateReflectedAmount = @@ -185,22 +182,14 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: JavaTime, G[_]: ContextCoercion private def computeManaRecoveryAmount(appleConsumptionAmount: Int): F[Int] = for { defaultRecoveryManaAmount <- fairyPersistence.fairyRecoveryMana(uuid) appleOpenState <- fairyPersistence.appleConsumeStrategy(uuid) - oldManaAmount <- ContextCoercion { - manaApi.readManaAmount(player) - } } yield { - val isAppleOpenStateIsOpenOrOpenALittle = - appleOpenState == FairyAppleConsumeStrategy.LessConsume || appleOpenState == FairyAppleConsumeStrategy.Consume - val isEnoughMana = oldManaAmount.ratioToCap.exists(_ >= 0.75) - - // マナの回復量を算出する - val appleOpenStateDivision = - if (isAppleOpenStateIsOpenOrOpenALittle && isEnoughMana) 2 - else if ( - appleOpenState == FairyAppleConsumeStrategy.NoConsume || appleConsumptionAmount == 0 - ) 4 + if (appleOpenState == FairyAppleConsumeStrategy.NoConsume || appleConsumptionAmount == 0) + 4 + else if (appleOpenState == FairyAppleConsumeStrategy.LessConsume) 3 + else if (appleOpenState == FairyAppleConsumeStrategy.Consume) 2 else 1 + val reflectedAppleOpenStateAmount = defaultRecoveryManaAmount.recoveryMana / appleOpenStateDivision @@ -209,7 +198,7 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: JavaTime, G[_]: ContextCoercion Random.nextInt(reflectedAppleOpenStateAmount / 50) else 0 - (reflectedAppleOpenStateAmount - reflectedAppleOpenStateAmount / 100) + randomizedAdd + reflectedAppleOpenStateAmount + randomizedAdd } } From c445fa23e81fd57d1b988b78409bde9fdd1792ce Mon Sep 17 00:00:00 2001 From: rito528 Date: Fri, 21 Apr 2023 23:56:19 +0900 Subject: [PATCH 443/482] =?UTF-8?q?fix:=20=E5=A6=96=E7=B2=BE=E3=81=8C?= =?UTF-8?q?=E5=B8=B0=E3=82=8B=E3=81=A8=E3=81=8D=E3=81=AE=E3=83=A1=E3=83=83?= =?UTF-8?q?=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=AE=E9=A0=86=E7=95=AA=E3=82=92?= =?UTF-8?q?=E7=9B=B4=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairy/bukkit/actions/BukkitRecoveryMana.scala | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala index 26152d15d1..6c552ab691 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/vote/subsystems/fairy/bukkit/actions/BukkitRecoveryMana.scala @@ -45,13 +45,6 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: JavaTime, G[_]: ContextCoercion for { isFairyUsing <- fairyPersistence.isFairyUsing(uuid) fairyEndTimeOpt <- fairyPersistence.fairyEndTime(uuid) - finishUse <- JavaTime[F] - .getLocalDateTime(ZoneId.systemDefault()) - .map(now => isFairyUsing && fairyEndTimeOpt.exists(_.endTime.isBefore(now))) - _ <- { - fairySpeech - .bye(player) >> fairyPersistence.updateIsFairyUsing(uuid, isFairyUsing = false) - }.whenA(finishUse) oldManaAmount <- ContextCoercion { manaApi.readManaAmount(player) } @@ -60,7 +53,6 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: JavaTime, G[_]: ContextCoercion }.whenA(isFairyUsing && oldManaAmount.isFull) appleConsumptionAmount <- computeAppleConsumptionAmount - _ = println(s"appleConsumptionAmount: $appleConsumptionAmount") finallyAppleConsumptionAmount <- computeFinallyAppleConsumptionAmount( appleConsumptionAmount ) @@ -108,6 +100,13 @@ class BukkitRecoveryMana[F[_]: ConcurrentEffect: JavaTime, G[_]: ContextCoercion else MessageEffectF(s"$RESET$YELLOW${BOLD}あなたは妖精にりんごを渡しませんでした。") ).apply(player) }.whenA(isFairyUsing && !oldManaAmount.isFull) + finishUse <- JavaTime[F] + .getLocalDateTime(ZoneId.systemDefault()) + .map(now => isFairyUsing && fairyEndTimeOpt.exists(_.endTime.isBefore(now))) + _ <- { + fairySpeech + .bye(player) >> fairyPersistence.updateIsFairyUsing(uuid, isFairyUsing = false) + }.whenA(finishUse) } yield () /** From 6e20cf4dcd6c85c79741e3e1a52df7ee181f0161 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Apr 2023 00:54:34 +0900 Subject: [PATCH 444/482] =?UTF-8?q?fix:=20PLayerData=E3=81=8B=E3=82=89Vote?= =?UTF-8?q?Count=E3=82=92=E5=89=8A=E9=99=A4=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/achievement/AchievementConditions.scala | 4 +++- .../github/unchama/seichiassist/data/player/PlayerData.scala | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/achievement/AchievementConditions.scala b/src/main/scala/com/github/unchama/seichiassist/achievement/AchievementConditions.scala index 7238c5dd55..4a7f0cf32e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/achievement/AchievementConditions.scala +++ b/src/main/scala/com/github/unchama/seichiassist/achievement/AchievementConditions.scala @@ -112,7 +112,9 @@ object AchievementConditions { } def voteCount_>=(n: Int): AchievementCondition[String] = { - val predicate = playerDataPredicate(d => IO { d.p_vote_forT >= n }) + val predicate = playerDataPredicate(d => + IO { SeichiAssist.instance.voteSystem.api.count(d.uuid).unsafeRunSync().value >= n } + ) AchievementCondition(predicate, "JMS投票数が " + _ + " を超える", n.toString) } diff --git a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala index 89299af394..34b0cd9564 100644 --- a/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala +++ b/src/main/scala/com/github/unchama/seichiassist/data/player/PlayerData.scala @@ -94,10 +94,6 @@ class PlayerData(@Deprecated() val uuid: UUID, val name: String) { // 二つ名解禁フラグ保存用 var TitleFlags: mutable.BitSet = new mutable.BitSet(10001) - // 二つ名関連用にp_vote(投票数)を引っ張る。(予期せぬエラー回避のため名前を複雑化) - // TODO: Achievementシステムが再実装されたら速攻でこれを消すべき - var p_vote_forT: Int = - SeichiAssist.instance.voteSystem.api.count(uuid).unsafeRunSync().value // 二つ名配布予約NOの保存 var giveachvNo = 0 // 実績ポイント用 From c09e34120f4d83ecb6de1eafed94e8f9f459ef08 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sat, 22 Apr 2023 15:30:21 +0900 Subject: [PATCH 445/482] =?UTF-8?q?refactor:=20batchParams=E3=81=AE?= =?UTF-8?q?=E6=A7=8B=E7=AF=89=E3=82=92=E3=83=88=E3=83=A9=E3=83=B3=E3=82=B6?= =?UTF-8?q?=E3=82=AF=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=AE=E4=B8=AD=E3=81=8B?= =?UTF-8?q?=E3=82=89=E5=87=BA=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JdbcMineStackObjectPersistence.scala | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/infrastructure/JdbcMineStackObjectPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/infrastructure/JdbcMineStackObjectPersistence.scala index e57a68055a..effb089078 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/infrastructure/JdbcMineStackObjectPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/infrastructure/JdbcMineStackObjectPersistence.scala @@ -30,22 +30,21 @@ class JdbcMineStackObjectPersistence[F[_]: Sync, ItemStack, Player]( } .toList() .apply() - .filterNot(_.isEmpty) - .map(_.get) } - Some(mineStackObjectsWithAmount) + Some(mineStackObjectsWithAmount.filterNot(_.isEmpty) + .map(_.get)) } override def write(key: UUID, value: List[MineStackObjectWithAmount[ItemStack]]): F[Unit] = Sync[F].delay { - DB.localTx { implicit session => - val batchParams = value.map { mineStackObjectWithAmount => - val objectName = mineStackObjectWithAmount.mineStackObject.mineStackObjectName - val amount = mineStackObjectWithAmount.amount - Seq(key.toString, objectName, amount) - } + val batchParams = value.map { mineStackObjectWithAmount => + val objectName = mineStackObjectWithAmount.mineStackObject.mineStackObjectName + val amount = mineStackObjectWithAmount.amount + Seq(key.toString, objectName, amount) + } + DB.localTx { implicit session => sql"""INSERT INTO mine_stack | (player_uuid, object_name, amount) | VALUES (?, ?, ?) From 37697644c6dfdfea2851adeedb1d3e9516950f79 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Apr 2023 00:02:56 +0900 Subject: [PATCH 446/482] =?UTF-8?q?feat:=20retryUntilSucceeds=E3=82=92?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generic/effect/concurrent/Retry.scala | 17 +++++++++++++++++ .../JdbcMineStackObjectPersistence.scala | 9 ++++----- 2 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 src/main/scala/com/github/unchama/generic/effect/concurrent/Retry.scala diff --git a/src/main/scala/com/github/unchama/generic/effect/concurrent/Retry.scala b/src/main/scala/com/github/unchama/generic/effect/concurrent/Retry.scala new file mode 100644 index 0000000000..5800cb82db --- /dev/null +++ b/src/main/scala/com/github/unchama/generic/effect/concurrent/Retry.scala @@ -0,0 +1,17 @@ +package com.github.unchama.generic.effect.concurrent + +import cats.effect.{MonadThrow, Sync} + +object Retry { + + import cats.implicits._ + + def retryUntilSucceeds[F[_]: MonadThrow: Sync, A](fa: F[A]): F[A] = { + fa.attempt.flatMap { + case Right(a) => a.pure[F] + case Left(error) => + Sync[F].delay(error.printStackTrace()) >> retryUntilSucceeds(fa) + } + } + +} diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/infrastructure/JdbcMineStackObjectPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/infrastructure/JdbcMineStackObjectPersistence.scala index effb089078..f6a2ab6480 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/infrastructure/JdbcMineStackObjectPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/infrastructure/JdbcMineStackObjectPersistence.scala @@ -8,6 +8,7 @@ import com.github.unchama.seichiassist.subsystems.minestack.domain.minestackobje import com.github.unchama.seichiassist.subsystems.minestack.domain.persistence.MineStackObjectPersistence import scalikejdbc._ +import java.sql.BatchUpdateException import java.util.UUID class JdbcMineStackObjectPersistence[F[_]: Sync, ItemStack, Player]( @@ -32,8 +33,7 @@ class JdbcMineStackObjectPersistence[F[_]: Sync, ItemStack, Player]( .apply() } - Some(mineStackObjectsWithAmount.filterNot(_.isEmpty) - .map(_.get)) + Some(mineStackObjectsWithAmount.filterNot(_.isEmpty).map(_.get)) } override def write(key: UUID, value: List[MineStackObjectWithAmount[ItemStack]]): F[Unit] = @@ -43,10 +43,9 @@ class JdbcMineStackObjectPersistence[F[_]: Sync, ItemStack, Player]( val amount = mineStackObjectWithAmount.amount Seq(key.toString, objectName, amount) } - DB.localTx { implicit session => - sql"""INSERT INTO mine_stack - | (player_uuid, object_name, amount) + sql"""INSERT INTO mine_stack + | (player_uuid, object_name, amount) | VALUES (?, ?, ?) | ON DUPLICATE KEY UPDATE | amount = VALUES(amount) From 1b35b9a49a665b502b2ea5bd6aca95dc61159e32 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Apr 2023 00:36:44 +0900 Subject: [PATCH 447/482] =?UTF-8?q?feat:=20RefDict=E3=81=AEwrite=E3=81=A7r?= =?UTF-8?q?etry=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RefDictBackedRepositoryDefinition.scala | 17 ++++++++--------- .../generic/effect/concurrent/Retry.scala | 9 ++++++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/scala/com/github/unchama/datarepository/definitions/RefDictBackedRepositoryDefinition.scala b/src/main/scala/com/github/unchama/datarepository/definitions/RefDictBackedRepositoryDefinition.scala index 254941c81c..cb73384275 100644 --- a/src/main/scala/com/github/unchama/datarepository/definitions/RefDictBackedRepositoryDefinition.scala +++ b/src/main/scala/com/github/unchama/datarepository/definitions/RefDictBackedRepositoryDefinition.scala @@ -1,13 +1,12 @@ package com.github.unchama.datarepository.definitions import cats.Monad +import cats.effect.MonadThrow import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.datarepository.template.finalization.RepositoryFinalization -import com.github.unchama.datarepository.template.initialization.{ - PrefetchResult, - SinglePhasedRepositoryInitialization -} +import com.github.unchama.datarepository.template.initialization.{PrefetchResult, SinglePhasedRepositoryInitialization} import com.github.unchama.generic.RefDict +import com.github.unchama.generic.effect.concurrent.Retry.retryUntilSucceeds import java.util.UUID @@ -15,7 +14,7 @@ object RefDictBackedRepositoryDefinition { import cats.implicits._ - def usingUuidRefDictWithEffectfulDefault[F[_]: Monad, Player, R]( + def usingUuidRefDictWithEffectfulDefault[F[_]: MonadThrow, Player, R]( refDict: RefDict[F, UUID, R] )(getDefaultValue: F[R]): RepositoryDefinition.Phased.SinglePhased[F, Player, R] = { val initialization: SinglePhasedRepositoryInitialization[F, R] = @@ -29,12 +28,12 @@ object RefDictBackedRepositoryDefinition { .map(PrefetchResult.Success.apply) val finalization: RepositoryFinalization[F, UUID, R] = - RepositoryFinalization.withoutAnyFinalization((uuid, r) => refDict.write(uuid, r)) + RepositoryFinalization.withoutAnyFinalization((uuid, r) => retryUntilSucceeds(refDict.write(uuid, r))) RepositoryDefinition.Phased.SinglePhased.withoutTappingAction(initialization, finalization) } - def usingUuidRefDictWithoutDefault[F[_]: Monad, Player, R]( + def usingUuidRefDictWithoutDefault[F[_]: MonadThrow, Player, R]( refDict: RefDict[F, UUID, R] ): RepositoryDefinition.Phased.SinglePhased[F, Player, Option[R]] = { val initialization: SinglePhasedRepositoryInitialization[F, Option[R]] = @@ -42,13 +41,13 @@ object RefDictBackedRepositoryDefinition { val finalization: RepositoryFinalization[F, UUID, Option[R]] = RepositoryFinalization.withoutAnyFinalization((uuid, optR) => - optR.fold(Monad[F].pure(()))(r => refDict.write(uuid, r)) + optR.fold(Monad[F].pure(()))(r => retryUntilSucceeds(refDict.write(uuid, r))) ) RepositoryDefinition.Phased.SinglePhased.withoutTappingAction(initialization, finalization) } - def usingUuidRefDict[F[_]: Monad, Player, R](refDict: RefDict[F, UUID, R])( + def usingUuidRefDict[F[_]: MonadThrow, Player, R](refDict: RefDict[F, UUID, R])( defaultValue: R ): RepositoryDefinition.Phased.SinglePhased[F, Player, R] = usingUuidRefDictWithEffectfulDefault(refDict)(Monad[F].pure(defaultValue)) diff --git a/src/main/scala/com/github/unchama/generic/effect/concurrent/Retry.scala b/src/main/scala/com/github/unchama/generic/effect/concurrent/Retry.scala index 5800cb82db..9765589eef 100644 --- a/src/main/scala/com/github/unchama/generic/effect/concurrent/Retry.scala +++ b/src/main/scala/com/github/unchama/generic/effect/concurrent/Retry.scala @@ -1,16 +1,19 @@ package com.github.unchama.generic.effect.concurrent -import cats.effect.{MonadThrow, Sync} +import cats.effect.MonadThrow object Retry { import cats.implicits._ - def retryUntilSucceeds[F[_]: MonadThrow: Sync, A](fa: F[A]): F[A] = { + def retryUntilSucceeds[F[_]: MonadThrow, A](fa: F[A]): F[A] = { fa.attempt.flatMap { case Right(a) => a.pure[F] case Left(error) => - Sync[F].delay(error.printStackTrace()) >> retryUntilSucceeds(fa) + retryUntilSucceeds(fa).map { a => + error.printStackTrace() + a + } } } From de281ce02462cca4842980f369cb93c5c6e49416 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Apr 2023 00:41:03 +0900 Subject: [PATCH 448/482] =?UTF-8?q?Revert=20"refactor:=20batchParams?= =?UTF-8?q?=E3=81=AE=E6=A7=8B=E7=AF=89=E3=82=92=E3=83=88=E3=83=A9=E3=83=B3?= =?UTF-8?q?=E3=82=B6=E3=82=AF=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=AE=E4=B8=AD?= =?UTF-8?q?=E3=81=8B=E3=82=89=E5=87=BA=E3=81=99"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit c09e3412 --- .../JdbcMineStackObjectPersistence.scala | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/infrastructure/JdbcMineStackObjectPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/infrastructure/JdbcMineStackObjectPersistence.scala index f6a2ab6480..032e8cfc59 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/infrastructure/JdbcMineStackObjectPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/infrastructure/JdbcMineStackObjectPersistence.scala @@ -1,14 +1,10 @@ package com.github.unchama.seichiassist.subsystems.minestack.infrastructure import cats.effect.Sync -import com.github.unchama.seichiassist.subsystems.minestack.domain.minestackobject.{ - MineStackObject, - MineStackObjectWithAmount -} +import com.github.unchama.seichiassist.subsystems.minestack.domain.minestackobject.{MineStackObject, MineStackObjectWithAmount} import com.github.unchama.seichiassist.subsystems.minestack.domain.persistence.MineStackObjectPersistence import scalikejdbc._ -import java.sql.BatchUpdateException import java.util.UUID class JdbcMineStackObjectPersistence[F[_]: Sync, ItemStack, Player]( @@ -31,21 +27,24 @@ class JdbcMineStackObjectPersistence[F[_]: Sync, ItemStack, Player]( } .toList() .apply() + .filterNot(_.isEmpty) + .map(_.get) } - Some(mineStackObjectsWithAmount.filterNot(_.isEmpty).map(_.get)) + Some(mineStackObjectsWithAmount) } override def write(key: UUID, value: List[MineStackObjectWithAmount[ItemStack]]): F[Unit] = Sync[F].delay { - val batchParams = value.map { mineStackObjectWithAmount => - val objectName = mineStackObjectWithAmount.mineStackObject.mineStackObjectName - val amount = mineStackObjectWithAmount.amount - Seq(key.toString, objectName, amount) - } DB.localTx { implicit session => - sql"""INSERT INTO mine_stack - | (player_uuid, object_name, amount) + val batchParams = value.map { mineStackObjectWithAmount => + val objectName = mineStackObjectWithAmount.mineStackObject.mineStackObjectName + val amount = mineStackObjectWithAmount.amount + Seq(key.toString, objectName, amount) + } + + sql"""INSERT INTO mine_stack + | (player_uuid, object_name, amount) | VALUES (?, ?, ?) | ON DUPLICATE KEY UPDATE | amount = VALUES(amount) From 2765810ad36e059658206daff1916006264b83f5 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Apr 2023 00:44:03 +0900 Subject: [PATCH 449/482] style: apply scalafix --- .../definitions/RefDictBackedRepositoryDefinition.scala | 9 +++++++-- .../infrastructure/JdbcMineStackObjectPersistence.scala | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/datarepository/definitions/RefDictBackedRepositoryDefinition.scala b/src/main/scala/com/github/unchama/datarepository/definitions/RefDictBackedRepositoryDefinition.scala index cb73384275..43813bd81a 100644 --- a/src/main/scala/com/github/unchama/datarepository/definitions/RefDictBackedRepositoryDefinition.scala +++ b/src/main/scala/com/github/unchama/datarepository/definitions/RefDictBackedRepositoryDefinition.scala @@ -4,7 +4,10 @@ import cats.Monad import cats.effect.MonadThrow import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.datarepository.template.finalization.RepositoryFinalization -import com.github.unchama.datarepository.template.initialization.{PrefetchResult, SinglePhasedRepositoryInitialization} +import com.github.unchama.datarepository.template.initialization.{ + PrefetchResult, + SinglePhasedRepositoryInitialization +} import com.github.unchama.generic.RefDict import com.github.unchama.generic.effect.concurrent.Retry.retryUntilSucceeds @@ -28,7 +31,9 @@ object RefDictBackedRepositoryDefinition { .map(PrefetchResult.Success.apply) val finalization: RepositoryFinalization[F, UUID, R] = - RepositoryFinalization.withoutAnyFinalization((uuid, r) => retryUntilSucceeds(refDict.write(uuid, r))) + RepositoryFinalization.withoutAnyFinalization((uuid, r) => + retryUntilSucceeds(refDict.write(uuid, r)) + ) RepositoryDefinition.Phased.SinglePhased.withoutTappingAction(initialization, finalization) } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/infrastructure/JdbcMineStackObjectPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/infrastructure/JdbcMineStackObjectPersistence.scala index 032e8cfc59..e57a68055a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/infrastructure/JdbcMineStackObjectPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/minestack/infrastructure/JdbcMineStackObjectPersistence.scala @@ -1,7 +1,10 @@ package com.github.unchama.seichiassist.subsystems.minestack.infrastructure import cats.effect.Sync -import com.github.unchama.seichiassist.subsystems.minestack.domain.minestackobject.{MineStackObject, MineStackObjectWithAmount} +import com.github.unchama.seichiassist.subsystems.minestack.domain.minestackobject.{ + MineStackObject, + MineStackObjectWithAmount +} import com.github.unchama.seichiassist.subsystems.minestack.domain.persistence.MineStackObjectPersistence import scalikejdbc._ From 02ff75ccbd273d113052406951167deeb1aac732 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Apr 2023 01:06:56 +0900 Subject: [PATCH 450/482] =?UTF-8?q?chore:=20Retry=E3=82=92MonadThrowExtra?= =?UTF-8?q?=E3=81=AB=E6=94=B9=E5=90=8D=E3=81=97=E3=80=81effect=E4=B8=8B?= =?UTF-8?q?=E3=81=AB=E9=85=8D=E7=BD=AE=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../definitions/RefDictBackedRepositoryDefinition.scala | 2 +- .../effect/{concurrent/Retry.scala => MonadThrowExtra.scala} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename src/main/scala/com/github/unchama/generic/effect/{concurrent/Retry.scala => MonadThrowExtra.scala} (82%) diff --git a/src/main/scala/com/github/unchama/datarepository/definitions/RefDictBackedRepositoryDefinition.scala b/src/main/scala/com/github/unchama/datarepository/definitions/RefDictBackedRepositoryDefinition.scala index 43813bd81a..4f5b06da60 100644 --- a/src/main/scala/com/github/unchama/datarepository/definitions/RefDictBackedRepositoryDefinition.scala +++ b/src/main/scala/com/github/unchama/datarepository/definitions/RefDictBackedRepositoryDefinition.scala @@ -9,7 +9,7 @@ import com.github.unchama.datarepository.template.initialization.{ SinglePhasedRepositoryInitialization } import com.github.unchama.generic.RefDict -import com.github.unchama.generic.effect.concurrent.Retry.retryUntilSucceeds +import com.github.unchama.generic.effect.MonadThrowExtra.retryUntilSucceeds import java.util.UUID diff --git a/src/main/scala/com/github/unchama/generic/effect/concurrent/Retry.scala b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala similarity index 82% rename from src/main/scala/com/github/unchama/generic/effect/concurrent/Retry.scala rename to src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala index 9765589eef..b2ec62eefb 100644 --- a/src/main/scala/com/github/unchama/generic/effect/concurrent/Retry.scala +++ b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala @@ -1,8 +1,8 @@ -package com.github.unchama.generic.effect.concurrent +package com.github.unchama.generic.effect import cats.effect.MonadThrow -object Retry { +object MonadThrowExtra { import cats.implicits._ From 352af3253c51c188211a08d99cee4fa13a89b37d Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Apr 2023 01:24:50 +0900 Subject: [PATCH 451/482] =?UTF-8?q?chore:=20finalizer=E3=81=AE=E4=B8=AD?= =?UTF-8?q?=E3=81=A7retry=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/PlayerDataFinalizer.scala | 12 +++++++----- .../bukkit/player/BukkitRepositoryControls.scala | 8 +++++--- .../RefDictBackedRepositoryDefinition.scala | 14 +++++--------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/domain/PlayerDataFinalizer.scala b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/domain/PlayerDataFinalizer.scala index 45e6a72a3d..edc1e8a38e 100644 --- a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/domain/PlayerDataFinalizer.scala +++ b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/domain/PlayerDataFinalizer.scala @@ -1,8 +1,9 @@ package com.github.unchama.bungeesemaphoreresponder.domain import cats.effect.ConcurrentEffect -import cats.{Applicative, ApplicativeError, ~>} +import cats.{Applicative, ApplicativeError, MonadThrow, ~>} import com.github.unchama.generic.ContextCoercion +import com.github.unchama.generic.effect.MonadThrowExtra.retryUntilSucceeds /** * The type of a pure callback object that should be invoked when a player quits the Minecraft @@ -24,19 +25,20 @@ trait PlayerDataFinalizer[F[_], Player] { */ def onQuitOf(player: Player): F[Unit] - def transformContext[G[_]](trans: F ~> G): PlayerDataFinalizer[G, Player] = { + def transformContext[G[_]: MonadThrow](trans: F ~> G): PlayerDataFinalizer[G, Player] = { PlayerDataFinalizer(player => trans.apply(onQuitOf(player))) } - def coerceContextTo[G[_]: ContextCoercion[F, *[_]]]: PlayerDataFinalizer[G, Player] = + def coerceContextTo[G[_]: MonadThrow: ContextCoercion[F, *[_]]] + : PlayerDataFinalizer[G, Player] = transformContext[G](implicitly) } object PlayerDataFinalizer { - def apply[F[_], Player](f: Player => F[Unit]): PlayerDataFinalizer[F, Player] = - (player: Player) => f(player) + def apply[F[_]: MonadThrow, Player](f: Player => F[Unit]): PlayerDataFinalizer[F, Player] = + (player: Player) => retryUntilSucceeds(f(player)) import cats.effect.implicits._ import cats.implicits._ diff --git a/src/main/scala/com/github/unchama/datarepository/bukkit/player/BukkitRepositoryControls.scala b/src/main/scala/com/github/unchama/datarepository/bukkit/player/BukkitRepositoryControls.scala index fe292bf311..8d0649158a 100644 --- a/src/main/scala/com/github/unchama/datarepository/bukkit/player/BukkitRepositoryControls.scala +++ b/src/main/scala/com/github/unchama/datarepository/bukkit/player/BukkitRepositoryControls.scala @@ -1,7 +1,7 @@ package com.github.unchama.datarepository.bukkit.player import cats.effect.{Sync, SyncEffect, SyncIO} -import cats.{Monad, ~>} +import cats.{Monad, MonadThrow, ~>} import com.github.unchama.bungeesemaphoreresponder.domain.PlayerDataFinalizer import com.github.unchama.datarepository.template._ import com.github.unchama.datarepository.template.finalization.RepositoryFinalization @@ -25,7 +25,9 @@ case class BukkitRepositoryControls[F[_], R]( finalizer: PlayerDataFinalizer[F, Player] ) { - def transformFinalizationContext[G[_]](trans: F ~> G): BukkitRepositoryControls[G, R] = + def transformFinalizationContext[G[_]: MonadThrow]( + trans: F ~> G + ): BukkitRepositoryControls[G, R] = BukkitRepositoryControls( repository, initializer, @@ -38,7 +40,7 @@ case class BukkitRepositoryControls[F[_], R]( def map[S](f: R => S): BukkitRepositoryControls[F, S] = BukkitRepositoryControls(repository.map(f), initializer, backupProcess, finalizer) - def coerceFinalizationContextTo[G[_]: ContextCoercion[F, *[_]]] + def coerceFinalizationContextTo[G[_]: MonadThrow: ContextCoercion[F, *[_]]] : BukkitRepositoryControls[G, R] = transformFinalizationContext(ContextCoercion.asFunctionK) } diff --git a/src/main/scala/com/github/unchama/datarepository/definitions/RefDictBackedRepositoryDefinition.scala b/src/main/scala/com/github/unchama/datarepository/definitions/RefDictBackedRepositoryDefinition.scala index 4f5b06da60..254941c81c 100644 --- a/src/main/scala/com/github/unchama/datarepository/definitions/RefDictBackedRepositoryDefinition.scala +++ b/src/main/scala/com/github/unchama/datarepository/definitions/RefDictBackedRepositoryDefinition.scala @@ -1,7 +1,6 @@ package com.github.unchama.datarepository.definitions import cats.Monad -import cats.effect.MonadThrow import com.github.unchama.datarepository.template.RepositoryDefinition import com.github.unchama.datarepository.template.finalization.RepositoryFinalization import com.github.unchama.datarepository.template.initialization.{ @@ -9,7 +8,6 @@ import com.github.unchama.datarepository.template.initialization.{ SinglePhasedRepositoryInitialization } import com.github.unchama.generic.RefDict -import com.github.unchama.generic.effect.MonadThrowExtra.retryUntilSucceeds import java.util.UUID @@ -17,7 +15,7 @@ object RefDictBackedRepositoryDefinition { import cats.implicits._ - def usingUuidRefDictWithEffectfulDefault[F[_]: MonadThrow, Player, R]( + def usingUuidRefDictWithEffectfulDefault[F[_]: Monad, Player, R]( refDict: RefDict[F, UUID, R] )(getDefaultValue: F[R]): RepositoryDefinition.Phased.SinglePhased[F, Player, R] = { val initialization: SinglePhasedRepositoryInitialization[F, R] = @@ -31,14 +29,12 @@ object RefDictBackedRepositoryDefinition { .map(PrefetchResult.Success.apply) val finalization: RepositoryFinalization[F, UUID, R] = - RepositoryFinalization.withoutAnyFinalization((uuid, r) => - retryUntilSucceeds(refDict.write(uuid, r)) - ) + RepositoryFinalization.withoutAnyFinalization((uuid, r) => refDict.write(uuid, r)) RepositoryDefinition.Phased.SinglePhased.withoutTappingAction(initialization, finalization) } - def usingUuidRefDictWithoutDefault[F[_]: MonadThrow, Player, R]( + def usingUuidRefDictWithoutDefault[F[_]: Monad, Player, R]( refDict: RefDict[F, UUID, R] ): RepositoryDefinition.Phased.SinglePhased[F, Player, Option[R]] = { val initialization: SinglePhasedRepositoryInitialization[F, Option[R]] = @@ -46,13 +42,13 @@ object RefDictBackedRepositoryDefinition { val finalization: RepositoryFinalization[F, UUID, Option[R]] = RepositoryFinalization.withoutAnyFinalization((uuid, optR) => - optR.fold(Monad[F].pure(()))(r => retryUntilSucceeds(refDict.write(uuid, r))) + optR.fold(Monad[F].pure(()))(r => refDict.write(uuid, r)) ) RepositoryDefinition.Phased.SinglePhased.withoutTappingAction(initialization, finalization) } - def usingUuidRefDict[F[_]: MonadThrow, Player, R](refDict: RefDict[F, UUID, R])( + def usingUuidRefDict[F[_]: Monad, Player, R](refDict: RefDict[F, UUID, R])( defaultValue: R ): RepositoryDefinition.Phased.SinglePhased[F, Player, R] = usingUuidRefDictWithEffectfulDefault(refDict)(Monad[F].pure(defaultValue)) From 94f143e14f7438ad00864cebf3079094e606c239 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Apr 2023 01:46:08 +0900 Subject: [PATCH 452/482] =?UTF-8?q?chore:=20finalizer=E5=AE=9F=E8=A1=8C?= =?UTF-8?q?=E6=99=82=E3=81=ABretry=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listeners/BungeeSemaphoreCooperator.scala | 13 ++++++------- .../domain/PlayerDataFinalizer.scala | 12 +++++------- .../bukkit/player/BukkitRepositoryControls.scala | 8 +++----- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala index d004ca451b..61f4274099 100644 --- a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala +++ b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala @@ -6,6 +6,7 @@ import com.github.unchama.bungeesemaphoreresponder.Configuration import com.github.unchama.bungeesemaphoreresponder.domain.actions.BungeeSemaphoreSynchronization import com.github.unchama.bungeesemaphoreresponder.domain.{PlayerDataFinalizer, PlayerName} import com.github.unchama.generic.EitherExtra +import com.github.unchama.generic.effect.MonadThrowExtra.retryUntilSucceeds import com.github.unchama.generic.effect.unsafe.EffectEnvironment import org.bukkit.entity.Player import org.bukkit.event.player.PlayerQuitEvent @@ -37,14 +38,12 @@ class BungeeSemaphoreCooperator[F[_]: ConcurrentEffect: Timer]( extends Exception(s"Timeout ${configuration.saveTimeoutDuration} reached!") val program = for { - fiber <- finalizer.onQuitOf(player).attempt.start + fiber <- retryUntilSucceeds(finalizer.onQuitOf(player)).start result <- ConcurrentEffect[F].race(timeout, fiber.join) - _ <- EitherExtra.unassociate(result) match { - case Left(timeoutOrErrorOnFinalization) => - synchronization.notifySaveFailureOf(name) >> - ApplicativeError[F, Throwable].raiseError[Unit] { - timeoutOrErrorOnFinalization.getOrElse(TimeoutReached) - } + _ <- result match { + case Left(_) => + synchronization.notifySaveFailureOf(name) >> ApplicativeError[F, Throwable] + .raiseError[Unit](TimeoutReached) case Right(_) => synchronization.confirmSaveCompletionOf(name) } diff --git a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/domain/PlayerDataFinalizer.scala b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/domain/PlayerDataFinalizer.scala index edc1e8a38e..45e6a72a3d 100644 --- a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/domain/PlayerDataFinalizer.scala +++ b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/domain/PlayerDataFinalizer.scala @@ -1,9 +1,8 @@ package com.github.unchama.bungeesemaphoreresponder.domain import cats.effect.ConcurrentEffect -import cats.{Applicative, ApplicativeError, MonadThrow, ~>} +import cats.{Applicative, ApplicativeError, ~>} import com.github.unchama.generic.ContextCoercion -import com.github.unchama.generic.effect.MonadThrowExtra.retryUntilSucceeds /** * The type of a pure callback object that should be invoked when a player quits the Minecraft @@ -25,20 +24,19 @@ trait PlayerDataFinalizer[F[_], Player] { */ def onQuitOf(player: Player): F[Unit] - def transformContext[G[_]: MonadThrow](trans: F ~> G): PlayerDataFinalizer[G, Player] = { + def transformContext[G[_]](trans: F ~> G): PlayerDataFinalizer[G, Player] = { PlayerDataFinalizer(player => trans.apply(onQuitOf(player))) } - def coerceContextTo[G[_]: MonadThrow: ContextCoercion[F, *[_]]] - : PlayerDataFinalizer[G, Player] = + def coerceContextTo[G[_]: ContextCoercion[F, *[_]]]: PlayerDataFinalizer[G, Player] = transformContext[G](implicitly) } object PlayerDataFinalizer { - def apply[F[_]: MonadThrow, Player](f: Player => F[Unit]): PlayerDataFinalizer[F, Player] = - (player: Player) => retryUntilSucceeds(f(player)) + def apply[F[_], Player](f: Player => F[Unit]): PlayerDataFinalizer[F, Player] = + (player: Player) => f(player) import cats.effect.implicits._ import cats.implicits._ diff --git a/src/main/scala/com/github/unchama/datarepository/bukkit/player/BukkitRepositoryControls.scala b/src/main/scala/com/github/unchama/datarepository/bukkit/player/BukkitRepositoryControls.scala index 8d0649158a..fe292bf311 100644 --- a/src/main/scala/com/github/unchama/datarepository/bukkit/player/BukkitRepositoryControls.scala +++ b/src/main/scala/com/github/unchama/datarepository/bukkit/player/BukkitRepositoryControls.scala @@ -1,7 +1,7 @@ package com.github.unchama.datarepository.bukkit.player import cats.effect.{Sync, SyncEffect, SyncIO} -import cats.{Monad, MonadThrow, ~>} +import cats.{Monad, ~>} import com.github.unchama.bungeesemaphoreresponder.domain.PlayerDataFinalizer import com.github.unchama.datarepository.template._ import com.github.unchama.datarepository.template.finalization.RepositoryFinalization @@ -25,9 +25,7 @@ case class BukkitRepositoryControls[F[_], R]( finalizer: PlayerDataFinalizer[F, Player] ) { - def transformFinalizationContext[G[_]: MonadThrow]( - trans: F ~> G - ): BukkitRepositoryControls[G, R] = + def transformFinalizationContext[G[_]](trans: F ~> G): BukkitRepositoryControls[G, R] = BukkitRepositoryControls( repository, initializer, @@ -40,7 +38,7 @@ case class BukkitRepositoryControls[F[_], R]( def map[S](f: R => S): BukkitRepositoryControls[F, S] = BukkitRepositoryControls(repository.map(f), initializer, backupProcess, finalizer) - def coerceFinalizationContextTo[G[_]: MonadThrow: ContextCoercion[F, *[_]]] + def coerceFinalizationContextTo[G[_]: ContextCoercion[F, *[_]]] : BukkitRepositoryControls[G, R] = transformFinalizationContext(ContextCoercion.asFunctionK) } From 93aebe4ba09981274c95aa017e8cf0c4dd4c4662 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 23 Apr 2023 22:35:18 +0900 Subject: [PATCH 453/482] =?UTF-8?q?feat:=20retryUnitlSucceeds=E3=81=ABretr?= =?UTF-8?q?y=E3=81=AE=E4=B8=8A=E9=99=90=E5=80=A4=E3=82=92=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listeners/BungeeSemaphoreCooperator.scala | 3 +-- .../generic/effect/MonadThrowExtra.scala | 23 ++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala index 61f4274099..d0e9a8a2ce 100644 --- a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala +++ b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala @@ -5,7 +5,6 @@ import cats.effect.{Async, ConcurrentEffect, Timer} import com.github.unchama.bungeesemaphoreresponder.Configuration import com.github.unchama.bungeesemaphoreresponder.domain.actions.BungeeSemaphoreSynchronization import com.github.unchama.bungeesemaphoreresponder.domain.{PlayerDataFinalizer, PlayerName} -import com.github.unchama.generic.EitherExtra import com.github.unchama.generic.effect.MonadThrowExtra.retryUntilSucceeds import com.github.unchama.generic.effect.unsafe.EffectEnvironment import org.bukkit.entity.Player @@ -38,7 +37,7 @@ class BungeeSemaphoreCooperator[F[_]: ConcurrentEffect: Timer]( extends Exception(s"Timeout ${configuration.saveTimeoutDuration} reached!") val program = for { - fiber <- retryUntilSucceeds(finalizer.onQuitOf(player)).start + fiber <- retryUntilSucceeds(finalizer.onQuitOf(player))(10).start result <- ConcurrentEffect[F].race(timeout, fiber.join) _ <- result match { case Left(_) => diff --git a/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala index b2ec62eefb..4704d89715 100644 --- a/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala +++ b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala @@ -1,19 +1,26 @@ package com.github.unchama.generic.effect +import cats.MonadError import cats.effect.MonadThrow object MonadThrowExtra { import cats.implicits._ - def retryUntilSucceeds[F[_]: MonadThrow, A](fa: F[A]): F[A] = { - fa.attempt.flatMap { - case Right(a) => a.pure[F] - case Left(error) => - retryUntilSucceeds(fa).map { a => - error.printStackTrace() - a - } + def retryUntilSucceeds[F[_]: MonadThrow, A](fa: F[A])(limit: Int, now: Int = 0): F[A] = { + if (now <= limit) { + fa.attempt.flatMap { + case Right(a) => a.pure[F] + case Left(error) => + retryUntilSucceeds(fa)(limit, now + 1).map { a => + error.printStackTrace() + a + } + } + } else { + case object LimitReached extends Exception(s"Limit $limit reached!") + + MonadError[F, Throwable].raiseError(LimitReached) } } From 32768ccda1cef5fcac2200d556a03bd368739e94 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 25 Apr 2023 23:48:42 +0900 Subject: [PATCH 454/482] =?UTF-8?q?chore:=20finalizer=E3=81=AE=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=81=A7=E5=A4=B1=E6=95=97=E3=81=97=E3=81=9F=E3=82=82?= =?UTF-8?q?=E3=81=AE=E3=81=A0=E3=81=91=E3=83=AA=E3=83=88=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bungeesemaphoreresponder/System.scala | 4 ++-- .../listeners/BungeeSemaphoreCooperator.scala | 9 +++++--- .../domain/PlayerDataFinalizer.scala | 23 ++++++++++--------- .../unchama/seichiassist/SeichiAssist.scala | 5 +++- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/System.scala b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/System.scala index c6bbed2cb2..830a55e2ab 100644 --- a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/System.scala +++ b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/System.scala @@ -11,7 +11,7 @@ import org.bukkit.entity.Player import org.bukkit.event.Listener class System[F[_]: ConcurrentEffect: Timer]( - val finalizer: PlayerDataFinalizer[F, Player], + val finalizers: List[PlayerDataFinalizer[F, Player]], messagePublishingContext: ContextShift[IO] )( implicit configuration: Configuration, @@ -26,6 +26,6 @@ class System[F[_]: ConcurrentEffect: Timer]( implicit val _synchronization: BungeeSemaphoreSynchronization[F[Unit], PlayerName] = { new RedisBungeeSemaphoreSynchronization[F]() } - Seq(new BungeeSemaphoreCooperator[F](finalizer)) + Seq(new BungeeSemaphoreCooperator[F](finalizers)) } } diff --git a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala index d0e9a8a2ce..7bc9645944 100644 --- a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala +++ b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala @@ -14,7 +14,7 @@ import org.bukkit.event.{EventHandler, EventPriority, Listener} import scala.concurrent.duration.{Duration, FiniteDuration} class BungeeSemaphoreCooperator[F[_]: ConcurrentEffect: Timer]( - finalizer: PlayerDataFinalizer[F, Player] + finalizers: List[PlayerDataFinalizer[F, Player]] )( implicit synchronization: BungeeSemaphoreSynchronization[F[Unit], PlayerName], configuration: Configuration, @@ -37,8 +37,11 @@ class BungeeSemaphoreCooperator[F[_]: ConcurrentEffect: Timer]( extends Exception(s"Timeout ${configuration.saveTimeoutDuration} reached!") val program = for { - fiber <- retryUntilSucceeds(finalizer.onQuitOf(player))(10).start - result <- ConcurrentEffect[F].race(timeout, fiber.join) + fibers <- finalizers.traverse { finalizer => + retryUntilSucceeds(finalizer.onQuitOf(player))(10).start + } + joinedFibers = fibers.map(_.join).reduceLeft(_ >> _) + result <- ConcurrentEffect[F].race(timeout, joinedFibers) _ <- result match { case Left(_) => synchronization.notifySaveFailureOf(name) >> ApplicativeError[F, Throwable] diff --git a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/domain/PlayerDataFinalizer.scala b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/domain/PlayerDataFinalizer.scala index 45e6a72a3d..5e600ba02b 100644 --- a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/domain/PlayerDataFinalizer.scala +++ b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/domain/PlayerDataFinalizer.scala @@ -43,19 +43,20 @@ object PlayerDataFinalizer { def concurrently[F[_]: ConcurrentEffect, Player]( finalizers: List[PlayerDataFinalizer[F, Player]] - ): PlayerDataFinalizer[F, Player] = - PlayerDataFinalizer { player => - for { - fibers <- finalizers.traverse(_.onQuitOf(player).attempt.start) - results <- fibers.traverse(_.join) - _ <- - // TODO: 最初のエラーしか報告されていないが、全部報告すべき - results.collectFirst { case Left(error) => error } match { - case Some(error) => + ): List[PlayerDataFinalizer[F, Player]] = { + finalizers.map { finalizer => + PlayerDataFinalizer { player => + for { + fiber <- finalizer.onQuitOf(player).attempt.start + result <- fiber.join + _ <- result match { + case Left(error) => ApplicativeError[F, Throwable].raiseError(error) - case None => + case Right(_) => Applicative[F].unit } - } yield () + } yield () + } } + } } diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index eb159d2e64..6ed6f8b9d6 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -869,8 +869,11 @@ class SeichiAssist extends JavaPlugin() { .getOnlinePlayers .asScala .toList - .traverse(bungeeSemaphoreResponderSystem.finalizer.onQuitOf) + .flatTraverse { player => + bungeeSemaphoreResponderSystem.finalizers.traverse(_.onQuitOf(player)) + } .unsafeRunSync() + .foreach(_ => ()) if (SeichiAssist.databaseGateway.disconnect() == ActionStatus.Fail) { logger.info("データベース切断に失敗しました") From 2aa794b7fbb4d3a5c2d33e5f867c4e02e5b61c0f Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 27 Apr 2023 14:44:05 +0900 Subject: [PATCH 455/482] =?UTF-8?q?fix:=20finalizers=E3=82=92=E5=AE=9F?= =?UTF-8?q?=E8=A1=8C=E3=81=99=E3=82=8B=E3=81=9F=E3=82=81=E3=81=AB=E5=8D=98?= =?UTF-8?q?=E3=81=ABunsafeRunSync=E3=81=99=E3=82=8B=E3=81=A0=E3=81=91?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scala/com/github/unchama/seichiassist/SeichiAssist.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 6ed6f8b9d6..a71d07541e 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -873,7 +873,6 @@ class SeichiAssist extends JavaPlugin() { bungeeSemaphoreResponderSystem.finalizers.traverse(_.onQuitOf(player)) } .unsafeRunSync() - .foreach(_ => ()) if (SeichiAssist.databaseGateway.disconnect() == ActionStatus.Fail) { logger.info("データベース切断に失敗しました") From 54e7988de41ad2d77520463715405bf49d72c0c4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 27 Apr 2023 14:53:49 +0900 Subject: [PATCH 456/482] =?UTF-8?q?style:=20retryUntilSucceeds=E3=81=AB?= =?UTF-8?q?=E5=AF=BE=E3=81=97=E3=81=A6now=E3=82=92=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generic/effect/MonadThrowExtra.scala | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala index 4704d89715..bd2ffc373d 100644 --- a/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala +++ b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala @@ -7,21 +7,25 @@ object MonadThrowExtra { import cats.implicits._ - def retryUntilSucceeds[F[_]: MonadThrow, A](fa: F[A])(limit: Int, now: Int = 0): F[A] = { - if (now <= limit) { - fa.attempt.flatMap { - case Right(a) => a.pure[F] - case Left(error) => - retryUntilSucceeds(fa)(limit, now + 1).map { a => - error.printStackTrace() - a - } - } - } else { - case object LimitReached extends Exception(s"Limit $limit reached!") + def retryUntilSucceeds[F[_]: MonadThrow, A](fa: F[A])(limit: Int): F[A] = { + def go(currentIterationCount: Int): F[A] = { + if (currentIterationCount <= limit) { + fa.attempt.flatMap { + case Right(a) => a.pure[F] + case Left(error) => + go(currentIterationCount + 1).map { a => + error.printStackTrace() + a + } + } + } else { + case object LimitReached extends Exception(s"Limit $limit reached!") - MonadError[F, Throwable].raiseError(LimitReached) + MonadError[F, Throwable].raiseError(LimitReached) + } } + + go(0) } } From 2775b4363a32aea0e08a39b62e157f79aa93b6f4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 27 Apr 2023 15:00:23 +0900 Subject: [PATCH 457/482] =?UTF-8?q?feat:=20LimitReached=E3=81=AB=E6=9C=80?= =?UTF-8?q?=E5=BE=8C=E3=81=AB=E7=99=BA=E7=94=9F=E3=81=97=E3=81=9F=E4=BE=8B?= =?UTF-8?q?=E5=A4=96=E3=82=92=E5=90=AB=E3=82=80=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/generic/effect/MonadThrowExtra.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala index bd2ffc373d..f0ea74d921 100644 --- a/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala +++ b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala @@ -8,24 +8,25 @@ object MonadThrowExtra { import cats.implicits._ def retryUntilSucceeds[F[_]: MonadThrow, A](fa: F[A])(limit: Int): F[A] = { - def go(currentIterationCount: Int): F[A] = { + def go(currentIterationCount: Int, lastException: Option[Throwable]): F[A] = { if (currentIterationCount <= limit) { fa.attempt.flatMap { case Right(a) => a.pure[F] case Left(error) => - go(currentIterationCount + 1).map { a => + go(currentIterationCount + 1, Some(error)).map { a => error.printStackTrace() a } } } else { - case object LimitReached extends Exception(s"Limit $limit reached!") + // このelse節に入っている時点で1度は失敗しているので、`lastException`が`None`であることはありえない。 + case object LimitReached extends Exception(s"Limit $limit reached!", lastException.get) MonadError[F, Throwable].raiseError(LimitReached) } } - go(0) + go(0, None) } } From b37c80568cc36bff9da1a3c21646d29196c72a70 Mon Sep 17 00:00:00 2001 From: rito528 Date: Thu, 27 Apr 2023 15:09:51 +0900 Subject: [PATCH 458/482] =?UTF-8?q?refactor:=20concurrently=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/PlayerDataFinalizer.scala | 24 +------------------ .../unchama/seichiassist/SeichiAssist.scala | 16 ++++++------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/domain/PlayerDataFinalizer.scala b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/domain/PlayerDataFinalizer.scala index 5e600ba02b..6ef72324c2 100644 --- a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/domain/PlayerDataFinalizer.scala +++ b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/domain/PlayerDataFinalizer.scala @@ -1,7 +1,6 @@ package com.github.unchama.bungeesemaphoreresponder.domain -import cats.effect.ConcurrentEffect -import cats.{Applicative, ApplicativeError, ~>} +import cats.~> import com.github.unchama.generic.ContextCoercion /** @@ -38,25 +37,4 @@ object PlayerDataFinalizer { def apply[F[_], Player](f: Player => F[Unit]): PlayerDataFinalizer[F, Player] = (player: Player) => f(player) - import cats.effect.implicits._ - import cats.implicits._ - - def concurrently[F[_]: ConcurrentEffect, Player]( - finalizers: List[PlayerDataFinalizer[F, Player]] - ): List[PlayerDataFinalizer[F, Player]] = { - finalizers.map { finalizer => - PlayerDataFinalizer { player => - for { - fiber <- finalizer.onQuitOf(player).attempt.start - result <- fiber.join - _ <- result match { - case Left(error) => - ApplicativeError[F, Throwable].raiseError(error) - case Right(_) => - Applicative[F].unit - } - } yield () - } - } - } } diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index a71d07541e..5d9dc4d1ba 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -546,15 +546,13 @@ class SeichiAssist extends JavaPlugin() { import PluginExecutionContexts.timer new BungeeSemaphoreResponderSystem( - PlayerDataFinalizer.concurrently[IO, Player]( - Seq( - savePlayerData, - assaultSkillRoutinesRepositoryControls.finalizer.coerceContextTo[IO], - activeSkillAvailabilityRepositoryControls.finalizer.coerceContextTo[IO] - ).appendedAll(wiredSubsystems.flatMap(_.managedFinalizers)) - .appendedAll(wiredSubsystems.flatMap(_.managedRepositoryControls.map(_.finalizer))) - .toList - ), + Seq( + savePlayerData, + assaultSkillRoutinesRepositoryControls.finalizer.coerceContextTo[IO], + activeSkillAvailabilityRepositoryControls.finalizer.coerceContextTo[IO] + ).appendedAll(wiredSubsystems.flatMap(_.managedFinalizers)) + .appendedAll(wiredSubsystems.flatMap(_.managedRepositoryControls.map(_.finalizer))) + .toList, PluginExecutionContexts.asyncShift ) } From 596c9c20779b72a0c6449ffe7b32f2acca3b7a62 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 30 Apr 2023 00:47:16 +0900 Subject: [PATCH 459/482] =?UTF-8?q?feat:=20runConcurrentlyCancellable?= =?UTF-8?q?=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/generic/effect/ConcurrentExtra.scala | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/scala/com/github/unchama/generic/effect/ConcurrentExtra.scala b/src/main/scala/com/github/unchama/generic/effect/ConcurrentExtra.scala index a7a5576702..5f5df7ce4b 100644 --- a/src/main/scala/com/github/unchama/generic/effect/ConcurrentExtra.scala +++ b/src/main/scala/com/github/unchama/generic/effect/ConcurrentExtra.scala @@ -33,4 +33,13 @@ object ConcurrentExtra { a <- fiber.join } yield a + + import cats.effect._ + + def runConcurrentlyCancellable[F[_]: ConcurrentEffect, A](programs: List[F[A]]): F[List[A]] = + for { + fibers <- programs.traverse(Concurrent[F].start(_)) + _ <- Concurrent[F].start(fibers.map(_.cancel).sequence) + result <- fibers.traverse(_.join.attempt).map(_.collect { case Right(result) => result }) + } yield result } From 751c2194631c4d999fe20bea73a24e98c5eece30 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 30 Apr 2023 00:54:19 +0900 Subject: [PATCH 460/482] =?UTF-8?q?refactor:=20runConcurrentlyCancellable?= =?UTF-8?q?=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/listeners/BungeeSemaphoreCooperator.scala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala index 7bc9645944..465a06e747 100644 --- a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala +++ b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala @@ -5,6 +5,7 @@ import cats.effect.{Async, ConcurrentEffect, Timer} import com.github.unchama.bungeesemaphoreresponder.Configuration import com.github.unchama.bungeesemaphoreresponder.domain.actions.BungeeSemaphoreSynchronization import com.github.unchama.bungeesemaphoreresponder.domain.{PlayerDataFinalizer, PlayerName} +import com.github.unchama.generic.effect.ConcurrentExtra.runConcurrentlyCancellable import com.github.unchama.generic.effect.MonadThrowExtra.retryUntilSucceeds import com.github.unchama.generic.effect.unsafe.EffectEnvironment import org.bukkit.entity.Player @@ -36,12 +37,12 @@ class BungeeSemaphoreCooperator[F[_]: ConcurrentEffect: Timer]( case object TimeoutReached extends Exception(s"Timeout ${configuration.saveTimeoutDuration} reached!") + val quitProcess = runConcurrentlyCancellable( + finalizers.map(finalizer => retryUntilSucceeds(finalizer.onQuitOf(player))(10)) + ) + val program = for { - fibers <- finalizers.traverse { finalizer => - retryUntilSucceeds(finalizer.onQuitOf(player))(10).start - } - joinedFibers = fibers.map(_.join).reduceLeft(_ >> _) - result <- ConcurrentEffect[F].race(timeout, joinedFibers) + result <- ConcurrentEffect[F].race(timeout, quitProcess) _ <- result match { case Left(_) => synchronization.notifySaveFailureOf(name) >> ApplicativeError[F, Throwable] From 46cec0ce795107b86ab1f8887025f7b5b8c3584c Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 30 Apr 2023 00:57:40 +0900 Subject: [PATCH 461/482] style: apply scalafmt and scalafix --- .../bukkit/listeners/BungeeSemaphoreCooperator.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala index 465a06e747..d82e02cbe4 100644 --- a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala +++ b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala @@ -22,7 +22,6 @@ class BungeeSemaphoreCooperator[F[_]: ConcurrentEffect: Timer]( effectEnvironment: EffectEnvironment ) extends Listener { - import cats.effect.implicits._ import cats.implicits._ @EventHandler(priority = EventPriority.LOWEST) From 910bd1465c5b21e7649345ab6ccf084f9a0aaa79 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 30 Apr 2023 16:43:06 +0900 Subject: [PATCH 462/482] =?UTF-8?q?fix:=20retryUnitilSecceeds=E3=81=AElimi?= =?UTF-8?q?t=E3=81=AB1=E4=BB=A5=E4=B8=8A=E3=81=AE=E5=88=B6=E9=99=90?= =?UTF-8?q?=E3=82=92=E3=81=8B=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/unchama/generic/effect/MonadThrowExtra.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala index f0ea74d921..b7cf42b30b 100644 --- a/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala +++ b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala @@ -8,6 +8,7 @@ object MonadThrowExtra { import cats.implicits._ def retryUntilSucceeds[F[_]: MonadThrow, A](fa: F[A])(limit: Int): F[A] = { + require(limit >= 1) def go(currentIterationCount: Int, lastException: Option[Throwable]): F[A] = { if (currentIterationCount <= limit) { fa.attempt.flatMap { From 32c671d49bacdb49f0f72466336fb0331042c783 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 30 Apr 2023 22:32:05 +0900 Subject: [PATCH 463/482] =?UTF-8?q?chore:=20go=E3=81=A7=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E3=81=97=E3=81=9F=E5=A0=B4=E5=90=88=E3=81=AB=E4=BB=8A=E3=81=BE?= =?UTF-8?q?=E3=81=A7=E7=99=BA=E7=94=9F=E3=81=97=E3=81=9F=E4=BE=8B=E5=A4=96?= =?UTF-8?q?=E3=82=92=E3=83=AD=E3=82=B0=E3=81=AB=E6=AE=8B=E3=81=99=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generic/effect/MonadThrowExtra.scala | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala index b7cf42b30b..f38b9d13b2 100644 --- a/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala +++ b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala @@ -9,25 +9,27 @@ object MonadThrowExtra { def retryUntilSucceeds[F[_]: MonadThrow, A](fa: F[A])(limit: Int): F[A] = { require(limit >= 1) - def go(currentIterationCount: Int, lastException: Option[Throwable]): F[A] = { + def go(currentIterationCount: Int, occurredExceptions: List[Throwable]): F[A] = { if (currentIterationCount <= limit) { fa.attempt.flatMap { - case Right(a) => a.pure[F] - case Left(error) => - go(currentIterationCount + 1, Some(error)).map { a => - error.printStackTrace() + case Right(a) => + a.pure[F].map { a => + occurredExceptions.foreach(_.printStackTrace()) a } + case Left(error) => + go(currentIterationCount + 1, occurredExceptions :+ error) } } else { - // このelse節に入っている時点で1度は失敗しているので、`lastException`が`None`であることはありえない。 - case object LimitReached extends Exception(s"Limit $limit reached!", lastException.get) + // このelse節に入っている時点で1度は失敗しているので、`occurredExceptions`が`empty`であることはありえない。 + case object LimitReached + extends Exception(s"Limit $limit reached!", occurredExceptions.last) MonadError[F, Throwable].raiseError(LimitReached) } } - go(0, None) + go(0, Nil) } } From c2a3995cd6bda8fabed299462b0c64da0d5da472 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 30 Apr 2023 22:42:31 +0900 Subject: [PATCH 464/482] =?UTF-8?q?refactor:=20printStackTrace=E3=82=92Syn?= =?UTF-8?q?c#delay=E3=81=A7=E5=8C=85=E3=82=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/unchama/generic/effect/MonadThrowExtra.scala | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala index f38b9d13b2..dbe23a30a1 100644 --- a/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala +++ b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala @@ -1,22 +1,19 @@ package com.github.unchama.generic.effect import cats.MonadError -import cats.effect.MonadThrow +import cats.effect.{MonadThrow, Sync} object MonadThrowExtra { import cats.implicits._ - def retryUntilSucceeds[F[_]: MonadThrow, A](fa: F[A])(limit: Int): F[A] = { + def retryUntilSucceeds[F[_]: Sync, A](fa: F[A])(limit: Int): F[A] = { require(limit >= 1) def go(currentIterationCount: Int, occurredExceptions: List[Throwable]): F[A] = { if (currentIterationCount <= limit) { fa.attempt.flatMap { case Right(a) => - a.pure[F].map { a => - occurredExceptions.foreach(_.printStackTrace()) - a - } + Sync[F].delay(occurredExceptions.foreach(_.printStackTrace())).as(a) case Left(error) => go(currentIterationCount + 1, occurredExceptions :+ error) } From c3f8674253d985b5115a0a5a04bbb33af385d095 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 7 May 2023 15:14:56 +0900 Subject: [PATCH 465/482] =?UTF-8?q?fix:=20quitProcess=E3=81=A7Throwable?= =?UTF-8?q?=E3=81=8C=E5=B8=B0=E3=81=A3=E3=81=A6=E3=81=8D=E3=81=9F=E3=81=A8?= =?UTF-8?q?=E3=81=8D=E3=81=ABraiseError=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listeners/BungeeSemaphoreCooperator.scala | 7 +++-- .../generic/effect/ConcurrentExtra.scala | 31 +++++++++++++++---- .../generic/effect/MonadThrowExtra.scala | 2 +- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala index d82e02cbe4..0cbe834d90 100644 --- a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala +++ b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala @@ -5,7 +5,7 @@ import cats.effect.{Async, ConcurrentEffect, Timer} import com.github.unchama.bungeesemaphoreresponder.Configuration import com.github.unchama.bungeesemaphoreresponder.domain.actions.BungeeSemaphoreSynchronization import com.github.unchama.bungeesemaphoreresponder.domain.{PlayerDataFinalizer, PlayerName} -import com.github.unchama.generic.effect.ConcurrentExtra.runConcurrentlyCancellable +import com.github.unchama.generic.effect.ConcurrentExtra.attemptInParallel import com.github.unchama.generic.effect.MonadThrowExtra.retryUntilSucceeds import com.github.unchama.generic.effect.unsafe.EffectEnvironment import org.bukkit.entity.Player @@ -36,7 +36,7 @@ class BungeeSemaphoreCooperator[F[_]: ConcurrentEffect: Timer]( case object TimeoutReached extends Exception(s"Timeout ${configuration.saveTimeoutDuration} reached!") - val quitProcess = runConcurrentlyCancellable( + val quitProcess = attemptInParallel( finalizers.map(finalizer => retryUntilSucceeds(finalizer.onQuitOf(player))(10)) ) @@ -46,6 +46,9 @@ class BungeeSemaphoreCooperator[F[_]: ConcurrentEffect: Timer]( case Left(_) => synchronization.notifySaveFailureOf(name) >> ApplicativeError[F, Throwable] .raiseError[Unit](TimeoutReached) + case Right(List(Left(e))) => + synchronization.notifySaveFailureOf(name) >> ApplicativeError[F, Throwable] + .raiseError[Unit](e) case Right(_) => synchronization.confirmSaveCompletionOf(name) } diff --git a/src/main/scala/com/github/unchama/generic/effect/ConcurrentExtra.scala b/src/main/scala/com/github/unchama/generic/effect/ConcurrentExtra.scala index 5f5df7ce4b..a7b6ec4a4b 100644 --- a/src/main/scala/com/github/unchama/generic/effect/ConcurrentExtra.scala +++ b/src/main/scala/com/github/unchama/generic/effect/ConcurrentExtra.scala @@ -1,5 +1,6 @@ package com.github.unchama.generic.effect +import cats.Applicative import cats.effect.concurrent.Deferred import cats.effect.{CancelToken, Concurrent} @@ -36,10 +37,28 @@ object ConcurrentExtra { import cats.effect._ - def runConcurrentlyCancellable[F[_]: ConcurrentEffect, A](programs: List[F[A]]): F[List[A]] = - for { - fibers <- programs.traverse(Concurrent[F].start(_)) - _ <- Concurrent[F].start(fibers.map(_.cancel).sequence) - result <- fibers.traverse(_.join.attempt).map(_.collect { case Right(result) => result }) - } yield result + /** + * 与えられた複数の入力プログラムをすべて並列に実行するようなプログラムを構築します。 + * 構築されたプログラムは次のような挙動をします: + * - 構築されたプログラムの実行 fiber がキャンセルされた時、 + * その時点で並列で走っている入力プログラムの実行 fiber がすべてキャンセルされます + * - 入力プログラムの実行 fiber がエラー等で早期終了しても、他の実行 fiber への影響はありません + * (一つの fiber が異常終了しても、他の fiber のキャンセルなどは行われません) + * - 結果の `List[Either[Throwable, A]]` は入力プログラムの終了結果を + * (入力プログラムが与えられた順と同じ順で) 保持しています。 + * + * 各値は + * - `Right[A]` だった場合、入力プログラムが `A` を結果として正常終了したこと + * - `Left[Throwable]` だった場合、入力プログラムが例外を送出して異常終了したこと + * をそれぞれ表します。 + */ + def attemptInParallel[F[_]: ConcurrentEffect, A]( + programs: List[F[A]] + ): F[List[Either[Throwable, A]]] = { + ConcurrentEffect[F] + .bracketCase(programs.traverse(Concurrent[F].start(_)))(_.traverse(_.join.attempt)) { + case (fibers, ExitCase.Canceled) => fibers.traverse(_.cancel).void + case _ => Applicative[F].unit + } + } } diff --git a/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala index dbe23a30a1..49e8a5a31d 100644 --- a/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala +++ b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala @@ -1,7 +1,7 @@ package com.github.unchama.generic.effect import cats.MonadError -import cats.effect.{MonadThrow, Sync} +import cats.effect.Sync object MonadThrowExtra { From e7560b613bcc15365b8b07ec70f7e23da1d3c22f Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 7 May 2023 15:57:59 +0900 Subject: [PATCH 466/482] =?UTF-8?q?fix:=20occurredExceptions=E3=81=AE?= =?UTF-8?q?=E5=9E=8B=E3=82=B7=E3=82=B0=E3=83=8D=E3=83=81=E3=83=A3=E3=82=92?= =?UTF-8?q?Option=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/generic/effect/MonadThrowExtra.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala index 49e8a5a31d..419b88733b 100644 --- a/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala +++ b/src/main/scala/com/github/unchama/generic/effect/MonadThrowExtra.scala @@ -9,24 +9,24 @@ object MonadThrowExtra { def retryUntilSucceeds[F[_]: Sync, A](fa: F[A])(limit: Int): F[A] = { require(limit >= 1) - def go(currentIterationCount: Int, occurredExceptions: List[Throwable]): F[A] = { + def go(currentIterationCount: Int, occurredException: Option[Throwable]): F[A] = { if (currentIterationCount <= limit) { fa.attempt.flatMap { case Right(a) => - Sync[F].delay(occurredExceptions.foreach(_.printStackTrace())).as(a) + Sync[F].delay(occurredException.foreach(_.printStackTrace())).as(a) case Left(error) => - go(currentIterationCount + 1, occurredExceptions :+ error) + go(currentIterationCount + 1, Some(error)) } } else { - // このelse節に入っている時点で1度は失敗しているので、`occurredExceptions`が`empty`であることはありえない。 + // このelse節に入っている時点で1度は失敗しているので、`occurredExceptions`が`None`であることはありえない。 case object LimitReached - extends Exception(s"Limit $limit reached!", occurredExceptions.last) + extends Exception(s"Limit $limit reached!", occurredException.last) MonadError[F, Throwable].raiseError(LimitReached) } } - go(0, Nil) + go(0, None) } } From 97bf8c1be8fc1b3f60322c248d130abc11351371 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 7 May 2023 16:23:45 +0900 Subject: [PATCH 467/482] =?UTF-8?q?fix:=20Right=E3=81=8C=E5=B8=B0=E3=81=A3?= =?UTF-8?q?=E3=81=A6=E3=81=8D=E3=81=9F=E3=81=A8=E3=81=8D=E3=81=ABtraverse?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=99=E3=81=B9=E3=81=A6=E3=81=AE=E8=A6=81?= =?UTF-8?q?=E7=B4=A0=E3=82=92=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listeners/BungeeSemaphoreCooperator.scala | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala index 0cbe834d90..ea623e638c 100644 --- a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala +++ b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala @@ -41,16 +41,19 @@ class BungeeSemaphoreCooperator[F[_]: ConcurrentEffect: Timer]( ) val program = for { - result <- ConcurrentEffect[F].race(timeout, quitProcess) - _ <- result match { + raceResult <- ConcurrentEffect[F].race(timeout, quitProcess) + _ <- raceResult match { case Left(_) => synchronization.notifySaveFailureOf(name) >> ApplicativeError[F, Throwable] .raiseError[Unit](TimeoutReached) - case Right(List(Left(e))) => - synchronization.notifySaveFailureOf(name) >> ApplicativeError[F, Throwable] - .raiseError[Unit](e) - case Right(_) => - synchronization.confirmSaveCompletionOf(name) + case Right(result) => + result.traverse { + case Left(e) => + synchronization.notifySaveFailureOf(name) >> ApplicativeError[F, Throwable] + .raiseError[Unit](e) + case Right(_) => + synchronization.confirmSaveCompletionOf(name) + } } } yield () From 944df64908766c370e51db2f553591de2aa29ba4 Mon Sep 17 00:00:00 2001 From: rito528 Date: Sun, 7 May 2023 22:31:17 +0900 Subject: [PATCH 468/482] =?UTF-8?q?fix:=20=E3=81=99=E3=81=B9=E3=81=A6?= =?UTF-8?q?=E3=81=AE=E3=83=97=E3=83=AD=E3=82=BB=E3=82=B9=E3=81=8C=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E3=81=99=E3=82=8C=E3=81=B0save=E3=81=97=E3=80=81?= =?UTF-8?q?=E3=81=9D=E3=81=86=E3=81=98=E3=82=83=E3=81=AA=E3=81=91=E3=82=8C?= =?UTF-8?q?=E3=81=B0=E3=81=99=E3=81=B9=E3=81=A6raiseError=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listeners/BungeeSemaphoreCooperator.scala | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala index ea623e638c..49911e484e 100644 --- a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala +++ b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala @@ -1,6 +1,6 @@ package com.github.unchama.bungeesemaphoreresponder.bukkit.listeners -import cats.ApplicativeError +import cats.{Applicative, ApplicativeError} import cats.effect.{Async, ConcurrentEffect, Timer} import com.github.unchama.bungeesemaphoreresponder.Configuration import com.github.unchama.bungeesemaphoreresponder.domain.actions.BungeeSemaphoreSynchronization @@ -46,13 +46,17 @@ class BungeeSemaphoreCooperator[F[_]: ConcurrentEffect: Timer]( case Left(_) => synchronization.notifySaveFailureOf(name) >> ApplicativeError[F, Throwable] .raiseError[Unit](TimeoutReached) - case Right(result) => - result.traverse { - case Left(e) => - synchronization.notifySaveFailureOf(name) >> ApplicativeError[F, Throwable] - .raiseError[Unit](e) - case Right(_) => + case Right(results) => + results.partition(_.isRight) match { + case (_, Nil) => synchronization.confirmSaveCompletionOf(name) + case (_, lefts) => + lefts.traverse { + case Left(throwable) => + synchronization.notifySaveFailureOf(name) >> ApplicativeError[F, Throwable] + .raiseError[Unit](throwable) + case Right(_) => Applicative[F].unit + } } } } yield () From 9debe674aa9517472aa2537401c737cef6ee3ce1 Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 8 May 2023 00:21:21 +0900 Subject: [PATCH 469/482] =?UTF-8?q?fix:=20Validated=E3=82=92=E4=BD=BF?= =?UTF-8?q?=E3=81=A3=E3=81=A6=E3=82=A8=E3=83=A9=E3=83=BC=E3=83=AD=E3=82=B0?= =?UTF-8?q?=E3=82=92=E3=81=99=E3=81=B9=E3=81=A6=E5=87=BA=E3=81=99=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listeners/BungeeSemaphoreCooperator.scala | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala index 49911e484e..2c8d6d914d 100644 --- a/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala +++ b/src/main/scala/com/github/unchama/bungeesemaphoreresponder/bukkit/listeners/BungeeSemaphoreCooperator.scala @@ -1,7 +1,8 @@ package com.github.unchama.bungeesemaphoreresponder.bukkit.listeners -import cats.{Applicative, ApplicativeError} -import cats.effect.{Async, ConcurrentEffect, Timer} +import cats.ApplicativeError +import cats.data.Validated +import cats.effect.{Async, ConcurrentEffect, Sync, Timer} import com.github.unchama.bungeesemaphoreresponder.Configuration import com.github.unchama.bungeesemaphoreresponder.domain.actions.BungeeSemaphoreSynchronization import com.github.unchama.bungeesemaphoreresponder.domain.{PlayerDataFinalizer, PlayerName} @@ -22,8 +23,6 @@ class BungeeSemaphoreCooperator[F[_]: ConcurrentEffect: Timer]( effectEnvironment: EffectEnvironment ) extends Listener { - import cats.implicits._ - @EventHandler(priority = EventPriority.LOWEST) def onQuit(event: PlayerQuitEvent): Unit = { val player = event.getPlayer @@ -40,6 +39,8 @@ class BungeeSemaphoreCooperator[F[_]: ConcurrentEffect: Timer]( finalizers.map(finalizer => retryUntilSucceeds(finalizer.onQuitOf(player))(10)) ) + import cats.implicits._ + val program = for { raceResult <- ConcurrentEffect[F].race(timeout, quitProcess) _ <- raceResult match { @@ -47,16 +48,15 @@ class BungeeSemaphoreCooperator[F[_]: ConcurrentEffect: Timer]( synchronization.notifySaveFailureOf(name) >> ApplicativeError[F, Throwable] .raiseError[Unit](TimeoutReached) case Right(results) => - results.partition(_.isRight) match { - case (_, Nil) => + results.traverse(e => Validated.fromEither(e).leftMap(List.apply(_))) match { + case Validated.Valid(_) => synchronization.confirmSaveCompletionOf(name) - case (_, lefts) => - lefts.traverse { - case Left(throwable) => - synchronization.notifySaveFailureOf(name) >> ApplicativeError[F, Throwable] - .raiseError[Unit](throwable) - case Right(_) => Applicative[F].unit - } + case Validated.Invalid(errors) => + synchronization.notifySaveFailureOf(name) >> errors.traverse(error => + Sync[F].delay { + error.printStackTrace() + } + ) } } } yield () From 1a11303640431db0aa908dbc5d059520dc0e4adc Mon Sep 17 00:00:00 2001 From: inductor Date: Mon, 8 May 2023 02:13:19 +0900 Subject: [PATCH 470/482] Add Sentry --- build.sbt | 3 +++ .../com/github/unchama/seichiassist/SeichiAssist.scala | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/build.sbt b/build.sbt index 4b27dd2393..062ba654f7 100644 --- a/build.sbt +++ b/build.sbt @@ -116,6 +116,9 @@ val dependenciesToEmbed = Seq( // ajd4jp "com.github.KisaragiEffective" % "ajd4jp-mirror" % "8.0.2.2021", + + // Sentry + "io.sentry" % "sentry" % "6.18.1", ) // endregion diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 5d9dc4d1ba..2630ad5295 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -92,6 +92,7 @@ import com.github.unchama.seichiassist.task.PlayerDataSaveTask import com.github.unchama.seichiassist.task.global._ import com.github.unchama.util.{ActionStatus, ClassUtils} import io.chrisdavenport.log4cats.slf4j.Slf4jLogger +import io.sentry.Sentry import org.bukkit.Bukkit import org.bukkit.ChatColor._ import org.bukkit.entity.{Entity, Player, Projectile} @@ -136,6 +137,15 @@ class SeichiAssist extends JavaPlugin() { implicit val loggerF: io.chrisdavenport.log4cats.Logger[IO] = Slf4jLogger.getLoggerFromSlf4j(logger) + Sentry.init(options -> { + options.setDsn("https://7f241763b17c49db982ea29ad64b0264@sentry.onp.admin.seichi.click/2"); + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.setTracesSampleRate(1.0); + // When first trying Sentry it's good to see what the SDK is doing: + options.setDebug(true); + }); + // endregion private var repeatedTaskFiber: Option[Fiber[IO, List[Nothing]]] = None From 3a209fadb03fced6abcdab32c264563feea5b067 Mon Sep 17 00:00:00 2001 From: inductor Date: Mon, 8 May 2023 02:18:48 +0900 Subject: [PATCH 471/482] fix format --- .../scala/com/github/unchama/seichiassist/SeichiAssist.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 2630ad5295..20e3df702a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -137,7 +137,7 @@ class SeichiAssist extends JavaPlugin() { implicit val loggerF: io.chrisdavenport.log4cats.Logger[IO] = Slf4jLogger.getLoggerFromSlf4j(logger) - Sentry.init(options -> { + Sentry.init(options => { options.setDsn("https://7f241763b17c49db982ea29ad64b0264@sentry.onp.admin.seichi.click/2"); // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. // We recommend adjusting this value in production. From 56fac9060e691cc9668d0be62ade68f4ab45ee3d Mon Sep 17 00:00:00 2001 From: inductor Date: Mon, 8 May 2023 02:43:31 +0900 Subject: [PATCH 472/482] set server id on sentry --- .../unchama/seichiassist/SeichiAssist.scala | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 20e3df702a..3ae7e49b50 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -93,6 +93,7 @@ import com.github.unchama.seichiassist.task.global._ import com.github.unchama.util.{ActionStatus, ClassUtils} import io.chrisdavenport.log4cats.slf4j.Slf4jLogger import io.sentry.Sentry +import io.sentry.SentryLevel; import org.bukkit.Bukkit import org.bukkit.ChatColor._ import org.bukkit.entity.{Entity, Player, Projectile} @@ -137,15 +138,6 @@ class SeichiAssist extends JavaPlugin() { implicit val loggerF: io.chrisdavenport.log4cats.Logger[IO] = Slf4jLogger.getLoggerFromSlf4j(logger) - Sentry.init(options => { - options.setDsn("https://7f241763b17c49db982ea29ad64b0264@sentry.onp.admin.seichi.click/2"); - // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.setTracesSampleRate(1.0); - // When first trying Sentry it's good to see what the SDK is doing: - options.setDebug(true); - }); - // endregion private var repeatedTaskFiber: Option[Fiber[IO, List[Nothing]]] = None @@ -604,6 +596,18 @@ class SeichiAssist extends JavaPlugin() { // コンフィグ系の設定は全てConfig.javaに移動 SeichiAssist.seichiAssistConfig = Config.loadFrom(this) + Sentry.init(options => { + options.setDsn("https://7f241763b17c49db982ea29ad64b0264@sentry.onp.admin.seichi.click/2"); + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.setTracesSampleRate(1.0); + // When first trying Sentry it's good to see what the SDK is doing: + options.setDebug(true); + options.setEnvironment(SeichiAssist.seichiAssistConfig.getServerId); + }); + + Sentry.configureScope(scope => scope.setLevel(SentryLevel.WARNING)); + if (SeichiAssist.seichiAssistConfig.getDebugMode == 1) { // debugmode=1の時は最初からデバッグモードで鯖を起動 logger.info(s"${RED}SeichiAssistをデバッグモードで起動します") From b1664f4c19bc7e75442fc2da4e87a6f9a7744135 Mon Sep 17 00:00:00 2001 From: inductor Date: Mon, 8 May 2023 02:50:51 +0900 Subject: [PATCH 473/482] decrease sample rate --- .../com/github/unchama/seichiassist/SeichiAssist.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 3ae7e49b50..d2355eb989 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -598,11 +598,13 @@ class SeichiAssist extends JavaPlugin() { Sentry.init(options => { options.setDsn("https://7f241763b17c49db982ea29ad64b0264@sentry.onp.admin.seichi.click/2"); - // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.setTracesSampleRate(1.0); + // パフォーマンスモニタリングに使うトレースサンプルの送信割合 + // tracesSampleRateを1.0にすると全てのイベントが送られるため、送りすぎないように調整する必要がある + options.setTracesSampleRate(0.25); // When first trying Sentry it's good to see what the SDK is doing: options.setDebug(true); + + // どのサーバーからイベントが送られているのかを判別する識別子 options.setEnvironment(SeichiAssist.seichiAssistConfig.getServerId); }); From c5364f50b934022ee1f735c27d8426d5d3ca7d81 Mon Sep 17 00:00:00 2001 From: inductor Date: Mon, 8 May 2023 03:20:29 +0900 Subject: [PATCH 474/482] scalafmt --- .../com/github/unchama/seichiassist/SeichiAssist.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index d2355eb989..34f30298ee 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -93,7 +93,7 @@ import com.github.unchama.seichiassist.task.global._ import com.github.unchama.util.{ActionStatus, ClassUtils} import io.chrisdavenport.log4cats.slf4j.Slf4jLogger import io.sentry.Sentry -import io.sentry.SentryLevel; +import io.sentry.SentryLevel import org.bukkit.Bukkit import org.bukkit.ChatColor._ import org.bukkit.entity.{Entity, Player, Projectile} @@ -597,7 +597,9 @@ class SeichiAssist extends JavaPlugin() { SeichiAssist.seichiAssistConfig = Config.loadFrom(this) Sentry.init(options => { - options.setDsn("https://7f241763b17c49db982ea29ad64b0264@sentry.onp.admin.seichi.click/2"); + options.setDsn( + "https://7f241763b17c49db982ea29ad64b0264@sentry.onp.admin.seichi.click/2" + ); // パフォーマンスモニタリングに使うトレースサンプルの送信割合 // tracesSampleRateを1.0にすると全てのイベントが送られるため、送りすぎないように調整する必要がある options.setTracesSampleRate(0.25); From dd370ca28e4b686dcf5dd9813c96f59c6c02783f Mon Sep 17 00:00:00 2001 From: inductor Date: Mon, 8 May 2023 03:20:44 +0900 Subject: [PATCH 475/482] gitignore --- .gitignore | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 63be34873e..bade594553 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ .idea/ *.iml +# VSCode +.vscode + # SBT /project/target /project/project @@ -15,4 +18,10 @@ localDependencies/spigot-1.12.2.jar # Docker docker/spigot/serverfiles/eula.txt -.env \ No newline at end of file +.env + +# Metal +.bloop +.metals +project/.bloop/ +project/metals.sbt From 2e026e5c17d7622d8e3b8621d1a6aed2b80e22dc Mon Sep 17 00:00:00 2001 From: rito528 Date: Mon, 8 May 2023 22:30:40 +0900 Subject: [PATCH 476/482] =?UTF-8?q?feat:=20mariadb-java-client=E3=82=92?= =?UTF-8?q?=E4=BE=9D=E5=AD=98=E9=96=A2=E4=BF=82=E3=81=AB=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sbt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 062ba654f7..2e6190faca 100644 --- a/build.sbt +++ b/build.sbt @@ -52,7 +52,7 @@ resolvers ++= Seq( "maven.elmakers.com" at "https://maven.elmakers.com/repository/", // spigot-api 1.12.2がhub.spigotmc.orgからダウンロードできなくなったため "repo.phoenix616.dev" at "https://repo.phoenix616.dev", // authlibのための // ajd4jpのミラーのため - "jitpack.io" at "https://jitpack.io", + "jitpack.io" at "https://jitpack.io" ) val providedDependencies = Seq( @@ -81,6 +81,7 @@ val dependenciesToEmbed = Seq( "org.scala-lang.modules" %% "scala-collection-contrib" % "0.2.1", // DB + "org.mariadb.jdbc" % "mariadb-java-client" % "3.1.4", "org.flywaydb" % "flyway-core" % "5.2.4", "org.scalikejdbc" %% "scalikejdbc" % "3.5.0", @@ -118,7 +119,7 @@ val dependenciesToEmbed = Seq( "com.github.KisaragiEffective" % "ajd4jp-mirror" % "8.0.2.2021", // Sentry - "io.sentry" % "sentry" % "6.18.1", + "io.sentry" % "sentry" % "6.18.1" ) // endregion @@ -139,6 +140,8 @@ assembly / assemblyExcludedJars := { // cf. https://github.com/sbt/sbt-assembly/issues/141 assembly / assemblyMergeStrategy := { case PathList(ps @ _*) if ps.last endsWith "LICENSE" => MergeStrategy.rename + case PathList("org", "apache", "commons", "logging", xs @ _*) => + MergeStrategy.last case otherFile => val oldStrategy = (assembly / assemblyMergeStrategy).value oldStrategy(otherFile) @@ -201,7 +204,10 @@ lazy val root = (project in file(".")).settings( "-Ymacro-annotations", "-Ywarn-unused" ), - javacOptions ++= Seq("-encoding", "utf8") + javacOptions ++= Seq("-encoding", "utf8"), + assembly / assemblyShadeRules ++= Seq( + ShadeRule.rename("org.mariadb.jdbc.**" -> "seichiassist.jdbc.@1").inAll + ) ) // endregion From a0938e1b6562364f2dbe620267906971f490fd07 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 9 May 2023 13:38:39 +0900 Subject: [PATCH 477/482] =?UTF-8?q?feat:=20Scalikejdbc=E3=81=AE=E3=83=89?= =?UTF-8?q?=E3=83=A9=E3=82=A4=E3=83=90=E3=81=A7mariadb=E3=81=AE=E3=83=89?= =?UTF-8?q?=E3=83=A9=E3=82=A4=E3=83=90=E3=82=92=E4=BD=BF=E3=81=86=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/codeStyles/codeStyleConfig.xml | 2 +- .../unchama/seichiassist/SeichiAssist.scala | 17 +++++++---------- .../scalikejdbc/ScalikeJDBCConfiguration.scala | 8 +++++++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml index 79ee123c2b..a55e7a179b 100644 --- a/.idea/codeStyles/codeStyleConfig.xml +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -1,5 +1,5 @@ - \ No newline at end of file diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 34f30298ee..63fd303166 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -596,21 +596,19 @@ class SeichiAssist extends JavaPlugin() { // コンフィグ系の設定は全てConfig.javaに移動 SeichiAssist.seichiAssistConfig = Config.loadFrom(this) - Sentry.init(options => { - options.setDsn( - "https://7f241763b17c49db982ea29ad64b0264@sentry.onp.admin.seichi.click/2" - ); + Sentry.init { options => + options.setDsn("https://7f241763b17c49db982ea29ad64b0264@sentry.onp.admin.seichi.click/2") // パフォーマンスモニタリングに使うトレースサンプルの送信割合 // tracesSampleRateを1.0にすると全てのイベントが送られるため、送りすぎないように調整する必要がある - options.setTracesSampleRate(0.25); + options.setTracesSampleRate(0.25) // When first trying Sentry it's good to see what the SDK is doing: - options.setDebug(true); + options.setDebug(true) // どのサーバーからイベントが送られているのかを判別する識別子 - options.setEnvironment(SeichiAssist.seichiAssistConfig.getServerId); - }); + options.setEnvironment(SeichiAssist.seichiAssistConfig.getServerId) + } - Sentry.configureScope(scope => scope.setLevel(SentryLevel.WARNING)); + Sentry.configureScope(_.setLevel(SentryLevel.WARNING)) if (SeichiAssist.seichiAssistConfig.getDebugMode == 1) { // debugmode=1の時は最初からデバッグモードで鯖を起動 @@ -807,7 +805,6 @@ class SeichiAssist extends JavaPlugin() { val startTask = { val dataRecalculationRoutine = { import PluginExecutionContexts._ - implicit val manaApi: ManaApi[IO, SyncIO, Player] = manaSystem.manaApi PlayerDataRecalculationRoutine() } diff --git a/src/main/scala/com/github/unchama/seichiassist/infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala b/src/main/scala/com/github/unchama/seichiassist/infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala index ef4f86e28c..cf7da36cae 100644 --- a/src/main/scala/com/github/unchama/seichiassist/infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala +++ b/src/main/scala/com/github/unchama/seichiassist/infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala @@ -5,7 +5,12 @@ import scalikejdbc._ object ScalikeJDBCConfiguration { private val connectionPoolSettings: ConnectionPoolSettings = - ConnectionPoolSettings(initialSize = 5, maxSize = 20, connectionTimeoutMillis = 100000L) + ConnectionPoolSettings( + initialSize = 5, + maxSize = 20, + connectionTimeoutMillis = 100000L, + driverName = "org.mariadb.jdbc.Driver" + ) private val loggingSettings: LoggingSQLAndTimeSettings = LoggingSQLAndTimeSettings( enabled = true, @@ -17,6 +22,7 @@ object ScalikeJDBCConfiguration { ) def initializeConnectionPool(url: String, user: String, password: String): Unit = { + Class.forName("org.mariadb.jdbc.Driver") ConnectionPool.singleton(url, user, password, connectionPoolSettings) } From 306d2470836a27b0ebbbab9e26743785623eefc6 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 9 May 2023 21:54:15 +0900 Subject: [PATCH 478/482] =?UTF-8?q?fix:=20ShadingName=E3=82=92=E3=83=89?= =?UTF-8?q?=E3=83=A1=E3=82=A4=E3=83=B3=E3=82=92=E4=BD=BF=E3=81=86=E3=82=82?= =?UTF-8?q?=E3=81=AE=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kory | Ryosuke Kondo <6561358+kory33@users.noreply.github.com> --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 2e6190faca..ad705d0143 100644 --- a/build.sbt +++ b/build.sbt @@ -206,7 +206,7 @@ lazy val root = (project in file(".")).settings( ), javacOptions ++= Seq("-encoding", "utf8"), assembly / assemblyShadeRules ++= Seq( - ShadeRule.rename("org.mariadb.jdbc.**" -> "seichiassist.jdbc.@1").inAll + ShadeRule.rename("org.mariadb.jdbc.**" -> "com.github.unchama.seichiassist.relocateddependencies.org.mariadb.jdbc.@1").inAll ) ) From 21fe8cde45816cd3f89610d6e0b4f5575b5bf9d1 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 9 May 2023 21:54:49 +0900 Subject: [PATCH 479/482] =?UTF-8?q?fix:=20driverName=E3=81=ABrelocate?= =?UTF-8?q?=E5=BE=8C=E3=81=AEFQCN=E3=82=92=E8=A8=98=E8=BC=89=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kory | Ryosuke Kondo <6561358+kory33@users.noreply.github.com> --- .../infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala b/src/main/scala/com/github/unchama/seichiassist/infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala index cf7da36cae..599086ae92 100644 --- a/src/main/scala/com/github/unchama/seichiassist/infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala +++ b/src/main/scala/com/github/unchama/seichiassist/infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala @@ -9,7 +9,7 @@ object ScalikeJDBCConfiguration { initialSize = 5, maxSize = 20, connectionTimeoutMillis = 100000L, - driverName = "org.mariadb.jdbc.Driver" + driverName = "com.github.unchama.seichiassist.relocateddependencies.org.mariadb.jdbc.Driver" ) private val loggingSettings: LoggingSQLAndTimeSettings = LoggingSQLAndTimeSettings( From 173a69c990e737ca33addbff612e2086f01a2f13 Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 9 May 2023 23:39:48 +0900 Subject: [PATCH 480/482] =?UTF-8?q?chore:=20Class#forName=E3=82=92?= =?UTF-8?q?=E5=91=BC=E3=81=B3=E5=87=BA=E3=81=95=E3=81=AA=E3=81=84=E3=81=A7?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala b/src/main/scala/com/github/unchama/seichiassist/infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala index 599086ae92..affed3eefc 100644 --- a/src/main/scala/com/github/unchama/seichiassist/infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala +++ b/src/main/scala/com/github/unchama/seichiassist/infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala @@ -22,7 +22,6 @@ object ScalikeJDBCConfiguration { ) def initializeConnectionPool(url: String, user: String, password: String): Unit = { - Class.forName("org.mariadb.jdbc.Driver") ConnectionPool.singleton(url, user, password, connectionPoolSettings) } From 4e1bc61a6bdaf1aab3cc35a0a79eab47373139ba Mon Sep 17 00:00:00 2001 From: rito528 Date: Tue, 9 May 2023 23:42:05 +0900 Subject: [PATCH 481/482] style: apply scalafmt --- .../infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala b/src/main/scala/com/github/unchama/seichiassist/infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala index affed3eefc..28acc5ae32 100644 --- a/src/main/scala/com/github/unchama/seichiassist/infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala +++ b/src/main/scala/com/github/unchama/seichiassist/infrastructure/scalikejdbc/ScalikeJDBCConfiguration.scala @@ -9,7 +9,8 @@ object ScalikeJDBCConfiguration { initialSize = 5, maxSize = 20, connectionTimeoutMillis = 100000L, - driverName = "com.github.unchama.seichiassist.relocateddependencies.org.mariadb.jdbc.Driver" + driverName = + "com.github.unchama.seichiassist.relocateddependencies.org.mariadb.jdbc.Driver" ) private val loggingSettings: LoggingSQLAndTimeSettings = LoggingSQLAndTimeSettings( From 8b961e0075beb113f66b79c5f0fa67fa1415b352 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 10 May 2023 07:26:09 +0000 Subject: [PATCH 482/482] chore(bump): 76 -> 77 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index ad705d0143..ce496a0c94 100644 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,7 @@ import java.io._ ThisBuild / scalaVersion := "2.13.4" // ThisBuild / version はGitHub Actionsによって取得/自動更新される。 // 次の行は ThisBuild / version := "(\d*)" の形式でなければならない。 -ThisBuild / version := "76" +ThisBuild / version := "77" ThisBuild / organization := "click.seichi" ThisBuild / description := "ギガンティック☆整地鯖の独自要素を司るプラグイン"